diff options
author | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2013-11-07 22:16:37 -0500 |
---|---|---|
committer | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2013-11-07 22:16:37 -0500 |
commit | 4b4e10ff1d4f1bde96c47331738e4af27bec6142 (patch) | |
tree | 3d5a07f680e0b7eef590a995de480fae1cff2d61 /stairsplus.lua | |
parent | 524dcb1396aa9df0f60c6f74d91c2e24c19e9ad6 (diff) |
Rewrite slightly to use the new 6d facedir prediction code in builtin.
Keeps the old behavior of sneak == force wall (rather than invert).
Add protection/ownership checking. Can be phased out later after protection
mods start taking advantage of the engine's built-in ownershi-checking
functions.
Got rid of the /st command, since it didn't work anyway.
Minor re-arrangement of init.lua to put the mod's title block at the top
where it belongs :-)
Diffstat (limited to 'stairsplus.lua')
-rw-r--r-- | stairsplus.lua | 73 |
1 files changed, 13 insertions, 60 deletions
diff --git a/stairsplus.lua b/stairsplus.lua index c99ffd2..c03a3e9 100644 --- a/stairsplus.lua +++ b/stairsplus.lua @@ -14,22 +14,6 @@ local dirs1 = { 21, 20, 23, 22, 21 } local dirs2 = { 15, 8, 17, 6, 15 } local dirs3 = { 14, 11, 16, 5, 14 } -stairsplus_players_onwall = {} - -minetest.register_chatcommand("st", { - params = "", - description = "Toggle stairsplus between placing wall/vertical stairs/panels and normal.", - func = function(name, param) - stairsplus_players_onwall[name] = not stairsplus_players_onwall[name] - - if stairsplus_players_onwall[name] then - minetest.chat_send_player(name, "Stairsplus: Placing wall stairs/vertical panels.") - else - minetest.chat_send_player(name, "Stairsplus: Placing floor/ceiling stairs/panels.") - end - end -}) - stairsplus_can_it_stack = function(itemstack, placer, pointed_thing) return false --[[ @@ -100,54 +84,23 @@ local function get_nodedef_field(nodename, fieldname) return minetest.registered_nodes[nodename][fieldname] end -function stairsplus_rotate_and_place(itemstack, placer, pointed_thing, onwall) - - local node = minetest.env:get_node(pointed_thing.under) - - if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then - - local above = pointed_thing.above - local under = pointed_thing.under - local top = {x=under.x, y=under.y+1, z=under.z} - - local pitch = placer:get_look_pitch() - local node = minetest.env:get_node(above) - local fdir = minetest.dir_to_facedir(placer:get_look_dir()) - local wield_name = itemstack:get_name() - - local slab = string.find(wield_name, "slab") - local panel = string.find(wield_name, "panel") - local micro = string.find(wield_name, "micro") - local iswall = (above.x ~= under.x) or (above.z ~= under.z) - local isceiling = (above.x == under.x) and (above.z == under.z) and (pitch > 0) - - if get_nodedef_field(minetest.env:get_node(under).name, "buildable_to") then - if slab then fdir = 0 end - minetest.env:add_node(under, {name = wield_name, param2 = fdir }) -- place right side up - elseif not get_nodedef_field(minetest.env:get_node(above).name, "buildable_to") then - return - elseif onwall or (iswall and (slab or panel)) then - if slab then - minetest.env:add_node(above, {name = wield_name, param2 = dirs2[fdir+2] }) -- place with wall slab rotation - else - minetest.env:add_node(above, {name = wield_name, param2 = dirs3[fdir+2] }) -- place with wall panel/micro rotation - end - elseif isceiling then - local nfdir = dirs1[fdir+2] - if slab then nfdir = 22 end - minetest.env:add_node(above, {name = wield_name, param2 = nfdir }) -- place upside down variant - else - if slab then fdir = 0 end - minetest.env:add_node(above, {name = wield_name, param2 = fdir }) -- place right side up - end +--[[ - if not stairsplus_expect_infinite_stacks then - itemstack:take_item() +function(itemstack, placer, pointed_thing) + local keys=placer:get_player_control() + stairsplus_rotate_and_place(itemstack, placer, pointed_thing, keys["sneak"]) return itemstack end - else - minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer) + +]]-- + +function stairsplus_rotate_and_place(itemstack, placer, pointed_thing) + if not moreblocks.node_is_owned(pointed_thing.under, placer) then + local keys=placer:get_player_control() + minetest.rotate_and_place(itemstack, placer, pointed_thing, + stairsplus_expect_infinite_stacks, {force_wall = keys.sneak}) end + return itemstack end function register_stair_slab_panel_micro(modname, subname, recipeitem, groups, images, description, drop, light) |