aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_minimap.h
blob: ba702b0b1433b5bad659007d4bc1a26addc52650 (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
/*
Minetest
Copyright (C) 2017 Loic Blot <loic.blot@unix-experience.fr>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef L_MINIMAP_H_
#define L_MINIMAP_H_

#include "l_base.h"

class Minimap;

class LuaMinimap : public ModApiBase
{
private:
	static const char className[];
	static const luaL_Reg methods[];

	// garbage collector
	static int gc_object(lua_State *L);

	static int l_get_pos(lua_State *L);
	static int l_set_pos(lua_State *L);

	static int l_get_angle(lua_State *L);
	static int l_set_angle(lua_State *L);

	static int l_get_mode(lua_State *L);
	static int l_set_mode(lua_State *L);

	static int l_show(lua_State *L);
	static int l_hide(lua_State *L);

	static int l_set_shape(lua_State *L);
	static int l_get_shape(lua_State *L);

	Minimap *m_minimap;

public:
	LuaMinimap(Minimap *m);
	~LuaMinimap() {}

	static void create(lua_State *L, Minimap *object);

	static LuaMinimap *checkobject(lua_State *L, int narg);
	static Minimap *getobject(LuaMinimap *ref);

	static void Register(lua_State *L);
};

#endif // L_MINIMAP_H_
>check_player_privs(pname, {atlatc=true}) then minetest.chat_send_player(pname, S("You are not allowed to name LuaATC passive components without the @1 privilege.", "atlatc")) return end if pointed_thing.type=="node" then local pos=pointed_thing.under if advtrains.is_protected(pos, pname) then minetest.record_protection_violation(pos, pname) return end local node = advtrains.ndb.get_node(pos) local ndef = minetest.registered_nodes[node.name] if node.name and ( minetest.get_item_group(node.name, "advtrains_signal")>0 --is IL signal or advtrains.is_passive(pos) -- is passive component or (ndef and ndef.luaautomation) -- is active component ) then --look if this one already has a name local pn="" for name, npos in pairs(atlatc.pcnaming.name_map) do if vector.equals(npos, pos) then pn=name end end pcrename[pname] = pos minetest.show_formspec(pname, "atlatc_naming", "field[pn;"..S("Set name of component (empty to clear)")..";"..minetest.formspec_escape(pn).."]") end end end, }) minetest.register_on_player_receive_fields(function(player, formname, fields) if formname == "atlatc_naming" then local pname = player:get_player_name() local pos=pcrename[pname] if fields.pn and pos then --first remove all occurences for name, npos in pairs(atlatc.pcnaming.name_map) do if vector.equals(npos, pos) then atlatc.pcnaming.name_map[name]=nil end end if fields.pn~="" then atlatc.pcnaming.name_map[fields.pn]=pos end end end end)