Skip to content

Commit

Permalink
Merge pull request #24 from Yona-TYT/master
Browse files Browse the repository at this point in the history
New feature added to darken or disable tools (visually only)
  • Loading branch information
Yona-TYT authored Oct 8, 2024
2 parents d8a804b + 9bc21ce commit 12a5ec0
Show file tree
Hide file tree
Showing 12 changed files with 994 additions and 109 deletions.
50 changes: 50 additions & 0 deletions pak128.prototype/scenario/tutorial/class/class_basic_chapter.nut
Original file line number Diff line number Diff line change
Expand Up @@ -3203,6 +3203,56 @@ class basic_chapter
}
return null
}

function upedate_tools(list, id, wt_list, wt) {
local res = {ok = false, result = false }
local wt_res = false
if(wt < 0){
foreach (tool_id in list){
if(tool_id == id){
res.ok = true
res.result = true
return res
break
}
else if(tool_id < 0 && tool_id*(-1) == id){
res.ok = true
res.result = false
return res
break
}
}
res.result = true
return res
}
foreach (way_t in wt_list){
if(way_t == wt){
wt_res = true
}
}
if (!wt_res){
return res
}
foreach (tool_id in list){
if(tool_id == id){
res.ok = true
res.result = true
break
}
else if(tool_id < 0 && tool_id*(-1) == id){
res.ok = true
res.result = false
break
}
else if(tool_id == 0){
res.ok = true
res.result = true
return res
break
}
}
return res
}
}

// END OF FILE
11 changes: 11 additions & 0 deletions pak128.prototype/scenario/tutorial/class/class_chapter_00.nut
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ class tutorial.chapter_00 extends basic_chapter
foreach (tool_id in forbid)
rules.forbid_tool(pl, tool_id )
}

function is_tool_active(pl, tool_id, wt) {
local result = true
return result
}

function is_tool_allowed(pl, tool_id, wt){
local result = true
return result
}

function script_text()
{
return null
Expand Down
11 changes: 11 additions & 0 deletions pak128.prototype/scenario/tutorial/class/class_chapter_01.nut
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,17 @@ class tutorial.chapter_01 extends basic_chapter
foreach (tool_id in forbid)
rules.forbid_tool(pl, tool_id )
}

function is_tool_active(pl, tool_id, wt) {
local result = true
return result
}

function is_tool_allowed(pl, tool_id, wt){
local result = true
return result
}

function script_text()
{
if (this.step==1){
Expand Down
117 changes: 99 additions & 18 deletions pak128.prototype/scenario/tutorial/class/class_chapter_02.nut
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ class tutorial.chapter_02 extends basic_chapter
break

case 2:
local forbid = [ tool_remove_wayobj,tool_build_way,tool_build_bridge,tool_build_tunnel,tool_build_station,
local forbid = [ tool_remove_wayobj,tool_build_bridge,tool_build_tunnel,tool_build_station,
tool_remove_way,tool_build_roadsign,tool_build_wayobj
]
foreach (tool_id in forbid)
Expand All @@ -1352,8 +1352,8 @@ class tutorial.chapter_02 extends basic_chapter
break

case 3:
local forbid= [ tool_remove_wayobj,tool_build_way,tool_build_bridge,tool_build_tunnel,
tool_remove_way,tool_build_depot,tool_build_roadsign,tool_build_wayobj
local forbid= [ tool_remove_wayobj,tool_build_bridge,tool_build_tunnel,
tool_remove_way,tool_build_roadsign,tool_build_wayobj
]
foreach (tool_id in forbid)
rules.forbid_way_tool(pl, tool_id, wt_road)
Expand All @@ -1364,8 +1364,8 @@ class tutorial.chapter_02 extends basic_chapter
break

case 4:
local forbid = [ tool_remove_wayobj,tool_build_way,tool_build_bridge,tool_build_tunnel,
tool_remove_way,tool_build_depot,tool_build_roadsign,tool_build_wayobj
local forbid = [ tool_remove_wayobj,tool_build_tunnel,
tool_remove_way,tool_build_roadsign,tool_build_wayobj
]
foreach (tool_id in forbid)
rules.forbid_way_tool(pl, tool_id, wt_road)
Expand All @@ -1376,51 +1376,132 @@ class tutorial.chapter_02 extends basic_chapter
break

case 5:
local forbid = [ tool_remove_wayobj,tool_build_way,tool_build_tunnel,tool_build_station,
tool_remove_way,tool_build_depot,tool_build_roadsign,tool_build_wayobj
local forbid = [ tool_remove_wayobj, tool_build_tunnel,
tool_remove_way, tool_build_depot, tool_build_roadsign, tool_build_wayobj
]
foreach (tool_id in forbid)
rules.forbid_way_tool(pl, tool_id, wt_road)

local forbid = [tool_build_station,tool_remover,tool_make_stop_public]
local forbid = [tool_make_stop_public]
foreach (tool_id in forbid)
rules.forbid_tool(pl, tool_id )
break

case 6:
local forbid = [ tool_remove_wayobj,tool_build_way,tool_build_bridge,tool_build_tunnel,
tool_remove_way,tool_build_depot,tool_build_roadsign,tool_build_wayobj
local forbid = [ tool_remove_wayobj, tool_build_tunnel,
tool_remove_way, tool_build_roadsign, tool_build_wayobj
]
foreach (tool_id in forbid)
rules.forbid_way_tool(pl, tool_id, wt_road)

local forbid = [tool_build_station, tool_remover, tool_make_stop_public]
local forbid = [tool_make_stop_public]
foreach (tool_id in forbid)
rules.forbid_tool(pl, tool_id )
break

case 7:
local forbid = [ tool_remove_wayobj,tool_build_tunnel,tool_build_depot,
tool_build_roadsign,tool_build_wayobj
local forbid = [ tool_remove_wayobj, tool_build_tunnel,
tool_build_roadsign, tool_build_wayobj
]
foreach (tool_id in forbid)
rules.forbid_way_tool(pl, tool_id, wt_road)
break

case 8:
local forbid = [ tool_remove_wayobj,tool_build_way,tool_build_bridge,tool_build_tunnel,tool_build_station,
tool_remove_way,tool_build_depot,tool_build_roadsign,tool_build_wayobj
local forbid = [ tool_remove_wayobj, tool_build_tunnel,
tool_build_roadsign, tool_build_wayobj
]
foreach (tool_id in forbid)
rules.forbid_way_tool(pl, tool_id, wt_road)

local forbid = [tool_build_station,tool_remover]
foreach (tool_id in forbid)
rules.forbid_tool(pl, tool_id )
break
}
}

function is_tool_active(pl, tool_id, wt) {
local result = false
switch (this.step) {
case 1:
local t_list = [tool_build_way]
local wt_list = [gl_wt]
local res = upedate_tools(t_list, tool_id, wt_list, wt)
result = res.result
if(res.ok) return result
break
case 2:
local t_list = [tool_build_depot]
local wt_list = [gl_wt]
local res = upedate_tools(t_list, tool_id, wt_list, wt)
result = res.result
if(res.ok) return result
break
case 3:
local t_list = [tool_build_station]
local wt_list = [gl_wt]
local res = upedate_tools(t_list, tool_id, wt_list, wt)
result = res.result
if(res.ok) return result
break
case 4: //Schedule
local t_list = [-tool_remover, -t_icon.road]
local wt_list = [0]
local res = upedate_tools(t_list, tool_id, wt_list, wt)
result = res.result
if(res.ok) return result
break
case 5:
local t_list = [-tool_remover, tool_build_bridge]
local wt_list = [gl_wt]
local res = upedate_tools(t_list, tool_id, wt_list, wt)
result = res.result
if(res.ok) return result
break
case 6: //Schedule
local t_list = [-tool_remover, -t_icon.road]
local wt_list = [0]
local res = upedate_tools(t_list, tool_id, wt_list, wt)
result = res.result
if(res.ok) return result
break
case 7:
local t_list = [tool_build_station, tool_build_way, tool_remove_way]
local wt_list = [gl_wt]
local res = upedate_tools(t_list, tool_id, wt_list, wt)
result = res.result
if(res.ok) return result
break
case 8: //Make Stop public
local t_list = [-tool_remover, -t_icon.road]
local wt_list = [-1]
local res = upedate_tools(t_list, tool_id, wt_list, wt)
result = res.result
if(res.ok) return result
break
}
return result
}

function is_tool_allowed(pl, tool_id, wt){
local result = true
if(step < 8) {
local t_list = [-tool_make_stop_public, 0] // 0 = all tools allowed
local wt_list = [gl_wt]
local res = upedate_tools(t_list, tool_id, wt_list, wt)
result = res.result
if(res.ok) return result
return result
}
else {
local t_list = [0] // 0 = all tools allowed
local wt_list = [gl_wt, -1]
local res = upedate_tools(t_list, tool_id, wt_list, wt)
result = res.result
if(res.ok) return result
return result
}
}


function sch_conv_list(pl, coord) {
local c_dep = this.my_tile(coord)
local depot = depot_x(c_dep.x, c_dep.y, c_dep.z)
Expand Down
Loading

0 comments on commit 12a5ec0

Please sign in to comment.