Jump to content

Svarog

Member
  • Posts

    1885
  • Joined

  • Last visited

Community Answers

  1. Svarog's post in Testing for when the game is running Lua was marked as the answer   
    Pretty sure there is an event that fires after the game has loaded (Black screen is gone).

    Events.OnGameStart

    You could have it fire a function that sets a "GameHasStarted = true" and make your thing depended on that being true through if then else.
  2. Svarog's post in Where is the "moving furniture" file? was marked as the answer   
    C:\Steam\steamapps\common\ProjectZomboid\media\lua\client\Moveables\ISMoveableDefinitions.lua

    Everything you need is in this part of the code as far as I can tell.
    -- _name, _items, _perk, _baseActionTime, _sound, _isWav moveableDefinitions.addToolDefinition( "Hammer", {"Hammer","HammerStone"}, Perks.Woodwork, 75, "PZ_Hammer", true ); moveableDefinitions.addToolDefinition( "Crowbar", {"Crowbar"}, Perks.Woodwork, 150, "PZ_Hammer", true ); moveableDefinitions.addToolDefinition( "Electrician", {"Screwdriver"}, Perks.Electricity, 100, "PZ_Hammer", true ); moveableDefinitions.addToolDefinition( "Cutter", {"KitchenKnife","Scissors","HuntingKnife","SharpedStone"}, Perks.Woodwork, 50, "PZ_Hammer", true ); moveableDefinitions.addToolDefinition( "Shovel", {"Shovel","HandShovel"}, Perks.Farming, 100, "bushes", false );
  3. Svarog's post in Issue with editing base items was marked as the answer   
    You need to include the module. Also, my Littering mod does this exact thing, feel free to take a peak into it and see how it works.
     
    ReplaceOnUse = MODULE.EmptyTin,
  4. Svarog's post in How do I edit the weapons stats and building recipes? was marked as the answer   
    Files in C:\Steam\steamapps\common\ProjectZomboid\media\scripts\ called items.txt or newitems.txt Contain item code that controls item weight, you'll just need to find the item you want to alter and lower the Weight value.
    For clip size you can edit ClipSize value in the same file.
    Lastly, to change the "recipe" for buildable things you need to edit this file C:\Steam\steamapps\common\ProjectZomboid\media\lua\client\BuildingObjects\ISUI\ISBuildMenu.lua
     
    In it find this line
     
    if ISBuildMenu.countMaterial(player, "Base.Garbagebag") < 4
     
    Change it to
     
    if ISBuildMenu.countMaterial(player, "Base.Garbagebag") < 2
     
    I recommend using Notepad ++ for editing those files. Also, of course, I can't really recommend altering the game files, make a mod instead, otherwise every single update will restore the files to defaults.
    Changing that stuff shouldn't have a bad effect on your saves.
    If you need help making a mod let me know.
  5. Svarog's post in Fixing option not appearing in menu of custom weapon was marked as the answer   
    ConditionMax = 5, <-- There's your problem, I did some in-game testing and Repairing started to work when I increased it to 15. Not sure what's the minimum for it if you want the item to be repairable.
  6. Svarog's post in Simple Sound Addition Mod help was marked as the answer   
    In Item Script
     
    CustomEatSound = 
     
    Defines the sound file that plays when item is consumed Example:
     
    CustomEatSound = PZ_DrinkingFromBottle,

    My Littering mod uses custom Sound effect for breaking a bottle, the file is called PZ_BreakBottle.wav code when executing recipe is:

    Sound:PZ_BreakBottle,

    To get what you want it would be for example:

     
    item Cigarettes { Count = 20, HungerChange = 0, Weight = 0.0, RequireInHandOrInventory = Lighter, Type = Food, UnhappyChange = 10, DisplayName = Cigarettes, StressChange = -25, Icon = IckySticks, CustomContextMenu = Smoke, CustomEatSound = YourCustomSoundFileName, }The YourCustomSoundFileName should be in media\sound of the mod.
  7. Svarog's post in Creating meta containers. was marked as the answer   
    I just checked if I could do it and You can make a container "autoequip" and work just like the keyring. The answer you're looking for can be found in this file.
     
    E:\Steam\steamapps\common\ProjectZomboid\media\lua\client\ISUI\ISInventoryPage.lua
     
    The code you want to look at is this part.
    if item:getCategory() == "Container" and getSpecificPlayer(self.player):isEquipped(item) or item:getType() == "KeyRing" then -- found a container, so create a button for it... local containerButton = ISButton:new(self.width-32, ((c-1)*32)+15, 32, 32, "", self, ISInventoryPage.selectContainer, ISInventoryPage.onBackpackMouseDown, true); containerButton:setImage(item:getTex()); containerButton:forceImageSize(30, 30) containerButton.anchorBottom = false; containerButton:setOnMouseOverFunction(ISInventoryPage.onMouseOverButton); containerButton:setOnMouseOutFunction(ISInventoryPage.onMouseOutButton); containerButton.anchorRight = true; containerButton.anchorTop = false; containerButton.anchorLeft = false; containerButton:initialise(); containerButton.borderColor.a = 0.0; containerButton.backgroundColor.a = 0.0; containerButton.backgroundColorMouseOver = {r=0.3, g=0.3, b=0.3, a=1.0}; containerButton.inventory = item:getInventory(); containerButton.capacity = item:getEffectiveCapacity(playerObj); containerButton.name = item:getName(); if self.inventoryPane.inventory == containerButton.inventory then containerButton.backgroundColor = {r=0.7, g=0.7, b=0.7, a=1.0}; foundIndex = c; found = true; end self:addChild(containerButton); self.backpacks[c] = containerButton; c = c + 1; endIf you wanted to, say, make First Aid Kit work like they keyring, being forever equipped without the need to actually equip it, you just make one simple modification to one line. Like below
    if item:getCategory() == "Container" and getSpecificPlayer(self.player):isEquipped(item) or item:getType() == "KeyRing" or item:getType() == "FirstAidKit" thenIt's probably possible to do it without modifying the game file or replacing it by means of a mod but I wouldn't know how to do it efficiently. I kind of suck with .lua coding.

    Hope this helps you get started.

    Also, thank you, now that I made that modification I'm much happier with carrying a First Aid Kit around. Thanks for giving the motivation to finally mod it
     
    Note: item:getType() == "FirstAidKit"

    "FirstAidKit" < This is the ItemID, it doesn't require a module or anything, you just put the same ItemID as in the script. Item type should be container, I just tested this by creating a random Pouch item for this purpose. Screen Below, all equip slots are taken, pouch works.



    Edit: I'm looking into making it not require editing or completely replacing the game file.
  8. Svarog's post in Where to look for starter kit change was marked as the answer   
    The .lua file responsible for what's in starter kit is in Project Zomboid/media/lua/server/XPSystem and it's called XPUpdate.lua
     
    The piece of specific code is:
     
    xpUpdate.onNewGame = function(playerObj, square) if SandboxVars.StarterKit then local bag = playerObj:getInventory():AddItem("Base.Schoolbag"); local bat = bag:getItemContainer():AddItem("Base.BaseballBat"); bat:setCondition(7); local hammer = bag:getItemContainer():AddItem("Base.Hammer"); hammer:setCondition(5); playerObj:getInventory():AddItem("Base.WaterBottleFull"); playerObj:getInventory():AddItem("Base.Crisps"); playerObj:setClothingItem_Back(bag); endendIf you wanted to turn School Bag into a Duffelbag you'd have to modify this line
     
    local bag = playerObj:getInventory():AddItem("Base.Schoolbag");
     
    to something like this
     
    local bag = playerObj:getInventory():AddItem("Base.Duffelbag");
     
    if you wanted to add a saw and nails for example then directly below the line above you need to add this.
     
    bag:getItemContainer():AddItem("Base.Saw");
    bag:getItemContainer():AddItem("Base.Nails");
     
    It will add 5 nails, for more you need to add another line like it below, each line will ad 5 nails, or if you want a Box of Nails then
     
    bag:getItemContainer():AddItem("Base.NailsBox");
     
    For other item ID's check items.txt and newitems.txt in media/lua/scripts and if you want to spawn something directly in inventory just add something below the line
     
    playerObj:getInventory():AddItem("Base.Crisps");
     
    For example Let's add a Spiffo to inventory
     
    playerObj:getInventory():AddItem("Base.Spiffo");
     
    I hope it answers your question. If you're going to modify the game file remember keep the backup of the original!
  9. Svarog's post in Where to look for starter kit change was marked as the answer   
    The .lua file responsible for what's in starter kit is in Project Zomboid/media/lua/server/XPSystem and it's called XPUpdate.lua
     
    The piece of specific code is:
     
    xpUpdate.onNewGame = function(playerObj, square) if SandboxVars.StarterKit then local bag = playerObj:getInventory():AddItem("Base.Schoolbag"); local bat = bag:getItemContainer():AddItem("Base.BaseballBat"); bat:setCondition(7); local hammer = bag:getItemContainer():AddItem("Base.Hammer"); hammer:setCondition(5); playerObj:getInventory():AddItem("Base.WaterBottleFull"); playerObj:getInventory():AddItem("Base.Crisps"); playerObj:setClothingItem_Back(bag); endendIf you wanted to turn School Bag into a Duffelbag you'd have to modify this line
     
    local bag = playerObj:getInventory():AddItem("Base.Schoolbag");
     
    to something like this
     
    local bag = playerObj:getInventory():AddItem("Base.Duffelbag");
     
    if you wanted to add a saw and nails for example then directly below the line above you need to add this.
     
    bag:getItemContainer():AddItem("Base.Saw");
    bag:getItemContainer():AddItem("Base.Nails");
     
    It will add 5 nails, for more you need to add another line like it below, each line will ad 5 nails, or if you want a Box of Nails then
     
    bag:getItemContainer():AddItem("Base.NailsBox");
     
    For other item ID's check items.txt and newitems.txt in media/lua/scripts and if you want to spawn something directly in inventory just add something below the line
     
    playerObj:getInventory():AddItem("Base.Crisps");
     
    For example Let's add a Spiffo to inventory
     
    playerObj:getInventory():AddItem("Base.Spiffo");
     
    I hope it answers your question. If you're going to modify the game file remember keep the backup of the original!
  10. Svarog's post in Getters was marked as the answer   
    I knew I remembered it being somewhere on the forums. Look in the spoilers.

    http://theindiestone.com/forums/index.php/topic/8090-references-luamethods-events-exposed-classes/
  11. Svarog's post in Getters was marked as the answer   
    I knew I remembered it being somewhere on the forums. Look in the spoilers.

    http://theindiestone.com/forums/index.php/topic/8090-references-luamethods-events-exposed-classes/
  12. Svarog's post in [Help] Item Distribution was marked as the answer   
    http://theindiestone.com/forums/index.php/topic/14420-item-distribution/

    I hope it helps.

    But if you need specific code for the item of yours. here

     
    require 'Items/SuburbsDistributions'table.insert(SuburbsDistributions["all"]["shelves"].items, "NewJunkMod.BlueBook");table.insert(SuburbsDistributions["all"]["shelves"].items, 3);
  13. Svarog's post in [Help] Item Distribution was marked as the answer   
    http://theindiestone.com/forums/index.php/topic/14420-item-distribution/

    I hope it helps.

    But if you need specific code for the item of yours. here

     
    require 'Items/SuburbsDistributions'table.insert(SuburbsDistributions["all"]["shelves"].items, "NewJunkMod.BlueBook");table.insert(SuburbsDistributions["all"]["shelves"].items, 3);
  14. Svarog's post in Blood Color was marked as the answer   
    You'd need to find a way to replace the original blood spatter tiles from Tiles.pack in Project Zomboid\media\texturepacks

    You'd also need unpacker to get them out of that file in the first place.
     

  15. Svarog's post in Blood Color was marked as the answer   
    You'd need to find a way to replace the original blood spatter tiles from Tiles.pack in Project Zomboid\media\texturepacks

    You'd also need unpacker to get them out of that file in the first place.
     

  16. Svarog's post in Item distribution was marked as the answer   
    ModDistribution.lua or whatever you decide to call it should be located in your mod's media\lua\server\Items directory
    require 'Items/SuburbsDistributions'------------------------ Trash Items ----------------------table.insert(SuburbsDistributions["all"]["bin"].items, "littering.DogfoodEmpty");table.insert(SuburbsDistributions["all"]["bin"].items, 3);This piece of code is from my own mod.
     
    require 'Items/SuburbsDistributions' - It needs to start with this as this is the path to the original distribution file where we will insert our own items.
     
    table.insert(SuburbsDistributions["all"]["bin"].items, "littering.DogfoodEmpty"); 
     
    This line will insert an item to the table of items that can spawn in trash bins across the map.
     
    "all" is usually the name of the room or type of building like "kitchen" "motel" "hardwarestore" etc.
     
    "bin" can be replaced with "shelves" "counter" "fridge" depening on what type of container you want your item to spawn in.
     
    littering.DogFoodEmpty - modulename.Itemname from your item script.
     
    table.insert(SuburbsDistributions["all"]["bin"].items, 3);
     
    The 3 will be the rarity of the item, anything below 1 like 0.1 -> 0.9 will be very rare to rare anything above 1 will be more and more common.
     
    To get information about available rooms and containers within them look at the original SuburbsDistributions.lua located in Project Zomboid\media\lua\server\Items

     
    conveniencestore = { fridge = { rolls = 4, items = { "Base.Steak", 3, "Base.Burger", 3, "Base.MeatPatty", 3, "Base.Chicken", 3, "Base.Ham", 3, "farming.Bacon", 3, "Base.Pie", 3, "Base.Cheese", 4, "Base.PorkChop", 3, "Base.MuttonChop", 3, "Base.Hotdog", 3, "Base.Corndog", 3, "farming.MayonnaiseFull", 3, "farming.RemouladeFull", 3, } },This is a piece of code from original SuburbsDistributions.lua

    conveniencestore - Name of the building\room type

    fridge - Name of the container

    So if we wanted something to spawn in fridges of convenience stores it would look like this.

     
    require 'Items/SuburbsDistributions'------------------------ Trash Items ----------------------table.insert(SuburbsDistributions["conveniencestore"]["fridge"].items, "examplemodule.ExampleItem");table.insert(SuburbsDistributions["conveniencestore"]["fridge"].items, 1);It will spawn ExampleItem from examplemodule script in fridges in convenience stores around the map and it won't be too rare or common.
  17. Svarog's post in How do you make custom Icons? was marked as the answer   
    Item icon images should be 32x32 or YZx32 or 32xYZ in resolution (YZ can be anything else, it looks best if image has 32 in height or width) and a .png with transparent background.

    The file itself needs to have Item_ prefix in the name ex. Item_Fruit.png and must be placed in the mod's media\textures folder.

    If you're asking about how to actually draw one then I can't help much other than give you a tip to just take some default PZ icon and modify it to suit your liking with some photo editing tool, personally I use Photoshop for that. Pixel art is not my forte, I have a problem with portraying perspective right.

    If you choose to modify a PZ sprite then PZ item icons are withing .pack files in Project Zomboid\media\texturepacks specifically UI.pack and UI2.pack to unpack them you'll need a tool like PZ Unpacker
  18. Svarog's post in How do you make custom Icons? was marked as the answer   
    Item icon images should be 32x32 or YZx32 or 32xYZ in resolution (YZ can be anything else, it looks best if image has 32 in height or width) and a .png with transparent background.

    The file itself needs to have Item_ prefix in the name ex. Item_Fruit.png and must be placed in the mod's media\textures folder.

    If you're asking about how to actually draw one then I can't help much other than give you a tip to just take some default PZ icon and modify it to suit your liking with some photo editing tool, personally I use Photoshop for that. Pixel art is not my forte, I have a problem with portraying perspective right.

    If you choose to modify a PZ sprite then PZ item icons are withing .pack files in Project Zomboid\media\texturepacks specifically UI.pack and UI2.pack to unpack them you'll need a tool like PZ Unpacker
  19. Svarog's post in Farming modding - things required to seed a plant was marked as the answer   
    Welp, I know It's a little late but I figured it out.

    media\lua\client\Farming\ISUI\ISFarmingMenu.lua is the file where seed definitions are.
     
    if item:getType() == "PotatoSeed" or item:getType() == "PotatoSeed50" then table.insert(seedsList.potatoSeed, item); endChange PotatoSeed to Potato like below:
     
    if item:getType() == "Potato" or item:getType() == "PotatoSeed50" then table.insert(seedsList.potatoSeed, item); endAnd you can use potatoes as seeds.
  20. Svarog's post in Farming modding - things required to seed a plant was marked as the answer   
    Welp, I know It's a little late but I figured it out.

    media\lua\client\Farming\ISUI\ISFarmingMenu.lua is the file where seed definitions are.
     
    if item:getType() == "PotatoSeed" or item:getType() == "PotatoSeed50" then table.insert(seedsList.potatoSeed, item); endChange PotatoSeed to Potato like below:
     
    if item:getType() == "Potato" or item:getType() == "PotatoSeed50" then table.insert(seedsList.potatoSeed, item); endAnd you can use potatoes as seeds.
  21. Svarog's post in Custom Hair Color was marked as the answer   
    Default hair colors are set by the lua file MainCreationMethods.lua

    media\lua\shared\NPCs\MainCreationMethods.lua default hair colors are at the bottom.

    I always try to avoid modifying default game files as that more often than not has the effect of mod becoming incompatible or game breaking as soon as a new Build comes out.

    A bit, yes but not too much, I'm glad that what little I know I can use to help out others.
  22. Svarog's post in Custom Hair Color was marked as the answer   
    Default hair colors are set by the lua file MainCreationMethods.lua

    media\lua\shared\NPCs\MainCreationMethods.lua default hair colors are at the bottom.

    I always try to avoid modifying default game files as that more often than not has the effect of mod becoming incompatible or game breaking as soon as a new Build comes out.

    A bit, yes but not too much, I'm glad that what little I know I can use to help out others.
  23. Svarog's post in scripts and lua folders was marked as the answer   
    Every file in scripts does something except for distribution files, they are obsolete.
    items.txt
    newitems.txt
    recipes.txt
    uniquerecipes.txt
    camping.txt
    farming.txt
    fixing.txt
    All those files contain item\recipe\fixing code and are used by the game. If you modify them, the effect will be visible in game. Sometimes not immediately but after creating a new world.
  24. Svarog's post in scripts and lua folders was marked as the answer   
    Every file in scripts does something except for distribution files, they are obsolete.
    items.txt
    newitems.txt
    recipes.txt
    uniquerecipes.txt
    camping.txt
    farming.txt
    fixing.txt
    All those files contain item\recipe\fixing code and are used by the game. If you modify them, the effect will be visible in game. Sometimes not immediately but after creating a new world.
  25. Svarog's post in Superhuman trait mod. was marked as the answer   
    I redesigned the mod to add two Cheat traits, one adds 1000 points to spend and the other does that + adds skill bonuses. Enjoy.
    http://pz-mods.net/professions/Cheaterman/
    Remember to place the folder into your C:\Users\%username\Zomboid\mods directory and then activate the mod from the MODS menu after you launch the game.
    Also, sorry for the delay but I had a ton of stuff to do IRL and I couldn't even get 6 hours of sleep
×
×
  • Create New...