Jump to content

ModdableFarming


cecilkorik

Recommended Posts

Hello folks, I wanted to share something I've been working on. This is a mod that makes it easier for you (as a fellow modder) to add new crops to the game, which can then be grown using the usual farming methods with no additional work on your part.

 

About ModdableFarming

 

My intent is to give other modders a foundation which they can use to add their own custom crops to the game. I have tried to override as little as possible within the default farming code, both to make updating the mod easier as the game develops, and to keep it true to the original intent of farming. I'm new at modding and new to the community so I hope I'm not stepping on any toes or anything by doing this.

 

This mod started when I wanted to add a few new crops to the game, however looking through the farming code, it did not look like it would be easy. A lot of vegetable names and behaviors were hardcoded and some of the UI design was not friendly to having potentially many new crops become available. So I started by overriding farming_vegetableconf.lua, and then as I got that cleaned up it became clear I would need to make some changes to basicFarming.lua, ISFarmingMenu.lua and ISFarmingInfo.lua as well. At the moment those are the only 4 files modified by this mod, however vegetableconf in particular has been heavily modified.

 

Note: I have recently discovered the magic of lua "hooking". In future versions, I expect the only file I will override fully is farming_vegetableconf.lua. I will use hooking to modify only specific functions in other files as needed. This will make the mod easier to maintain.

 

Download Link

 

First you need to download and install the mod. I've also created an example (which you can use as a template if you prefer) that grows an Eggplant. Special thanks to blackteapie who has been absolutely invaluable helping me figure out and fix numerous issues with the mod.

 

THE MOD ITSELF:

ModdableFarming-0.4.zip (released 2015-Jun-23)

Changelog:

v0.4 - 2015-Jun-23 - download

- important fix to regrowing crops; both after-harvest regrowing, like strawberries, and continuous regrowing, like trees. neither setting was working properly in certain situations, but it is now

- fixed dead-plant sprites. all dead plants should now display the correct sprite

- several fields can now be set to a lua table OR to a single number. Using a table allows you to set different values for each growth level, using a single number sets the same value for all growth levels

- the fields that currently support both tables and numbers are: waterMins, waterMaxes, timeToGrowMin, timeToGrowMax

- waterMins can now be set to 0 and the plant should not die instantly/lose health due to being unwatered

- fixed a potential issue that could cause waterMin to be ignored in some cases

 

 

v0.3 - 2015-May-25 - download

- redesigned to use lua "hooking" instead of overriding whole files

- added "finalGrowResetTo" vegetableprop

- when "finalGrowResetTo" is set the plant will not die (go rotten) once last growth stage is finished and hasn't been harvested

instead plant will change back to whatever growth stage is specified by "finalGrowResetTo" value

- this creates a loop, the purpose of this is to allow trees/vines which do not die of old age, as long as they are kept watered

 

 

v0.2 - 2015-Apr-08 - download

- fixed info window not displaying at high skill levels due to mildewLvl being null

- improved handling for seed bags

- fixed bug with sprites not changing when the crop grows (thanks again blackteapie!)

- clarified "time to grow" mechanics

- cleanup some variable names and spelling mistakes

 

v0.12 - 2015-Mar-31

- resolved the seed menu problem with blackteapie's help

 

v0.11 - 2015-Mar-27

- added debugging information to investigate blackteapie's seed menu problem

 

v0.1 - 2015-Mar-24

- initial release

 

The example/template:

EggplantExample.zip (v0.2 - released 2015-Apr-08)

Changelog:

v0.2

added functional eggplant seed bags

fixed props descriptions

lowered growth time ridiculously for easier demonstration of growth and farming experience

changed seed bags to be distributed in kitchens, instead of individual seeds

increased spawn rate of seeds and handshovel (trowel) to make testing easier

 

v0.1

initial release

Unzip to your mods directory, as normal.

 

Note that the mod itself doesn't really do anything by itself. It's just a toolkit/library for other mods.

 

The example mod adds eggplant seeds which will grow eggplants. If you want to add more than just eggplants, you'll need to create your own mod. You can use ExampleEggplant as a starting point for your own mod if you want. Don't modify ModdableFarming though, unless you know what you're doing.

 

How to use as part of your own mod

 

If you're creating your own mod, you'll want to change mod.info to require=ModdableFarming in addition to any other dependencies you might have.

 

To get started with your mod, you'll have to create your own items to represent the crop and the seeds. If the vegetable you want to use is already in game, all you need to make is some seeds for it. Seed packets like the default crops use are optional and a little more complex, but provide a good way of distributing the seeds, but unless you're familiar with distributions and unpacking recipes I'd recommend just sticking to raw seeds for now. If you're creating a totally new vegetable you'll need to create that too. You'll also have to make sure the seeds get distributed in the game somehow. All of that stuff is up to you, ModdableFarming does not help with that part, although there is a simple method of doing it in ExampleEggplant which you can reuse if you want.

 

Where ModdableFarming helps you is by making it possible to tie your new objects into the farming mechanics. You will do this through your LUA. Specifically, you need to add your crop's data to the tables in farming_vegetableconf. You can add to these tables from your own mod, you should not need to modify ModdableFarming's code directly (at least that is the intention)

 

There are four important tables, your crop will need to have its data added to all 4. I will provide and explain an example for each. First, the "props" table contains most of the logic that defines how your crop works, how it grows, and so on. All values are required unless noted otherwise, but the most important is probably maxGrow which defines how many "growth states" your plant will go through. Each growth state must have an entry in the growPhases table. Each growPhase also requires its own entry in waterMins, waterMaxes, and its own sprite (but we'll get to the sprites later).

 

By default most of the stock plants use a maxGrow of 7, with the first two phases as seedlings, the next three or four as growing, and a final phase or two which provides the harvest and the seeds. Often the first phase or two will have different water requirements. Some of them also "bloom" near harvest time, but this is entirely just a cosmetic feature used for the text descriptions.

 

In short, if you set maxGrow to 7, then your growPhases must also have a length of 7, waterMins must have a length of 7, your waterMaxes must have a length of 7 (although all 7 entries can be nil if you like), and your sprites_growing table will need to have a length of 7 too. Should be pretty obvious once you start looking at it.

 

Examples

 

This is a very bare-bones, simple example of how to make an eggplant farmable. A more complete example, with support for seed packets and distribution throughout the game's many kitchen counters, is available by looking at the download EggplantExample.zip above.

 

Here is my example, an "Eggplant" in case you have an insatiable need for cooking up some Eggplant Parm in the middle of the apocalypse.

require "Farming/farming_vegetableconf"-- growPhases values:--   -2 = in bloom (not harvestable)--   -1 = seedling--   0 = growing--   1 = harvestable vegetable--   2 = harvestable vegetable + seeds--   3 = seeds only--   4 = in bloom (with harvestable vegetable)local props = farming_vegetableconf.props;local sprite_dead = farming_vegetableconf.sprite_dead;local sprite_growing = farming_vegetableconf.sprite_growing;local icons = farming_vegetableconf.icons;props["Eggplant"] = {};props["Eggplant"].regrowResetTo = nil; --reset plant to earlier growPhase when harvesting, instead of destroying plant after harvestprops["Eggplant"].seedsRequired = 1; --number of seeds required to plantprops["Eggplant"].waterLvl = 65; --minimum water required, only used for display purposes nowprops["Eggplant"].waterMins = {85, 65, 65, 65, 65, 65, 65};props["Eggplant"].waterMaxes = {nil, nil, nil, nil, nil, nil, nil};props["Eggplant"].timeToGrowMin = 8; --hours per growth phaseprops["Eggplant"].timeToGrowMax = 8; --hours per growth phaseprops["Eggplant"].minVeg = 3; --number of vegetables harvestedprops["Eggplant"].maxVeg = 4; --number of vegetables harvestedprops["Eggplant"].minVegAutorized = 5; --vegetables harvested at max skill?props["Eggplant"].maxVegAutorized = 9; --vegetables harvested at max skill?props["Eggplant"].vegetableName = "Base.Eggplant"; --ID of the vegetable it provides when harvested (prefix required)props["Eggplant"].seedName = "ExampleEggplant.EggplantSeed"; --ID of the seed it provides when harvested (prefix required)props["Eggplant"].seedTypeName = "EggplantSeed"; --ID of the seed used to grow it (no prefix)props["Eggplant"].seedPackTypeName = nil; --leave this nil for now, I have future plans for itprops["Eggplant"].seedPackSize = 50; --unused due to nil seedpackprops["Eggplant"].seedPerVeg = 2; --seeds received when harvestingprops["Eggplant"].maxGrow = 7; --number of growing phasesprops["Eggplant"].growPhases = {-1, -1, 0, 0, 0, 1, 2};props["Eggplant"].plantName = "Eggplant"; --displayed name (no translations yet)

I know that seems like a lot of stuff, but once you've got that info added, that's the majority of the work done! All that remains is to tell it which sprites to use for your new plant... There are three sprites tables, sprite_dead, sprite_growing, and icons. sprite_dead will for now always have 3 entries and will be used when the plant is in various forms of being dead. sprite_growing will have a sprite for each growPhase, depending on what value you set for maxGrow it should have that many sprites. The icons are used for the farming info windows to show you what vegetable you are growing.

 

Because I am lazy and not an artist for the example I have just re-used the stock sprite tiles for Broccoli (yes sprites 22 and 21 are reversed in the stock game too).

sprite_dead["Eggplant"] = {"vegetation_farming_01_23", -- rotten"vegetation_farming_01_13", -- smashed"vegetation_farming_01_5", -- dry}sprite_growing["Eggplant"] = {"vegetation_farming_01_16", --phase 1 (seedling)"vegetation_farming_01_17", --phase 2 (seedling)"vegetation_farming_01_18", --phase 3 (growing)"vegetation_farming_01_19", --phase 4 (growing)"vegetation_farming_01_20", --phase 5 (growing)"vegetation_farming_01_22", --phase 6 (harvest)"vegetation_farming_01_21" --phase 7 (harvest + seed)}icons["Eggplant"] = "Item_Eggplant";

Now that you have added the correct info for the Eggplant, everything should be ready to go. When you happen across some "EggplantSeeds" in the game somehow (that part is up to you, look at ExampleEggplant mod for a simplistic distribution) as long as you have a trowel you will be able to plant them, and once planted and watered they should grow into several nice healthy fresh Eggplant that you can harvest and then eat or cook.

 

Compatibility and Testing

 

The mod is not yet thoroughly tested. It seems to work fine, at least on build 31 I haven't encountered any exceptions or obvious errors. Running it on build 30 should also work, though I haven't tested recently. IWBUMS might work, but also has not been actively tested.

 

This almost certainly WON'T work with any other existing mods that add their own crops to the game, since those modders probably had to modify the farming code to get their mod to work, and they probably did it differently than me. If there is a mod that does a totally different kind of farming (like hydroponics) that might be okay, but again has not been tested. This will only work with mods that specifically "Require ModdableFarming", and since it is a new mod, there are not any mods like that built on it yet.

 

This mod seems to work with existing savegames and existing farms/crops, at least for me. I don't see any reason it should cause problems, but if you encounter issues, let me know please!

 

What doesn't it do?

 

It tries not to change the basic farming mechanics in any fundamental ways, and it doesn't provide much ability for you to change those mechanics either. That's not my goal. I like farming as it is for the most part, I just want "more stuff" to farm with. A few functional changes were made to the menus and info windows, and the mod may have accidentally fixed some bugs or oversights due to the parts that were rewritten, but the purpose is not to change farming, it is just to make it easier to extend.

 

It also doesn't try to second-guess what you tell it to do. This is good and bad, but overall I think it's important. It's your responsibility to make sure you are telling it to do reasonable things with your plant. If you have a phase where water requirement goes to 5000, the plant is just going to die immediately and dry up. The mod is not going to stop you from creating an impossible plant.

 

What else?

 

I have tried to make the mod flexible enough that you can do things I haven't specifically intended to do. For example if you wanted to make a tree that you can grow and harvest into logs, that should be possible. Or perhaps you want a tree that grows fruit, which when harvested simply has to wait awhile to grow more fruit (using the "regrowResetTo" property). Or if you want to do something silly and plant a butter knife into the ground and have the it magically start dispensing steaks every day, you can do that too, I'm certainly not going to stop you :)

 

One thing I was considering was making it possible to configure how (and which) diseases will affect your new plant, but the diseases are a bit confusing to me and I'm not sure what kind of things people might want to do with that functionality. Another thing I'd like to do is change the growPhases to each have their own timeToGrow, so you can make some phases faster and some slower.

 

I have lots of other ideas for the future as well. I would like to add a bunch of events that you can assign your own lua functions to, such as when a plant is planted, when it grows to the next stage, when it gets watered, etc.

 

What do people think? Is this useful to you? Is there anything I else should add? All feedback is welcome at this stage.

Edited by cecilkorik
Link to comment
Share on other sites

Good job! this will help many people. I have an unfinished mod that adds a dozen of new crops to the game (Marijuana apart...), but currently do not have much time to do it, since my other mods already published are hogging all my time.

 

Maybe with your help, someone do a great mod for farming! Good job!

Link to comment
Share on other sites

In theory... It should be as simple as adding a whatever.png file to your mod's "media" folder, then setting the sprite tables to "media/whatever.png"

 

I haven't actually tried, but please let us know if it works for you!

 

If that doesn't work you might need to meddle with pack files instead, not sure...

Link to comment
Share on other sites

In theory... It should be as simple as adding a whatever.png file to your mod's "media" folder, then setting the sprite tables to "media/whatever.png"

I haven't actually tried, but please let us know if it works for you!

If that doesn't work you might need to meddle with pack files instead, not sure...

I'll give it a try. Thanks.
Link to comment
Share on other sites

I tried the mod today. But it didn't work, I cannot sow the seeds to the ground. 

Would someone tell which part (or parts) I did wrong?

My mod's name is Fuel and Reservation.

:???:

 

The mod.info is as follow:


name= Fuel and Reservation

poster=

id=FuelandReservation

description=This makes it easier for getting food and fuel

require=ModdableFarming


:???:

 

I only create one lua file (including both the main part and sprites part) . The file name is farming_bamboo.lua. It puts in the directory of adminitrator/zomboid/mod/FuelandReservation/media/server/.

And here is the codes I write:

-- growPhases values:

--   -2 = in bloom (not harvestable)

--   -1 = seedling

--   0 = growing

--   1 = harvestable vegetable

--   2 = harvestable vegetable + seeds

--   3 = seeds only

--   4 = in bloom (with harvestable vegetable)

 

local props = farming_vegetableconf.props;

local sprites_dead = farming_vegetableconf.sprites_dead;

local sprites_growing = farming_vegetableconf.sprites_growing;

 

props["Bamboo"] = {};

props["Bamboo"].regrowResetTo = nil; --reset plant to earlier growPhase when harvesting, instead of destroying plant after harvest

props["Bamboo"].seedsRequired = 1; --number of seeds required to plant

props["Bamboo"].waterLvl = 65; --minimum water required, only used for display purposes now

props["Bamboo"].waterMins = {85, 65, 65, 65, 65, 65, 65};

props["Bamboo"].waterMaxes = {nil, nil, nil, nil, nil, nil, nil};

props["Bamboo"].timeToGrowMin = 7; --in days

props["Bamboo"].timeToGrowMax = 10; --in days

props["Bamboo"].minVeg = 1; --number harvested

props["Bamboo"].maxVeg = 2; --number harvested

props["Bamboo"].minVegAutorized = 5; --harvest at min skill?

props["Bamboo"].maxVegAutorized = 9; --harvest at max skill?

props["Bamboo"].vegetableName = "Base.Bamboo"; --this is the ID of the vegetable it provides when harvested

props["Bamboo"].seedName = "Base.BambooSeed"; --this is the ID of the seed it provides when harvested (prefix required)

props["Bamboo"].seedTypeName = "BambooSeed"; --this is the ID of the seed used to grow it (no prefix)

props["Bamboo"].seedPackTypeName = nil; --leave this nil for now, I have future plans for it

props["Bamboo"].seedPackSize = 50; --unused due to nil seedpack

props["Bamboo"].seedPerVeg = 2; --seeds received when harvesting

props["Bamboo"].maxGrow = 7; --number of growing phases

props["Bamboo"].growPhases = {-1, -1, 0, 0, 0, 1, 2};

 

sprite_dead["Bamboo"] = {

"bamboo001.png", -- rotten

"bamboo002.png", -- smashed

"bamboo003.png", -- dry

}

 

sprite_growing["Bamboo"] = {

"bamboo004.png", --phase 1 (seedling)

"bamboo005.png", --phase 2 (seedling)

"bamboo006.png", --phase 3 (growing)

"bamboo006.png", --phase 4 (growing)

"bamboo006.png", --phase 5 (growing)

"bamboo007.png", --phase 6 (harvest)

"bamboo008.png" --phase 7 (harvest + seed)

:???:

 

I write the scripts of the new seeds and items into the original script file, which is in PZ's installation directory. And the seed item's name is BambooSeed. The new items do showed up in the game. But I can't sow it to the ground. 

Link to comment
Share on other sites

I don't think you've done anything wrong, but I have discovered a few bugs in the code and there are a few things I messed up in my instructions. I'm working on fixing both and should have a new version in a couple days at most.

Thank you.

And waiting for the new version.

Link to comment
Share on other sites

 

I don't think you've done anything wrong, but I have discovered a few bugs in the code and there are a few things I messed up in my instructions. I'm working on fixing both and should have a new version in a couple days at most.

Thank you.

And waiting for the new version.

 

 

The new version is ready! It should fix the issues you were having. I've edited the links into the original post.

 

As I mentioned, I also screwed up on the instructions a little bit, you will want to make the following changes to your mod:

 

Add entry to "icons" table to display the icon in the info window:

local icons = farming_vegetableconf.icons;icons['Bamboo'] = "Item_Bamboo";

Add extra prop value to display the correct name:

props["Bamboo"].plantName = "Bamboo";

Fix the typo I did with sprite_dead and sprite_growing  :oops:  : (I originally spelled these lines as "sprites" instead of "sprite")

local sprite_dead = farming_vegetableconf.sprite_dead;local sprite_growing = farming_vegetableconf.sprite_growing;

 

I write the scripts of the new seeds and items into the original script file, which is in PZ's installation directory.

 

I just wanted to make sure of this: You should be adding a lua file with the Bamboo settings to your own mod, you should not need to make any changes to PZ's code, or to ModdableFarming's code. It is designed to let you do everything you need to do from within your own mod's directory. See the ExampleEggplant mod I linked for a good layout, that might help make things clearer.

 

In case the new version does not fix your problem with planting seeds, I have added some additional debugging information to the console which I will need to you look at for me. Let me know if you're still having problems and look for some text in the console that says "DEBUG: Found item BambooSeed that looked like it was supposed to be a seed", and tell me what it says after that.

Link to comment
Share on other sites

 

 

I don't think you've done anything wrong, but I have discovered a few bugs in the code and there are a few things I messed up in my instructions. I'm working on fixing both and should have a new version in a couple days at most.

Thank you.

And waiting for the new version.

 

 

The new version is ready! It should fix the issues you were having. I've edited the links into the original post.

 

As I mentioned, I also screwed up on the instructions a little bit, you will want to make the following changes to your mod:

 

Add entry to "icons" table to display the icon in the info window:

local icons = farming_vegetableconf.icons;icons['Bamboo'] = "Item_Bamboo";

Add extra prop value to display the correct name:

props["Bamboo"].plantName = "Bamboo";

Fix the typo I did with sprite_dead and sprite_growing  :oops:  : (I originally spelled these lines as "sprites" instead of "sprite")

local sprite_dead = farming_vegetableconf.sprite_dead;local sprite_growing = farming_vegetableconf.sprite_growing;

 

I write the scripts of the new seeds and items into the original script file, which is in PZ's installation directory.

 

I just wanted to make sure of this: You should be adding a lua file with the Bamboo settings to your own mod, you should not need to make any changes to PZ's code, or to ModdableFarming's code. It is designed to let you do everything you need to do from within your own mod's directory. See the ExampleEggplant mod I linked for a good layout, that might help make things clearer.

 

In case the new version does not fix your problem with planting seeds, I have added some additional debugging information to the console which I will need to you look at for me. Let me know if you're still having problems and look for some text in the console that says "DEBUG: Found item BambooSeed that looked like it was supposed to be a seed", and tell me what it says after that.

 

great, I will try it asap.

Link to comment
Share on other sites

 

 

I don't think you've done anything wrong, but I have discovered a few bugs in the code and there are a few things I messed up in my instructions. I'm working on fixing both and should have a new version in a couple days at most.

Thank you.

And waiting for the new version.

The new version is ready! It should fix the issues you were having. I've edited the links into the original post.

As I mentioned, I also screwed up on the instructions a little bit, you will want to make the following changes to your mod:

Add entry to "icons" table to display the icon in the info window:

local icons = farming_vegetableconf.icons;icons['Bamboo'] = "Item_Bamboo";
Add extra prop value to display the correct name:
props["Bamboo"].plantName = "Bamboo";
Fix the typo I did with sprite_dead and sprite_growing :oops: : (I originally spelled these lines as "sprites" instead of "sprite")
local sprite_dead = farming_vegetableconf.sprite_dead;local sprite_growing = farming_vegetableconf.sprite_growing;

I write the scripts of the new seeds and items into the original script file, which is in PZ's installation directory.

I just wanted to make sure of this: You should be adding a lua file with the Bamboo settings to your own mod, you should not need to make any changes to PZ's code, or to ModdableFarming's code. It is designed to let you do everything you need to do from within your own mod's directory. See the ExampleEggplant mod I linked for a good layout, that might help make things clearer.

In case the new version does not fix your problem with planting seeds, I have added some additional debugging information to the console which I will need to you look at for me. Let me know if you're still having problems and look for some text in the console that says "DEBUG: Found item BambooSeed that looked like it was supposed to be a seed", and tell me what it says after that.

Just tried, but result is even worse. I can't plant any seed at all, no matter it is new seeds or original seeds.

My testing mod's name is "Agriculture Advanced", Mod id is "AgricultureAdvanced".

The mod.info codes are as follow:

name= Agriculture Advanced

poster=

id=AgricultureAdvanced

description=This mod uses ModdableFarming to add new agricultural functions

require=ModdableFarming

:oops: 

I create a lua file named "AgricultureAdvanced_Flax"

The codes are as follow:

require "Farming/farming_vegetableconf"

-- growPhases values:

-- -2 = in bloom (not harvestable)

-- -1 = seedling

-- 0 = growing

-- 1 = harvestable vegetable

-- 2 = harvestable vegetable + seeds

-- 3 = seeds only

-- 4 = in bloom (with harvestable vegetable)

local props = farming_vegetableconf.props;

local sprite_dead = farming_vegetableconf.sprite_dead;

local sprite_growing = farming_vegetableconf.sprite_growing;

local icons = farming_vegetableconf.icons;

props["Flax"] = {};

props["Flax"].regrowResetTo = nil; --reset plant to earlier growPhase when harvesting, instead of destroying plant after harvest

props["Flax"].seedsRequired = 1; --number of seeds required to plant

props["Flax"].waterLvl = 65; --minimum water required, only used for display purposes now

props["Flax"].waterMins = {85, 65, 65, 65, 65, 65, 65};

props["Flax"].waterMaxes = {nil, nil, nil, nil, nil, nil, nil};

props["Flax"].timeToGrowMin = 7; --in days

props["Flax"].timeToGrowMax = 8; --in days

props["Flax"].minVeg = 3; --number harvested

props["Flax"].maxVeg = 4; --number harvested

props["Flax"].minVegAutorized = 5; --harvest at max skill?

props["Flax"].maxVegAutorized = 9; --harvest at max skill?

props["Flax"].vegetableName = "AgricultureAdvanced.Flax"; --this is the ID of the vegetable it provides when harvested

props["Flax"].seedName = "AgricultureAdvanced.FlaxSeed"; --this is the ID of the seed it provides when harvested (prefix required)

props["Flax"].seedTypeName = "FlaxSeed"; --this is the ID of the seed used to grow it (no prefix)

props["Flax"].seedPackTypeName = nil; --leave this nil for now, I have future plans for it

props["Flax"].seedPackSize = 50; --unused due to nil seedpack

props["Flax"].seedPerVeg = 2; --seeds received when harvesting

props["Flax"].maxGrow = 7; --number of growing phases

props["Flax"].growPhases = {-1, -1, 0, 0, 0, 1, 2};

props["Flax"].plantName = "Flax"; --displayed name (no translations)

sprite_dead["Flax"] = {

"tileThuztorFarming1_broccoliRotten", -- rotten

"tileThuztorFarming1_smashed", -- smashed

"TileThuztorDryDirtP_0" -- dry

}

sprite_growing["Flax"] = {

"tileThuztorFarming1_seededRedRadish",

"vegetation_farming_01_17",

"vegetation_farming_01_19",

"vegetation_farming_01_38",

"vegetation_farming_01_38",

"vegetation_farming_01_44",

"vegetation_farm_01_1"

}

icons["Flax"] = "e_easternredbud_1_18";

:oops: 

The new items' script file is named as "item_AgricultureAdvanced"

The codes are as follow:

module AgricultureAdvanced

{

imports

{

Base

}

item FlaxSeed

{

Type = Normal,

DisplayName = Flax Seeds,

Icon = vegetation_groundcover_01_22,

Weight = 0.009,

}

item Flax

{

Type = Normal,

DisplayName = Flax,

Icon = e_easternredbud_1_18,

Weight = 0.01

}

}

:oops: 

The icon of the flax seeds doesnot show correctly, but I don't think this is the reason of the no-sow-seed problem.

Link to comment
Share on other sites

That's very strange... if you still have your console.txt (found in your username\Zomboid directory, assuming you're on Windows) that keeps a logfile of the last time you ran the game. It should contain the debugging information I need, if you can upload it to a file sharing site or pastebin or something like that I will take a look and see if I can figure out what's going wrong.

 

If you have run the game unmodded since then, please tediously repeat the steps of finding the seeds and trying to plant them in-game before sending me the console.txt, otherwise it won't contain the debugging info I need.

 

Thanks for your help and your patience :-)

Link to comment
Share on other sites

That's very strange... if you still have your console.txt (found in your username\Zomboid directory, assuming you're on Windows) that keeps a logfile of the last time you ran the game. It should contain the debugging information I need, if you can upload it to a file sharing site or pastebin or something like that I will take a look and see if I can figure out what's going wrong.

If you have run the game unmodded since then, please tediously repeat the steps of finding the seeds and trying to plant them in-game before sending me the console.txt, otherwise it won't contain the debugging info I need.

Thanks for your help and your patience :-)

You are welcome. I'm quite like your mod.
Link to comment
Share on other sites

 

 

I don't think you've done anything wrong, but I have discovered a few bugs in the code and there are a few things I messed up in my instructions. I'm working on fixing both and should have a new version in a couple days at most.

Thank you.

And waiting for the new version.

 

 

The new version is ready! It should fix the issues you were having. I've edited the links into the original post.

 

As I mentioned, I also screwed up on the instructions a little bit, you will want to make the following changes to your mod:

 

Add entry to "icons" table to display the icon in the info window:

local icons = farming_vegetableconf.icons;icons['Bamboo'] = "Item_Bamboo";

Add extra prop value to display the correct name:

props["Bamboo"].plantName = "Bamboo";

Fix the typo I did with sprite_dead and sprite_growing  :oops:  : (I originally spelled these lines as "sprites" instead of "sprite")

local sprite_dead = farming_vegetableconf.sprite_dead;local sprite_growing = farming_vegetableconf.sprite_growing;

 

I write the scripts of the new seeds and items into the original script file, which is in PZ's installation directory.

 

I just wanted to make sure of this: You should be adding a lua file with the Bamboo settings to your own mod, you should not need to make any changes to PZ's code, or to ModdableFarming's code. It is designed to let you do everything you need to do from within your own mod's directory. See the ExampleEggplant mod I linked for a good layout, that might help make things clearer.

 

In case the new version does not fix your problem with planting seeds, I have added some additional debugging information to the console which I will need to you look at for me. Let me know if you're still having problems and look for some text in the console that says "DEBUG: Found item BambooSeed that looked like it was supposed to be a seed", and tell me what it says after that.

 

Here is the debug information:

DEBUG: Found item BroccoliBagSeed that looked like it was supposed to be a seed
'BroccoliBagSeed' did not match Carrots, expected seed name: 'CarrotSeed'
'BroccoliBagSeed' did not match Broccoli, expected seed name: 'BroccoliSeed'
'BroccoliBagSeed' did not match Radishes, expected seed name: 'RedRadishSeed'
'BroccoliBagSeed' did not match Strawberry plant, expected seed name: 'StrewberrieSeed'
'BroccoliBagSeed' did not match Tomato, expected seed name: 'TomatoSeed'
'BroccoliBagSeed' did not match Potatoes, expected seed name: 'PotatoSeed'
'BroccoliBagSeed' did not match Cabbages, expected seed name: 'CabbageSeed'
'BroccoliBagSeed' did not match Flax, expected seed name: 'FlaxSeed'
Found 0 seeds for Carrots
Found 0 seeds for Broccoli
Found 0 seeds for Radishes
Found 0 seeds for Strawberry plant
Found 0 seeds for Tomato
Found 0 seeds for Potatoes
Found 0 seeds for Cabbages
Found seed FlaxSeed
Found seed FlaxSeed
Found 2 seeds for Flax
Link to comment
Share on other sites

 

Found seed FlaxSeed
Found seed FlaxSeed
Found 2 seeds for Flax

 

So it looks like it is finding your seeds properly... Something else must have gone wrong if you tried to plant them and it still won't let you. Are there any "STACK TRACE" messages?

Link to comment
Share on other sites

 

 

Found seed FlaxSeed
Found seed FlaxSeed
Found 2 seeds for Flax

 

So it looks like it is finding your seeds properly... Something else must have gone wrong if you tried to plant them and it still won't let you. Are there any "STACK TRACE" messages?

 

There is a lot "stack trace" messages. Which one specific you want to see?

Link to comment
Share on other sites

 

 

Found seed FlaxSeed
Found seed FlaxSeed
Found 2 seeds for Flax

 

So it looks like it is finding your seeds properly... Something else must have gone wrong if you tried to plant them and it still won't let you. Are there any "STACK TRACE" messages?

 

Here is a part of it. rest of it looks similar with this one.

 
-----------------------------------------
STACK TRACE
-----------------------------------------
Callframe at: se.krka.kahlua.integration.expose.MultiLuaJavaInvoker@8d380701
function: GetItem -- file: crafthelper.lua line # 97
function: loadDatas -- file: crafthelper.lua line # 215
java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at se.krka.kahlua.integration.expose.caller.MethodCaller.call(MethodCaller.java:61)
at se.krka.kahlua.integration.expose.LuaJavaInvoker.call(LuaJavaInvoker.java:199)
at se.krka.kahlua.integration.expose.MultiLuaJavaInvoker.call(MultiLuaJavaInvoker.java:55)
at se.krka.kahlua.vm.KahluaThread.callJava(KahluaThread.java:181)
at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:981)
at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:162)
at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1722)
at se.krka.kahlua.vm.KahluaThread.pcallvoid(KahluaThread.java:1667)
at se.krka.kahlua.integration.LuaCaller.pcallvoid(LuaCaller.java:53)
at se.krka.kahlua.integration.LuaCaller.protectedCallVoid(LuaCaller.java:81)
at zombie.Lua.Event.trigger(Event.java:37)
at zombie.Lua.LuaEventManager.triggerEvent(LuaEventManager.java:64)
at zombie.GameWindow.run(GameWindow.java:1108)
at zombie.GameWindow.maina(GameWindow.java:977)
at zombie.gameStates.MainScreenState.main(MainScreenState.java:162)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.exe4j.runtime.LauncherEngine.launch(Unknown Source)
at com.exe4j.runtime.WinLauncher.main(Unknown Source)
Caused by: java.lang.StackOverflowError
at java.util.HashMap.hash(HashMap.java:351)
at java.util.HashMap.getEntry(HashMap.java:443)
at java.util.HashMap.containsKey(HashMap.java:434)
at zombie.scripting.ScriptManager.getModule(ScriptManager.java:1081)
at zombie.scripting.objects.ScriptModule.getItem(ScriptModule.java:1164)
at zombie.scripting.objects.ScriptModule.getItem(ScriptModule.java:1164)
at zombie.scripting.objects.ScriptModule.getItem(ScriptModule.java:1164)
at zombie.scripting.objects.ScriptModule.getItem(ScriptModule.java:1164)
at zombie.scripting.objects.ScriptModule.getItem(ScriptModule.java:1164)
at zombie.scripting.objects.ScriptModule.getItem(ScriptModule.java:1164)
at zombie.scripting.objects.ScriptModule.getItem(ScriptModule.java:1164)
at zombie.scripting.objects.ScriptModule.getItem(ScriptModule.java:1164)
at zombie.scripting.objects.ScriptModule.getItem(ScriptModule.java:1164)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...