aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation/operation_panel.lua
blob: 8e12651fc991bc64cb79794109e1b7d85a6ea97f (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
local S = atltrans

local function on_punch(pos,node,player)
	atlatc.interrupt.add(0, pos, {type="punch", punch=true, name=player:get_player_name()})
end


minetest.register_node("advtrains_luaautomation:oppanel", {
	drawtype = "normal",
	tiles={"atlatc_oppanel.png"},
	description = S("LuaATC Operation Panel"),
	groups = {
		cracky = 1,
		save_in_at_nodedb=1,
	},
	after_place_node = atlatc.active.after_place_node,
	after_dig_node = atlatc.active.after_dig_node,
	on_receive_fields = atlatc.active.on_receive_fields,
	on_punch = on_punch,
	luaautomation = {
		fire_event=atlatc.active.run_in_env
	},
	digiline = {
		receptor = {},
		effector = {
			action = atlatc.active.on_digiline_receive
		},
	},
})
span class="hl opt">.."]") end local adefunc = function(def, preset, suffix, rotation) return { after_place_node=function(pos) updateform(pos) end, after_dig_node=function(pos) local pe = advtrains.encode_pos(pos) advtrains.interlocking.npr_rails[pe] = nil end, on_receive_fields = function(pos, formname, fields, player) local pname = player:get_player_name() if not minetest.check_player_privs(pname, {interlocking=true}) then minetest.chat_send_player(pname, S("You are not allowed to configure this track without the @1 privilege.", "interlocking")) return end if minetest.is_protected(pos, pname) then minetest.chat_send_player(pname, S("You are not allowed to configure this track.")) minetest.record_protection_violation(pos, pname) return end if fields.npr then local pe = advtrains.encode_pos(pos) advtrains.interlocking.npr_rails[pe] = tonumber(fields.npr) updateform(pos) end end, advtrains = { on_train_approach = function(pos,train_id, train, index) if train.path_cn[index] == 1 then local pe = advtrains.encode_pos(pos) local npr = advtrains.interlocking.npr_rails[pe] or 2 advtrains.lzb_add_checkpoint(train, index, npr, nil) end end, }, } end if minetest.get_modpath("advtrains_train_track") ~= nil then advtrains.register_tracks("default", { nodename_prefix="advtrains_interlocking:dtrack_npr", texture_prefix="advtrains_dtrack_npr", models_prefix="advtrains_dtrack", models_suffix=".b3d", shared_texture="advtrains_dtrack_shared_npr.png", description=S("Point Speed Restriction Track"), formats={}, get_additional_definiton = adefunc, }, advtrains.trackpresets.t_30deg_straightonly) end