The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: Yona-TYT on November 30, 2022, 06:45:37 AM

Title: [API Script] Get label list in world
Post by: Yona-TYT on November 30, 2022, 06:45:37 AM
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.

Title: Re: [API Script] Get label list in world
Post by: Dwachs on November 30, 2022, 07:01:13 AM
What in this patch does not work when rotating the map?
Title: Re: [API Script] Get label list in world
Post by: Yona-TYT on November 30, 2022, 01:01:25 PM
Quote from: Dwachs on November 30, 2022, 07:01:13 AMWhat in this patch does not work when rotating the map?
Captura desde 2022-11-30 09-00-52.png
Title: Re: [API Script] Get label list in world
Post by: Dwachs on November 30, 2022, 01:08:09 PM
I cannot download the attached picture 'file not found'.
Title: Re: [API Script] Get label list in world
Post by: Yona-TYT on November 30, 2022, 01:12:02 PM
Quote from: Dwachs on November 30, 2022, 01:08:09 PMI cannot download the attached picture 'file not found'.
Wow, that must be a problem on the forum. :o

Look here: https://www.mediafire.com/file/tuo3zlloarqtrih/Captura+desde+2022-11-30+09-00-52.png/file
Title: Re: [API Script] Get label list in world
Post by: Yona-TYT on December 01, 2022, 05:48:27 AM
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
Title: Re: [API Script] Get label list in world
Post by: Yona-TYT on December 14, 2022, 04:38:38 AM
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. ;)
Title: Re: [API Script] Get label list in world
Post by: Dwachs on December 15, 2022, 09:20:23 PM
implemented in r10832. try
foreach(label in world.get_label_list()) {...}
Implementation is a bit different from your patch.
Title: Re: [API Script] Get label list in world
Post by: Yona-TYT on December 16, 2022, 03:29:56 PM
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()
   }
}