Jump to content

Undefined

Member
  • Posts

    15
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Thanks for the link! I noticed the OnGameStart event, which I first saw from looking at Item Tweaker API's code. I think this or OnLoad would have the least overhead, but I'd still need a way to pull an array with all the toolboxes (or items spawned) in the current game. Optionally, I would save the name of the game file to to a text file so it only runs one time per game. The problem is getting an array with the items, which I don't know how to go about. The OnPlayerUpdate would be easier since I'd just have to check the player's inventory and I'm sure getting the player's inventory is better documented. The problem would be the overhead, which would be excessive and unnecessary. So now the next step is, how to get an array of all the world items to loop through them and setWeightReduction. If you happen to know a method that returns the items in the world, I would be grateful if you could share it. In the meantime, I'll be looking around to see if such a method exists.
  2. I thought that maybe someone in the workshop might have this figured out so I looked around for other weight reduction mods. The only workaround I've found is someone who added a crafting recipe where you use the old item to craft a new item of the same type, which then has the changed attribute. If it's not possible to change the attribute of a spawned item, this will have to suffice.
  3. Thanks. I've known about that method and have looked through the code base for statements that call setWeightReduction (link), but I'm not sure how I would implement it. I was thinking I'd need to loop through all Toolboxes in the game and then call setWeightReduction, but I don't know the name of the array (or what method I can call that returns an array of all spawned toolboxes). I also figured that maybe the toolbox attributes where saved in the game files once they spawned so it might not even be possible.
  4. I want to modify the Weight Reduction of the Toolbox. I'm using Item Tweaker API. The changes doesn't take effect in a currently saved game, but it does work in a new game. Does anyone know how to get it to work for toolboxes that have already spawned?
  5. Sorry for the late response, I didn't receive a notification for this thread. I went to try it now and it worked. Three times in a row. It's probably me, but I could've sworn they were full. I don't use Duct Tape for anything else and I *believe* all Duct Tape spawns 100% full. I'll record a video the next time I create more upgraded spears in case it happens. Thanks, everyone!
  6. Thanks for the response. The TL;DR is that I switched the file to the "server" folder and renamed it to something other than "recipecode.lua" and it worked. --- With the above in mind, before changing the folder name and renaming the file, I checked console.txt and saw errors like "indexing null table UpgradeSpear" and that it also couldn't find other functions that were related to recipecode.lua I figured the mod was replacing the original recipecode.lua and renamed it. I didn't check if changing the folder name had any effect on it, I'll get to that later and post back.
  7. Folder structure (not sure if this is correct): mods/Better Spear Upgrade/media/lua/client/recipecode.lua mod.info file: name=Better Spear Upgrade poster= id=BetterSpearUpgrade description=Changes the formula for the starting condition of an upgraded spear url= Code: local _orig_UpgradeSpear = Recipe.OnCreate.UpgradeSpear -- get a mix of spear & upgrade item to do a correct condition of the result -- we take the craftedSpear condition and substract the attached weapon condition function Recipe.OnCreate.UpgradeSpear(items, result, player, selectedItem) local spearCondition = 0 local spearConditionMax = 0 local weaponCondition = 0 local weaponConditionMax = 0 local conditionMax = 0; for i=0,items:size() - 1 do if items:get(i):getType() == "SpearCrafted" then spearCondition = items:get(i):getCondition() spearConditionMax = items:get(i):getConditionMax() end end for i=0,items:size() - 1 do if instanceof (items:get(i), "HandWeapon") and items:get(i):getType() ~= "SpearCrafted" then weaponCondition = items:get(i):getCondition() weaponConditionMax = items:get(i):getConditionMax() end end local conditionPct = ((spearCondition / spearConditionMax) + (weaponCondition / weaponConditionMax)) / 2 conditionMax = result:getConditionMax() * conditionPct if conditionMax > result:getConditionMax() then conditionMax = result:getConditionMax(); end if conditionMax < 2 then conditionMax = 2; end result:setCondition(conditionMax); end
  8. The Wiki says there's 4 units and media\scripts\newitems.txt says its UseDelta is 0.25, but I'm unable to use a single roll of Duct Tape to create two upgraded spears (each upgrade only requires 2 units). I'm wondering if this is a bug or the wiki is wrong or what.
  9. I have the GOG version and I'm able to download mods by using SteamCMD. I even wrote a batch script to automate the process. The only downside is that mods aren't automatically updated. Here's the code. Instructions: 1.Download SteamCMD: https://developer.valvesoftware.com/wiki/SteamCMD#Downloading_SteamCMD 2. Open a text file in the same folder as steamcmd.exe 3. Modify line 4 to reflect where you have the folder for "steamcmd" ("D:\Games") and where the files should be moved to once they're downloaded ("C:\Users\YourNameHere\Zomboid") 4. Save the text file with the .bat file extension set /p id=Enter the ID of the mod you wish to download: Start "" /wait steamcmd +login anonymous +workshop_download_item 108600 %id% +quit echo Moving folder... robocopy D:\Games\steamcmd\steamapps\workshop\content\108600\%id% C:\Users\YourNameHere\Zomboid\ /E /MOVE echo Done! Once it's all set up, just go to the mod page you want to download, copy the mod ID (it's in the address bar, but can also usually be found at the bottom of the mod's description), run the .bat file, paste the ID, hit enter, and that's it.
  10. My question is about the "items" parameter: is it all the items in the player's inventory or just the Crafted Spear or Hand Weapon that the player selected? I left the code snippet below for your convenience. -- get a mix of spear & upgrade item to do a correct condition of the result -- we take the craftedSpear condition and substract the attached weapon condition function Recipe.OnCreate.UpgradeSpear(items, result, player, selectedItem) local conditionMax = 0; for i=0,items:size() - 1 do if items:get(i):getType() == "SpearCrafted" then conditionMax = items:get(i):getCondition() end end for i=0,items:size() - 1 do if instanceof (items:get(i), "HandWeapon") and items:get(i):getType() ~= "SpearCrafted" then conditionMax = conditionMax - ((items:get(i):getConditionMax() - items:get(i):getCondition())/2) end end if conditionMax > result:getConditionMax() then conditionMax = result:getConditionMax(); end if conditionMax < 2 then conditionMax = 2; end result:setCondition(conditionMax); end
  11. > Version: 41.71 > SP/MP: Single player > Solo/Host/Dedicated: Solo > Mods: None > New/Current Save: Either > Reproduce: Not possible, it's just how it is I figured this is just how the game renders them and was trying to mod it to make it bigger, but someone suggested that I report this as a bug. I was told to include my font settings, so here they are: UI: * Inventory Container Button Size: Large Fonts: * Font Size: 3x * Context Menu Font: Large * Inventory Font: Large * Tooltip Font: Large
  12. EDIT: the function I was looking for is isSpice. So: item:IsSpice() I found the function using this link: https://projectzomboid.com/modding/ ------ I'm trying to modify the AutoCook mod to exclude spices. Relevant section of code (I think). The last line in particular is where I would add the check to see if the item is a spice, but I don't know the function to call on the item object for checking its spice value. function AutoCook:chooseItem(items,baseItem, recipe) if AutoCook.Verbose then print ("AutoCook:chooseItem "..baseItem:getName()) end if not items or items:size() == 0 then--if there is no more available items stop auto cook return nil end --take the one that will become rotten the fastest ? --take the one that gives most nutrition ? --take the one that gives most happiness ? local evoItem = nil local listItemsNotAlreadyUsed = {} local listItemsUsedOnce = {} for i=1,items:size() do local item = items:get(i-1); if instanceof(item, "Food") and not self.playerObj:isKnownPoison(item) and (recipe:isCookable() or not item:isbDangerousUncooked() or item:isCooked()) then--do we risk to apply also survivor / carpentry / .. recipes ?
×
×
  • Create New...