Important Dates

Currently Online

Latest Posts

Topic: Debug-Script

MarkMcWire
Avatar
Topic Opener
Joined: 2017-02-08, 21:06
Posts: 340
Ranking
Tribe Member
Location: Eisenach, Germany
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.
The previous code works in such a way that you specify a direction from the start flag (l, bl, tl, r, br, tr) and build the road part by part.

Do any of you know a good way to connect two flags directly together? So that you simply enter the coordinates of the start flag and the finish flag as parameters and the road is generated automatically?

Edited: 2020-10-26, 19:05

My widelands addons: https://drive.google.com/file/d/1jopANlODo41T2reHJ0zaCOMYxq_rxXP-/view?usp=sharing

Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3317
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2020-10-26, 20:08

There is no Lua code for that available.


Busy indexing nil values

Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2721
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-10-26, 20:17

MarkMcWire wrote:

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. The previous code works in such a way that you specify a direction from the start flag (l, bl, tl, r, br, tr) and build the road part by part.

Do any of you know a good way to connect two flags directly together? So that you simply enter the coordinates of the start flag and the finish flag as parameters and the road is generated automatically?

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
Avatar
Joined: 2013-10-07, 15:56
Posts: 3317
Ranking
One Elder of Players
Location: RenderedRect
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 Map::findpath (Called by InteractiveBase::append_build_road). It definitely normalizes the coordinates before calling the pathfinder.

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
Avatar
Topic Opener
Joined: 2017-02-08, 21:06
Posts: 340
Ranking
Tribe Member
Location: Eisenach, Germany
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
Avatar
Joined: 2014-12-11, 23:16
Posts: 2721
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-10-27, 12:33

MarkMcWire wrote:

I prefer the variant with Lua code, because you can also integrate the lua code in the editor.

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.
So would be glad if you could share your intents and the Scripts you made

Edited: 2020-10-27, 12:33

Top Quote
MarkMcWire
Avatar
Topic Opener
Joined: 2017-02-08, 21:06
Posts: 340
Ranking
Tribe Member
Location: Eisenach, Germany
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
Avatar
Joined: 2014-12-11, 23:16
Posts: 2721
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-10-27, 12:46

MarkMcWire wrote:

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.

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
Avatar
Topic Opener
Joined: 2017-02-08, 21:06
Posts: 340
Ranking
Tribe Member
Location: Eisenach, Germany
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
Avatar
Joined: 2019-01-19, 13:23
Posts: 967
Ranking
One Elder of Players
Posted at: 2020-10-27, 14:55

For expample? Which values do you play around?


Top Quote