Latest Posts

Topic: Debug-Script

MarkMcWire
Avatar
Topic Opener
Joined: 2017-02-08, 21:06
Posts: 349
Ranking
Tribe Member
Location: Eisenach, Germany
Posted at: 2020-10-28, 13:15

Here my script as attachement.


Attachment:
debug.lua (5.7 KB)

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: 2745
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-10-28, 13:28

Would be nice if you could keep us updated with any observations you make


Top Quote
MarkMcWire
Avatar
Topic Opener
Joined: 2017-02-08, 21:06
Posts: 349
Ranking
Tribe Member
Location: Eisenach, Germany
Posted at: 2020-10-28, 14:03

hessenfarmer wrote:

Would be nice if you could keep us updated with any observations you make

My europeans KI dont dismantle fisher huts, even if they have 0% fish left. I don't know, if this is an error in my tribe code or a general problem.


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: 2745
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-10-28, 14:38

MarkMcWire wrote:

hessenfarmer wrote:

Would be nice if you could keep us updated with any observations you make

My europeans KI dont dismantle fisher huts, even if they have 0% fish left. I don't know, if this is an error in my tribe code or a general problem.

I don't have much time for analysis currently, but this sounds not ok. Did you try with other tribes as well?


Top Quote
MarkMcWire
Avatar
Topic Opener
Joined: 2017-02-08, 21:06
Posts: 349
Ranking
Tribe Member
Location: Eisenach, Germany
Posted at: 2020-11-11, 11:42

Here a new extended version of the script.


Attachment:
debug.lua (10.8 KB)

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: 2745
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-11-11, 19:59

Thanks for the script.
Especially gald to see you got the suggestion for getting the connected road implemented.
If asked I would vote for having some funtion like that in the official lua functions repertoire implemented in c++ a this is more efficient in terms of performance. But the function itself provides potential for scripting scenarios. I would like to use it probably.


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3317
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2020-11-12, 09:40

I'll need the pathfinding bit of the road connection for the training wheels too.

+1 for implementing in C++.

Edited: 2020-11-12, 09:40

Busy indexing nil values

Top Quote
MarkMcWire
Avatar
Topic Opener
Joined: 2017-02-08, 21:06
Posts: 349
Ranking
Tribe Member
Location: Eisenach, Germany
Posted at: 2020-11-12, 16:21

The code isn't final. Actual, the function make only one step in the right direction but don't connect the flags. I have to implement a loop, which executes the code multiple times.


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-11-12, 20:31

I very recently wrote this bit that might come in useful:

https://github.com/widelands/widelands/blob/84883ac1be6e2798a6d9879f2cf9c4e81723cd8b/data/scripting/training_wheels/utils/buildings.lua#L177

function find_needed_flag_on_road(center_field, player, radius)
   for f_idx, field in ipairs(center_field:region(radius)) do
      if player == field.owner and field.buildable and field.has_roads == true then
         return field
      end
   end
   return nil
end

Busy indexing nil values

Top Quote
MarkMcWire
Avatar
Topic Opener
Joined: 2017-02-08, 21:06
Posts: 349
Ranking
Tribe Member
Location: Eisenach, Germany
Posted at: 2020-11-19, 18:44

Some extensions of my script. Just for fun or developement. Not to cheat face-wink.png


Attachment:
debug.lua (14.8 KB)

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

Top Quote