An Inquiry on Food

Users who are viewing this thread

I am interested in adding new crops and food types. How would one go about doing that? Say, for example, putting in an olive tree or a head of lettuce. If I were to procure models for both of those, how would I make them harvestable and eatable?
 
It depends whether you want to add new mechanics, or just add new meshes as a visual variant using existing behaviours: to implement cabbage farming as a field that is planted with seeds, which after a growing period spawns cabbage items that can be picked up, would require quite a few script changes and adaptations - that sort of idea has been planned and experimented with quite a while ago - it just hasn't seemed to deserve priority over other things to be worked on.

To use the scripts for growing wheat (as an example) just using different meshes, would be easy: copy the scene prop entries for "pw_wheat_field" and "code_wheat", renaming appropriately and using different meshes, using different items to replace "itm_wheat_sheaf" and "itm_wheat_sack"; you would want to add some sort of static "field" of cabbage leaves that appears and disappears all at once, similar to the pw_wheat mesh it replaces. Not a very nice solution, in my opinion, but it might be good enough for your purposes.

To make food items eatable, just use the itm_class(item_class_food, <value>) function in the triggers parameter, as other existing food items do.
 
This is all very interesting. Now, what about an olive tree? Or a strawberry bush? All I would need to do is copy the code for something like, say, a stick bush, replace the mesh of the stick bush, and then replace the items that it drops with the mesh for the olives, and that's it?
 
Duke_Tritus said:
This is all very interesting. Now, what about an olive tree? Or a strawberry bush? All I would need to do is copy the code for something like, say, a stick bush, replace the mesh of the stick bush, and then replace the items that it drops with the mesh for the olives, and that's it?
Yes, you could copy the stick bush, the herb plants, the grape vines, or something else, depending on which behaviour you want. Take a look at the scene prop entries: almost none are scripted directly with triggers and operations in each entry, rather they use Python functions that generate the trigger code, with variations based on the parameters you pass. The definitions of all the functions are at the top of module_scene_props, similarly in module_items, module_tableau_materials, etc.

Note that the Python functions can only be executed when building the module, not when running the game; the module system on the server and clients is not Python.
 
Back
Top Bottom