/po/pl/

e/favicon.png'/>
aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation/chatcmds.lua
blob: 2d0c69d73168913ef7876250cf1261bbdf76150b (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
--chatcmds.lua
--Registers commands to modify the init and step code for LuaAutomation

--position helper.
--punching a node will result in that position being saved and inserted into a text field on the top of init form.
local punchpos={}

minetest.register_on_punchnode(function(pos, node, player, pointed_thing)
	local pname=player:get_player_name()
	punchpos[pname]=pos
end)

local function get_init_form(env, pname)
	local err = env.init_err or ""
	local code = env.init_code or ""
	local ppos=punchpos[pname]
	local pp=""
	if ppos then
		pp="POS"..minetest.pos_to_string(ppos)
	end
	local form = "size[10,10]button[0,0;2,1;run;Run InitCode]button[2,0;2,1;cls;Clear S]"
		.."button[4,0;2,1;save;Save] button[6,0;2,1;del;Delete Env.] field[8.1,0.5;2,1;punchpos;Last punched position;"..pp.."]"
		.."textarea[0.2,1;10,10;code;Environment initialization code;"..minetest.formspec_escape(code).."]"
		.."label[0,9.8;"..err.."]"
	return form
end

core.register_chatcommand("env_setup", {
	params = "<environment name>",
	description = "Set up and modify AdvTrains LuaAutomation environment",
	privs = {atlatc=true},
	func = function(name, param)
		local env=atlatc.envs[param]