aboutsummaryrefslogtreecommitdiff
path: root/advtrains_line_automation
diff options
context:
space:
mode:
authorSingularis <singularis@volny.cz>2025-03-23 04:24:30 +0100
committerorwell <orwell@bleipb.de>2025-05-27 20:22:01 +0200
commitc80d5470cd231c50a4f929781deb412cd2351fd1 (patch)
tree48fbffaf09b56ee1ba2158d1c2147d404ab1b7c5 /advtrains_line_automation
parente0febba0a9b6876b1e056abc06c5664f5fd0d7a0 (diff)
downloadadvtrains-c80d5470cd231c50a4f929781deb412cd2351fd1.tar.gz
advtrains-c80d5470cd231c50a4f929781deb412cd2351fd1.tar.bz2
advtrains-c80d5470cd231c50a4f929781deb412cd2351fd1.zip
[advtrains_line_automation] opravy jízdního řádu, možnost použití v ruce
- [ch_core/registrace] z výchozích předmětů odebrána mapa, přidána runa návratu a jízdní řád
Diffstat (limited to 'advtrains_line_automation')
-rw-r--r--advtrains_line_automation/init.lua1
-rw-r--r--advtrains_line_automation/station_editor.lua183
-rw-r--r--advtrains_line_automation/time_table.lua88
3 files changed, 139 insertions, 133 deletions
diff --git a/advtrains_line_automation/init.lua b/advtrains_line_automation/init.lua
index fbf1d8d..a54fdfe 100644
--- a/advtrains_line_automation/init.lua
+++ b/advtrains_line_automation/init.lua
@@ -25,6 +25,7 @@ dofile(modpath.."scheduler.lua")
dofile(modpath.."station_editor.lua")
dofile(modpath.."stoprail.lua")
dofile(modpath.."station_announcement.lua")
+dofile(modpath.."time_table.lua")
function advtrains.lines.load(data)
if data then
diff --git a/advtrains_line_automation/station_editor.lua b/advtrains_line_automation/station_editor.lua
index 5af9005..084d3e9 100644
--- a/advtrains_line_automation/station_editor.lua
+++ b/advtrains_line_automation/station_editor.lua
@@ -731,59 +731,58 @@ local function get_jr_formspec(custom_state)
access_level = "owner"
end
- if access_level ~= "player" then
- -- admin or owner:
- table.insert(formspec, "label[0.5,0.6;Jízdní řády]"..
- "dropdown[5,0.3;10,0.6;dopravna;")
- for i, r in ipairs(custom_state.stns) do
- table.insert(formspec, ifthenelse(i == 1, r.fs, ","..r.fs))
- end
- table.insert(formspec, ";"..custom_state.stn..";true]"..
- "dropdown[15.25,0.3;3.5,0.6;kolej;")
- for i, r in ipairs(custom_state.tracks) do
- if i == 1 then
- table.insert(formspec, "(všechny koleje)")
- else
- table.insert(formspec, ","..F(r))
+ if node_owner ~= nil then
+ if access_level ~= "player" then
+ -- admin or owner:
+ table.insert(formspec, "label[0.5,0.6;Jízdní řády]"..
+ "dropdown[5,0.3;10,0.6;dopravna;")
+ for i, r in ipairs(custom_state.stns) do
+ table.insert(formspec, ifthenelse(i == 1, r.fs, ","..r.fs))
end
- end
- table.insert(formspec, ";"..custom_state.track..";true]")
- else
- -- player (including 'new' players)
- local stn_info = custom_state.stns[custom_state.stn]
- if stn_info.stn == "" then
- table.insert(formspec, "label[0.5,0.6;Jízdní řády (všechny linky)]")
+ table.insert(formspec, ";"..custom_state.stn..";true]"..
+ "dropdown[15.25,0.3;3.5,0.6;kolej;")
+ for i, r in ipairs(custom_state.tracks) do
+ if i == 1 then
+ table.insert(formspec, "(všechny koleje)")
+ else
+ table.insert(formspec, ","..F(r))
+ end
+ end
+ table.insert(formspec, ";"..custom_state.track..";true]")
else
- local track = custom_state.tracks[custom_state.track]
- if track ~= "" then
- track = F(" ["..track.."]")
+ -- player (including 'new' players)
+ local stn_info = custom_state.stns[custom_state.stn]
+ if stn_info.stn == "" then
+ table.insert(formspec, "label[0.5,0.6;Jízdní řády (všechny linky)]")
+ else
+ local track = custom_state.tracks[custom_state.track]
+ if track ~= "" then
+ track = F(" ["..track.."]")
+ end
+ table.insert(formspec, "label[0.5,0.6;"..F("Jízdní řády: ")..stn_info.name_fs..track.."]")
end
- table.insert(formspec, "label[0.5,0.6;"..F("Jízdní řády: ")..stn_info.name_fs..track.."]")
end
- end
-
- if access_level ~= "admin" then
- table.insert(formspec, "label[0.5,1.65;vlastník/ice j. řádu: ")
- if node_owner ~= nil then
+ if access_level ~= "admin" then
+ -- player/owner
+ table.insert(formspec, "label[0.5,1.65;vlastník/ice j. řádu: ")
table.insert(formspec, ch_core.prihlasovaci_na_zobrazovaci(node_owner))
+ if stn_owner ~= nil then
+ table.insert(formspec, " | dopravnu spravuje: ")
+ table.insert(formspec, ch_core.prihlasovaci_na_zobrazovaci(stn_owner))
+ end
+ table.insert(formspec, "]")
else
- table.insert(formspec, "???")
- end
- if stn_owner ~= nil then
- table.insert(formspec, " | dopravnu spravuje: ")
- table.insert(formspec, ch_core.prihlasovaci_na_zobrazovaci(stn_owner))
- end
- table.insert(formspec, "]")
- else
- if node_owner ~= nil then
+ -- admin only
table.insert(formspec, "label[0.5,1.65;vlastník/ice:]"..
"field[2.75,1.25;5,0.75;owner;;")
table.insert(formspec, ch_core.prihlasovaci_na_zobrazovaci(node_owner))
table.insert(formspec, "]button[8,1.25;3,0.75;setowner;nastavit]")
+ if stn_owner ~= nil then
+ table.insert(formspec, "label[11.25,1.65;dopravnu spravuje: "..ch_core.prihlasovaci_na_zobrazovaci(stn_owner).."]")
+ end
end
- if stn_owner ~= nil then
- table.insert(formspec, "label[11.25,1.65;dopravnu spravuje: "..ch_core.prihlasovaci_na_zobrazovaci(stn_owner).."]")
- end
+ else
+ table.insert(formspec, "label[0.5,0.6;Příruční jízdní řády (všechny linky)]")
end
table.insert(formspec, "tablecolumns[text,align=right,tooltip=linka;text,width=12,tooltip=cíl;text,tooltip=kolej;color;text,tooltip=stav]"..
@@ -832,17 +831,6 @@ local function get_jr_formspec(custom_state)
end
local function jr_formspec_callback(custom_state, player, formname, fields)
- --[[
- fields:
- - dopravna (dropdown)
- - kolej (dropdown)
- - owner (field)
- - setowner (button)
- - linka (table)
- - zastavka (table)
- - close (button_exit)
- - refresh (button)
- ]]
if fields.dopravna then
local new_stn = tonumber(fields.dopravna)
if new_stn ~= nil and new_stn ~= custom_state.stn and custom_state.stns[new_stn] ~= nil then
@@ -875,8 +863,14 @@ local function jr_formspec_callback(custom_state, player, formname, fields)
return get_jr_formspec(custom_state)
end
end
- if fields.setowner then
- -- TODO: implementovat změnu vlastníka/ice
+ if fields.setowner and custom_state.pos ~= nil and is_jr_node_name(core.get_node(custom_state.pos).name) then
+ local meta = core.get_meta(custom_state.pos)
+ local jm = ch_core.jmeno_na_existujici_prihlasovaci(fields.owner)
+ if jm ~= nil then
+ meta:set_string("owner", jm)
+ else
+ core.chat_send_player(custom_state.player_name, "*** Postava '"..fields.owner.."' neexistuje!")
+ end
return get_jr_formspec(custom_state)
end
if fields.linka then
@@ -916,7 +910,7 @@ local function jr_formspec_callback(custom_state, player, formname, fields)
end
end
-local function show_jr_formspec(player, pos, stn, track, linevar, stop_stn)
+function advtrains.lines.show_jr_formspec(player, pos, stn, track, linevar, stop_stn)
assert(core.is_player(player))
local custom_state = {
player_name = player:get_player_name(),
@@ -946,80 +940,3 @@ local function show_jr_formspec(player, pos, stn, track, linevar, stop_stn)
return ch_core.show_formspec(player, "advtrains_line_automation:jizdni_rad",
get_jr_formspec(custom_state), jr_formspec_callback, custom_state, {})
end
-
-local visual_scale = 15/16
-local node_box = {type = "fixed", fixed = {
- -16/32, -16/32, 15/32 / visual_scale,
- 16/32, 16/32, 16/32 / visual_scale,
-}}
-local sbox = {type = "fixed", fixed = {
- -16/32 * visual_scale, -16/32 * visual_scale, 15/32,
- 16/32 * visual_scale, 16/32 * visual_scale, 16/32,
-}}
-
-local def = {
- description = "jízdní řád",
- drawtype = "nodebox",
- node_box = node_box,
- selection_box = sbox,
- collision_box = sbox,
- tiles = {
- {name = "ch_core_white_pixel.png^[multiply:#aaaaaa"},
- {name = "ch_core_white_pixel.png^[multiply:#aaaaaa"},
- {name = "ch_core_white_pixel.png^[multiply:#aaaaaa"},
- {name = "ch_core_white_pixel.png^[multiply:#aaaaaa"},
- {name = "advtrains_line_automation_jrad.png"},
- {name = "advtrains_line_automation_jrad.png"},
- },
- paramtype = "light",
- paramtype2 = "4dir",
- sunlight_propagates = true,
- groups = {cracky = 3, ch_jrad = 1},
- sounds = default.node_sound_metal_defaults(),
- visual_scale = visual_scale,
- after_place_node = function(pos, placer, itemstack, pointed_thing)
- local player_name = placer and placer:get_player_name()
- if player_name ~= nil then
- local meta = core.get_meta(pos)
- meta:set_string("infotext", "jízdní řád")
- meta:set_string("owner", player_name)
- end
- end,
- can_dig = function(pos, player)
- if player == nil then
- return false
- end
- local player_name = player:get_player_name()
- if ch_core.get_player_role(player_name) == "admin" then
- return true
- end
- if core.is_protected(pos, player_name) then
- core.record_protection_violation(pos, player_name)
- return false
- end
- local meta = core.get_meta(pos)
- local owner = meta:get_string("owner")
- return owner == "" or owner == player_name
- end,
- on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
- if clicker ~= nil and core.is_player(clicker) then
- local meta = core.get_meta(pos)
- show_jr_formspec(clicker, pos, meta:get_string("stn"), meta:get_string("track"))
- end
- end,
-}
-
-core.register_node("advtrains_line_automation:jrad", table.copy(def))
-def.description = "jízdní řád (na tyč)"
-def.node_box = {type = "fixed", fixed = {
- -16/32, -16/32, 27/32 / visual_scale,
- 16/32, 16/32, 28/32 / visual_scale,
-}}
-def.selection_box = {type = "fixed", fixed = {
- -16/32 * visual_scale, -16/32 * visual_scale, 27/32,
- 16/32 * visual_scale, 16/32 * visual_scale, 28/32,
-}}
-def.collision_box = def.selection_box
-def.tiles = table.copy(def.tiles)
-def.tiles[5] = def.tiles[1]
-core.register_node("advtrains_line_automation:jrad_on_pole", def)
diff --git a/advtrains_line_automation/time_table.lua b/advtrains_line_automation/time_table.lua
index e69de29..975abd3 100644
--- a/advtrains_line_automation/time_table.lua
+++ b/advtrains_line_automation/time_table.lua
@@ -0,0 +1,88 @@
+local visual_scale = 15/16
+local node_box = {type = "fixed", fixed = {
+ -16/32, -16/32, 15/32 / visual_scale,
+ 16/32, 16/32, 16/32 / visual_scale,
+}}
+local sbox = {type = "fixed", fixed = {
+ -16/32 * visual_scale, -16/32 * visual_scale, 15/32,
+ 16/32 * visual_scale, 16/32 * visual_scale, 16/32,
+}}
+
+local def = {
+ description = "jízdní řád",
+ drawtype = "nodebox",
+ node_box = node_box,
+ selection_box = sbox,
+ collision_box = sbox,
+ tiles = {
+ {name = "ch_core_white_pixel.png^[multiply:#aaaaaa"},
+ {name = "ch_core_white_pixel.png^[multiply:#aaaaaa"},
+ {name = "ch_core_white_pixel.png^[multiply:#aaaaaa"},
+ {name = "ch_core_white_pixel.png^[multiply:#aaaaaa"},
+ {name = "advtrains_line_automation_jrad.png"},
+ {name = "advtrains_line_automation_jrad.png"},
+ },
+ paramtype = "light",
+ paramtype2 = "4dir",
+ sunlight_propagates = true,
+ groups = {cracky = 3, ch_jrad = 1},
+ sounds = default.node_sound_metal_defaults(),
+ visual_scale = visual_scale,
+ _ch_help = "Použitím (levým klikem) zobrazí jízdní řády všech linek.\nLze umístit do světa a nastavit na jízdní řády v konkrétní stanici/zastávce.\nPo umístění lze také barvit barvicí pistolí.",
+ _ch_help_group = "jrad",
+ after_place_node = function(pos, placer, itemstack, pointed_thing)
+ local player_name = placer and placer:get_player_name()
+ if player_name ~= nil then
+ local meta = core.get_meta(pos)
+ meta:set_string("infotext", "jízdní řád (spravuje: "..ch_core.prihlasovaci_na_zobrazovaci(player_name)..")")
+ meta:set_string("owner", player_name)
+ end
+ end,
+ can_dig = function(pos, player)
+ if player == nil then
+ return false
+ end
+ local player_name = player:get_player_name()
+ if ch_core.get_player_role(player_name) == "admin" then
+ return true
+ end
+ if core.is_protected(pos, player_name) then
+ core.record_protection_violation(pos, player_name)
+ return false
+ end
+ local meta = core.get_meta(pos)
+ local owner = meta:get_string("owner")
+ return owner == "" or owner == player_name
+ end,
+ on_use = function(itemstack, user, pointed_thing)
+ if core.is_player(user) then
+ advtrains.lines.show_jr_formspec(user)
+ end
+ end,
+ on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
+ if clicker ~= nil and core.is_player(clicker) then
+ local meta = core.get_meta(pos)
+ advtrains.lines.show_jr_formspec(clicker, pos, meta:get_string("stn"), meta:get_string("track"))
+ end
+ end,
+}
+
+core.register_node("advtrains_line_automation:jrad", table.copy(def))
+
+def.description = "jízdní řád (na tyč)"
+def.tiles = table.copy(def.tiles)
+def.tiles[5] = def.tiles[1]
+def.node_box = {
+ type = "fixed",
+ fixed = {
+ -16/32, -16/32, 27/32 / visual_scale,
+ 16/32, 16/32, 28/32 / visual_scale,
+ }}
+def.selection_box = {
+ type = "fixed",
+ fixed = {
+ -16/32 * visual_scale, -16/32 * visual_scale, 27/32,
+ 16/32 * visual_scale, 16/32 * visual_scale, 28/32,
+}}
+def.collision_box = def.selection_box
+core.register_node("advtrains_line_automation:jrad_on_pole", def)