aboutsummaryrefslogtreecommitdiff
path: root/advtrains_line_automation/time_table.lua
blob: 9e4885ec567d36e2a7ff08385806f17b212b8422 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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)
			-- show_jr_formspec(player, pos, stn, track, linevar, stop_stn, force_unprivileged)
			local force_unprivileged = false
			if clicker:get_player_control().aux1 then
				force_unprivileged = true
			end
			advtrains.lines.show_jr_formspec(clicker, pos, meta:get_string("stn"), meta:get_string("track"), nil, nil, force_unprivileged)
		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)