-
Notifications
You must be signed in to change notification settings - Fork 6
/
internal.lua
57 lines (55 loc) · 1.37 KB
/
internal.lua
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
digistuff.mesecons_installed = minetest.get_modpath("mesecons")
digistuff.rotate_rules = function(rulesin,dir)
local rules = {}
for k,v in ipairs(rulesin) do rules[k] = v end
if dir.z > 0 then
return rules
elseif dir.z < 0 then
for _,i in ipairs(rules) do
i.x = -i.x
i.z = -i.z
end
return rules
elseif dir.x > 0 then
for _,i in ipairs(rules) do
local z = i.x
i.x = i.z
i.z = -z
end
return rules
elseif dir.x < 0 then
for _,i in ipairs(rules) do
local z = i.x
i.x = -i.z
i.z = z
end
return rules
elseif dir.y > 0 then
for _,i in ipairs(rules) do
local z = i.y
i.y = i.z
i.z = z
end
return rules
elseif dir.y < 0 then
for _,i in ipairs(rules) do
local z = i.y
i.y = -i.z
i.z = -z
end
return rules
else
minetest.log("warning",string.format("digistuff.rotate_rules() called with invalid direction %s,%s,%s",dir.x,dir.y,dir.z))
return {}
end
end
digistuff.check_protection = function(pos,player)
assert(type(pos) == "table","Position must be a table")
assert(type(player) == "string" or type(player) == "userdata","Invalid player specified")
if type(player) == "userdata" then player = player:get_player_name() end
if minetest.is_protected(pos,player) and not minetest.check_player_privs(player,{protection_bypass=true}) then
minetest.record_protection_violation(pos,player)
return false
end
return true
end