Jump to content

ATPHHe

Member
  • Posts

    43
  • Joined

  • Last visited

Everything posted by ATPHHe

  1. Ah thanks! That a really nice find. I'll credit you for the this workaround.
  2. Hello, I am currently fixing a mod for Build 41.60+ Multiplayer. The function zombie:changeSpeed(3) does not work anymore as it throws exceptions now. I saw that changedSpeed() does not exist in 41.60+ looking in the Java Decompiler. Will it be added back? function setSpeedCZ(zombie) local zModData = zombie:getModData(); if zModData.done ~= "done" then zombie:changeSpeed(3); zombie:DoZombieStats(); zModData.done = "done"; end end Events.OnZombieUpdate.Add(setSpeed)
  3. Someone using one of my mods tells me they are getting a Java error in Build 41.53. The mod being used is Customizable Zombies. After about 10-15 minutes of them playing the game in West Point, a crash occurs and kicks them back to the main menu. Testing the mod on my own PC and the mod runs fine for me. No crashes have occurred in my game which makes it very confusing for me. My mod changes zombie speeds and toggles on or off crawlers based on the settings. The error seems related to Broken Fences. Here is the Java error. Also, with permission they allowed me to upload their console.txt file. It will be attached to the very bottom. The error occurs on Line 7294. ERROR: General , 1628108154417> DebugLogStream.printException> Stack trace: java.lang.IllegalArgumentException: invalid direction at zombie.iso.BrokenFences.addDebrisObject(BrokenFences.java:414) at zombie.iso.BrokenFences.destroyFence(BrokenFences.java:262) at zombie.iso.IsoObject.Thump(IsoObject.java:5377) at zombie.ai.states.ThumpState.execute(ThumpState.java:76) at zombie.ai.StateMachine.update(StateMachine.java:200) at zombie.characters.IsoGameCharacter.updateInternal(IsoGameCharacter.java:9710) at zombie.util.lambda.Invokers$Params1$CallbackStackItem.run(Invokers.java:37) at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71) at zombie.core.profiling.AbstractPerformanceProfileProbe.lambda$invokeAndMeasure$0(AbstractPerformanceProfileProbe.java:83) at zombie.util.lambda.Stacks$Params3$CallbackStackItem.invoke(Stacks.java:230) at zombie.util.lambda.Stacks$GenericStack.invokeAndRelease(Stacks.java:26) at zombie.util.Lambda.capture(Lambda.java:130) at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:81) at zombie.characters.IsoGameCharacter.update(IsoGameCharacter.java:9355) at zombie.characters.IsoZombie.updateInternal(IsoZombie.java:2289) at zombie.util.lambda.Invokers$Params1$CallbackStackItem.run(Invokers.java:37) at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71) at zombie.core.profiling.AbstractPerformanceProfileProbe.lambda$invokeAndMeasure$0(AbstractPerformanceProfileProbe.java:83) at zombie.util.lambda.Stacks$Params3$CallbackStackItem.invoke(Stacks.java:230) at zombie.util.lambda.Stacks$GenericStack.invokeAndRelease(Stacks.java:26) at zombie.util.Lambda.capture(Lambda.java:130) at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:81) at zombie.characters.IsoZombie.update(IsoZombie.java:2001) at zombie.MovingObjectUpdateSchedulerUpdateBucket.update(MovingObjectUpdateSchedulerUpdateBucket.java:69) at zombie.MovingObjectUpdateScheduler.update(MovingObjectUpdateScheduler.java:149) at zombie.iso.IsoCell.ProcessObjects(IsoCell.java:2862) at zombie.iso.IsoCell.updateInternal(IsoCell.java:5626) at zombie.util.lambda.Invokers$Params1$CallbackStackItem.run(Invokers.java:37) at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71) at zombie.core.profiling.AbstractPerformanceProfileProbe.lambda$invokeAndMeasure$0(AbstractPerformanceProfileProbe.java:83) at zombie.util.lambda.Stacks$Params3$CallbackStackItem.invoke(Stacks.java:230) at zombie.util.lambda.Stacks$GenericStack.invokeAndRelease(Stacks.java:26) at zombie.util.Lambda.capture(Lambda.java:130) at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:81) at zombie.iso.IsoCell.update(IsoCell.java:5572) at zombie.iso.IsoWorld.updateInternal(IsoWorld.java:3175) at zombie.util.lambda.Invokers$Params1$CallbackStackItem.run(Invokers.java:37) at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71) at zombie.core.profiling.AbstractPerformanceProfileProbe.lambda$invokeAndMeasure$0(AbstractPerformanceProfileProbe.java:83) at zombie.util.lambda.Stacks$Params3$CallbackStackItem.invoke(Stacks.java:230) at zombie.util.lambda.Stacks$GenericStack.invokeAndRelease(Stacks.java:26) at zombie.util.Lambda.capture(Lambda.java:130) at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:81) at zombie.iso.IsoWorld.update(IsoWorld.java:3113) at zombie.gameStates.IngameState.updateInternal(IngameState.java:1612) at zombie.gameStates.IngameState.update(IngameState.java:1319) at zombie.gameStates.GameStateMachine.update(GameStateMachine.java:101) at zombie.GameWindow.logic(GameWindow.java:285) at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71) at zombie.GameWindow.frameStep(GameWindow.java:726) at zombie.GameWindow.run_ez(GameWindow.java:642) at zombie.GameWindow.mainThread(GameWindow.java:471) at java.base/java.lang.Thread.run(Unknown Source) console.txt
  4. Sorry for the late reply. Zombies were usually reupdated every 8128 tick since they sometimes defaulted back to the Zombie Lore settings. I lowered the value to 2000 now which should allow zombies to update faster when you drive across town. If 2000 is not enough, I'll lower the tick value even more. Thanks for letting me know about the issue.
  5. When jogging, you burn calories normally very fast. When sprinting, you burn calories slower than jogging.
  6. The function "setFakeDead(boolean)" for the IsoZombie object doesn't work properly in this update. If they are Crawlers, they die and have their clothes removed sometimes when setFakeDead(true) is called. If they are not Crawlers, nothing occurs to the zombie.
  7. The sirens and light bars on all vehicles don't save their enabled or disabled states it seems. If you turn on a vehicle's siren or light bar, then immediately reload the same save file, the vehicle loads back in with a disabled siren and light bar. Same thing happens when you leave the area and unload the chunk that the vehicle is in, then come back to the vehicle. The vehicle loads in and their sirens and light bars are disabled.
  8. ATPHHe

    Help !

    Mods should not be inside "C:\Users\USER_NAME\Zomboid" Mods must be extracted to "C:\Users\USER_NAME\Zomboid\mods" instead.
  9. ATPHHe

    Load files order

    Hmm. Not sure if one guide exists yet as I haven't found one. From what I've seen in the CMD/Debug Console, the game loads PZ Lua files, then Mod Lua files from the "lua" folder based on what's happening below. Build 40 Lua files in these folders are loaded when you are booting up Project Zomboid, reloading lua mods, or returning to the main menu: Loaded 1st: "../media/lua/shared" ( folders/files loaded alphabetically - PZ Lua files, then Mod Lua files ) Loaded 2nd: "../media/lua/client" ( folders/files loaded alphabetically - PZ Lua files, then Mod Lua files ) Lua files in these folders are loaded only when you are starting up a Singleplayer game/save, or a Multiplayer Server: "../media/lua/server" ( folders/files loaded alphabetically - PZ Lua files, then Mod Lua files ) Build 41 seems to keep the same load order for Lua files from Build 40. --------------------------------------------------------------------------------------------------------------------- For other files like 3d models, scripts, textures, texturepacks, etc., I cannot confirm yet how they are loaded exactly. Hope this helps a little bit though.
  10. ATPHHe

    getMusicPosition()

    Here you go, you can stop all music that is forced to play by muting like this. -- Mute Music getSoundManager():setMusicVolume(0.0); -- Unmute Music getSoundManager():setMusicVolume(getCore().getOptionMusicVolume() / 10.0);
  11. ATPHHe

    getMusicPosition()

    Ah, getPosition() doesn't work now that I have tested it. It's only mean't for "Music" objects and doesn't work with the "SoundManager" object.
  12. ATPHHe

    getMusicPosition()

    You're welcome. Glad to try and help out. Hopefully this function will be added sometime in an update.
  13. ATPHHe

    getMusicPosition()

    I looked all over the SoundManager class and could not find a way to get the timeline position of Sounds. The devs may have to add the function or feature for sounds, or the function "PlayAsMusic" would need to be finished.
  14. ATPHHe

    getMusicPosition()

    Ah, I took a closer look at "PlayAsMusic()" and I guess the function "getSoundManager():PlayAsMusic("1", obj, false, 1)" has not been implemented/finished yet. There's no getSoundPosition for sounds that I could find in the Decompiler yet. You can stop music with "getSoundManager():StopMusic()" You can try calling "playMusic()", then printing out the time. I used the parameter String "1". getSoundManager():playMusic("1")
  15. ATPHHe

    getMusicPosition()

    You can use "getSoundManager():getMusicPosition()". You can also test and play around with "getSoundManager():getPosition()". Both functions "getMusicPosition()" and "getPosition()" return only floats. To be exact, they both return Time Elapsed in milliseconds (ms). To get seconds, you need to divide the music position by 1000. local sound_position = getSoundManager():getMusicPosition() local totalSeconds = sound_position / 1000 I created a function that prints the time of the music being played in many various forms. You can choose which time formats you'd like from this, or you can edit or reference this code. -- Prints in various forms, the current elapsed time of the music that is currently playing. function printCurrentMusicTime(isoPlayer) local sound_position = getSoundManager():getMusicPosition() print(string.format("Current Music Time Elapsed (ms): %.2f", sound_position)) local totalHours = sound_position / 1000 / 60 / 60 local totalMinutes = sound_position / 1000 / 60 local totalSeconds = sound_position / 1000 print(string.format("Current Music Time Elapsed (hours): %.1f", totalHours)) print(string.format("Current Music Time Elapsed (minutes): %.1f", totalMinutes)) print(string.format("Current Music Time Elapsed (seconds): %.1f", totalSeconds)) local totalHoursRounded = math.floor(sound_position / 1000 / 60 / 60) local totalMinutesRounded = math.floor(sound_position / 1000 / 60) local totalSecondsRounded = math.floor(sound_position / 1000) print(string.format("Current Music Time Elapsed (hoursRounded): %.1f", totalHoursRounded)) print(string.format("Current Music Time Elapsed (minutesRounded): %.1f", totalMinutesRounded)) print(string.format("Current Music Time Elapsed (secondsRounded): %.1f", totalSecondsRounded)) local music_clock = millisecondsToClock(sound_position) print(string.format("Music Clock: %s", music_clock)) end -- Returns a clock as a String in "hh:mm:ss" format. function millisecondsToClock(ms) local sec = tonumber(ms)/1000 if sec <= 0 then return "00:00:00"; else local hours = string.format("%02.f", math.floor(sec/3600)); local minutes = string.format("%02.f", math.floor(sec/60 - (hours*60))); local seconds = string.format("%02.f", math.floor(sec - hours*3600 - minutes*60)); return string.format("%s:%s:%s", hours, minutes, seconds) end end Events.OnRenderTick.Add(printCurrentMusicTime) When this function "printCurrentMusicTime" is called, it prints the various time formats on console. Here's the actual SoundManager functions. I hope this all helps. Enjoy MusicTimePrinter.lua
  16. One solution is to change "MyClass:OnPlayerUpdate(p)" by removing the colon and replacing it with a period, "MyClass.OnPlayerUpdate(p)". I am not sure why this works, but it has to do with how . and : on "MyClass" both act with Zomboid's Events. local MyClass = {} function MyClass:new(o) setmetatable(o, self) self.__index = self --Events.OnPlayerUpdate.Add(self:OnPlayerUpdate) -- Error: function arguments expected near `)` Events.OnPlayerUpdate.Add(self.OnPlayerUpdate) return o end function MyClass.OnPlayerUpdate(p) print(p) end local o = {} local instance = MyClass:new(o) With this change, "print(p)" should produce this now.
  17. ATPHHe

    Get item ID

    Do you need the item ID from lua? If so, then you must call getID() of an "InventoryItem" object. local itemID = someInventoryItem:getID()
  18. You must iterate through the list of items that are participating in the craft from the "items" ArrayList<InventoryItem>. This for loop will iterate through each single item that is participating in the craft. The if statements will make sure to only give the correct DisplayName that you need for the "WorkItemName" varaible. I do not know which name you need so you'll have to play with this until you get a desired outcome. function recipe_WorkExampleCreat(items, result, player) for i=0, items:size()-1 do local item = items:get(i) local itemDisplayName = item:getDisplayName() local itemName = item:getName() -- Is "IGUI_WorkItem1" the "itemDisplayName" for the "item" at items:get(i)? if itemDisplayName == getText("IGUI_WorkItem1") then WorkItemName = itemDisplayName -- Store item display name into WorkItemName end -- Is "IGUI_WorkItem1" the "itemName" for the "item" at items:get(i)? if itemName == getText("IGUI_WorkItem1") then WorkItemName = itemName -- Store item name into WorkItemName end end end If you need the result item's displayname, then you must use "result:getDisplayName()" function recipe_WorkExampleCreat(items, result, player) WorkItemName = result:getDisplayName() end This is the InventoryItem class with all the methods I used: https://projectzomboid.com/modding/zombie/inventory/InventoryItem.html https://projectzomboid.com/modding/zombie/inventory/InventoryItem.html#getDisplayName-- https://projectzomboid.com/modding/zombie/inventory/InventoryItem.html#getName--
  19. Use the function "getPlayer():isFemale()" There's more ways to get some player's gender, but this is one way. "getPlayer()" is a global Project Zomboid function that returns an "IsoPlayer" object that is the client's character. https://projectzomboid.com/modding/zombie/Lua/LuaManager.GlobalObject.html https://projectzomboid.com/modding/zombie/Lua/LuaManager.GlobalObject.html#getPlayer-- "isFemale()" is a function of "IsoPlayer" which is inherited from the "IsoGameCharacter" class. https://projectzomboid.com/modding/zombie/characters/IsoPlayer.html "IsoGameCharacter" https://projectzomboid.com/modding/zombie/characters/IsoGameCharacter.html#isFemale-- Here's some example functions that use these classes and their functions. This only returns if the client's gender is female as true or false. The code has to be put inside the client folder in "..\media\lua\client" on some lua file. Any questions feel free to ask me. PlayerFunctions = {} --[[ Returns a boolean true if the player is female. Returns a boolean false if the player is male. Requirements: This code must be run under the client folder inside "..\media\lua\client" inside some lua file. ]] function PlayerFunctions.isFemale() local playerObj = getPlayer() local isFemale = playerObj:isFemale() return isFemale end function PlayerFunctions.isFemale2() return getPlayer():isFemale() end local function isFemale() return getPlayer():isFemale() end function isFemaleGlobalFunction() return getPlayer():isFemale() end local function printPlayerGender() print("IsFemale? --> " .. getPlayer():isFemale()) end function printPlayerGenderGlobalFunction() print("IsFemale? --> " .. getPlayer():isFemale()) end PlayerFunctions.lua
  20. ATPHHe

    drainableComboItem

    Some examples objects of type "DrainableComboItem" are: Flashlight Water Bottle Bottle of Disinfectant Soap Twine Wire etc. Some examples objects of type "Radio" are: ValuTech Radio Makeshift Radio Premium Technologies Radio US ARMY COMM. Ham Radio etc. "Radio" is listed as a subclass of "DrainableComboItem". Here's two links to the sites listing this. https://projectzomboid.com/modding/zombie/inventory/types/Radio.html https://theindiestone.com/zomboidjavadocs/zombie/inventory/types/Radio.html There's some more item examples listed under "newitems.txt", "items.txt", and "items_radio.txt" in these locations: ..\steamapps\common\ProjectZomboid\media\scripts\newitems.txt ..\steamapps\common\ProjectZomboid\media\scripts\items.txt ..\steamapps\common\ProjectZomboid\media\scripts\items_radio.txt There's probably more examples in some other text files under the "scripts" folder. "DrainableComboItem" items have the Type name of "Drainable" in the files. "Radio" items have the Type name of "Radio" in the files. items.txt newitems.txt items_radio.txt Hope this helps.
  21. Ah, I just realized that I forgot to convert "lineOfSightTestResults" to a string. It is on Line 91 in "CookingUtils.lua". If it's not converted to a string, then suddenly you can cook through walls. if lineOfSightTestResults ~= "Blocked" then if tostring(lineOfSightTestResults) ~= "Blocked" then Here's a fixed "CookingUtils.lua" file. The Line Of Sight should work again and you shouldn't be able to cook though walls with this minor fix. I'll edit the zip file in all my posts to include this fix also. CookingUtilsMod.zip CookingUtils.lua
  22. Good idea. Probably next week, I'll find the time to create the video showcase and mod description and release it as a modding resource. Cheers.
  23. I found these variable names. Seems like only these can be used currently in the recipes.txt file to call lua functions. OnTest OnCreate OnGiveXP You can reference these in the future if you need examples on what they do with these functions. ..\steamapps\common\ProjectZomboid\media\lua\server\recipecode.lua ..\steamapps\common\ProjectZomboid\media\scripts\recipes.txt You will need "OnTest". To use "OnTest", you have to write a custom function with the correct parameters. "OnTest" will basically test an each item need for the recipe. When "OnTest" returns true for that item, that item can be used for crafting. Here's the bare minimum. The finished code will be in "recipecode_CookingUtils.lua". -- (OnTest) function CookingUtils_OnTest(sourceItem, result) return true; end -- (OnCreate) function CookingUtils_OnCreate(items, result, player, selectedItem) return; end -- (OnGiveXP) Gives by default, 3 XP to cooking. function CookingUtils_GiveSomeCookingXP(recipe, ingredients, result, player) player:getXp():AddXP(Perks.Cooking, 3); end Here's how the functions should be written in the recipes.txt file. OnTest:CookingUtils_OnTest, OnCreate:CookingUtils_OnCreate, OnGiveXP:CookingUtils_GiveSomeCookingXP, module SomeCustomRecipes { /*** Import Project Zomboid's Base recipes ***/ imports { Base } /************** Cooking Recipes **************/ recipe Fry Chicken Edit { keep Pan, Chicken, Egg, Water;2, OnTest:CookingUtils_OnTest, OnCreate:CookingUtils_OnCreate, Result:ChickenFried, Time:60.0, Category:Cooking, SkillRequired:Cooking=0, OnGiveXP:CookingUtils_GiveSomeCookingXP, } } I got it to work like this now, once you have all of the ingredients inside your inventory. Stove Turned On: Stove Turned Off: The only problem that came up was speed. I had to optimize/speed up the code. The code got super laggy and started slowing down the game by a ton using "OnTest". Apparently "OnTest" is seems to be called for every single item on the recipe. All of the items in the recipe calling "CookingUtils.isCloseToCookingUtil(playerObj, maxDistance)" caused lag problems. To fix this, I added a "CookingUtils_Ticks" variable to call the function every 30 ticks and I added some other variables. This helped reduced the lag by a ton. Here's the new files below I made for you. All code was modified. ..\media\lua\server\CookingUtils.lua ..\media\lua\server\recipecode_CookingUtils.lua ..\media\scripts\recipes.txt CookingUtilsMod.zip
×
×
  • Create New...