Add owner to translocators.
This commit is contained in:
parent
04ade2f8ff
commit
ada9d80bc6
5 changed files with 23 additions and 5 deletions
|
@ -3,6 +3,7 @@ local max_depth = 31000
|
|||
-- pyramid stone
|
||||
newnode = fun_caves.clone_node("default:sandstone")
|
||||
newnode.description = "Pyramid Stone"
|
||||
newnode.tiles = {'fun_caves_pyramid_stone.png'}
|
||||
newnode.groups.pyramid = 1
|
||||
newnode.drop = 'default:sandstone'
|
||||
minetest.register_node("fun_caves:pyramid_1", newnode)
|
||||
|
|
|
@ -362,6 +362,10 @@ local function trans_place(itemstack, placer, pointed_thing)
|
|||
if not (data and data.id) then
|
||||
return
|
||||
end
|
||||
local player_name = placer:get_player_name()
|
||||
if not data.owner or data.owner == '' then
|
||||
data.owner = player_name
|
||||
end
|
||||
local pos = pointed_thing.above
|
||||
local pair = fun_caves.db.translocators[tonumber(data.id)]
|
||||
if not pair or #pair > 1 then
|
||||
|
@ -373,6 +377,7 @@ local function trans_place(itemstack, placer, pointed_thing)
|
|||
pair[#pair+1] = pos
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string('id', data.id)
|
||||
meta:set_string('owner', data.owner)
|
||||
end
|
||||
return ret, place_good
|
||||
end
|
||||
|
@ -382,16 +387,25 @@ local function trans_dig(pos, node, digger)
|
|||
return
|
||||
end
|
||||
|
||||
if minetest.is_protected(pos, digger:get_player_name()) then
|
||||
local player_name = digger:get_player_name()
|
||||
if minetest.is_protected(pos, player_name) then
|
||||
return
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local id = meta:get_string('id')
|
||||
local data = { id = id }
|
||||
if not (data and data.id) then
|
||||
local owner = meta:get_string('owner')
|
||||
local data = { id = id, owner = owner }
|
||||
if not (data and data.id) or (data.owner ~= '' and data.owner ~= player_name) then
|
||||
local privs = minetest.check_player_privs(player_name, {server=true})
|
||||
if privs then
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
return
|
||||
end
|
||||
if data.owner == '' then
|
||||
data.owner = player_name
|
||||
end
|
||||
local pair = fun_caves.db.translocators[tonumber(data.id)]
|
||||
if not pair or #pair < 1 then
|
||||
print('* Fun Caves: low error in translocator storage')
|
||||
|
@ -413,8 +427,9 @@ local function trans_dig(pos, node, digger)
|
|||
end
|
||||
end
|
||||
|
||||
newnode = fun_caves.clone_node("default:steelblock")
|
||||
local newnode = fun_caves.clone_node("default:steelblock")
|
||||
newnode.description = "Translocator"
|
||||
newnode.tiles = {'fun_caves_translocator.png'}
|
||||
newnode.on_rightclick = translocate
|
||||
newnode.on_use = trans_use
|
||||
newnode.on_place = trans_place
|
||||
|
@ -440,8 +455,9 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv
|
|||
return
|
||||
end
|
||||
|
||||
data = {}
|
||||
local data = {}
|
||||
data.id = string.format('%d', #fun_caves.db.translocators+1)
|
||||
data.owner = player:get_player_name()
|
||||
fun_caves.db.translocators[#fun_caves.db.translocators+1] = {}
|
||||
local data_str = minetest.serialize(data)
|
||||
itemstack:set_metadata(data_str)
|
||||
|
|
BIN
textures/fun_caves_pyramid_stone.png
Normal file
BIN
textures/fun_caves_pyramid_stone.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 258 B |
BIN
textures/fun_caves_translocator.png
Normal file
BIN
textures/fun_caves_translocator.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 357 B |
|
@ -9,3 +9,4 @@ Modified radioactive ore: everamzah
|
|||
Original DNA: Zephyris (cc-by-sa 3), https://en.wikipedia.org/wiki/File:DNA_Structure%2BKey%2BLabelled.pn_NoBB.png
|
||||
Original moonstone: Didier Descouens (cc-by-sa 4), https://en.wikipedia.org/wiki/File:Pierrelune.jpg
|
||||
Wallhammer images by the eminent DonBatman (DWYWPL), https://forum.minetest.net/viewtopic.php?f=11&t=13484&hilit=masonry+hammer
|
||||
The pyramid and translocator textures are copied from the default sandstone and steel block, respectively.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue