Beta test the new forum at
Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.


Started by THLeaderH, April 11, 2021, 09:51:11 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


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.



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_tunn, sc_tunn_name)
                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_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

          , 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.


scenario <> script ai <> script tool

script ai
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).


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)