News:

Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

[API Script] Get label list in world

Started by Yona-TYT, November 30, 2022, 06:45:37 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT

I was trying to make a function that returns an array with all the labels in the map, but unfortunately it doesn't work when rotating the map.


Dwachs

What in this patch does not work when rotating the map?
Parsley, sage, rosemary, and maggikraut.


Dwachs

I cannot download the attached picture 'file not found'.
Parsley, sage, rosemary, and maggikraut.


Yona-TYT

#5
Quote from: Dwachs on November 30, 2022, 01:08:09 PMI cannot download the attached picture 'file not found'.
It says: "_nexti returned an invalid idx", but I really have no idea, I thought it was due to the change of coordinates due to the rotation. :-[

Edit.
Well, this was what occurred to me to solve: Update Add-get-label-list.patch

Yona-TYT

Quote from: Yona-TYT on December 01, 2022, 05:48:27 AMIt says: "_nexti returned an invalid idx", but I really have no idea, I thought it was due to the change of coordinates due to the rotation. :-[

Edit.
Well, this was what occurred to me to solve: Update Add-get-label-list.patch
@Dwachs

Greetings, I just wanted to remember this little patch. ;)

Dwachs

implemented in r10832. try
foreach(label in world.get_label_list()) {...}
Implementation is a bit different from your patch.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Quote from: Dwachs on December 15, 2022, 09:20:23 PMimplemented in r10832. try
foreach(label in world.get_label_list()) {...}
Implementation is a bit different from your patch.

Thank you ! this is great!. Now I can mark the text labels when starting the scenario. 8)


Quotefunction resume_game()
{
   //Mark all text labels
   foreach(label in world.get_label_list()){
      if(label.get_text() == "X")
         label.mark()
   }
}