From 570e864f1c48c3f8fba95caaf4f406a3d21d9302 Mon Sep 17 00:00:00 2001 From: Phil Morrell Date: Wed, 5 Sep 2018 19:45:38 +0100 Subject: [PATCH 1/4] convert walking_light to ocd diff * two potential forks after v0.6: myoung008 or petermaloney --- diff/walking_light.diff/init.lua | 144 ++++++++++++++++++ diff/walking_light.diff/init.lua.diff | 9 ++ .../textures/walking_light_mesepick.png | Bin 0 -> 122 bytes mods/walking_light/init.lua.diff | 9 ++ 4 files changed, 162 insertions(+) create mode 100644 diff/walking_light.diff/init.lua create mode 100644 diff/walking_light.diff/init.lua.diff create mode 100644 diff/walking_light.diff/textures/walking_light_mesepick.png create mode 100644 mods/walking_light/init.lua.diff diff --git a/diff/walking_light.diff/init.lua b/diff/walking_light.diff/init.lua new file mode 100644 index 0000000..515a919 --- /dev/null +++ b/diff/walking_light.diff/init.lua @@ -0,0 +1,144 @@ +local players = {} +local player_positions = {} +local last_wielded = {} + +function round(num) + return math.floor(num + 0.5) +end + +minetest.register_on_joinplayer(function(player) + local player_name = player:get_player_name() + table.insert(players, player_name) + last_wielded[player_name] = player:get_wielded_item():get_name() + local pos = player:getpos() + local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)} + local wielded_item = player:get_wielded_item():get_name() + if wielded_item ~= "default:torch" and wielded_item ~= "walking_light:pick_mese" then + -- Neuberechnung des Lichts erzwingen + minetest.env:add_node(rounded_pos,{type="node",name="default:cobble"}) + minetest.env:add_node(rounded_pos,{type="node",name="air"}) + end + player_positions[player_name] = {} + player_positions[player_name]["x"] = rounded_pos.x; + player_positions[player_name]["y"] = rounded_pos.y; + player_positions[player_name]["z"] = rounded_pos.z; +end) + +minetest.register_on_leaveplayer(function(player) + local player_name = player:get_player_name() + for i,v in ipairs(players) do + if v == player_name then + table.remove(players, i) + last_wielded[player_name] = nil + -- Neuberechnung des Lichts erzwingen + local pos = player:getpos() + local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)} + minetest.env:add_node(rounded_pos,{type="node",name="default:cobble"}) + minetest.env:add_node(rounded_pos,{type="node",name="air"}) + player_positions[player_name]["x"] = nil + player_positions[player_name]["y"] = nil + player_positions[player_name]["z"] = nil + player_positions[player_name]["m"] = nil + player_positions[player_name] = nil + end + end +end) + +minetest.register_globalstep(function(dtime) + for i,player_name in ipairs(players) do + local player = minetest.env:get_player_by_name(player_name) + local wielded_item = player:get_wielded_item():get_name() + if wielded_item == "default:torch" or wielded_item == "walking_light:pick_mese" then + -- Fackel ist in der Hand + local pos = player:getpos() + local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)} + if (last_wielded[player_name] ~= "default:torch" and last_wielded[player_name] ~= "walking_light:pick_mese") or (player_positions[player_name]["x"] ~= rounded_pos.x or player_positions[player_name]["y"] ~= rounded_pos.y or player_positions[player_name]["z"] ~= rounded_pos.z) then + -- Fackel gerade in die Hand genommen oder zu neuem Node bewegt + local is_air = minetest.env:get_node_or_nil(rounded_pos) + if is_air == nil or (is_air ~= nil and (is_air.name == "air" or is_air.name == "walking_light:light")) then + -- wenn an aktueller Position "air" ist, Fackellicht setzen + minetest.env:add_node(rounded_pos,{type="node",name="walking_light:light"}) + end + if (player_positions[player_name]["x"] ~= rounded_pos.x or player_positions[player_name]["y"] ~= rounded_pos.y or player_positions[player_name]["z"] ~= rounded_pos.z) then + -- wenn Position geänder, dann altes Licht löschen + local old_pos = {x=player_positions[player_name]["x"], y=player_positions[player_name]["y"], z=player_positions[player_name]["z"]} + -- Neuberechnung des Lichts erzwingen + local is_light = minetest.env:get_node_or_nil(old_pos) + if is_light ~= nil and is_light.name == "walking_light:light" then + minetest.env:add_node(old_pos,{type="node",name="default:cobble"}) + minetest.env:add_node(old_pos,{type="node",name="air"}) + end + end + -- gemerkte Position ist nun die gerundete neue Position + player_positions[player_name]["x"] = rounded_pos.x + player_positions[player_name]["y"] = rounded_pos.y + player_positions[player_name]["z"] = rounded_pos.z + end + + last_wielded[player_name] = wielded_item; + elseif last_wielded[player_name] == "default:torch" or last_wielded[player_name] == "walking_light:pick_mese" then + -- Fackel nicht in der Hand, aber beim letzten Durchgang war die Fackel noch in der Hand + local pos = player:getpos() + local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)} + repeat + local is_light = minetest.env:get_node_or_nil(rounded_pos) + if is_light ~= nil and is_light.name == "walking_light:light" then + -- minetest.env:remove_node(rounded_pos) + -- Erzwinge Neuberechnung des Lichts + minetest.env:add_node(rounded_pos,{type="node",name="default:cobble"}) + minetest.env:add_node(rounded_pos,{type="node",name="air"}) + end + until minetest.env:get_node_or_nil(rounded_pos) ~= "walking_light:light" + local old_pos = {x=player_positions[player_name]["x"], y=player_positions[player_name]["y"], z=player_positions[player_name]["z"]} + repeat + is_light = minetest.env:get_node_or_nil(old_pos) + if is_light ~= nil and is_light.name == "walking_light:light" then + -- minetest.env:remove_node(old_pos) + -- Erzwinge Neuberechnung des Lichts + minetest.env:add_node(old_pos,{type="node",name="default:cobble"}) + minetest.env:add_node(old_pos,{type="node",name="air"}) + end + until minetest.env:get_node_or_nil(old_pos) ~= "walking_light:light" + last_wielded[player_name] = wielded_item + end + end +end) + +minetest.register_node("walking_light:light", { + drawtype = "glasslike", + tile_images = {"walking_light.png"}, + -- tile_images = {"walking_light_debug.png"}, + inventory_image = minetest.inventorycube("walking_light.png"), + paramtype = "light", + walkable = false, + is_ground_content = true, + light_propagates = true, + sunlight_propagates = true, + light_source = 14, + selection_box = { + type = "fixed", + fixed = {0, 0, 0, 0, 0, 0}, + }, +}) +minetest.register_tool("walking_light:pick_mese", { + description = "Mese Pickaxe with light", + inventory_image = "walking_light_mesepick.png", + wield_image = "default_tool_mesepick.png", + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=3, + groupcaps={ + cracky={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3}, + crumbly={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3}, + snappy={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3} + } + }, +}) + +minetest.register_craft({ + output = 'walking_light:pick_mese', + recipe = { + {'default:torch'}, + {'default:pick_mese'}, + } +}) diff --git a/diff/walking_light.diff/init.lua.diff b/diff/walking_light.diff/init.lua.diff new file mode 100644 index 0000000..f62f26c --- /dev/null +++ b/diff/walking_light.diff/init.lua.diff @@ -0,0 +1,9 @@ +117c117 +< light_source = 13, +--- +> light_source = 14, +144c144 +< }) +\ No newline at end of file +--- +> }) diff --git a/diff/walking_light.diff/textures/walking_light_mesepick.png b/diff/walking_light.diff/textures/walking_light_mesepick.png new file mode 100644 index 0000000000000000000000000000000000000000..9586a16dbedfa30857966237effaf0f70c963838 GIT binary patch literal 122 zcmeAS@N?(olHy`uVBq!ia0vp^Y#_|S3?zjfeX0gh`~f~8uBj!u8U9*R3vE7sjrja^ zL+|->tw1Tpk|4ie28U-i(tsREPZ!4!j_b( light_source = 14, +144c144 +< }) +\ No newline at end of file +--- +> }) From c24e20d22b656a2e3e7c836d26b6d39d16f87739 Mon Sep 17 00:00:00 2001 From: Phil Morrell Date: Thu, 6 Sep 2018 07:49:23 +0100 Subject: [PATCH 2/4] update walking_light from petermaloney fork * https://github.com/petermaloney/walking_light * because this fork has an addLightItem function * I'm hoping the lack of 3d_armor doesn't break everything --- diff/walking_light.diff/init.lua | 710 +++++++++++++++--- diff/walking_light.diff/init.lua.diff | 13 +- mods/walking_light/README.md | 24 + mods/walking_light/init.lua | 710 +++++++++++++++--- mods/walking_light/init.lua.diff | 13 +- mods/walking_light/textures/walking_light.png | Bin 246 -> 128 bytes .../textures/walking_light_helmet_diamond.png | Bin 0 -> 524 bytes .../walking_light_helmet_diamond_preview.png | Bin 0 -> 902 bytes .../walking_light_inv_helmet_diamond.png | Bin 0 -> 371 bytes .../walking_light_inv_helmet_diamond.xcf | Bin 0 -> 1947 bytes 10 files changed, 1290 insertions(+), 180 deletions(-) create mode 100644 mods/walking_light/README.md create mode 100644 mods/walking_light/textures/walking_light_helmet_diamond.png create mode 100644 mods/walking_light/textures/walking_light_helmet_diamond_preview.png create mode 100644 mods/walking_light/textures/walking_light_inv_helmet_diamond.png create mode 100644 mods/walking_light/textures/walking_light_inv_helmet_diamond.xcf diff --git a/diff/walking_light.diff/init.lua b/diff/walking_light.diff/init.lua index 515a919..a24fb5a 100644 --- a/diff/walking_light.diff/init.lua +++ b/diff/walking_light.diff/init.lua @@ -1,125 +1,528 @@ +-- list of all players seen by minetest.register_on_joinplayer local players = {} +-- all player positions last time light was updated: {player_name : {x, y, z}} local player_positions = {} +-- all light positions of light that currently is created {player_name : {i: {x, y, z}} +local light_positions = {} +-- last item seen wielded by players local last_wielded = {} +-- toggles debug mode +local walking_light_debug = false +-- name of light node, changed by toggling debug mode +local walking_light_node = nil + +-- initialize walking light +walking_light = {} + +-- list of items that use walking light +local light_items = { + "default:torch", "walking_light:pick_mese", + "walking_light:helmet_diamond", "walking_light:megatorch" +} + +function walking_light.addLightItem(item) + for I in pairs(light_items) do + if item == light_items[I] then + minetest.log("warning", "[walking_light] \"" .. item .. "\" is already light item.") + return + end + end + + table.insert(light_items, -1, item) +end + +function walking_light.getLightItems() + return light_items +end + + +-- from http://lua-users.org/wiki/IteratorsTutorial +-- useful for removing things from a table because removing from the middle makes it skip elements otherwise +function ripairs(t) + local function ripairs_it(t,i) + i=i-1 + local v=t[i] + if v==nil then return v end + return i,v + end + return ripairs_it, t, #t+1 +end + +-- formats a vector with shorter output than dump +local function dumppos(pos) + if pos == nil then + return "nil" + end + local x = "nil" + if pos.x then + x = pos.x + end + local y = "nil" + if pos.y then + y = pos.y + end + local z = "nil" + if pos.z then + z = pos.z + end + + return "(" .. x .. "," .. y .. "," .. z .. ")" +end + +-- formats a table containing vectors with shorter output than dump +local function dumppostable(t) + if t == nil then + return "nil" + end + if #t == 0 then + return "0{}" + end + + ret = #t .. "{\n" + for i,pos in ipairs(t) do + ret = ret .. " " .. dumppos(pos) .. "\n" + end + ret = ret .. "}" + return ret +end + +function mt_get_node_or_nil(pos) + if pos == nil then + print("ERROR: walking_light.mt_get_node_or_nil(), pos is nil") + print(debug.traceback("Current Callstack:\n")) + return nil + end + return minetest.get_node_or_nil(pos) +end + +function mt_add_node(pos, sometable) + if pos == nil then + print("ERROR: walking_light.mt_add_node(), pos is nil") + print(debug.traceback("Current Callstack:\n")) + return nil + end + if sometable == nil then + print("ERROR: walking_light.mt_add_node(), sometable is nil") + print(debug.traceback("Current Callstack:\n")) + return nil + end + minetest.add_node(pos,sometable) +end + function round(num) return math.floor(num + 0.5) end +local function poseq(pos1, pos2) + if pos1 == nil and pos2 == nil then + return true + end + if pos1 == nil or pos2 == nil then + return false + end + return pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z +end + +-- return true if the player moved since last player_positions update +local function player_moved(player) + local player_name = player:get_player_name() + local pos = player:getpos() + local rounded_pos = vector.round(pos) + local oldpos = player_positions[player_name] + if oldpos == nil or not poseq(rounded_pos, oldpos) then + -- if oldpos is nil, we assume they just logged in, so consider them moved +-- print("DEBUG: walking_light, player_moved(); moved = true; rounded_pos = " .. dumppos(rounded_pos) .. ", oldpos = " .. dumppos(oldpos)) + return true + end +-- print("DEBUG: walking_light, player_moved(); moved = false; rounded_pos = " .. dumppos(rounded_pos) .. ", oldpos = " .. dumppos(oldpos)) + return false +end + +-- same as table.remove(t,remove_pos), but uses poseq instead of comparing references (does lua have comparator support, so this isn't needed?) +local function table_remove_pos(t, remove_pos) +-- local DEBUG_oldsize = #t + + for i,pos in ipairs(t) do + if poseq(pos, remove_pos) then + table.remove(t, i) + break + end + end + +-- local DEBUG_newsize = #t +-- print("DEBUG: walking_light.table_remove_pos(), oldsize = " .. DEBUG_oldsize .. ", newsize = " .. DEBUG_newsize) +end + +-- same as t[remove_pos], but uses poseq instead of comparing references (does lua have comparator support, so this isn't needed?) +local function table_contains_pos(t, remove_pos) + for i,pos in ipairs(t) do + if poseq(pos, remove_pos) then + return true + end + end + return false +end + +-- same as table.insert(t,pos) but makes sure it is not duplicated +local function table_insert_pos(t, pos) + if not table_contains_pos( pos ) then + table.insert(t, pos) + end +end + +local function is_light(node) + if node ~= nil and ( node.name == "walking_light:light" or node.name == "walking_light:light_debug" ) then + return true + end + return false +end + +-- removes light at the given position +-- player is optional +local function remove_light(player, pos) + local player_name + if player then + player_name = player:get_player_name() + end + local node = mt_get_node_or_nil(pos) + if is_light(node) then + mt_add_node(pos,{type="node",name="air"}) + if player_name then + table_remove_pos(light_positions[player_name], pos) + end + else + if node ~= nil then + print("WARNING: walking_light.remove_light(), pos = " .. dumppos(pos) .. ", tried to remove light but node was " .. node.name) + table_remove_pos(light_positions[player_name], pos) + else + print("WARNING: walking_light.remove_light(), pos = " .. dumppos(pos) .. ", tried to remove light but node was nil") + end + end +end + +-- removes all light owned by a player +local function remove_light_player(player) + local player_name = player:get_player_name() + + for i,old_pos in ripairs(light_positions[player_name]) do + if old_pos then +-- print("DEBUG: walking_light.remove_light_player(), removing old light; old_pos = " .. dumppos(old_pos)) + remove_light(player, old_pos) + end + end +-- print("DEBUG: walking_light.remove_light_player(), done; light_positions = " .. dumppostable(light_positions[player_name])) +end + +local function can_add_light(pos) + local node = mt_get_node_or_nil(pos) + if node == nil or node.name == "air" then +-- print("walking_light can_add_light(), pos = " .. dumppos(pos) .. ", true") + return true + elseif is_light(node) then +-- print("walking_light can_add_light(), pos = " .. dumppos(pos) .. ", true") + return true + end +-- print("walking_light can_add_light(), pos = " .. dumppos(pos) .. ", false") + return false +end + +-- old function returns pos instead of table, for only one position +local function pick_light_position_regular(player, pos) + if can_add_light(pos) then + return {pos} + end + + local pos2 + + -- if pos is not possible, try the old player position first, to make it more likely that it has a line of sight + local player_name = player:get_player_name() + local oldplayerpos = player_positions[player_name] + if oldplayerpos and can_add_light( vector.new(oldplayerpos.x, oldplayerpos.y + 1, oldplayerpos.z) ) then + return oldplayerpos + end + + -- if not, try all positions around the pos + pos2 = vector.new(pos.x + 1, pos.y, pos.z) + if can_add_light( pos2 ) then + return {pos2} + end + + pos2 = vector.new(pos.x - 1, pos.y, pos.z) + if can_add_light( pos2 ) then + return {pos2} + end + + pos2 = vector.new(pos.x, pos.y, pos.z + 1) + if can_add_light( pos2 ) then + return {pos2} + end + + pos2 = vector.new(pos.x, pos.y, pos.z - 1) + if can_add_light( pos2 ) then + return {pos2} + end + + pos2 = vector.new(pos.x, pos.y + 1, pos.z) + if can_add_light( pos2 ) then + return {pos2} + end + + pos2 = vector.new(pos.x, pos.y - 1, pos.z) + if can_add_light( pos2 ) then + return {pos2} + end + + return nil +end + +-- new function, returns table +local function pick_light_position_radius(player, pos, ret, radius) + local pos2 + local step = 4 + local unstep = 1/step + + for x = pos.x - radius, pos.x + radius, step do + for y = pos.y - radius, pos.y + radius, step do + for z = pos.z - radius, pos.z + radius, step do + pos2 = vector.new(round(x*unstep)*step, round(y*unstep)*step, round(z*unstep)*step) + distance = math.sqrt(math.pow(pos.x - x, 2) + math.pow(pos.y - y, 2) + math.pow(pos.z - z, 2)) + if distance <= radius and can_add_light( pos2 ) then + table.insert(ret, pos2) + end + end + end + end + + return ret +end + +local function pick_light_position_mega(player, pos) + local ret = {} + + if can_add_light(pos) then + table.insert(ret, pos) + end + pick_light_position_radius(player, pos, ret, 10) + + return ret +end + +local function pick_light_position(player, pos, light_item) + if light_item == "walking_light:megatorch" then + return pick_light_position_mega(player, pos) + end + return pick_light_position_regular(player, pos) +end + +-- adds light at the given position +local function add_light(player, pos) + local player_name = player:get_player_name() + local node = mt_get_node_or_nil(pos) + if node == nil then + -- don't do anything for nil blocks... they are non-loaded blocks, so we don't want to overwrite anything there +-- print("DEBUG: walking_light.add_light(), node is nil, pos = " .. dumppos(pos)) + return false + elseif node.name == "air" then + -- when the node that is already there is air, add light + mt_add_node(pos,{type="node",name=walking_light_node}) + if not table_contains_pos(light_positions[player_name], pos) then + table_insert_pos(light_positions[player_name], pos) + end + +-- if node then +-- print("DEBUG: add_light(), node.name = " .. node.name .. ", pos = " .. dumppos(pos)) +-- else +-- print("DEBUG: add_light(), node.name = nil, pos = " .. dumppos(pos)) +-- end + return true + elseif is_light(node) then + -- no point in adding light where it is already, but we should assign it to the player so it gets removed (in case it has no player) +-- print("DEBUG: add_light(), not adding; node.name = " .. node.name .. ", pos = " .. dumppos(pos)) + + if not table_contains_pos(light_positions[player_name], pos) then + table_insert_pos(light_positions[player_name], pos) + end + + return true + end +-- print("DEBUG: add_light(), not adding; node.name = " .. node.name) + return false +end + +-- updates all the light around the player, depending on what they are wielding +local function update_light_player(player) + -- if there is no player, there can be no update + if not player then + return + end + + -- figure out if they wield light; this will be nil if not + local wielded_item = get_wielded_light_item(player) + + local player_name = player:get_player_name() + local pos = player:getpos() + local rounded_pos = vector.round(pos) + + -- check for a nil node where the player is; if it is nil, we assume the block is not loaded, so we return without updating player_positions + -- that way, it should add light next step + local node = mt_get_node_or_nil(rounded_pos) + if node == nil then + return + end + + if not player_moved(player) and wielded_item == last_wielded[player_name] then + -- no update needed if the wiedled light item is the same as before (including nil), and the player didn't move + return + end + last_wielded[player_name] = wielded_item; + + local wantlightpos = nil + local wantpos = vector.new(rounded_pos.x, rounded_pos.y + 1, rounded_pos.z) + if wielded_item then + -- decide where light should be + wantlightpos = pick_light_position(player, wantpos, wielded_item) +-- print("DEBUG: walking_light update_light_player(); wantpos = " .. dumppos(wantpos) .. ", wantlightpos = " .. dumppos(wantlightpos)) + end + + if wielded_item and wantlightpos then + -- add light that isn't already there + for i,newpos in ipairs(wantlightpos) do + add_light(player, newpos) + end + end + + -- go through all light owned by the player to remove all but what should be kept + for i,oldlightpos in ripairs(light_positions[player_name]) do + if not wantlightpos or oldlightpos and oldlightpos.x and not table_contains_pos(wantlightpos, oldlightpos) then + remove_light(player, oldlightpos) + end + end + + player_positions[player_name] = vector.round(pos) + +-- print("DEBUG: walking_light.update_light_player(): wantlightpos = " .. dumppostable(wantlightpos) .. ", light_positions = " .. dumppostable(light_positions[player_name])) +end + +local function update_light_all() + -- go through all players to check + for i,player_name in ipairs(players) do + local player = minetest.get_player_by_name(player_name) + update_light_player(player) + end +end + +-- return true if item is a light item +function is_light_item(item) + for I in pairs(light_items) do + if item == light_items[I] then + return true + end + end + return false +end + +-- returns a string, the name of the item found that is a light item +function get_wielded_light_item(player) + local wielded_item = player:get_wielded_item():get_name() + if is_light_item(wielded_item) then + return wielded_item + end + + -- check equipped armor - requires unified_inventory maybe + local player_name = player:get_player_name() + if player_name then + local armor_inv = minetest.get_inventory({type="detached", name=player_name.."_armor"}) + if armor_inv then +-- print( dump(armor_inv:get_lists()) ) + local item_name = "walking_light:helmet_diamond" + local stack = ItemStack(item_name) + if armor_inv:contains_item("armor", stack) then + return item_name + end + end + end + + return nil +end + +-- return true if player is wielding a light item +function wielded_light(player) + return get_wielded_light_item(player) ~= nil +end + minetest.register_on_joinplayer(function(player) local player_name = player:get_player_name() table.insert(players, player_name) - last_wielded[player_name] = player:get_wielded_item():get_name() + last_wielded[player_name] = get_wielded_light_item(player) local pos = player:getpos() - local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)} - local wielded_item = player:get_wielded_item():get_name() - if wielded_item ~= "default:torch" and wielded_item ~= "walking_light:pick_mese" then - -- Neuberechnung des Lichts erzwingen - minetest.env:add_node(rounded_pos,{type="node",name="default:cobble"}) - minetest.env:add_node(rounded_pos,{type="node",name="air"}) - end - player_positions[player_name] = {} - player_positions[player_name]["x"] = rounded_pos.x; - player_positions[player_name]["y"] = rounded_pos.y; - player_positions[player_name]["z"] = rounded_pos.z; + player_positions[player_name] = nil + light_positions[player_name] = {} + update_light_player(player) end) minetest.register_on_leaveplayer(function(player) local player_name = player:get_player_name() for i,v in ipairs(players) do - if v == player_name then + if v == player_name then table.remove(players, i) - last_wielded[player_name] = nil - -- Neuberechnung des Lichts erzwingen - local pos = player:getpos() - local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)} - minetest.env:add_node(rounded_pos,{type="node",name="default:cobble"}) - minetest.env:add_node(rounded_pos,{type="node",name="air"}) - player_positions[player_name]["x"] = nil - player_positions[player_name]["y"] = nil - player_positions[player_name]["z"] = nil - player_positions[player_name]["m"] = nil - player_positions[player_name] = nil end end + last_wielded[player_name] = false + remove_light_player(player) + player_positions[player_name]=nil end) minetest.register_globalstep(function(dtime) for i,player_name in ipairs(players) do - local player = minetest.env:get_player_by_name(player_name) - local wielded_item = player:get_wielded_item():get_name() - if wielded_item == "default:torch" or wielded_item == "walking_light:pick_mese" then - -- Fackel ist in der Hand - local pos = player:getpos() - local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)} - if (last_wielded[player_name] ~= "default:torch" and last_wielded[player_name] ~= "walking_light:pick_mese") or (player_positions[player_name]["x"] ~= rounded_pos.x or player_positions[player_name]["y"] ~= rounded_pos.y or player_positions[player_name]["z"] ~= rounded_pos.z) then - -- Fackel gerade in die Hand genommen oder zu neuem Node bewegt - local is_air = minetest.env:get_node_or_nil(rounded_pos) - if is_air == nil or (is_air ~= nil and (is_air.name == "air" or is_air.name == "walking_light:light")) then - -- wenn an aktueller Position "air" ist, Fackellicht setzen - minetest.env:add_node(rounded_pos,{type="node",name="walking_light:light"}) - end - if (player_positions[player_name]["x"] ~= rounded_pos.x or player_positions[player_name]["y"] ~= rounded_pos.y or player_positions[player_name]["z"] ~= rounded_pos.z) then - -- wenn Position geänder, dann altes Licht löschen - local old_pos = {x=player_positions[player_name]["x"], y=player_positions[player_name]["y"], z=player_positions[player_name]["z"]} - -- Neuberechnung des Lichts erzwingen - local is_light = minetest.env:get_node_or_nil(old_pos) - if is_light ~= nil and is_light.name == "walking_light:light" then - minetest.env:add_node(old_pos,{type="node",name="default:cobble"}) - minetest.env:add_node(old_pos,{type="node",name="air"}) - end - end - -- gemerkte Position ist nun die gerundete neue Position - player_positions[player_name]["x"] = rounded_pos.x - player_positions[player_name]["y"] = rounded_pos.y - player_positions[player_name]["z"] = rounded_pos.z - end - - last_wielded[player_name] = wielded_item; - elseif last_wielded[player_name] == "default:torch" or last_wielded[player_name] == "walking_light:pick_mese" then - -- Fackel nicht in der Hand, aber beim letzten Durchgang war die Fackel noch in der Hand - local pos = player:getpos() - local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)} - repeat - local is_light = minetest.env:get_node_or_nil(rounded_pos) - if is_light ~= nil and is_light.name == "walking_light:light" then - -- minetest.env:remove_node(rounded_pos) - -- Erzwinge Neuberechnung des Lichts - minetest.env:add_node(rounded_pos,{type="node",name="default:cobble"}) - minetest.env:add_node(rounded_pos,{type="node",name="air"}) - end - until minetest.env:get_node_or_nil(rounded_pos) ~= "walking_light:light" - local old_pos = {x=player_positions[player_name]["x"], y=player_positions[player_name]["y"], z=player_positions[player_name]["z"]} - repeat - is_light = minetest.env:get_node_or_nil(old_pos) - if is_light ~= nil and is_light.name == "walking_light:light" then - -- minetest.env:remove_node(old_pos) - -- Erzwinge Neuberechnung des Lichts - minetest.env:add_node(old_pos,{type="node",name="default:cobble"}) - minetest.env:add_node(old_pos,{type="node",name="air"}) - end - until minetest.env:get_node_or_nil(old_pos) ~= "walking_light:light" - last_wielded[player_name] = wielded_item + local player = minetest.get_player_by_name(player_name) + if player ~= nil then + update_light_player(player) + else + table.remove(players, i) end end end) -minetest.register_node("walking_light:light", { +minetest.register_node("walking_light:light_debug", { drawtype = "glasslike", - tile_images = {"walking_light.png"}, - -- tile_images = {"walking_light_debug.png"}, + tiles = {"walking_light_debug.png"}, inventory_image = minetest.inventorycube("walking_light.png"), paramtype = "light", walkable = false, is_ground_content = true, - light_propagates = true, sunlight_propagates = true, light_source = 14, selection_box = { - type = "fixed", - fixed = {0, 0, 0, 0, 0, 0}, - }, + type = "fixed", + fixed = {0, 0, 0, 0, 0, 0}, + }, }) + +minetest.register_node("walking_light:light", { + drawtype = "glasslike", + tiles = {"walking_light.png"}, + inventory_image = minetest.inventorycube("walking_light.png"), + paramtype = "light", + walkable = false, + is_ground_content = true, + sunlight_propagates = true, + light_source = 14, + selection_box = { + type = "fixed", + fixed = {0, 0, 0, 0, 0, 0}, + }, +}) + +function update_walking_light_node() + if walking_light_debug then + walking_light_node = "walking_light:light_debug" + else + walking_light_node = "walking_light:light" + end +end +update_walking_light_node() + minetest.register_tool("walking_light:pick_mese", { description = "Mese Pickaxe with light", inventory_image = "walking_light_mesepick.png", @@ -135,6 +538,65 @@ minetest.register_tool("walking_light:pick_mese", { }, }) +minetest.register_tool("walking_light:helmet_diamond", { + description = "Diamond Helmet with light", + inventory_image = "walking_light_inv_helmet_diamond.png", + wield_image = "3d_armor_inv_helmet_diamond.png", + groups = {armor_head=15, armor_heal=12, armor_use=100}, + wear = 0, +}) + +minetest.register_node("walking_light:megatorch", { + description = "Megatorch", + drawtype = "torchlike", + tiles = { + { + name = "default_torch_on_floor_animated.png", + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 3.0 + }, + }, + { + name="default_torch_on_ceiling_animated.png", + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 3.0 + }, + }, + { + name="default_torch_animated.png", + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 3.0 + }, + }, + }, + inventory_image = "default_torch_on_floor.png", + wield_image = "default_torch_on_floor.png", + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + is_ground_content = false, + walkable = false, + light_source = 14, + selection_box = { + type = "wallmounted", + wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1}, + wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1}, + wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1}, + }, + groups = {choppy=2,dig_immediate=3,flammable=1,attached_node=1}, + legacy_wallmounted = true, + --sounds = default.node_sound_defaults(), +}) + minetest.register_craft({ output = 'walking_light:pick_mese', recipe = { @@ -142,3 +604,81 @@ minetest.register_craft({ {'default:pick_mese'}, } }) + +minetest.register_craft({ + output = 'walking_light:helmet_diamond', + recipe = { + {'default:torch'}, + {'3d_armor:helmet_diamond'}, + } +}) + +minetest.register_craft({ + output = 'walking_light:megatorch', + recipe = { + {'default:torch', 'default:torch', 'default:torch'}, + {'default:torch', 'default:torch', 'default:torch'}, + {'default:torch', 'default:torch', 'default:torch'}, + } +}) + +minetest.register_chatcommand("walking_light_clear_light", { + params = "", + description = "Remove light nodes from the area", + func = function(name, param) + if not minetest.check_player_privs(name, {server=true}) then + return false, "You need the server privilege to use mapclearlight" + end + + local pos = vector.round(minetest.get_player_by_name(name):getpos()) + local size = tonumber(param) or 40 + + for i,v in ipairs({"walking_light:light", "walking_light:light_debug"}) do + point = minetest.find_node_near(pos, size/2, v) + while point do + remove_light(nil, point) + oldpoint = point + point = minetest.find_node_near(pos, size/2, v) + if poseq(oldpoint, point) then + return false, "Failed... infinite loop detected" + end + end + end + return true, "Done." + end, +}) + +minetest.register_chatcommand("walking_light_add_light", { + params = "", + description = "Add walking_light:light to a position, without a player owning it", + func = function(name, param) + if not minetest.check_player_privs(name, {server=true}) then + return false, "You need the server privilege to use mapaddlight" + end + + local pos = vector.round(minetest.get_player_by_name(name):getpos()) + pos = vector.new(pos.x, pos.y + 1, pos.z) + + if pos then + mt_add_node(pos,{type="node",name=walking_light_node}) + end + + return true, "Done." + end, +}) + +minetest.register_chatcommand("walking_light_debug", { + description = "Change to debug mode, so light blocks are visible.", + func = function(name, param) + if not minetest.check_player_privs(name, {server=true}) then + return false, "You need the server privilege to use walking_light_debug" + end + + walking_light_debug = not walking_light_debug + update_walking_light_node() + + return true, "Done." + end, +}) + +-- vim: ts=4 sw=4 softtabstop=4 smarttab noexpandtab diff --git a/diff/walking_light.diff/init.lua.diff b/diff/walking_light.diff/init.lua.diff index f62f26c..9030280 100644 --- a/diff/walking_light.diff/init.lua.diff +++ b/diff/walking_light.diff/init.lua.diff @@ -1,9 +1,12 @@ -117c117 +495c495 < light_source = 13, --- > light_source = 14, -144c144 -< }) -\ No newline at end of file +510c510 +< light_source = 13, --- -> }) +> light_source = 14, +588c588 +< light_source = 13, +--- +> light_source = 14, diff --git a/mods/walking_light/README.md b/mods/walking_light/README.md new file mode 100644 index 0000000..e79e14f --- /dev/null +++ b/mods/walking_light/README.md @@ -0,0 +1,24 @@ +minetest mod walking_light + +forked from 0.6 https://forum.minetest.net/viewtopic.php?f=11&t=2621&hilit=walking+light + +Licensing: +========== + +If not noted elsewhere: + Code: WTFPL, textures: CC BY-SA + +Some textures taken from 3d_armor mod + these files are directly from the 3d_armor mod: + textures/walking_light_helmet_diamond.png + textures/walking_light_helmet_diamond_preview.png + parts of the following files came from 3d_armor's "3d_armor_inv_helmet_diamond.png": + textures/walking_light_inv_helmet_diamond.png + textures/walking_light_inv_helmet_diamond.xcf + + License Textures: 2013 Ryan Jones - CC-BY-SA + + see 3d_armor mod here + https://forum.minetest.net/viewtopic.php?f=11&t=4654 + https://github.com/stujones11/minetest-3d_armor + diff --git a/mods/walking_light/init.lua b/mods/walking_light/init.lua index 515a919..a24fb5a 100644 --- a/mods/walking_light/init.lua +++ b/mods/walking_light/init.lua @@ -1,125 +1,528 @@ +-- list of all players seen by minetest.register_on_joinplayer local players = {} +-- all player positions last time light was updated: {player_name : {x, y, z}} local player_positions = {} +-- all light positions of light that currently is created {player_name : {i: {x, y, z}} +local light_positions = {} +-- last item seen wielded by players local last_wielded = {} +-- toggles debug mode +local walking_light_debug = false +-- name of light node, changed by toggling debug mode +local walking_light_node = nil + +-- initialize walking light +walking_light = {} + +-- list of items that use walking light +local light_items = { + "default:torch", "walking_light:pick_mese", + "walking_light:helmet_diamond", "walking_light:megatorch" +} + +function walking_light.addLightItem(item) + for I in pairs(light_items) do + if item == light_items[I] then + minetest.log("warning", "[walking_light] \"" .. item .. "\" is already light item.") + return + end + end + + table.insert(light_items, -1, item) +end + +function walking_light.getLightItems() + return light_items +end + + +-- from http://lua-users.org/wiki/IteratorsTutorial +-- useful for removing things from a table because removing from the middle makes it skip elements otherwise +function ripairs(t) + local function ripairs_it(t,i) + i=i-1 + local v=t[i] + if v==nil then return v end + return i,v + end + return ripairs_it, t, #t+1 +end + +-- formats a vector with shorter output than dump +local function dumppos(pos) + if pos == nil then + return "nil" + end + local x = "nil" + if pos.x then + x = pos.x + end + local y = "nil" + if pos.y then + y = pos.y + end + local z = "nil" + if pos.z then + z = pos.z + end + + return "(" .. x .. "," .. y .. "," .. z .. ")" +end + +-- formats a table containing vectors with shorter output than dump +local function dumppostable(t) + if t == nil then + return "nil" + end + if #t == 0 then + return "0{}" + end + + ret = #t .. "{\n" + for i,pos in ipairs(t) do + ret = ret .. " " .. dumppos(pos) .. "\n" + end + ret = ret .. "}" + return ret +end + +function mt_get_node_or_nil(pos) + if pos == nil then + print("ERROR: walking_light.mt_get_node_or_nil(), pos is nil") + print(debug.traceback("Current Callstack:\n")) + return nil + end + return minetest.get_node_or_nil(pos) +end + +function mt_add_node(pos, sometable) + if pos == nil then + print("ERROR: walking_light.mt_add_node(), pos is nil") + print(debug.traceback("Current Callstack:\n")) + return nil + end + if sometable == nil then + print("ERROR: walking_light.mt_add_node(), sometable is nil") + print(debug.traceback("Current Callstack:\n")) + return nil + end + minetest.add_node(pos,sometable) +end + function round(num) return math.floor(num + 0.5) end +local function poseq(pos1, pos2) + if pos1 == nil and pos2 == nil then + return true + end + if pos1 == nil or pos2 == nil then + return false + end + return pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z +end + +-- return true if the player moved since last player_positions update +local function player_moved(player) + local player_name = player:get_player_name() + local pos = player:getpos() + local rounded_pos = vector.round(pos) + local oldpos = player_positions[player_name] + if oldpos == nil or not poseq(rounded_pos, oldpos) then + -- if oldpos is nil, we assume they just logged in, so consider them moved +-- print("DEBUG: walking_light, player_moved(); moved = true; rounded_pos = " .. dumppos(rounded_pos) .. ", oldpos = " .. dumppos(oldpos)) + return true + end +-- print("DEBUG: walking_light, player_moved(); moved = false; rounded_pos = " .. dumppos(rounded_pos) .. ", oldpos = " .. dumppos(oldpos)) + return false +end + +-- same as table.remove(t,remove_pos), but uses poseq instead of comparing references (does lua have comparator support, so this isn't needed?) +local function table_remove_pos(t, remove_pos) +-- local DEBUG_oldsize = #t + + for i,pos in ipairs(t) do + if poseq(pos, remove_pos) then + table.remove(t, i) + break + end + end + +-- local DEBUG_newsize = #t +-- print("DEBUG: walking_light.table_remove_pos(), oldsize = " .. DEBUG_oldsize .. ", newsize = " .. DEBUG_newsize) +end + +-- same as t[remove_pos], but uses poseq instead of comparing references (does lua have comparator support, so this isn't needed?) +local function table_contains_pos(t, remove_pos) + for i,pos in ipairs(t) do + if poseq(pos, remove_pos) then + return true + end + end + return false +end + +-- same as table.insert(t,pos) but makes sure it is not duplicated +local function table_insert_pos(t, pos) + if not table_contains_pos( pos ) then + table.insert(t, pos) + end +end + +local function is_light(node) + if node ~= nil and ( node.name == "walking_light:light" or node.name == "walking_light:light_debug" ) then + return true + end + return false +end + +-- removes light at the given position +-- player is optional +local function remove_light(player, pos) + local player_name + if player then + player_name = player:get_player_name() + end + local node = mt_get_node_or_nil(pos) + if is_light(node) then + mt_add_node(pos,{type="node",name="air"}) + if player_name then + table_remove_pos(light_positions[player_name], pos) + end + else + if node ~= nil then + print("WARNING: walking_light.remove_light(), pos = " .. dumppos(pos) .. ", tried to remove light but node was " .. node.name) + table_remove_pos(light_positions[player_name], pos) + else + print("WARNING: walking_light.remove_light(), pos = " .. dumppos(pos) .. ", tried to remove light but node was nil") + end + end +end + +-- removes all light owned by a player +local function remove_light_player(player) + local player_name = player:get_player_name() + + for i,old_pos in ripairs(light_positions[player_name]) do + if old_pos then +-- print("DEBUG: walking_light.remove_light_player(), removing old light; old_pos = " .. dumppos(old_pos)) + remove_light(player, old_pos) + end + end +-- print("DEBUG: walking_light.remove_light_player(), done; light_positions = " .. dumppostable(light_positions[player_name])) +end + +local function can_add_light(pos) + local node = mt_get_node_or_nil(pos) + if node == nil or node.name == "air" then +-- print("walking_light can_add_light(), pos = " .. dumppos(pos) .. ", true") + return true + elseif is_light(node) then +-- print("walking_light can_add_light(), pos = " .. dumppos(pos) .. ", true") + return true + end +-- print("walking_light can_add_light(), pos = " .. dumppos(pos) .. ", false") + return false +end + +-- old function returns pos instead of table, for only one position +local function pick_light_position_regular(player, pos) + if can_add_light(pos) then + return {pos} + end + + local pos2 + + -- if pos is not possible, try the old player position first, to make it more likely that it has a line of sight + local player_name = player:get_player_name() + local oldplayerpos = player_positions[player_name] + if oldplayerpos and can_add_light( vector.new(oldplayerpos.x, oldplayerpos.y + 1, oldplayerpos.z) ) then + return oldplayerpos + end + + -- if not, try all positions around the pos + pos2 = vector.new(pos.x + 1, pos.y, pos.z) + if can_add_light( pos2 ) then + return {pos2} + end + + pos2 = vector.new(pos.x - 1, pos.y, pos.z) + if can_add_light( pos2 ) then + return {pos2} + end + + pos2 = vector.new(pos.x, pos.y, pos.z + 1) + if can_add_light( pos2 ) then + return {pos2} + end + + pos2 = vector.new(pos.x, pos.y, pos.z - 1) + if can_add_light( pos2 ) then + return {pos2} + end + + pos2 = vector.new(pos.x, pos.y + 1, pos.z) + if can_add_light( pos2 ) then + return {pos2} + end + + pos2 = vector.new(pos.x, pos.y - 1, pos.z) + if can_add_light( pos2 ) then + return {pos2} + end + + return nil +end + +-- new function, returns table +local function pick_light_position_radius(player, pos, ret, radius) + local pos2 + local step = 4 + local unstep = 1/step + + for x = pos.x - radius, pos.x + radius, step do + for y = pos.y - radius, pos.y + radius, step do + for z = pos.z - radius, pos.z + radius, step do + pos2 = vector.new(round(x*unstep)*step, round(y*unstep)*step, round(z*unstep)*step) + distance = math.sqrt(math.pow(pos.x - x, 2) + math.pow(pos.y - y, 2) + math.pow(pos.z - z, 2)) + if distance <= radius and can_add_light( pos2 ) then + table.insert(ret, pos2) + end + end + end + end + + return ret +end + +local function pick_light_position_mega(player, pos) + local ret = {} + + if can_add_light(pos) then + table.insert(ret, pos) + end + pick_light_position_radius(player, pos, ret, 10) + + return ret +end + +local function pick_light_position(player, pos, light_item) + if light_item == "walking_light:megatorch" then + return pick_light_position_mega(player, pos) + end + return pick_light_position_regular(player, pos) +end + +-- adds light at the given position +local function add_light(player, pos) + local player_name = player:get_player_name() + local node = mt_get_node_or_nil(pos) + if node == nil then + -- don't do anything for nil blocks... they are non-loaded blocks, so we don't want to overwrite anything there +-- print("DEBUG: walking_light.add_light(), node is nil, pos = " .. dumppos(pos)) + return false + elseif node.name == "air" then + -- when the node that is already there is air, add light + mt_add_node(pos,{type="node",name=walking_light_node}) + if not table_contains_pos(light_positions[player_name], pos) then + table_insert_pos(light_positions[player_name], pos) + end + +-- if node then +-- print("DEBUG: add_light(), node.name = " .. node.name .. ", pos = " .. dumppos(pos)) +-- else +-- print("DEBUG: add_light(), node.name = nil, pos = " .. dumppos(pos)) +-- end + return true + elseif is_light(node) then + -- no point in adding light where it is already, but we should assign it to the player so it gets removed (in case it has no player) +-- print("DEBUG: add_light(), not adding; node.name = " .. node.name .. ", pos = " .. dumppos(pos)) + + if not table_contains_pos(light_positions[player_name], pos) then + table_insert_pos(light_positions[player_name], pos) + end + + return true + end +-- print("DEBUG: add_light(), not adding; node.name = " .. node.name) + return false +end + +-- updates all the light around the player, depending on what they are wielding +local function update_light_player(player) + -- if there is no player, there can be no update + if not player then + return + end + + -- figure out if they wield light; this will be nil if not + local wielded_item = get_wielded_light_item(player) + + local player_name = player:get_player_name() + local pos = player:getpos() + local rounded_pos = vector.round(pos) + + -- check for a nil node where the player is; if it is nil, we assume the block is not loaded, so we return without updating player_positions + -- that way, it should add light next step + local node = mt_get_node_or_nil(rounded_pos) + if node == nil then + return + end + + if not player_moved(player) and wielded_item == last_wielded[player_name] then + -- no update needed if the wiedled light item is the same as before (including nil), and the player didn't move + return + end + last_wielded[player_name] = wielded_item; + + local wantlightpos = nil + local wantpos = vector.new(rounded_pos.x, rounded_pos.y + 1, rounded_pos.z) + if wielded_item then + -- decide where light should be + wantlightpos = pick_light_position(player, wantpos, wielded_item) +-- print("DEBUG: walking_light update_light_player(); wantpos = " .. dumppos(wantpos) .. ", wantlightpos = " .. dumppos(wantlightpos)) + end + + if wielded_item and wantlightpos then + -- add light that isn't already there + for i,newpos in ipairs(wantlightpos) do + add_light(player, newpos) + end + end + + -- go through all light owned by the player to remove all but what should be kept + for i,oldlightpos in ripairs(light_positions[player_name]) do + if not wantlightpos or oldlightpos and oldlightpos.x and not table_contains_pos(wantlightpos, oldlightpos) then + remove_light(player, oldlightpos) + end + end + + player_positions[player_name] = vector.round(pos) + +-- print("DEBUG: walking_light.update_light_player(): wantlightpos = " .. dumppostable(wantlightpos) .. ", light_positions = " .. dumppostable(light_positions[player_name])) +end + +local function update_light_all() + -- go through all players to check + for i,player_name in ipairs(players) do + local player = minetest.get_player_by_name(player_name) + update_light_player(player) + end +end + +-- return true if item is a light item +function is_light_item(item) + for I in pairs(light_items) do + if item == light_items[I] then + return true + end + end + return false +end + +-- returns a string, the name of the item found that is a light item +function get_wielded_light_item(player) + local wielded_item = player:get_wielded_item():get_name() + if is_light_item(wielded_item) then + return wielded_item + end + + -- check equipped armor - requires unified_inventory maybe + local player_name = player:get_player_name() + if player_name then + local armor_inv = minetest.get_inventory({type="detached", name=player_name.."_armor"}) + if armor_inv then +-- print( dump(armor_inv:get_lists()) ) + local item_name = "walking_light:helmet_diamond" + local stack = ItemStack(item_name) + if armor_inv:contains_item("armor", stack) then + return item_name + end + end + end + + return nil +end + +-- return true if player is wielding a light item +function wielded_light(player) + return get_wielded_light_item(player) ~= nil +end + minetest.register_on_joinplayer(function(player) local player_name = player:get_player_name() table.insert(players, player_name) - last_wielded[player_name] = player:get_wielded_item():get_name() + last_wielded[player_name] = get_wielded_light_item(player) local pos = player:getpos() - local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)} - local wielded_item = player:get_wielded_item():get_name() - if wielded_item ~= "default:torch" and wielded_item ~= "walking_light:pick_mese" then - -- Neuberechnung des Lichts erzwingen - minetest.env:add_node(rounded_pos,{type="node",name="default:cobble"}) - minetest.env:add_node(rounded_pos,{type="node",name="air"}) - end - player_positions[player_name] = {} - player_positions[player_name]["x"] = rounded_pos.x; - player_positions[player_name]["y"] = rounded_pos.y; - player_positions[player_name]["z"] = rounded_pos.z; + player_positions[player_name] = nil + light_positions[player_name] = {} + update_light_player(player) end) minetest.register_on_leaveplayer(function(player) local player_name = player:get_player_name() for i,v in ipairs(players) do - if v == player_name then + if v == player_name then table.remove(players, i) - last_wielded[player_name] = nil - -- Neuberechnung des Lichts erzwingen - local pos = player:getpos() - local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)} - minetest.env:add_node(rounded_pos,{type="node",name="default:cobble"}) - minetest.env:add_node(rounded_pos,{type="node",name="air"}) - player_positions[player_name]["x"] = nil - player_positions[player_name]["y"] = nil - player_positions[player_name]["z"] = nil - player_positions[player_name]["m"] = nil - player_positions[player_name] = nil end end + last_wielded[player_name] = false + remove_light_player(player) + player_positions[player_name]=nil end) minetest.register_globalstep(function(dtime) for i,player_name in ipairs(players) do - local player = minetest.env:get_player_by_name(player_name) - local wielded_item = player:get_wielded_item():get_name() - if wielded_item == "default:torch" or wielded_item == "walking_light:pick_mese" then - -- Fackel ist in der Hand - local pos = player:getpos() - local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)} - if (last_wielded[player_name] ~= "default:torch" and last_wielded[player_name] ~= "walking_light:pick_mese") or (player_positions[player_name]["x"] ~= rounded_pos.x or player_positions[player_name]["y"] ~= rounded_pos.y or player_positions[player_name]["z"] ~= rounded_pos.z) then - -- Fackel gerade in die Hand genommen oder zu neuem Node bewegt - local is_air = minetest.env:get_node_or_nil(rounded_pos) - if is_air == nil or (is_air ~= nil and (is_air.name == "air" or is_air.name == "walking_light:light")) then - -- wenn an aktueller Position "air" ist, Fackellicht setzen - minetest.env:add_node(rounded_pos,{type="node",name="walking_light:light"}) - end - if (player_positions[player_name]["x"] ~= rounded_pos.x or player_positions[player_name]["y"] ~= rounded_pos.y or player_positions[player_name]["z"] ~= rounded_pos.z) then - -- wenn Position geänder, dann altes Licht löschen - local old_pos = {x=player_positions[player_name]["x"], y=player_positions[player_name]["y"], z=player_positions[player_name]["z"]} - -- Neuberechnung des Lichts erzwingen - local is_light = minetest.env:get_node_or_nil(old_pos) - if is_light ~= nil and is_light.name == "walking_light:light" then - minetest.env:add_node(old_pos,{type="node",name="default:cobble"}) - minetest.env:add_node(old_pos,{type="node",name="air"}) - end - end - -- gemerkte Position ist nun die gerundete neue Position - player_positions[player_name]["x"] = rounded_pos.x - player_positions[player_name]["y"] = rounded_pos.y - player_positions[player_name]["z"] = rounded_pos.z - end - - last_wielded[player_name] = wielded_item; - elseif last_wielded[player_name] == "default:torch" or last_wielded[player_name] == "walking_light:pick_mese" then - -- Fackel nicht in der Hand, aber beim letzten Durchgang war die Fackel noch in der Hand - local pos = player:getpos() - local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)} - repeat - local is_light = minetest.env:get_node_or_nil(rounded_pos) - if is_light ~= nil and is_light.name == "walking_light:light" then - -- minetest.env:remove_node(rounded_pos) - -- Erzwinge Neuberechnung des Lichts - minetest.env:add_node(rounded_pos,{type="node",name="default:cobble"}) - minetest.env:add_node(rounded_pos,{type="node",name="air"}) - end - until minetest.env:get_node_or_nil(rounded_pos) ~= "walking_light:light" - local old_pos = {x=player_positions[player_name]["x"], y=player_positions[player_name]["y"], z=player_positions[player_name]["z"]} - repeat - is_light = minetest.env:get_node_or_nil(old_pos) - if is_light ~= nil and is_light.name == "walking_light:light" then - -- minetest.env:remove_node(old_pos) - -- Erzwinge Neuberechnung des Lichts - minetest.env:add_node(old_pos,{type="node",name="default:cobble"}) - minetest.env:add_node(old_pos,{type="node",name="air"}) - end - until minetest.env:get_node_or_nil(old_pos) ~= "walking_light:light" - last_wielded[player_name] = wielded_item + local player = minetest.get_player_by_name(player_name) + if player ~= nil then + update_light_player(player) + else + table.remove(players, i) end end end) -minetest.register_node("walking_light:light", { +minetest.register_node("walking_light:light_debug", { drawtype = "glasslike", - tile_images = {"walking_light.png"}, - -- tile_images = {"walking_light_debug.png"}, + tiles = {"walking_light_debug.png"}, inventory_image = minetest.inventorycube("walking_light.png"), paramtype = "light", walkable = false, is_ground_content = true, - light_propagates = true, sunlight_propagates = true, light_source = 14, selection_box = { - type = "fixed", - fixed = {0, 0, 0, 0, 0, 0}, - }, + type = "fixed", + fixed = {0, 0, 0, 0, 0, 0}, + }, }) + +minetest.register_node("walking_light:light", { + drawtype = "glasslike", + tiles = {"walking_light.png"}, + inventory_image = minetest.inventorycube("walking_light.png"), + paramtype = "light", + walkable = false, + is_ground_content = true, + sunlight_propagates = true, + light_source = 14, + selection_box = { + type = "fixed", + fixed = {0, 0, 0, 0, 0, 0}, + }, +}) + +function update_walking_light_node() + if walking_light_debug then + walking_light_node = "walking_light:light_debug" + else + walking_light_node = "walking_light:light" + end +end +update_walking_light_node() + minetest.register_tool("walking_light:pick_mese", { description = "Mese Pickaxe with light", inventory_image = "walking_light_mesepick.png", @@ -135,6 +538,65 @@ minetest.register_tool("walking_light:pick_mese", { }, }) +minetest.register_tool("walking_light:helmet_diamond", { + description = "Diamond Helmet with light", + inventory_image = "walking_light_inv_helmet_diamond.png", + wield_image = "3d_armor_inv_helmet_diamond.png", + groups = {armor_head=15, armor_heal=12, armor_use=100}, + wear = 0, +}) + +minetest.register_node("walking_light:megatorch", { + description = "Megatorch", + drawtype = "torchlike", + tiles = { + { + name = "default_torch_on_floor_animated.png", + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 3.0 + }, + }, + { + name="default_torch_on_ceiling_animated.png", + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 3.0 + }, + }, + { + name="default_torch_animated.png", + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 3.0 + }, + }, + }, + inventory_image = "default_torch_on_floor.png", + wield_image = "default_torch_on_floor.png", + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + is_ground_content = false, + walkable = false, + light_source = 14, + selection_box = { + type = "wallmounted", + wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1}, + wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1}, + wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1}, + }, + groups = {choppy=2,dig_immediate=3,flammable=1,attached_node=1}, + legacy_wallmounted = true, + --sounds = default.node_sound_defaults(), +}) + minetest.register_craft({ output = 'walking_light:pick_mese', recipe = { @@ -142,3 +604,81 @@ minetest.register_craft({ {'default:pick_mese'}, } }) + +minetest.register_craft({ + output = 'walking_light:helmet_diamond', + recipe = { + {'default:torch'}, + {'3d_armor:helmet_diamond'}, + } +}) + +minetest.register_craft({ + output = 'walking_light:megatorch', + recipe = { + {'default:torch', 'default:torch', 'default:torch'}, + {'default:torch', 'default:torch', 'default:torch'}, + {'default:torch', 'default:torch', 'default:torch'}, + } +}) + +minetest.register_chatcommand("walking_light_clear_light", { + params = "", + description = "Remove light nodes from the area", + func = function(name, param) + if not minetest.check_player_privs(name, {server=true}) then + return false, "You need the server privilege to use mapclearlight" + end + + local pos = vector.round(minetest.get_player_by_name(name):getpos()) + local size = tonumber(param) or 40 + + for i,v in ipairs({"walking_light:light", "walking_light:light_debug"}) do + point = minetest.find_node_near(pos, size/2, v) + while point do + remove_light(nil, point) + oldpoint = point + point = minetest.find_node_near(pos, size/2, v) + if poseq(oldpoint, point) then + return false, "Failed... infinite loop detected" + end + end + end + return true, "Done." + end, +}) + +minetest.register_chatcommand("walking_light_add_light", { + params = "", + description = "Add walking_light:light to a position, without a player owning it", + func = function(name, param) + if not minetest.check_player_privs(name, {server=true}) then + return false, "You need the server privilege to use mapaddlight" + end + + local pos = vector.round(minetest.get_player_by_name(name):getpos()) + pos = vector.new(pos.x, pos.y + 1, pos.z) + + if pos then + mt_add_node(pos,{type="node",name=walking_light_node}) + end + + return true, "Done." + end, +}) + +minetest.register_chatcommand("walking_light_debug", { + description = "Change to debug mode, so light blocks are visible.", + func = function(name, param) + if not minetest.check_player_privs(name, {server=true}) then + return false, "You need the server privilege to use walking_light_debug" + end + + walking_light_debug = not walking_light_debug + update_walking_light_node() + + return true, "Done." + end, +}) + +-- vim: ts=4 sw=4 softtabstop=4 smarttab noexpandtab diff --git a/mods/walking_light/init.lua.diff b/mods/walking_light/init.lua.diff index f62f26c..9030280 100644 --- a/mods/walking_light/init.lua.diff +++ b/mods/walking_light/init.lua.diff @@ -1,9 +1,12 @@ -117c117 +495c495 < light_source = 13, --- > light_source = 14, -144c144 -< }) -\ No newline at end of file +510c510 +< light_source = 13, --- -> }) +> light_source = 14, +588c588 +< light_source = 13, +--- +> light_source = 14, diff --git a/mods/walking_light/textures/walking_light.png b/mods/walking_light/textures/walking_light.png index 334cb078a9a03b0d90342ac9418482494231ae71..bca3cf26e4198ffaee20b0cd9da9e3bef3b5bff4 100644 GIT binary patch delta 107 zcmeyy*uZGq8Q|y6%O%Cdz`(%k>ERLtq!~e&gAGW^iyr9&Qfx`y?k)`fL2$v|<&!5G x%IV){7i7~?4ZYoy3zX;eba4#fxSpH<1VAn;17qB0Eh`|4!PC{xWt~$(695rW8V&#e literal 246 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=G^tAk28_ZrvZCAbW|YuPgf<7GV}`=5HlBUO*wK64!{5;QX|b^2DN4hJeJ(yb?V> z*ARs=V?9$nLj!{^MGJwd;yqm)LoEE0f7H89W@P^V|NMvf9z552_&Tog1i5eV-N7Sk z+Hl0-NQZ6!&m@u547G;I44P~Qt{ghEa1vvNrrzopr0Oz_*WB>pF diff --git a/mods/walking_light/textures/walking_light_helmet_diamond.png b/mods/walking_light/textures/walking_light_helmet_diamond.png new file mode 100644 index 0000000000000000000000000000000000000000..2649670f679014904ca9e9c36e3f3d6543d7564f GIT binary patch literal 524 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3-p)I`?e@QtJYILR^8g`SRtKt5;jDTW7U? zz4hkJw%fPc?$}|!cdz}veMZx#8_%3+GIy@&f(51v7n&_zY`%1<`Lbm|EfyWP`SI7UuYdmhSo?iF z(8XLOL4LtN8VZURNMtZDFfx0(IEF|_zCC!?smVZu;X&}M8~y24meM-{`2?&MbuPVp z@Bh(Pi?s7L#D1p*^}&hzge6#FFpF{nejt^(lx0`Do46I(v2Otea&LkGJW89H58+EzYY7|~H&zpX2##FDZTaK*>5zBs*f8_kJtG8FT*_}}JU7TT5 zC2=22?U5H2?=Tflz3la(IeXd#$1@%4^~%>dzL;E7!7Y1j^OQHS?;@P!H)rdVMC7HV xJvU!>C;P=>BWY)Lubxn`>`9Sa%?A@cJZBfol)31`ais(lGM=t}F6*2Ung9e&{`LR> literal 0 HcmV?d00001 diff --git a/mods/walking_light/textures/walking_light_helmet_diamond_preview.png b/mods/walking_light/textures/walking_light_helmet_diamond_preview.png new file mode 100644 index 0000000000000000000000000000000000000000..33a273a2de0131b529240e4e89548ea1758d5f41 GIT binary patch literal 902 zcmeAS@N?(olHy`uVBq!ia0vp^4Gav73>?frmXCVhR3Jw!z$e5N$mMEg;Lc#+&SK!s zVc^bX;K^g)DPZ6!X5g)2;Hzcet7G76VBl+H;A>*wYi8hYVK6W-1Og)?BV!OSF*dd^ zH8nK@0dq5RD{~OAFkimh!otGR($Uh&)^hb~DWCJJDSf}Tbjm}qJCE*F|M_p9s6XfTQpH(8z0>x*pZ@I9y~ECzgoJn= z&(@2X>seK+J$Lt|=e+wF85ka%XPkbi{fpLK&-0hMzv#t!0-eiY_rR@c!n>u}FFmVD zmVO7SQuxteof#rEt!imu=9#JY*clvtGN{>v*)jZWeJr{FqJrUX^I>g=_nTMy3s-<>A=gz?GYePkt4cA#U%6MT;Cp`DZ1qatt%_Sau86bG$+1rT#?L>e zC^~E6-LpSgbKa$VPVT>YW%1sgs5yBB{1q7ipFk%4sN?y|WMk77&#xsK@F!;i!+v3i zWyF*J)Dw!bu5DVg^JhxZMa`LUgdB zr->17GF0W3?MFimL%m;L=vcM>wu$xG#(#R3Ex(Dxy*?2y*e$-!tV2VfmZ@*9Sz?R$ Q(_J7vp00i_>zopr0EPf4?*IS* literal 0 HcmV?d00001 diff --git a/mods/walking_light/textures/walking_light_inv_helmet_diamond.png b/mods/walking_light/textures/walking_light_inv_helmet_diamond.png new file mode 100644 index 0000000000000000000000000000000000000000..07f5a0f1654d54cd68b1d04f0728329677b9daa8 GIT binary patch literal 371 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP~JHN2Jh28OFQw9b`22U5q5R21GC)@fl8w#}U=WOJX z(#mtNVEiF4G02HK+`)^_!O_ak!AnCpSG1GK@gcW@Ziz`|fQvix(Zw5=PTg2O(P--P z=X)#V&N_5^{`2~jwfd#$z27tcFm9Mu6RY&X`=4CIteugUYPls8Ym>iC3M^-y6H##O zz@am-GJVI_PKsaeuARV|@T^byplpHFj5CZDQhb{q>{_LCQb%A;w9m0~ss&!3%;rW} z9q}tzx9oV^wfxC9uiAQFkPtbLey9InieGH#|KCmw%x_YY>N!>FXC5hU&`+@b!Jl@{ zYxateeKUVEmPzmYe(k4?oo)2P8F|IWRetstFx?H?<#uv@u8Y81@mD)5Sh9Y#asz{h N!PC{xWt~$(69A|cj;8e zzZI0>BE%I3ukD%=S)HU+#-zt4b zmby-q*-b6zwDHnM_k4M-)T%dIb3xx2axVh-$BX+A?retnBE7u)}{SE>zdf- zDd%NLc}`JzHgpa;L&huSi^jwCKBA#lEPA%5M*e|U^dzpls3;my4~$}U(6T&-EN@0? zg{T!eT@|8Mn1e>Gu$%9iP-^X=Vc6}4cBn@FLD&r?uEMA*8qrW{i8^RmA!>#Hc`eRT zfo(d%nSGLhEn+cPeWGV%0O^F}wPb67zt|D)|KUBQ?+bM7yFv;pWs8`-K60f#`!}&M zU!IKbtCG7b9uhNtJBp2An-w}TfJd-}ZaJ`{$gtwvD8=GvlQCaQ@-0@IHsv|$ZDQ6F zJV1z$Yi2paMo_dF+smkcWE|1&5j|X%_W}k|{o*oCGfWv8GR=}B*g3!y=fEp_{*7%R z&aw|-y!L90@mkFI`r3#wLNUWrdyLm&d*vfz{DvN_j4}RZWsLEuF~%Cb)eb3*o9Spn z%N{)>t);)(Y-n4fzj^?VV2cWI78q-_VQF+&k_1>Ikfl7%o4|Q+6m&)#(h6t5iunO5 z91}f`>BVJ-bULP|rJ)+XI5bqp4UK+a%8~gTtcJJ#dV)Jd_ewAZnXMQ1q5C&}rLEhb z`r>=udC5OL?_pGTnSa4^*kyk9$LcDA4)2=nr*EF$!G6s6y-fROjBAJAzQ(Izzz@7* zxG&hD{sVw*JQQ;bgv^hE`qFCrVraX=J#yYLuTzg7U=A>4$o-qZzazn*T@9xwm^ literal 0 HcmV?d00001 From 2720625083981ec4da6adc2f1bb37daee38c2370 Mon Sep 17 00:00:00 2001 From: Phil Morrell Date: Thu, 6 Sep 2018 10:06:01 +0100 Subject: [PATCH 3/4] update walking_light from emorrp1/any_tool --- diff/walking_light.diff/init.lua | 44 +++++++++++++++----------------- mods/walking_light/depends.txt | 1 + mods/walking_light/init.lua | 44 +++++++++++++++----------------- 3 files changed, 43 insertions(+), 46 deletions(-) create mode 100644 mods/walking_light/depends.txt diff --git a/diff/walking_light.diff/init.lua b/diff/walking_light.diff/init.lua index a24fb5a..351529f 100644 --- a/diff/walking_light.diff/init.lua +++ b/diff/walking_light.diff/init.lua @@ -17,7 +17,7 @@ walking_light = {} -- list of items that use walking light local light_items = { - "default:torch", "walking_light:pick_mese", + "default:torch", "walking_light:helmet_diamond", "walking_light:megatorch" } @@ -36,6 +36,25 @@ function walking_light.getLightItems() return light_items end +function walking_light.register_tool(tool) + item = 'walking_light:' .. tool .. '_mese' + default = 'default:' .. tool .. '_mese' + + definition = table.copy(minetest.registered_items[default]) + definition.description = definition.description .. ' with light' + definition.inventory_image = 'walking_light_mese' .. tool .. '.png' + + minetest.register_tool(item, definition) + minetest.register_craft({ + output = item, + recipe = { + {'default:torch'}, + { default }, + } + }) + + walking_light.addLightItem(item) +end -- from http://lua-users.org/wiki/IteratorsTutorial -- useful for removing things from a table because removing from the middle makes it skip elements otherwise @@ -523,20 +542,7 @@ function update_walking_light_node() end update_walking_light_node() -minetest.register_tool("walking_light:pick_mese", { - description = "Mese Pickaxe with light", - inventory_image = "walking_light_mesepick.png", - wield_image = "default_tool_mesepick.png", - tool_capabilities = { - full_punch_interval = 1.0, - max_drop_level=3, - groupcaps={ - cracky={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3}, - crumbly={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3}, - snappy={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3} - } - }, -}) +walking_light.register_tool('pick') minetest.register_tool("walking_light:helmet_diamond", { description = "Diamond Helmet with light", @@ -597,14 +603,6 @@ minetest.register_node("walking_light:megatorch", { --sounds = default.node_sound_defaults(), }) -minetest.register_craft({ - output = 'walking_light:pick_mese', - recipe = { - {'default:torch'}, - {'default:pick_mese'}, - } -}) - minetest.register_craft({ output = 'walking_light:helmet_diamond', recipe = { diff --git a/mods/walking_light/depends.txt b/mods/walking_light/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/mods/walking_light/depends.txt @@ -0,0 +1 @@ +default diff --git a/mods/walking_light/init.lua b/mods/walking_light/init.lua index a24fb5a..351529f 100644 --- a/mods/walking_light/init.lua +++ b/mods/walking_light/init.lua @@ -17,7 +17,7 @@ walking_light = {} -- list of items that use walking light local light_items = { - "default:torch", "walking_light:pick_mese", + "default:torch", "walking_light:helmet_diamond", "walking_light:megatorch" } @@ -36,6 +36,25 @@ function walking_light.getLightItems() return light_items end +function walking_light.register_tool(tool) + item = 'walking_light:' .. tool .. '_mese' + default = 'default:' .. tool .. '_mese' + + definition = table.copy(minetest.registered_items[default]) + definition.description = definition.description .. ' with light' + definition.inventory_image = 'walking_light_mese' .. tool .. '.png' + + minetest.register_tool(item, definition) + minetest.register_craft({ + output = item, + recipe = { + {'default:torch'}, + { default }, + } + }) + + walking_light.addLightItem(item) +end -- from http://lua-users.org/wiki/IteratorsTutorial -- useful for removing things from a table because removing from the middle makes it skip elements otherwise @@ -523,20 +542,7 @@ function update_walking_light_node() end update_walking_light_node() -minetest.register_tool("walking_light:pick_mese", { - description = "Mese Pickaxe with light", - inventory_image = "walking_light_mesepick.png", - wield_image = "default_tool_mesepick.png", - tool_capabilities = { - full_punch_interval = 1.0, - max_drop_level=3, - groupcaps={ - cracky={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3}, - crumbly={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3}, - snappy={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3} - } - }, -}) +walking_light.register_tool('pick') minetest.register_tool("walking_light:helmet_diamond", { description = "Diamond Helmet with light", @@ -597,14 +603,6 @@ minetest.register_node("walking_light:megatorch", { --sounds = default.node_sound_defaults(), }) -minetest.register_craft({ - output = 'walking_light:pick_mese', - recipe = { - {'default:torch'}, - {'default:pick_mese'}, - } -}) - minetest.register_craft({ output = 'walking_light:helmet_diamond', recipe = { From 1564ceb22e6c72a646820cf00a8767ca603fa5b4 Mon Sep 17 00:00:00 2001 From: Phil Morrell Date: Thu, 6 Sep 2018 10:10:34 +0100 Subject: [PATCH 4/4] add axe, shovel, sword with light (OCD) --- diff/walking_light.diff/init.lua | 3 +++ diff/walking_light.diff/init.lua.diff | 10 +++++++--- .../textures/walking_light_meseaxe.png | Bin 0 -> 179 bytes .../textures/walking_light_meseshovel.png | Bin 0 -> 171 bytes .../textures/walking_light_mesesword.png | Bin 0 -> 172 bytes mods/walking_light/init.lua | 3 +++ mods/walking_light/init.lua.diff | 10 +++++++--- .../textures/walking_light_meseaxe.png | Bin 0 -> 179 bytes .../textures/walking_light_meseshovel.png | Bin 0 -> 171 bytes .../textures/walking_light_mesesword.png | Bin 0 -> 172 bytes 10 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 diff/walking_light.diff/textures/walking_light_meseaxe.png create mode 100644 diff/walking_light.diff/textures/walking_light_meseshovel.png create mode 100644 diff/walking_light.diff/textures/walking_light_mesesword.png create mode 100644 mods/walking_light/textures/walking_light_meseaxe.png create mode 100644 mods/walking_light/textures/walking_light_meseshovel.png create mode 100644 mods/walking_light/textures/walking_light_mesesword.png diff --git a/diff/walking_light.diff/init.lua b/diff/walking_light.diff/init.lua index 351529f..147bd83 100644 --- a/diff/walking_light.diff/init.lua +++ b/diff/walking_light.diff/init.lua @@ -543,6 +543,9 @@ end update_walking_light_node() walking_light.register_tool('pick') +walking_light.register_tool('axe') +walking_light.register_tool('shovel') +walking_light.register_tool('sword') minetest.register_tool("walking_light:helmet_diamond", { description = "Diamond Helmet with light", diff --git a/diff/walking_light.diff/init.lua.diff b/diff/walking_light.diff/init.lua.diff index 9030280..171e27b 100644 --- a/diff/walking_light.diff/init.lua.diff +++ b/diff/walking_light.diff/init.lua.diff @@ -1,12 +1,16 @@ -495c495 +514c514 < light_source = 13, --- > light_source = 14, -510c510 +529c529 < light_source = 13, --- > light_source = 14, -588c588 +545a546,548 +> walking_light.register_tool('axe') +> walking_light.register_tool('shovel') +> walking_light.register_tool('sword') +594c597 < light_source = 13, --- > light_source = 14, diff --git a/diff/walking_light.diff/textures/walking_light_meseaxe.png b/diff/walking_light.diff/textures/walking_light_meseaxe.png new file mode 100644 index 0000000000000000000000000000000000000000..d297b3eaf4edb1d0edd387b97eed9ad90e8acac7 GIT binary patch literal 179 zcmeAS@N?(olHy`uVBq!ia0vp^Y#_|S3?zjfeX0gh`~f~8uBj!u8U9*R3vE7sjrja^ zL+|->tw1Tpk|4ie28U-i(mFVdQ&MBb@0G3QIcK`qY literal 0 HcmV?d00001 diff --git a/diff/walking_light.diff/textures/walking_light_meseshovel.png b/diff/walking_light.diff/textures/walking_light_meseshovel.png new file mode 100644 index 0000000000000000000000000000000000000000..cdff1f08466632de95c71cbf7e407bd52e2317c8 GIT binary patch literal 171 zcmeAS@N?(olHy`uVBq!ia0vp^Y#_|S3?zjfeX0gh`~f~8uBj!u8U9*R3vE7sjrja^ zL+|->tw1Tpk|4ie28U-i(mtw1Tpk|4ie28U-i(m light_source = 14, -510c510 +529c529 < light_source = 13, --- > light_source = 14, -588c588 +545a546,548 +> walking_light.register_tool('axe') +> walking_light.register_tool('shovel') +> walking_light.register_tool('sword') +594c597 < light_source = 13, --- > light_source = 14, diff --git a/mods/walking_light/textures/walking_light_meseaxe.png b/mods/walking_light/textures/walking_light_meseaxe.png new file mode 100644 index 0000000000000000000000000000000000000000..d297b3eaf4edb1d0edd387b97eed9ad90e8acac7 GIT binary patch literal 179 zcmeAS@N?(olHy`uVBq!ia0vp^Y#_|S3?zjfeX0gh`~f~8uBj!u8U9*R3vE7sjrja^ zL+|->tw1Tpk|4ie28U-i(mFVdQ&MBb@0G3QIcK`qY literal 0 HcmV?d00001 diff --git a/mods/walking_light/textures/walking_light_meseshovel.png b/mods/walking_light/textures/walking_light_meseshovel.png new file mode 100644 index 0000000000000000000000000000000000000000..cdff1f08466632de95c71cbf7e407bd52e2317c8 GIT binary patch literal 171 zcmeAS@N?(olHy`uVBq!ia0vp^Y#_|S3?zjfeX0gh`~f~8uBj!u8U9*R3vE7sjrja^ zL+|->tw1Tpk|4ie28U-i(mtw1Tpk|4ie28U-i(m