Skip to content

Commit

Permalink
Fix blocking when building the underground
Browse files Browse the repository at this point in the history
  • Loading branch information
Yona-TYT committed Aug 21, 2021
1 parent bcab1b6 commit 7fbc2ac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
13 changes: 10 additions & 3 deletions class/class_basic_chapter.nut
Original file line number Diff line number Diff line change
Expand Up @@ -1201,8 +1201,9 @@ class basic_chapter
function count_tunnel(coora, max){
local way = tile_x(coora.x, coora.y, coora.z).find_object(mo_way)
local r_dir = way? way.get_dirs():0

local result = true
if(!way)return true
local result = false
//gui.add_message(""+r_dir)
if(r_dir == 2){
for(local j = 0;true;j++){
local t = tile_x((coora.x + j), coora.y , coora.z)
Expand All @@ -1219,7 +1220,7 @@ class basic_chapter
if(w && j==max && (dir==2 || dir==10))result = true
else if(w && j>max)result = false

//gui.add_message(""+t.x+","+t.y+","+t.z+"::"+slope+" "+result)
//gui.add_message(""+t.x+","+t.y+","+t.z+"::"+slope+" "+result+" "+j)
if(slope != 0) return result
}
}
Expand All @@ -1238,6 +1239,8 @@ class basic_chapter
local dir = w? w.get_dirs():0
if(w && j==max && (dir==2 || dir==10))result = true
else if(w && j>max)result = false

//gui.add_message(""+t.x+","+t.y+","+t.z+"::"+slope+" "+result)
if(slope != 0) return result
}
}
Expand All @@ -1256,6 +1259,8 @@ class basic_chapter
local dir = w? w.get_dirs():0
if(w && j==max && (dir==4 || dir==5))result = true
else if(w && j>max)result = false

//gui.add_message(""+t.x+","+t.y+","+t.z+"::"+slope+" "+result)
if(slope != 0) return result
}
}
Expand All @@ -1274,6 +1279,8 @@ class basic_chapter
local dir = w? w.get_dirs():0
if(w && j==max && (dir==1 || dir==5))result = true
else if(w && j>max)result = false

//gui.add_message(""+t.x+","+t.y+","+t.z+"::"+slope+" "+result)
if(slope != 0) return result
}
}
Expand Down
16 changes: 8 additions & 8 deletions class/class_chapter_03.nut
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ class tutorial.chapter_03 extends basic_chapter
c_tunn2 = {a = coord3d(90,198,6), b = coord3d(63,198,8)} //Inicio y Fin de la via (fullway)

c_lock_tunn = [coord(65,199),coord(65,197)]
labex = coord(89,198) //Mark in slope surface

layer_lvl = 6
start_lvl_z = 6
Expand Down Expand Up @@ -952,7 +951,7 @@ class tutorial.chapter_03 extends basic_chapter
else if (pot0==1 && pot1==0){
local tile = my_tile(c_tunn1.a)
if ((!tile.find_object(mo_tunnel))){
label_x.create(c_tunn1.a, player_x(0), translate("Build a Bridge here!."))
label_x.create(c_tunn1.a, player_x(0), translate("Place a Tunnel here!."))
coorbord = coord3d(tile.x, tile.y, tile.z)
}
else {
Expand Down Expand Up @@ -1752,23 +1751,24 @@ class tutorial.chapter_03 extends basic_chapter
if (tool_id==tool_build_tunnel || tool_id==tool_build_way || tool_id== 4099){
if (pos.x>=c_tunn2_lim.a.x && pos.y<=c_tunn2_lim.a.y && pos.x<=c_tunn2_lim.b.x && pos.y>=c_tunn2_lim.b.y){


if (way && slope != 28 && slope!= 0) return translate("You must upper the ground first")+" ("+coorbord.tostring()+".)"
if (coorbord!=0){
if( count_tunn||(pos.z== start_lvl_z && slope==28)) return all_control(result, gl_wt, way, ribi, tool_id, pos, coorbord)
local slopebord = tile_x(coorbord.x, coorbord.y, coorbord.z).get_slope()
if((count_tunn && slopebord==28)||(pos.z== start_lvl_z && slope==28)) return all_control(result, gl_wt, way, ribi, tool_id, pos, coorbord)
if (pos.z < end_lvl_z){

local slopebord = tile_x(coorbord.x, coorbord.y, coorbord.z).get_slope()
if (slopebord==28){
//gui.add_message(""+count_tunn+" "+pos.tostring())
local is_mark = way? way.is_marked():false
local cursor = t.find_object(mo_pointer)
local max = 2
local lock = cursor_tile_count(cursor, is_mark, max, pos)
if(is_mark || label || lock) return all_control(result, gl_wt, way, ribi, tool_id, pos, coorbord)
else if (!count_tunn)
return translate("The tunnel is not correct, use the [Remove] tool here")+" ("+coorbord.tostring()+".)"
else return translate("First you must Upper the layer level.")
if (!count_tunn) return translate("The tunnel is not correct, use the [Remove] tool here")+" ("+coorbord.tostring()+".)"
return translate("First you must Upper the layer level.")
}
else if (slopebord==0){
if (!count_tunn) return translate("The tunnel is not correct, use the [Remove] tool here")+" ("+coorbord.tostring()+".)"
return translate("You must upper the ground first")+" ("+coorbord.tostring()+".)"
}
}
Expand Down

0 comments on commit 7fbc2ac

Please sign in to comment.