Topic: Debug-Script
MarkMcWire Topic Opener |
Posted at: 2020-10-26, 19:03
I programmed a bunch of debug scripts for Lua. I want to try out certain things on the debug console. I'm looking for a good code that connects two flags over a road.
Edited: 2020-10-26, 19:05
My widelands addons: https://drive.google.com/file/d/1jopANlODo41T2reHJ0zaCOMYxq_rxXP-/view?usp=sharing Top Quote |
GunChleoc |
Posted at: 2020-10-26, 20:08
There is no Lua code for that available. Busy indexing nil values Top Quote |
hessenfarmer |
Posted at: 2020-10-26, 20:17
Well, as long as you don't want to place flags you might get along with determining the steps and directions from the coordinates by subtracting x and y values from each of the flags and then have a loop for each direction to concatenate the string for the place_road() funtion. Top Quote |
GunChleoc |
Posted at: 2020-10-27, 07:28
This might get tricky around (0, 0) though when the coordinates wrap around - I don't know how this will behave. I have dug into the code and found the function that calculates the path for the UI - it's The question is, do we need to add this to the Lua interface, or would having a UI in the upcoming scenario editor be good enough? Busy indexing nil values Top Quote |
MarkMcWire Topic Opener |
Posted at: 2020-10-27, 12:25
I prefer the variant with Lua code, because you can also integrate the lua code in the editor. Edited: 2020-10-27, 12:27
My widelands addons: https://drive.google.com/file/d/1jopANlODo41T2reHJ0zaCOMYxq_rxXP-/view?usp=sharing Top Quote |
hessenfarmer |
Posted at: 2020-10-27, 12:33
I believe this depends on the intended use. If you want to use this frequently ins scenario e.g. it would be dead slow. I still remember the attempt of Nordfriese to make a sceanrio AI in lua which was a nightmare. Edited: 2020-10-27, 12:33
Top Quote |
MarkMcWire Topic Opener |
Posted at: 2020-10-27, 12:38
Currently, I only use the scripts in an endless game between several AI opponents. I took myself out of the game right from the start. I use the scripts to control the AI's, to place buildings, to create networks. I just want to see how the AI deals with how it behaves. Funnily enough, the AI regularly tears down buildings and streets that I have created and rebuilds them in very nonsensical places far away from any warehouse. Edited: 2020-10-27, 12:40
My widelands addons: https://drive.google.com/file/d/1jopANlODo41T2reHJ0zaCOMYxq_rxXP-/view?usp=sharing Top Quote |
hessenfarmer |
Posted at: 2020-10-27, 12:46
Not really funny but expectable. the AI has some state of internal knowledge about the things it build by itself and whenm they were build. so they are excluded from any decisions for performance reasons, which is not the case for the buildings you create by the script. saving after the script applied and loading again should clear this internal state and it should treat the buildings/roads like any others. Top Quote |
MarkMcWire Topic Opener |
Posted at: 2020-10-27, 12:53
By the way, it is much more fun to control the AI than to play it yourself. You can just try around a little. And above all, you can get the AI to do things that it wouldn't do on its own. For example, colonize small islands by simply forcing a port on them. My widelands addons: https://drive.google.com/file/d/1jopANlODo41T2reHJ0zaCOMYxq_rxXP-/view?usp=sharing Top Quote |
the-x |
Posted at: 2020-10-27, 14:55
For expample? Which values do you play around? Top Quote |