diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b25c15b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*~ diff --git a/mods/workbench/init.lua b/mods/workbench/init.lua index 085b12a..93ad4f5 100644 --- a/mods/workbench/init.lua +++ b/mods/workbench/init.lua @@ -15,6 +15,35 @@ minetest.register_node("workbench:workbench", { end, }) +local players_viewdir = {} + +minetest.register_globalstep(function(dtime) + for _,player in ipairs(minetest.get_connected_players()) do + local name = player:get_player_name() + local pitch = player:get_look_pitch() + local yaw = player:get_look_yaw() + local pos = player:getpos() + local o = players_viewdir[name] + if pitch ~= o.pitch or yaw ~= o.yaw or pos.x ~= o.pos.x or pos.y ~= o.pos.y or pos.z ~= o.pos.z then + players_viewdir[name] = {pitch = pitch, yaw = yaw, pos = {x = pos.x, y = pos.y, z = pos.z}} + local inv = player:get_inventory() + pos.y = pos.y+1.5 + local ldir = player:get_look_dir() + pos.x = pos.x + ldir.x + pos.y = pos.y + ldir.y + pos.z = pos.z + ldir.z + for i,stack in ipairs(inv:get_list("craft")) do + local obj = minetest.add_item(pos, stack) + if obj then + obj:setvelocity(ldir) + end + stack:clear() + inv:set_stack("craft", i, stack) + end + end + end +end) + minetest.register_craft({ output = "workbench:workbench", recipe = { @@ -25,6 +54,7 @@ minetest.register_craft({ minetest.register_on_joinplayer(function(player) if not minetest.setting_getbool("creative_mode") then + players_viewdir[player:get_player_name()] = {pitch = 0, yaw = 0, pos={x = 0, y = 0, z = 0}} player:get_inventory():set_width("craft", 3) player:get_inventory():set_size("craft", 9) player:get_inventory():set_size("main", 9*4)