News:

Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.

Im fixed some minors bugs

Started by Yona-TYT, February 15, 2026, 02:18:14 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT

Quote from: Andarix on February 06, 2026, 03:14:05 PM
  • When Chapter 5 Step D is loaded from save, the fields for building Post (halt, extension) are not highlighted in red.
  • If you perform Chapter 3 Step D using the automatic step, the track marker will remain. Fix!
  • Way tool select on key not work. Fix!
  • [pak64.german] Chapter 3 step D and E - autostep build wrong stations lenght


Red mark in CH3 ST D fix here:
https://github.com/simutrans/tutorial_multipak/commit/0c7f5b16f00951a7797e57d32ba262db707b26e3
Update, fix red mark in CH3 ST G too 

Key for build roads if fix, topic: "https://forum.simutrans.com/index.php?msg=212102"
Code:
        if (tool_id==tool_build_way){
          local way_desc =  way_desc_x.get_available_ways(gl_wt, gl_st)
          local is_execute = false
          local str_c = tool.start_pos
          local str_way = world.is_coord_valid(str_c)? tile_x(str_c.x, str_c.y, str_c.z).find_object(mo_way) : null
          foreach(desc in way_desc){
            if(desc.get_name() == name){
              is_execute = true
            }
          }
          local last_tool = way_desc_x.get_default_way_desc(wt_road)
          if( is_execute || ( name == wt_road.tostring() && last_tool.get_system_type() == gl_st ) ){
            for ( local i = 0; i < build_list.len()-1; i++ ) {
              if ( ((pos.x==build_list[i].x)&&(pos.y==build_list[i].y)) || ((pos.x==city1_road_depot.x)&&(pos.y==city1_road_depot.y)) ) {
                if(cursor_control(build_list[i])){
                  return null
                }
                if(!str_way){
                  return null
                }
              }
            }
            return get_tile_message(2, city1_road_depot.x, city1_road_depot.y)//translate("Connect the road here")+" ("+city1_road_depot.tostring()+")."
          }
        }


Andarix

#1
The check for road, rail and air is located in the function check_select_way().

For the power line (l) and canal in the Chapter file.

To my knowledge, runway and taxiway for aircraft don't have keyboard shortcuts. I have no idea if this can be set via the Menuconf.tab file.

Yona-TYT

Line 1909 in class_basic_chatpter.nut is commented " //local desc = way_desc_x.get_available_ways(wt, st)"

Screenshot_2026-02-18_19-02-38.png

Yona-TYT

There is a problem when building the first bridge in chapter 3, the bridge must not be built before point B.

I made this code to solve it, but adjustments must be made for this to be a useful function for other bridges.

        if (pot[0]==1 && pot[1]==0){
          if (pos.x>=bridge2_coords.b.x-1 && pos.y>=bridge2_coords.b.y-1 && pos.x<=bridge2_coords.a.x+1 && pos.y<=bridge2_coords.a.y+1){
            if(tool_id==tool_build_way || tool_id==tool_build_bridge){
              local pointer = my_tile(bridge2_coords.a).find_object(mo_pointer)
              if (pos.x == bridge2_coords.a.x){
                return null
              }
              if (pointer){
                  gl_control = false
                  if(pos.x == bridge2_coords.b.x)
                    gl_control = true

                  return null
}
else{
                  if (gl_control){
                    return null
                  }
                  return ""
      }
    }
          }
          else
            return translate("You must build the bridge here")+" ("+coord3d_to_string(bridge2_coords.a)+")."
        }

Screenshot_20260307_175331.png


Andarix

This seems suspicious to me.

If I click on the level field as a second click, then position 104,158,-1 is displayed, which is correct.

However, if I click on the slope field 103,158,-1, then position 105,158,0 is displayed. This is the field with the river one level higher. And that doesn't match the clicked field.


Yona-TYT


gl_ctrl_a = false
gl_ctrl_b = false
gl_click_dir = 0

function bridgeConstructionHandler(coord_a, coord_b, pos){
      local curr_pos = null
      local bridge_pos = {a = 0, b = 0}

      if (coord_a.y == coord_b.y && coord_a.x != coord_b.x ){
        bridge_pos.a = coord_a.x
        bridge_pos.b = coord_b.x
        curr_pos = pos.x
      }
      else{
        bridge_pos.a = coord_a.y
        bridge_pos.b = coord_b.y
        curr_pos = pos.y
      }

      local pointer_a = my_tile(coord_a).find_object(mo_pointer)
      local pointer_b = my_tile(coord_b).find_object(mo_pointer)

      if(gl_click_dir == 0 && !pointer_a && !pointer_b){
        return null
      }

      if(pointer_a && gl_click_dir == 0){
        gl_click_dir = 1
      }
        else if (pointer_b && gl_click_dir == 0){
          gl_click_dir = 2
      }
      if(gl_click_dir == 1){
      if (curr_pos == bridge_pos.a){
        return null
      }
      if (pointer_a){
          gl_ctrl_a = false
          if(curr_pos == bridge_pos.b)
            gl_ctrl_a = true

          return null
      }
      else{
                    gl_click_dir = 0
          if (gl_ctrl_a){
                    gl_ctrl_a = false
            return null
          }
          return ""
    }
      }

      else if(gl_click_dir == 2){
      if (curr_pos == bridge_pos.b){
        return null
      }
      if (pointer_b){
          gl_ctrl_b = false
          if(curr_pos == bridge_pos.a)
            gl_ctrl_b = true

          return null
      }
      else{
                  gl_click_dir = 0
          if (gl_ctrl_b){
                    gl_ctrl_b = false
            return null
          }
          return ""
        }
      }
}

The final result is that it now works in both directions and, in theory, should work for all bridges.

Andarix

I consider all this code unnecessary. It's perfectly sufficient to simply align the two bridge ends with the click positions.

I believe the current behavior is a bug. When I drag the bridge with the mouse, the coordinate doesn't jump to the mouse pointer (field 3) but back to field 1 (the river) one level higher.

bridge_drag.png