The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: Yona-TYT on June 25, 2017, 07:18:46 PM

Title: [Command_x] I can not place signals
Post by: Yona-TYT on June 25, 2017, 07:18:46 PM
Command_x does not work with passing signals  :o

code:
                            local t = command_x(tool_build_roadsign)       
                            local err = t.work(player_x(1), signal[j], "Modern_Signals_right")
Title: Re: [Command_x] I can not place signals
Post by: Yona-TYT on June 30, 2017, 07:34:39 PM
Is there any way to make this work?  ???
Title: Re: [Command_x] I can not place signals
Post by: Dwachs on July 02, 2017, 11:23:55 AM
This should work. What error message is returned?
Title: Re: [Command_x] I can not place signals
Post by: Yona-TYT on July 04, 2017, 03:59:59 PM
@Dwachs
Now I need to indicate the "ribi" so that the signal of passage points to the correct direction.  :P
Title: Re: [Command_x] I can not place signals
Post by: Dwachs on July 05, 2017, 05:57:03 PM
You have to query get_way_dirs_masked and call work until the ribis are as you like. One call to 'work' works as one click with the mouse.
Title: Re: [Command_x] I can not place signals
Post by: Yona-TYT on July 10, 2017, 02:39:17 AM
Solved, thank you !!.  ;D


                    for(local j=0;j<signr;j++){
                         
                        local tile = tile_x(signal[j].coor.x, signal[j].coor.y, signal[j].coor.z)
                        local way = tile.find_object(mo_way)
                        if (!tile.find_object(mo_roadsign)){
                            local t = command_x(tool_build_roadsign)
                            while(true){
                                local err = t.work(player_x(1), my_tile(coord(signal[j].coor.x, signal[j].coor.y)), "Signals")
                                local ribi = way.get_dirs_masked()
                                if (ribi == signal[j].ribi)
                                    break
                            }
                        }
                    }