Update walking_light mod to Git commit 6d32855...

https://github.com/AntumMT/mod-walking_light/tree/6d32855
master
Jordan Irwin 2021-06-26 00:22:57 -07:00
parent 484bef43a1
commit a10d454020
19 changed files with 442 additions and 185 deletions

View File

@ -58,7 +58,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
* lighting/
* [glow][] ([GPL][lic.gpl2.0]) -- version: [4c015a0 Git][ver.glow] *2019-02-05*
* [ilights][] ([LGPL][lic.lgpl3.0]) -- version: [2021-02-25-01][ver.ilights] ([patched][patch.ilights])
* [walking_light][] ([WTFPL / CC BY-SA][lic.walking_light]) -- version: [178ed36 Git][ver.walking_light] *2021-06-24*
* [walking_light][] ([MIT][lic.walking_light]) -- version: [6d32855 Git][ver.walking_light] *2021-06-25*
* materials/
* [amber][] ([LGPL][lic.lgpl2.1]) -- version: [56627fa Git][ver.amber] *2017-10-29* ([patched][patch.amber])
* [basic_materials][] ([LGPL][lic.lgpl3.0]) -- version: [2021-01-30][ver.basic_materials]
@ -460,7 +460,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[lic.trash_can]: mods/furniture/trash_can/LICENSE.txt
[lic.tree_monster]: mods/mobiles/tree_monster/license.txt
[lic.waffles]: mods/furniture/waffles/LICENSE.txt
[lic.walking_light]: mods/lighting/walking_light/README.md
[lic.walking_light]: mods/lighting/walking_light/LICENSE.txt
[lic.wardrobe]: mods/player/visuals/wardrobe/LICENSE.txt
[lic.wdata]: mods/misc/wdata/LICENSE.txt
[lic.whinny]: mods/mobiles/whinny/LICENSE.txt
@ -626,7 +626,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[ver.tree_monster]: https://github.com/AntumMT/mod-mob_tree_monster/tree/f2977ff
[ver.unifieddyes]: https://gitlab.com/VanessaE/unifieddyes/tags/2021-03-26-1
[ver.waffles]: https://github.com/GreenXenith/waffles/tree/15bcdce
[ver.walking_light]: https://github.com/AntumMT/mod-walking_light/tree/178ed36
[ver.walking_light]: https://github.com/AntumMT/mod-walking_light/tree/6d32855
[ver.wardrobe]: https://github.com/AntumMT/mod-wardrobe/tree/0500a78
[ver.wdata]: https://github.com/AntumMT/mod-wdata/releases/tag/v1.1
[ver.whinny]: https://github.com/AntumMT/mod-whinny/tree/32f2d9f

View File

@ -2445,6 +2445,14 @@ coloredwood_enable_stairsplus = true
#playeranim.animation_speed_sneak = 0.8
# *** walking_light
## Enables walking_light:megatorch item.
# type: bool
# default: true
#walking_light.enable_megatorch = true
# *** wardrobe ***
## Number of skins shown per page.

View File

@ -0,0 +1,24 @@
The MIT License (MIT)
Copyright © 2021 Jordan Irwin (AntumDeluge)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Code by Echo & petermaloney originally licensed under CC0

View File

@ -1,24 +1,35 @@
minetest mod walking_light
## Walking Light
forked from 0.6 https://forum.minetest.net/viewtopic.php?f=11&t=2621&hilit=walking+light
### Description:
Licensing:
==========
A mod for [Minetest][] that illuminates the area around a player when equipped with a light item.
If not noted elsewhere:
Code: WTFPL, textures: CC BY-SA
![screenshot](screenshot.png)
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
#### History:
License Textures: 2013 Ryan Jones - CC-BY-SA
- forked from [v0.6][forum] of Echo's walking_light
- forked from [Git commit 766ef0f](https://github.com/petermaloney/walking_light/tree/766ef0f) of petermaloney's walking_light
see 3d_armor mod here
https://forum.minetest.net/viewtopic.php?f=11&t=4654
https://github.com/stujones11/minetest-3d_armor
### Licensing:
- Code: [MIT](LICENSE.txt)
- Textures: [CC0](https://creativecommons.org/publicdomain/zero/1.0/legalcode)
### Requirements:
- Minetest minimum version: 5.0.0
- Depends: none
- Optional depends: default (for torch & megatorch)
### Links:
- [Forum][forum]
- [Git repo](https://github.com/AntumMT/mod-walking_light)
- [API](https://antummt.github.io/mod-walking_light/docs/api.html)
- [Changelog](changelog.txt)
- [TODO](TODO.txt)
[Minetest]: http://minetest.net/
[forum]: https://forum.minetest.net/viewtopic.php?t=2621

View File

@ -1,4 +1,6 @@
TODO:
- clean up
- add localization support
- rename
- walking_light_debug should only enable debugging for player invoking command
- replace chat commands with single command "walking_light"

View File

@ -1,4 +1,9 @@
--- walking_light Methods
--
-- @topic methods
-- list of all players seen by core.register_on_joinplayer
local players = {}
-- all player positions last time light was updated: {player_name : {x, y, z}}
@ -12,50 +17,97 @@ local last_wielded = {}
local walking_light_debug = false
-- name of light node, changed by toggling debug mode
local walking_light_node = nil
walking_light_node = nil
--- Sets debugging mode.
--
-- @tparam bool enabled Determines if debugging is enabled.
function walking_light.set_debug(enabled)
walking_light_debug = enabled
end
-- list of items that use walking light
local light_items = {
"default:torch",
"walking_light:megatorch",
}
-- list of items that use walking light when wielded
local light_items = {}
-- list of items that use walking light when equipped as armor
local light_armor = {}
function walking_light.register_item(item)
for _, li in ipairs(light_items) do
if item == li then
core.log("warning", "[walking_light] \"" .. item .. "\" is already light item.")
--- Registers an item to emit light when wielded.
--
-- @tparam string iname Item technical name.
-- @tparam[opt] int radius Distance light will reach (max: 10).
function walking_light.register_item(iname, radius)
if radius and radius > 10 then
walking_light.log("warning", "light radius too high, setting to 10")
radius = 10
end
local def = {radius=radius}
for li in pairs(light_items) do
if iname == li then
walking_light.log("warning", "\"" .. iname .. "\" is already light item.")
return
end
end
table.insert(light_items, item)
light_items[iname] = def
end
walking_light.addLightItem = walking_light.register_item -- backward compat
function walking_light.register_armor(iname, litem)
--- DEPRECATED
--
-- Use `walking_light.register_item`
function walking_light.addLightItem(item)
walking_light.log("warning",
"\"walking_light.addLightItem\" is deprecated, use \"walking_light.register_item\"")
return walking_light.register_item(item)
end
--- Registers an item to emit light when equipped in armor inventory.
--
-- Note: light radius will be overridden by light-emitting item being wielded.
--
-- @tparam string iname Item technical name.
-- @tparam[opt] int radius Distance light will reach (max: 10).
-- @tparam[opt] bool litem Whether or not this item should also be registered with `walking_light.register_item`.
function walking_light.register_armor(iname, radius, litem)
if radius and radius > 10 then
walking_light.log("warning", "light radius too high, setting to 10")
radius = 10
end
local def = {radius=radius}
if litem == nil then litem = true end
for _, a in ipairs(light_armor) do
if iname == a then
core.log("warning", "[walking_light] \"" .. iname .. "\" is already light armor.")
for la in pairs(light_armor) do
if iname == la then
walking_light.log("warning", "\"" .. iname .. "\" is already light armor.")
end
end
table.insert(light_armor, iname)
if litem then walking_light.register_item(iname) end
light_armor[iname] = def
if litem then walking_light.register_item(iname, radius) end
end
--- Retrieves list of items registered as emitting light when wielded.
--
-- @treturn table Table indexed by key.
function walking_light.get_light_items()
return light_items
end
walking_light.getLightItems = walking_light.get_light_items -- backward compat
--- DEPRECATED
--
-- Use `walking_light.get_light_items`
function walking_light.getLightItems()
walking_light.log("warning",
"\"walking_light.getLightItems\" is deprecated, use \"walking_light.get_light_items\"")
return walking_light.get_light_items()
end
--- DEPRECATED
function walking_light.register_tool(tool)
walking_light.log("warning", "\"walking_light.register_tool\" method is deprecated")
@ -132,7 +184,7 @@ end
local function mt_get_node_or_nil(pos)
if pos == nil then
print("ERROR: walking_light.mt_get_node_or_nil(), pos is nil")
walking_light.log("error", "mt_get_node_or_nil(), pos is nil")
print(debug.traceback("Current Callstack:\n"))
return nil
end
@ -143,66 +195,97 @@ local function mt_get_node_or_nil(pos)
core.get_voxel_manip():read_from_map(pos, pos)
node = core.get_node(pos)
end
-- If node.name is "ignore" here, the map probably isn't generated at pos.
return node
end
function mt_add_node(pos, sometable)
--- Adds a node to the world.
--
-- @tparam table pos Position.
-- @tparam table sometable
function walking_light.mt_add_node(pos, sometable)
if pos == nil then
print("ERROR: walking_light.mt_add_node(), pos is nil")
walking_light.log("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")
walking_light.log("error", "walking_light.mt_add_node(), sometable is nil")
print(debug.traceback("Current Callstack:\n"))
return nil
end
core.add_node(pos, sometable)
end
--- DEPRECATED
--
-- Use `walking_light.mt_add_node`
function mt_add_node(pos, sometable)
walking_light.log("warning", "\"mt_add_node\" is deprecated, use \"walking_light.mt_add_node\"")
return walking_light.mt_add_node(pos, sometable)
end
local function round(num)
return math.floor(num + 0.5)
end
local function poseq(pos1, pos2)
---
--
-- @tparam table pos1
-- @tparam table pos2
-- @treturn bool
function walking_light.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
--- DEPRECATED
--
-- Use `walking_light.poseq`
function poseq(pos1, pos2)
walking_light.log("warning", "\"poseq\" is deprecated, use \"walking_light.poseq\"")
return walking_light.poseq(pos1, pos2)
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:get_pos()
local rounded_pos = vector.round(pos)
local oldpos = player_positions[player_name]
if oldpos == nil or not poseq(rounded_pos, oldpos) then
if oldpos == nil or not walking_light.poseq(rounded_pos, oldpos) then
-- if oldpos is nil, we assume they just logged in, so consider them moved
return true
end
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?)
-- same as table.remove(t, remove_pos), but uses walking_light.poseq instead of comparing references (does lua have comparator support, so this isn't needed?)
local function table_remove_pos(t, remove_pos)
for i, pos in ipairs(t) do
if poseq(pos, remove_pos) then
if walking_light.poseq(pos, remove_pos) then
table.remove(t, i)
break
end
end
end
-- same as t[remove_pos], but uses poseq instead of comparing references (does lua have comparator support, so this isn't needed?)
-- same as t[remove_pos], but uses walking_light.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
if walking_light.poseq(pos, remove_pos) then
return true
end
end
@ -218,42 +301,55 @@ local function table_insert_pos(t, pos)
end
local function is_light(node)
if node ~= nil and node ~= "ignore" and( node.name == "walking_light:light" or node.name == "walking_light:light_debug" ) then
if node ~= nil and node ~= "ignore" 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
function remove_light(player, pos)
--- Removes light at the given position.
--
-- @tparam[opt] ObjectRef player
-- @tparam table pos Posistion where light will be removed.
function walking_light.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"})
walking_light.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)
walking_light.log("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")
walking_light.log("warning", "walking_light.remove_light(), pos = "
.. dumppos(pos) .. ", tried to remove light but node was nil")
end
end
end
--- DEPRECATED
--
-- Use `walking_light.remove_light`
function remove_light(player, pos)
walking_light.log("warning", "\"remove_light\" is deprecated, use \"walking_light.remove_light\"")
return walking_light.remove_light(player, pos)
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
remove_light(player, old_pos)
walking_light.remove_light(player, old_pos)
end
end
end
@ -268,6 +364,7 @@ local function can_add_light(pos)
elseif is_light(node) then
return true
end
return false
end
@ -282,38 +379,38 @@ local function pick_light_position_regular(player, pos)
-- 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
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
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
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
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
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
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
if can_add_light(pos2) then
return {pos2}
end
@ -321,7 +418,12 @@ local function pick_light_position_regular(player, pos)
end
-- new function, returns table
local function pick_light_position_radius(player, pos, ret, radius)
local function pick_light_position_radius(player, pos, radius)
local ret = {}
if can_add_light(pos) then
table.insert(ret, pos)
end
local pos2
local step = 4
local unstep = 1/step
@ -341,21 +443,11 @@ local function pick_light_position_radius(player, pos, ret, radius)
return ret
end
local function pick_light_position_mega(player, pos)
local ret = {}
if can_add_light(pos) then
table.insert(ret, pos)
local function pick_light_position(player, pos, radius)
if radius then
return pick_light_position_radius(player, pos, radius)
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
@ -368,7 +460,7 @@ local function add_light(player, 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})
walking_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
@ -386,6 +478,32 @@ local function add_light(player, pos)
return false
end
-- returns a string, the name of the item found that is a light item
local function get_wielded_light_item(player)
local wielded_item = player:get_wielded_item():get_name()
if wielded_item ~= "" and walking_light.is_light_item(wielded_item) then
return wielded_item
end
-- check equipped armor
if core.get_modpath("3d_armor") then
local player_name = player:get_player_name()
if player_name then
local armor_inv = core.get_inventory({type="detached", name=player_name.."_armor"})
if armor_inv then
for k, stack in pairs(armor_inv:get_list("armor")) do
local item_name = stack:get_name()
if walking_light.is_light_armor(item_name) then
return item_name, true
end
end
end
end
end
return nil
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
@ -394,7 +512,7 @@ local function update_light_player(player)
end
-- figure out if they wield light; this will be nil if not
local wielded_item = walking_light.get_wielded_light_item(player)
local wielded_item, is_armor = get_wielded_light_item(player)
local player_name = player:get_player_name()
local pos = player:get_pos()
@ -402,7 +520,7 @@ local function update_light_player(player)
-- 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)
local node = mt_get_node_or_nil(rounded_pos)
if node == nil or node == "ignore" then
return
end
@ -416,8 +534,15 @@ local function update_light_player(player)
local wantlightpos = nil
local wantpos = vector.new(rounded_pos.x, rounded_pos.y + 1, rounded_pos.z)
if wielded_item then
local radius
if is_armor then
radius = light_armor[wielded_item].radius
else
radius = light_items[wielded_item].radius
end
-- decide where light should be
wantlightpos = pick_light_position(player, wantpos, wielded_item)
wantlightpos = pick_light_position(player, wantpos, radius)
end
if wielded_item and wantlightpos then
@ -430,7 +555,7 @@ local function update_light_player(player)
-- 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)
walking_light.remove_light(player, oldlightpos)
end
end
@ -445,10 +570,13 @@ local function update_light_all()
end
end
-- return true if item is a light item
function walking_light.is_light_item(item)
for _, li in ipairs(light_items) do
if item == li then
--- Checks if an item is registered as emitting light when wielded.
--
-- @tparam string iname Item technical name.
-- @treturn bool `true` if item is registered.
function walking_light.is_light_item(iname)
for li in pairs(light_items) do
if iname == li then
return true
end
end
@ -456,41 +584,32 @@ function walking_light.is_light_item(item)
return false
end
-- returns a string, the name of the item found that is a light item
function walking_light.get_wielded_light_item(player)
local wielded_item = player:get_wielded_item():get_name()
if wielded_item ~= "" and walking_light.is_light_item(wielded_item) then
return wielded_item
end
-- check equipped armor
if core.get_modpath("3d_armor") then
local player_name = player:get_player_name()
if player_name then
local armor_inv = core.get_inventory({type="detached", name=player_name.."_armor"})
if armor_inv then
for k, stack in pairs(armor_inv:get_list("armor")) do
local item_name = stack:get_name()
if walking_light.is_light_item(item_name) then
return item_name
end
end
end
--- Checks if an item is registered as emitting light when equipped in armor inventory.
--
-- @tparam string iname Item technical name.
-- @treturn bool `true` if item is registered.
function walking_light.is_light_armor(iname)
for la in pairs(light_armor) do
if iname == la then
return true
end
end
return nil
return false
end
-- return true if player is wielding a light item
--- Checks if player is wielding a light-emitting item.
--
-- @tparam ObjectRef player Player to be checked.
-- @treturn bool `true` if player is wielding registered item.
function walking_light.wields_light(player)
return walking_light.get_wielded_light_item(player) ~= nil
return get_wielded_light_item(player) ~= nil
end
core.register_on_joinplayer(function(player)
local player_name = player:get_player_name()
table.insert(players, player_name)
last_wielded[player_name] = walking_light.get_wielded_light_item(player)
last_wielded[player_name] = get_wielded_light_item(player)
local pos = player:get_pos()
player_positions[player_name] = nil
light_positions[player_name] = {}
@ -520,6 +639,9 @@ core.register_globalstep(function(dtime)
end
end)
--- Updates light node texture.
--
-- If debugging, node will display a marker, otherwise will be transparent.
function walking_light.update_node()
if walking_light_debug then
walking_light_node = "walking_light:light_debug"

View File

@ -1,7 +1,26 @@
v1.0
- forked from petermaloney @ Git commit 766ef0f ( https://github.com/petermaloney/walking_light/tree/766ef0f )
v0.7
----
- forked from petermaloney @ Git commit 766ef0f ( https://github.com/petermaloney/walking_light/tree/766ef0f )
- changed code license to MIT
- added mod.conf
- re-created underlay image
- some code cleanup & optimization
- hand is not checked for light
- added global method for registering an armor item
- segregated code into modules
- removed walking_light:pick_mese & walking_light:helmet_diamond (mods should register their own light items)
- megatorch can be disabled via setting
- added localization support
- added option to set custom light radius when registering item or armor
petermaloney
------------
- forked from walking_light v0.6 by Echo ( https://forum.minetest.net/viewtopic.php?t=2621 )
- bug fixes & code optimizations
- light updated on player login
- added 3d_armor support
- added items walking_light:helmet_diamond & walking_light:megatorch
- added global method for registering items for use with walking_light
- replaced deprecated methods & parameters
- prefixed chat commands with "walking_light"

View File

@ -1,10 +1,22 @@
--- walking_light Chat Commands
--
-- @topic commands
local S = core.get_translator(walking_light.modname)
--- Removes light added with walking_light from nearby nodes.
--
-- @chatcmd walking_light_clear_light
-- @param size Diameter of which light should be removed.
core.register_chatcommand("walking_light_clear_light", {
params = "<size>",
description = "Remove light nodes from the area",
description = S("Remove light nodes from the area."),
func = function(name, param)
if not core.check_player_privs(name, {server=true}) then
return false, "You need the server privilege to use mapclearlight"
return false, S("You need the server privilege to use @1", "walking_light_clear_light")
end
local pos = vector.round(core.get_player_by_name(name):get_pos())
@ -13,48 +25,59 @@ core.register_chatcommand("walking_light_clear_light", {
for i, v in ipairs({"walking_light:light", "walking_light:light_debug"}) do
local point = core.find_node_near(pos, size/2, v)
while point do
remove_light(nil, point)
walking_light.remove_light(nil, point)
local oldpoint = point
point = core.find_node_near(pos, size/2, v)
if poseq(oldpoint, point) then
return false, "Failed... infinite loop detected"
if walking_light.poseq(oldpoint, point) then
return false, S("Failed... infinite loop detected")
end
end
end
return true, "Done."
return true, S("Done.")
end,
})
--- Adds light to nearby nodes.
--
-- FIXME: only adds one node, does not make use of "size" parameter
--
-- @chatcmd walking_light_add_light
-- @param size Diameter of which light should be added.
core.register_chatcommand("walking_light_add_light", {
params = "<size>",
description = "Add walking_light:light to a position, without a player owning it",
description = S("Add walking_light:light to a position, without a player owning it."),
func = function(name, param)
if not core.check_player_privs(name, {server=true}) then
return false, "You need the server privilege to use mapaddlight"
return false, S("You need the server privilege to use @1", "walking_light_add_light")
end
local pos = vector.round(core.get_player_by_name(name):get_pos())
pos = vector.new(pos.x, pos.y + 1, pos.z)
if pos then
mt_add_node(pos, {type="node", name=walking_light_node})
walking_light.mt_add_node(pos, {type="node", name=walking_light_node})
end
return true, "Done."
return true, S("Done.")
end,
})
--- Toggles debugging mode.
--
-- If enabled, nodes with added light will be visibly marked.
--
-- @chatcmd walking_light_debug
core.register_chatcommand("walking_light_debug", {
description = "Change to debug mode, so light blocks are visible.",
description = S("Change to debug mode, so light blocks are visible."),
func = function(name, param)
if not core.check_player_privs(name, {server=true}) then
return false, "You need the server privilege to use walking_light_debug"
return false, S("You need the server privilege to use @1", "walking_light_debug")
end
-- toggle debug mode
walking_light.set_debug(not walking_light_debug)
walking_light.update_node()
return true, "Done."
return true, S("Done.")
end,
})

View File

@ -1 +0,0 @@
default

View File

@ -19,6 +19,7 @@ end
local scripts = {
"settings",
"api",
"chat",
"nodes",
@ -27,3 +28,8 @@ local scripts = {
for _, sc in ipairs(scripts) do
dofile(walking_light.modpath .. "/" .. sc .. ".lua")
end
if core.registered_items["default:torch"] then
walking_light.register_item("default:torch")
end

View File

@ -0,0 +1,13 @@
Translated by:
# chat.lua
Remove light nodes from the area.=
Add walking_light:light to a position, without a player owning it.=
Change to debug mode, so light blocks are visible.=
You need the server privilege to use @1=
Failed... infinite loop detected=
Done.=
# nodes.lua
Megatorch=

View File

@ -1,2 +1,4 @@
name = walking_light
depends = default
description = Adds items that will illuminate area around player when wielded or equipped.
author = Echo, petermaloney, Jordan Irwin (AntumDeluge)
optional_depends = default

View File

@ -1,7 +1,10 @@
local S = core.get_translator(walking_light.modname)
core.register_node("walking_light:light_debug", {
drawtype = "glasslike",
tiles = {"walking_light_debug.png"},
tiles = {"walking_light_underlay.png"},
inventory_image = core.inventorycube("walking_light.png"),
paramtype = "light",
walkable = false,
@ -29,61 +32,65 @@ core.register_node("walking_light:light", {
},
})
core.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,
if walking_light.enable_megatorch and core.get_modpath("default") then
core.register_node("walking_light:megatorch", {
description = S("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,
},
},
},
{
name = "default_torch_on_ceiling_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 = 13,
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},
},
{
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 = 13,
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,
})
groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1},
legacy_wallmounted = true,
})
core.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"},
}
})
walking_light.register_item("walking_light:megatorch", 10)
core.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"},
}
})
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 KiB

View File

@ -0,0 +1,12 @@
--- walking_light Settings
--
-- @topic settings
--- Enables walking_light:megatorch item.
--
-- @setting walking_light.enable_megatorch
-- @settype bool
-- @default true
walking_light.enable_megatorch = core.settings:get_bool("walking_light.enable_megatorch", true)

View File

@ -0,0 +1,3 @@
# Enables walking_light:megatorch item.
walking_light.enable_megatorch (Enable megatorch) bool true

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 460 B

After

Width:  |  Height:  |  Size: 174 B

View File

@ -930,6 +930,12 @@ slingshot.ammos (Registered ammos) string default:mese_crystal=5
trampoline.damage_absorb (Trampoline damage absorption) int 100 0 100
[*walking_light]
# Enables walking_light:megatorch item.
walking_light.enable_megatorch (Enable megatorch) bool true
[*wardrobe]
# Number of skins shown per page.