Jump to content

ATPHHe

Member
  • Content Count

    36
  • Joined

  • Last visited

1 Follower

About ATPHHe

  • Rank
    Member
  • Birthday January 16

Contact Methods

  • Website URL
    https://steamcommunity.com/id/ATPHHe/

Profile Information

  • Interests
    Game Developer, Programmer, AI/Machine Learning

Recent Profile Visitors

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

  1. ATPHHe

    Help !

    Mods should not be inside "C:\Users\USER_NAME\Zomboid" Mods must be extracted to "C:\Users\USER_NAME\Zomboid\mods" instead.
  2. 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.
  3. 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);
  4. 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.
  5. ATPHHe

    getMusicPosition()

    You're welcome. Glad to try and help out. Hopefully this function will be added sometime in an update.
  6. 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.
  7. 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")
  8. 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
  9. 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.
  10. 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()
  11. 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--
  12. 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
  13. 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.
  14. 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
×
×
  • Create New...