wasplib: add some placement helpers
This commit is contained in:
parent
cdb58adb4f
commit
00feaa15ad
@ -588,6 +588,43 @@ function ws.gaim(tpos,v,g)
|
||||
minetest.localplayer:set_pitch(math.deg(pitch))
|
||||
end
|
||||
|
||||
function ws.buildable_to(pos)
|
||||
local node=minetest.get_node_or_nil(pos)
|
||||
if node then
|
||||
return minetest.get_node_def(node.name).buildable_to
|
||||
end
|
||||
end
|
||||
|
||||
function ws.tplace(p,n,stay)
|
||||
if not p then return end
|
||||
if n then ws.switch_to_item(n) end
|
||||
local opos=ws.dircoord(0,0,0)
|
||||
local tpos=vector.add(p,vector.new(0,1,0))
|
||||
minetest.localplayer:set_pos(tpos)
|
||||
ws.place(p,{n})
|
||||
if not stay then
|
||||
minetest.after(0.1,function()
|
||||
minetest.localplayer:set_pos(opos)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("tplace", {
|
||||
description = "tp-place",
|
||||
param = "Y",
|
||||
func = function(param)
|
||||
return ws.tplace(minetest.string_to_pos(param))
|
||||
end
|
||||
})
|
||||
|
||||
function ws.ytp(param)
|
||||
local y=tonumber(param)
|
||||
local lp=ws.dircoord(0,0,0)
|
||||
if lp.y < y + 50 then return false,"Can't TP up." end
|
||||
if y < -30912 then return false,"Don't TP into the void lol." end
|
||||
minetest.localplayer:set_pos(vector.new(lp.x,y,lp.z))
|
||||
end
|
||||
|
||||
local function tablearg(arg)
|
||||
local tb={}
|
||||
if type(arg) == 'string' then
|
||||
|
Loading…
x
Reference in New Issue
Block a user