Topic: Give goods periodically in script
PkK Topic Opener |
Posted at:
2015-02-18, 20:36 UTC+1.0
I used to have modified startiong conditions that periodically would give goods for build 18. I updated them (name of wares, etc) for current bzr, but they are not working (I do not see the expected periodic jump in wares). Here's the one for barbarians: http://colecovision.eu/stuff/sc64_headquarters_cheat.lua What am I doing wrong? Philipp ![]() ![]() |
GunChleoc![]() |
Posted at:
2015-02-18, 20:43 UTC+1.0
You will definitely want the commented out get_buildings function. It will give you an array, but since the player has only 1 headquarter, you can simply grab the first element. Something like this should work:
Headquarters are always warehouses, so you don't need the check there. Documentation for get_buildings is on this page: https://wl.widelands.org/docs/wl/autogen_wl_game/
Edited:
2015-02-18, 20:48 UTC+1.0
Busy indexing nil values ![]() ![]() |
PkK Topic Opener |
Posted at:
2015-02-18, 20:53 UTC+1.0
What's the issue with
Philipp
Edited:
2015-02-18, 20:53 UTC+1.0
![]() ![]() |
PkK Topic Opener |
Posted at:
2015-02-18, 21:21 UTC+1.0
Actually on checking closer, I see that the only thing that fails with my script is the test of the type. I need that one to make sure I have a warehouse or hq atthe tsart location.
Edited:
2015-02-18, 21:22 UTC+1.0
![]() ![]() |
PkK Topic Opener |
Posted at:
2015-02-18, 21:31 UTC+1.0
Found out by trial and error: It needs to be "Warehouse" insetad of "warehouse". Philipp Edit: Sorry, false positive, forgot to save after enabling check. I still don'tknow how to check that I have a hq.
Edited:
2015-02-18, 21:36 UTC+1.0
![]() ![]() |
wl-zocker |
Posted at:
2015-02-18, 21:55 UTC+1.0
It needs to be From infrastructure.lua: You can also use the following which is more general (not checked, I have not worked with Lua for a while now, so I do not remember the exact syntax):
You are right, you need to check if you found a building at all ( This way is more general because a) you can easily add it to fortified_village, where the citadel is at sf.x, sf.y and b) it still gives you resources when the headquarters has been destroyed. Some general notes:
Edited:
2015-02-18, 21:56 UTC+1.0
"Only few people know how much one has to know in order to know how little one knows." - Werner Heisenberg ![]() ![]() |
PkK Topic Opener |
Posted at:
2015-02-18, 22:04 UTC+1.0
Thanks for the long reply. I'll look into your warehouse finding later. I had just found out about [code] immovable.descr.type_name [/code] Myself (using grep in the widelands directory) Now let's see if this works to make a game against multiple AIs challenging (worked reasonable in build 18). Philipp ![]() ![]() |
SirVer |
Posted at:
2015-02-19, 07:00 UTC+1.0
I can clear that up :). Details are here, but what is boiling down to is that the colon is just syntactic sugar. That means the next two lines are exactly the same:
is the same in Lua as p.a_function(p, a, b) So the column means: pass the table that stands before the column as the first argument to the function I am calling after it. ![]() ![]() |
wl-zocker |
Posted at:
2015-02-19, 08:27 UTC+1.0
I have read the tutorial linked there when I was creating the tutorials. What is still unclear to me: How do I know/find out whether I have to use "Only few people know how much one has to know in order to know how little one knows." - Werner Heisenberg ![]() ![]() |
GunChleoc![]() |
Posted at:
2015-02-19, 08:36 UTC+1.0
I think we would all benefit from having short usage examples for the more complicated functions. I found the documentation for this function difficult to read as well. Busy indexing nil values ![]() ![]() |