forked from Bremaweb/landrush
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinit.lua
More file actions
166 lines (141 loc) · 4.5 KB
/
init.lua
File metadata and controls
166 lines (141 loc) · 4.5 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
local load_time_start = os.clock()
-- Freeminer Compatibility
if rawget(_G, "freeminer") then
minetest = freeminer
end
landrush = {}
local path = minetest.get_modpath("landrush")
dofile(path.."/config.lua")
dofile(path.."/functions.lua")
dofile(path.."/claims.lua")
dofile(path.."/protection.lua")
dofile(path.."/shared_door.lua")
dofile(path.."/chest.lua")
dofile(path.."/sign.lua")
dofile(path..'/shared_inbox.lua')
if ( landrush.config:get_bool("enableHud") ) then
dofile(path.."/hud.lua")
end
minetest.register_privilege(
"landrush",
"Allows player to dig and build anywhere, " ..
"and use the landrush chat commands."
)
landrush.load_claims()
minetest.register_node("landrush:landclaim", {
description = "Land Rush Land Claim",
tiles = {"landrush_landclaim.png"},
groups = {oddly_breakable_by_hand=2},
on_place = function(itemstack, placer, pointed_thing)
local owner = landrush.get_owner(pointed_thing.above)
local player = placer:get_player_name()
if player:find("[gG]uest") then
minetest.chat_send_player(player,"Guests cannot claim land")
return itemstack
end
if ( pointed_thing.above.y < -200 ) then
minetest.chat_send_player(player,"You cannot claim below -200")
return itemstack
end
if owner then
minetest.chat_send_player(player, "This area is already owned by "..owner)
else
minetest.env:remove_node(pointed_thing.above)
local chunk = landrush.get_chunk(pointed_thing.above)
landrush.claims[chunk] = {owner=placer:get_player_name(),shared={},claimtype="landclaim"}
landrush.save_claims()
if stats then stats.increase_stat(placer:get_player_name(), 'land_claims', 1) end
-- showarea
local entpos = landrush.get_chunk_center(pointed_thing.above)
entpos.y = (pointed_thing.above.y-1)
minetest.env:add_entity(entpos, "landrush:showarea")
minetest.chat_send_player(landrush.claims[chunk].owner, "You now own this area.")
minetest.log("action", "landrush chunk (" .. chunk .. ") claimed by " .. player)
itemstack:take_item()
return itemstack
end
end,
})
minetest.register_craft({
output = 'landrush:landclaim',
recipe = {
{'default:stone','default:steel_ingot','default:stone'},
{'default:steel_ingot','default:mese_crystal','default:steel_ingot'},
{'default:stone','default:steel_ingot','default:stone'}
}
})
minetest.register_alias("landclaim", "landrush:landclaim")
minetest.register_alias("landrush:landclaim_b","landrush:landclaim")
minetest.register_entity("landrush:showarea",{
on_activate = function(self, staticdata, dtime_s)
minetest.after(16,function()
self.object:remove()
end)
end,
initial_properties = {
hp_max = 1,
physical = true,
weight = 0,
collisionbox = {
landrush.config:get("chunkSize")/-2,
landrush.config:get("chunkSize")/-2,
landrush.config:get("chunkSize")/-2,
landrush.config:get("chunkSize")/2,
landrush.config:get("chunkSize")/2,
landrush.config:get("chunkSize")/2,
},
visual = "mesh",
visual_size = {
x=landrush.config:get("chunkSize")+0.1,
y=landrush.config:get("chunkSize")+0.1
},
mesh = "landrush_showarea.x",
textures = {nil, nil, "landrush_showarea.png", "landrush_showarea.png", "landrush_showarea.png", "landrush_showarea.png"}, -- number of required textures depends on visual
colors = {}, -- number of required colors depends on visual
spritediv = {x=1, y=1},
initial_sprite_basepos = {x=0, y=0},
is_visible = true,
makes_footstep_sound = false,
automatic_rotate = false,
}
})
if ( minetest.get_modpath("money2") ) then
minetest.log('action','Loading Landrush Land Sale')
dofile(path.."/landsale.lua")
end
if ( minetest.get_modpath('fire') ) then
minetest.log('action','[landrush] adding fire protection to claimed areas')
dofile(path..'/fire.lua')
end
if ( minetest.get_modpath('bucket') ) then
minetest.log('action','[landrush] adding liquids placement protection')
dofile(path..'/bucket.lua')
end
if minetest.get_modpath("stats") then
stats.register_stat({
name = "land_claims",
description = function(value)
return " - Land claims: "..value
end,
})
stats.register_stat({
name = "land_shares",
description = function(value)
return " - Land shares: "..value
end,
})
end
minetest.after(0, function ()
dofile(path.."/default.lua")
--dofile(path.."/doors.lua")
dofile(path.."/chatcommands.lua")
--dofile(path.."/screwdriver.lua")
dofile(path.."/snow.lua")
end )
minetest.log(
'action',
string.format(
'['..minetest.get_current_modname()..'] loaded in %.3fs',
os.clock() - load_time_start
)
)