The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: THLeaderH on April 11, 2021, 09:51:11 AM

Title: command_x.build_tunnel()
Post by: THLeaderH on April 11, 2021, 09:51:11 AM
Is there any means to build a tunnel with a script?
Any of command_x functions does not seem to take a tunnel_desc_x object as parameters.
Title: Re: command_x.build_tunnel()
Post by: Andarix on April 11, 2021, 10:23:41 AM
is not yet implemented
Title: Re: command_x.build_tunnel()
Post by: Yona-TYT on April 11, 2021, 01:36:24 PM
This is what I used in the tutorial:
                if (pot0==0){           
                    local t_tunn = my_tile(start_tunn)
                    t_tunn.remove_object(player_x(0), mo_label)                       
                    local t = command_x(tool_build_tunnel)
                    t.set_flags(2)
                    t.work(player_x(1), t_tunn, sc_tunn_name)
                    pot0=1                   
                }
                if (pot0==1 && pot1==0){
                    local t_tun = command_x(tool_build_tunnel)
                    local c_list =    c_tun_list
                    local t_start = my_tile(start_tunn)
                    for(local j = 0; j<(c_list.len()-1);j++){
                        local c = coord3d(c_list[j].x, c_list[j].y, (t_start.z-j))
                        t_tun.work(player_x(1), t_start, c, sc_tunn_name)
                        command_x.set_slope(player_x(1), c, slope.all_down_slope)
                    }
                    local c_start = c_tunn1.a
                    local c_end = c_tunn1.b

                    t_tun.work(player_x(1), c_start, c_end, sc_tunn_name)

                }   

The first block of code is to build the tunnel entrance.
The second block is to continue the tunnel going up / down a slope.
Title: Re: command_x.build_tunnel()
Post by: Andarix on April 11, 2021, 02:08:39 PM
scenario <> script ai <> script tool

script ai
https://www.simutrans-forum.de/mybb/showthread.php?tid=9313&pid=119681#pid119681 (https://www.simutrans-forum.de/mybb/showthread.php?tid=9313&pid=119681#pid119681)
Quote from: 'Dwachs2' pid='119681' dateline='1615826019'
Das Problem mit Tunnel ist, das um einen Tunnel zu bauen, man Felder testen muss, die es gar nicht gibt (also im Untergrund).
...
Title: Re: command_x.build_tunnel()
Post by: THLeaderH on April 13, 2021, 12:09:55 AM
Thanks to Yona-TYT, I got how to build a tunnel with a script.
However, since command_x.build_bridge() makes bridge constructions very handy, command_x.build_tunnel() should be very nice 8)