News:

Beta test the new forum at https://simutrans.forum/
Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

create_line

Started by jameskuyper, December 29, 2022, 02:47:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jameskuyper

Why doesn't player_x.create_line() return a line_x object? I suppose you can locate the newly created line by searching player_x get_line_list(). What's the best way to identify it in that list? Is it guaranteed to be the last one in the list?

Andarix

          pl.create_line(wt_rail)

          // find the line - it is a line without schedule and convoys
          local list = pl.get_line_list()
          foreach(line in list) {
            if (line.get_waytype() == wt_rail  &&  line.get_schedule().entries.len()==0) {
              // right type, no schedule -> take this.
              c_line = line
              break
            }
          }

Dwachs

This is not possible in the code. The code that actually creates the line does not know about the script, and does not know which script to call back with the new line. So we have to live with that inconvenience.

Of course such functionality can be implemented, but this would require some amount of work.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

It would be great to improve this, I would love several scripts with this.  8)