walking_light mod was renamed to "wlight" with many updates...
Sources: - ContentDB: https://content.minetest.net/packages/AntumDeluge/wlight/ - Release: https://github.com/AntumMT/mod-wlight/releases/tag/v1.0
This commit is contained in:
parent
75b7606859
commit
c9037c273f
@ -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][] ([MIT][lic.walking_light]) -- version: [6d32855 Git][ver.walking_light] *2021-06-25*
|
||||
* [wlight][] ([MIT][lic.wlight]) -- version: [1.0][ver.wlight] *2021-06-26*
|
||||
* 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]
|
||||
@ -376,7 +376,6 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
||||
[unifieddyes]: https://forum.minetest.net/viewtopic.php?t=2178
|
||||
[vines]: https://forum.minetest.net/viewtopic.php?f=11&t=2344
|
||||
[waffles]: https://forum.minetest.net/viewtopic.php?t=16669
|
||||
[walking_light]: https://forum.minetest.net/viewtopic.php?t=2621
|
||||
[wardrobe]: https://github.com/AntumMT/mod-wardrobe
|
||||
[wardrobe.old]: https://forum.minetest.net/viewtopic.php?t=9680
|
||||
[wdata]: https://forum.minetest.net/viewtopic.php?t=26804
|
||||
@ -384,6 +383,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
||||
[whinny]: https://github.com/AntumMT/mod-whinny
|
||||
[whitelist]: https://forum.minetest.net/viewtopic.php?t=8434
|
||||
[windmill]: https://forum.minetest.net/viewtopic.php?id=7440
|
||||
[wlight]: https://content.minetest.net/packages/AntumDeluge/wlight/
|
||||
[workbench]: https://forum.minetest.net/viewtopic.php?t=14085
|
||||
[xtraarmor]: https://forum.minetest.net/viewtopic.php?t=16645
|
||||
|
||||
@ -460,12 +460,12 @@ 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/LICENSE.txt
|
||||
[lic.wardrobe]: mods/player/visuals/wardrobe/LICENSE.txt
|
||||
[lic.wdata]: mods/misc/wdata/LICENSE.txt
|
||||
[lic.whinny]: mods/mobiles/whinny/LICENSE.txt
|
||||
[lic.whitelist]: mods/admin/whitelist/LICENSE.txt
|
||||
[lic.windmill]: mods/buildings/windmill/README.md
|
||||
[lic.wlight]: mods/lighting/wlight/LICENSE.txt
|
||||
[lic.workbench]: mods/tools/workbench/LICENSE.txt
|
||||
|
||||
[lic.cc0]: doc/licenses/CC0.txt
|
||||
@ -626,12 +626,12 @@ 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/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
|
||||
[ver.whitelist]: https://github.com/AntumMT/mod-whitelist/releases/tag/v1.1
|
||||
[ver.windmill]: https://github.com/Sokomine/windmill/tree/47b029d
|
||||
[ver.wlight]: https://github.com/AntumMT/mod-wlight/releases/tag/v1.0
|
||||
[ver.workbench]: https://github.com/AntumMT/mod-workbench/releases/tag/v1.0
|
||||
|
||||
[patch.3d_armor]: https://github.com/AntumMT/mp-3d_armor/tree/b3324f6
|
||||
|
@ -1750,12 +1750,12 @@ coloredwood_enable_stairsplus = true
|
||||
#playeranim.animation_speed_sneak = 0.8
|
||||
|
||||
|
||||
# *** walking_light
|
||||
# *** wlight ***
|
||||
|
||||
## Enables walking_light:megatorch item.
|
||||
## Enables wlight:megatorch item.
|
||||
# type: bool
|
||||
# default: true
|
||||
#walking_light.enable_megatorch = true
|
||||
#wlight.enable_megatorch = true
|
||||
|
||||
|
||||
# *** wardrobe ***
|
||||
|
@ -1,35 +0,0 @@
|
||||
## Walking Light
|
||||
|
||||
### Description:
|
||||
|
||||
A mod for [Minetest][] that illuminates the area around a player when equipped with a light item.
|
||||
|
||||
![screenshot](screenshot.png)
|
||||
|
||||
#### History:
|
||||
|
||||
- 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
|
||||
|
||||
### 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
|
@ -1,6 +0,0 @@
|
||||
|
||||
TODO:
|
||||
- clean up
|
||||
- rename
|
||||
- walking_light_debug should only enable debugging for player invoking command
|
||||
- replace chat commands with single command "walking_light"
|
@ -1,83 +0,0 @@
|
||||
|
||||
--- 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 = S("Remove light nodes from the area."),
|
||||
func = function(name, param)
|
||||
if not core.check_player_privs(name, {server=true}) then
|
||||
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())
|
||||
local size = tonumber(param) or 40
|
||||
|
||||
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
|
||||
walking_light.remove_light(nil, point)
|
||||
local oldpoint = point
|
||||
point = core.find_node_near(pos, size/2, v)
|
||||
if walking_light.poseq(oldpoint, point) then
|
||||
return false, S("Failed... infinite loop detected")
|
||||
end
|
||||
end
|
||||
end
|
||||
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 = 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, 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
|
||||
walking_light.mt_add_node(pos, {type="node", name=walking_light_node})
|
||||
end
|
||||
|
||||
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 = 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, 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, S("Done.")
|
||||
end,
|
||||
})
|
@ -1,35 +0,0 @@
|
||||
|
||||
walking_light = {}
|
||||
walking_light.modname = core.get_current_modname()
|
||||
walking_light.modpath = core.get_modpath(walking_light.modname)
|
||||
|
||||
function walking_light.log(lvl, msg)
|
||||
if not msg then
|
||||
msg = lvl
|
||||
lvl = nil
|
||||
end
|
||||
|
||||
msg = "[" .. walking_light.modname .. "] " .. msg
|
||||
if not lvl then
|
||||
core.log(msg)
|
||||
else
|
||||
core.log(lvl, msg)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local scripts = {
|
||||
"settings",
|
||||
"api",
|
||||
"chat",
|
||||
"nodes",
|
||||
}
|
||||
|
||||
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
|
@ -1,13 +0,0 @@
|
||||
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=
|
@ -1,12 +0,0 @@
|
||||
|
||||
--- 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)
|
@ -1,3 +0,0 @@
|
||||
|
||||
# Enables walking_light:megatorch item.
|
||||
walking_light.enable_megatorch (Enable megatorch) bool true
|
72
mods/lighting/wlight/README.md
Normal file
72
mods/lighting/wlight/README.md
Normal file
@ -0,0 +1,72 @@
|
||||
## Walking Light
|
||||
|
||||
### Description:
|
||||
|
||||
A mod for [Minetest](http://minetest.net/) that illuminates the area around a player when wielding a light-emitting item. Also supports equipped armor with [3d_armor](https://content.minetest.net/packages/stu/3d_armor/).
|
||||
|
||||
![screenshot](screenshot.png)
|
||||
|
||||
#### History:
|
||||
|
||||
- forked from [v0.6][forum.echo] of Echo's *walking_light*
|
||||
- forked from [Git commit 766ef0f](https://github.com/petermaloney/walking_light/tree/766ef0f) of petermaloney's *walking_light*
|
||||
|
||||
### 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)
|
||||
- Privileges: server (for using chat commands)
|
||||
```
|
||||
|
||||
### Usage:
|
||||
|
||||
Main methods:
|
||||
|
||||
```
|
||||
wlight.register_item(iname, radius)
|
||||
- Registers an item to emit light when wielded.
|
||||
- `iname`: Item technical name.
|
||||
- `radius`: Distance light will reach (max: 10).
|
||||
|
||||
wlight.register_armor(iname, radius, litem)
|
||||
- Registers an item to emit light when equipped in armor inventory.
|
||||
- `iname`: Item technical name.
|
||||
- `radius`: Distance light will reach (max: 10).
|
||||
- `litem`: Whether or not this item should also be registered with `wlight.register_item` (default: true).
|
||||
```
|
||||
|
||||
Settings:
|
||||
|
||||
```
|
||||
wlight.enable_megatorch
|
||||
- Enables wlight:megatorch item.
|
||||
- default: true
|
||||
```
|
||||
|
||||
### Links:
|
||||
|
||||
- [![ContentDB](https://content.minetest.net/packages/AntumDeluge/wlight/shields/title/)](https://content.minetest.net/packages/AntumDeluge/wlight/)
|
||||
- [Forum](https://forum.minetest.net/viewtopic.php?t=26938)
|
||||
- [Git repo](https://github.com/AntumMT/mod-wlight)
|
||||
- [API](https://antummt.github.io/mod-wlight/docs/api.html)
|
||||
- [Changelog](changelog.txt)
|
||||
- [TODO](TODO.txt)
|
||||
- Echo's *walking_light*:
|
||||
- [Forum][forum.echo]
|
||||
- [v0.6 release](https://github.com/AntumMT/mod-wlight/releases/tag/v0.6)
|
||||
- petermaloney's *walking_light*:
|
||||
- [Git repo](https://github.com/petermaloney/walking_light)
|
||||
|
||||
**Alternative Mods:**
|
||||
|
||||
- [![wielded_light](https://content.minetest.net/packages/bell07/wielded_light/shields/title/)](https://content.minetest.net/packages/bell07/wielded_light/)
|
||||
|
||||
|
||||
[forum.echo]: https://forum.minetest.net/viewtopic.php?t=2621
|
4
mods/lighting/wlight/TODO.txt
Normal file
4
mods/lighting/wlight/TODO.txt
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
TODO:
|
||||
- wlight_debug should only enable debugging for player invoking command
|
||||
- use spherical area when calculating radius for chat commands
|
@ -1,5 +1,5 @@
|
||||
|
||||
--- walking_light Methods
|
||||
--- wlight Methods
|
||||
--
|
||||
-- @topic methods
|
||||
|
||||
@ -14,16 +14,23 @@ local light_positions = {}
|
||||
local last_wielded = {}
|
||||
|
||||
-- toggles debug mode
|
||||
local walking_light_debug = false
|
||||
local wlight_debug = false
|
||||
|
||||
-- name of light node, changed by toggling debug mode
|
||||
walking_light_node = nil
|
||||
wlight_node = nil
|
||||
|
||||
--- Sets debugging mode.
|
||||
--
|
||||
-- @tparam bool enabled Determines if debugging is enabled.
|
||||
function walking_light.set_debug(enabled)
|
||||
walking_light_debug = enabled
|
||||
function wlight.set_debug(enabled)
|
||||
wlight_debug = enabled
|
||||
end
|
||||
|
||||
--- Checks if debugging is enabled.
|
||||
--
|
||||
-- @treturn bool
|
||||
function wlight.debug_enabled()
|
||||
return wlight_debug == true
|
||||
end
|
||||
|
||||
-- list of items that use walking light when wielded
|
||||
@ -36,9 +43,9 @@ local light_armor = {}
|
||||
--
|
||||
-- @tparam string iname Item technical name.
|
||||
-- @tparam[opt] int radius Distance light will reach (max: 10).
|
||||
function walking_light.register_item(iname, radius)
|
||||
function wlight.register_item(iname, radius)
|
||||
if radius and radius > 10 then
|
||||
walking_light.log("warning", "light radius too high, setting to 10")
|
||||
wlight.log("warning", "light radius too high, setting to 10")
|
||||
radius = 10
|
||||
end
|
||||
|
||||
@ -46,7 +53,7 @@ function walking_light.register_item(iname, radius)
|
||||
|
||||
for li in pairs(light_items) do
|
||||
if iname == li then
|
||||
walking_light.log("warning", "\"" .. iname .. "\" is already light item.")
|
||||
wlight.log("warning", "\"" .. iname .. "\" is already light item.")
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -56,12 +63,12 @@ end
|
||||
|
||||
--- 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\"")
|
||||
-- Use `wlight.register_item`
|
||||
function wlight.addLightItem(item)
|
||||
wlight.log("warning",
|
||||
"\"wlight.addLightItem\" is deprecated, use \"wlight.register_item\"")
|
||||
|
||||
return walking_light.register_item(item)
|
||||
return wlight.register_item(item)
|
||||
end
|
||||
|
||||
--- Registers an item to emit light when equipped in armor inventory.
|
||||
@ -70,10 +77,10 @@ end
|
||||
--
|
||||
-- @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)
|
||||
-- @tparam[opt] bool litem Whether or not this item should also be registered with `wlight.register_item`.
|
||||
function wlight.register_armor(iname, radius, litem)
|
||||
if radius and radius > 10 then
|
||||
walking_light.log("warning", "light radius too high, setting to 10")
|
||||
wlight.log("warning", "light radius too high, setting to 10")
|
||||
radius = 10
|
||||
end
|
||||
|
||||
@ -82,53 +89,29 @@ function walking_light.register_armor(iname, radius, litem)
|
||||
|
||||
for la in pairs(light_armor) do
|
||||
if iname == la then
|
||||
walking_light.log("warning", "\"" .. iname .. "\" is already light armor.")
|
||||
wlight.log("warning", "\"" .. iname .. "\" is already light armor.")
|
||||
end
|
||||
end
|
||||
|
||||
light_armor[iname] = def
|
||||
if litem then walking_light.register_item(iname, radius) end
|
||||
if litem then wlight.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()
|
||||
function wlight.get_light_items()
|
||||
return light_items
|
||||
end
|
||||
|
||||
--- 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\"")
|
||||
-- Use `wlight.get_light_items`
|
||||
function wlight.getLightItems()
|
||||
wlight.log("warning",
|
||||
"\"wlight.getLightItems\" is deprecated, use \"wlight.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")
|
||||
|
||||
local item, default, definition
|
||||
item = "walking_light:" .. tool .. "_mese"
|
||||
default = "default:" .. tool .. "_mese"
|
||||
|
||||
definition = table.copy(core.registered_items[default])
|
||||
definition.description = definition.description .. " with light"
|
||||
definition.inventory_image = "walking_light_mese" .. tool .. ".png"
|
||||
|
||||
core.register_tool(item, definition)
|
||||
core.register_craft({
|
||||
output = item,
|
||||
recipe = {
|
||||
{"default:torch"},
|
||||
{ default },
|
||||
}
|
||||
})
|
||||
|
||||
walking_light.register_item(item)
|
||||
return wlight.get_light_items()
|
||||
end
|
||||
|
||||
-- from http://lua-users.org/wiki/IteratorsTutorial
|
||||
@ -184,7 +167,7 @@ end
|
||||
|
||||
local function mt_get_node_or_nil(pos)
|
||||
if pos == nil then
|
||||
walking_light.log("error", "mt_get_node_or_nil(), pos is nil")
|
||||
wlight.log("error", "mt_get_node_or_nil(), pos is nil")
|
||||
print(debug.traceback("Current Callstack:\n"))
|
||||
return nil
|
||||
end
|
||||
@ -205,14 +188,14 @@ end
|
||||
--
|
||||
-- @tparam table pos Position.
|
||||
-- @tparam table sometable
|
||||
function walking_light.mt_add_node(pos, sometable)
|
||||
function wlight.mt_add_node(pos, sometable)
|
||||
if pos == nil then
|
||||
walking_light.log("error", "walking_light.mt_add_node(), pos is nil")
|
||||
wlight.log("error", "wlight.mt_add_node(), pos is nil")
|
||||
print(debug.traceback("Current Callstack:\n"))
|
||||
return nil
|
||||
end
|
||||
if sometable == nil then
|
||||
walking_light.log("error", "walking_light.mt_add_node(), sometable is nil")
|
||||
wlight.log("error", "wlight.mt_add_node(), sometable is nil")
|
||||
print(debug.traceback("Current Callstack:\n"))
|
||||
return nil
|
||||
end
|
||||
@ -222,11 +205,11 @@ end
|
||||
|
||||
--- DEPRECATED
|
||||
--
|
||||
-- Use `walking_light.mt_add_node`
|
||||
-- Use `wlight.mt_add_node`
|
||||
function mt_add_node(pos, sometable)
|
||||
walking_light.log("warning", "\"mt_add_node\" is deprecated, use \"walking_light.mt_add_node\"")
|
||||
wlight.log("warning", "\"mt_add_node\" is deprecated, use \"wlight.mt_add_node\"")
|
||||
|
||||
return walking_light.mt_add_node(pos, sometable)
|
||||
return wlight.mt_add_node(pos, sometable)
|
||||
end
|
||||
|
||||
local function round(num)
|
||||
@ -238,7 +221,7 @@ end
|
||||
-- @tparam table pos1
|
||||
-- @tparam table pos2
|
||||
-- @treturn bool
|
||||
function walking_light.poseq(pos1, pos2)
|
||||
function wlight.poseq(pos1, pos2)
|
||||
if pos1 == nil and pos2 == nil then
|
||||
return true
|
||||
end
|
||||
@ -251,11 +234,11 @@ end
|
||||
|
||||
--- DEPRECATED
|
||||
--
|
||||
-- Use `walking_light.poseq`
|
||||
-- Use `wlight.poseq`
|
||||
function poseq(pos1, pos2)
|
||||
walking_light.log("warning", "\"poseq\" is deprecated, use \"walking_light.poseq\"")
|
||||
wlight.log("warning", "\"poseq\" is deprecated, use \"wlight.poseq\"")
|
||||
|
||||
return walking_light.poseq(pos1, pos2)
|
||||
return wlight.poseq(pos1, pos2)
|
||||
end
|
||||
|
||||
-- return true if the player moved since last player_positions update
|
||||
@ -264,7 +247,7 @@ local function player_moved(player)
|
||||
local pos = player:get_pos()
|
||||
local rounded_pos = vector.round(pos)
|
||||
local oldpos = player_positions[player_name]
|
||||
if oldpos == nil or not walking_light.poseq(rounded_pos, oldpos) then
|
||||
if oldpos == nil or not wlight.poseq(rounded_pos, oldpos) then
|
||||
-- if oldpos is nil, we assume they just logged in, so consider them moved
|
||||
return true
|
||||
end
|
||||
@ -272,20 +255,20 @@ local function player_moved(player)
|
||||
return false
|
||||
end
|
||||
|
||||
-- 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?)
|
||||
-- same as table.remove(t, remove_pos), but uses wlight.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 walking_light.poseq(pos, remove_pos) then
|
||||
if wlight.poseq(pos, remove_pos) then
|
||||
table.remove(t, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- same as t[remove_pos], but uses walking_light.poseq instead of comparing references (does lua have comparator support, so this isn't needed?)
|
||||
-- same as t[remove_pos], but uses wlight.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 walking_light.poseq(pos, remove_pos) then
|
||||
if wlight.poseq(pos, remove_pos) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -301,7 +284,7 @@ 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 == "wlight:light" or node.name == "wlight:light_debug") then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
@ -311,24 +294,24 @@ end
|
||||
--
|
||||
-- @tparam[opt] ObjectRef player
|
||||
-- @tparam table pos Posistion where light will be removed.
|
||||
function walking_light.remove_light(player, pos)
|
||||
function wlight.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
|
||||
walking_light.mt_add_node(pos, {type="node", name="air"})
|
||||
wlight.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
|
||||
walking_light.log("warning", "walking_light.remove_light(), pos = "
|
||||
wlight.log("warning", "wlight.remove_light(), pos = "
|
||||
.. dumppos(pos) .. ", tried to remove light but node was " .. node.name)
|
||||
table_remove_pos(light_positions[player_name], pos)
|
||||
else
|
||||
walking_light.log("warning", "walking_light.remove_light(), pos = "
|
||||
wlight.log("warning", "wlight.remove_light(), pos = "
|
||||
.. dumppos(pos) .. ", tried to remove light but node was nil")
|
||||
end
|
||||
end
|
||||
@ -336,11 +319,11 @@ end
|
||||
|
||||
--- DEPRECATED
|
||||
--
|
||||
-- Use `walking_light.remove_light`
|
||||
-- Use `wlight.remove_light`
|
||||
function remove_light(player, pos)
|
||||
walking_light.log("warning", "\"remove_light\" is deprecated, use \"walking_light.remove_light\"")
|
||||
wlight.log("warning", "\"remove_light\" is deprecated, use \"wlight.remove_light\"")
|
||||
|
||||
return walking_light.remove_light(player, pos)
|
||||
return wlight.remove_light(player, pos)
|
||||
end
|
||||
|
||||
-- removes all light owned by a player
|
||||
@ -349,7 +332,7 @@ local function remove_light_player(player)
|
||||
|
||||
for i, old_pos in ripairs(light_positions[player_name]) do
|
||||
if old_pos then
|
||||
walking_light.remove_light(player, old_pos)
|
||||
wlight.remove_light(player, old_pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -460,7 +443,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
|
||||
walking_light.mt_add_node(pos, {type="node", name=walking_light_node})
|
||||
wlight.mt_add_node(pos, {type="node", name=wlight_node})
|
||||
if not table_contains_pos(light_positions[player_name], pos) then
|
||||
table_insert_pos(light_positions[player_name], pos)
|
||||
end
|
||||
@ -481,7 +464,7 @@ 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
|
||||
if wielded_item ~= "" and wlight.is_light_item(wielded_item) then
|
||||
return wielded_item
|
||||
end
|
||||
|
||||
@ -493,7 +476,7 @@ local function get_wielded_light_item(player)
|
||||
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
|
||||
if wlight.is_light_armor(item_name) then
|
||||
return item_name, true
|
||||
end
|
||||
end
|
||||
@ -555,7 +538,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
|
||||
walking_light.remove_light(player, oldlightpos)
|
||||
wlight.remove_light(player, oldlightpos)
|
||||
end
|
||||
end
|
||||
|
||||
@ -574,7 +557,7 @@ end
|
||||
--
|
||||
-- @tparam string iname Item technical name.
|
||||
-- @treturn bool `true` if item is registered.
|
||||
function walking_light.is_light_item(iname)
|
||||
function wlight.is_light_item(iname)
|
||||
for li in pairs(light_items) do
|
||||
if iname == li then
|
||||
return true
|
||||
@ -588,7 +571,7 @@ end
|
||||
--
|
||||
-- @tparam string iname Item technical name.
|
||||
-- @treturn bool `true` if item is registered.
|
||||
function walking_light.is_light_armor(iname)
|
||||
function wlight.is_light_armor(iname)
|
||||
for la in pairs(light_armor) do
|
||||
if iname == la then
|
||||
return true
|
||||
@ -602,7 +585,7 @@ end
|
||||
--
|
||||
-- @tparam ObjectRef player Player to be checked.
|
||||
-- @treturn bool `true` if player is wielding registered item.
|
||||
function walking_light.wields_light(player)
|
||||
function wlight.wields_light(player)
|
||||
return get_wielded_light_item(player) ~= nil
|
||||
end
|
||||
|
||||
@ -642,12 +625,12 @@ 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"
|
||||
function wlight.update_node()
|
||||
if wlight_debug then
|
||||
wlight_node = "wlight:light_debug"
|
||||
else
|
||||
walking_light_node = "walking_light:light"
|
||||
wlight_node = "wlight:light"
|
||||
end
|
||||
end
|
||||
|
||||
walking_light.update_node()
|
||||
wlight.update_node()
|
@ -13,6 +13,10 @@ v1.0
|
||||
- megatorch can be disabled via setting
|
||||
- added localization support
|
||||
- added option to set custom light radius when registering item or armor
|
||||
- removed method "walking_light.register_tool"
|
||||
- renamed to "wlight"
|
||||
- consolidated chat commands into single "wlight" command
|
||||
- fixed "/wlight add" command not able to illuminate more than one node
|
||||
|
||||
petermaloney
|
||||
------------
|
103
mods/lighting/wlight/chat.lua
Normal file
103
mods/lighting/wlight/chat.lua
Normal file
@ -0,0 +1,103 @@
|
||||
|
||||
--- wlight Chat Commands
|
||||
--
|
||||
-- @topic commands
|
||||
|
||||
|
||||
local S = core.get_translator(wlight.modname)
|
||||
|
||||
|
||||
--- Manages lighted nodes and debugging.
|
||||
--
|
||||
-- **Parameters:**
|
||||
--
|
||||
-- @chatcmd wlight
|
||||
-- @tparam command Command action to be executed.
|
||||
-- @tparam[opt] radius Area radius (default: 20).
|
||||
-- @usage /wlight <command> [radius]
|
||||
--
|
||||
-- Commands:
|
||||
-- - add: Add lighting to current position.
|
||||
-- - remove: Remove lighting from current position.
|
||||
-- - debug: Toggle illuminated nodes visible mark for debugging.
|
||||
--
|
||||
-- Options:
|
||||
-- - radius: Area radius (add default: 0, remove default: 20).
|
||||
--
|
||||
-- Example:
|
||||
-- /wlight add 5
|
||||
core.register_chatcommand(wlight.modname, {
|
||||
params = "<" .. S("command") .. "> [" .. S("radius") .. "]",
|
||||
privs = {server=true},
|
||||
description = S("Manage lighted nodes and debugging.")
|
||||
.. "\n\n" .. S("Commands:")
|
||||
.. "\n add: " .. S("Add lighting to current position.")
|
||||
.. "\n remove: " .. S("Remove lighting from current position.")
|
||||
.. "\n debug: " .. S("Toggle illuminated nodes visible mark for debugging.")
|
||||
.. "\n\n" .. S("Options:")
|
||||
.. "\n " .. S("radius") .. ": " .. S("Area radius (add default: 0, remove default: 20)."),
|
||||
func = function(name, param)
|
||||
local command
|
||||
local radius
|
||||
if param:find(" ") then
|
||||
local params = param:split(" ")
|
||||
command = params[1]
|
||||
radius = tonumber(params[2])
|
||||
else
|
||||
command = param
|
||||
end
|
||||
|
||||
if not radius then
|
||||
radius = 0
|
||||
if command == "remove" then
|
||||
radius = 20
|
||||
end
|
||||
end
|
||||
|
||||
if command == "" then
|
||||
core.chat_send_player(name, "\n" .. S("Missing command parameter."))
|
||||
return false
|
||||
end
|
||||
|
||||
if (command == "add" or command == "remove") and not radius then
|
||||
core.chat_send_player(name, "\n" .. S("Missing radius parameter."))
|
||||
return false
|
||||
end
|
||||
|
||||
local pos = vector.round(core.get_player_by_name(name):get_pos())
|
||||
|
||||
if command == "debug" then
|
||||
wlight.set_debug(not wlight.debug_enabled())
|
||||
wlight.update_node()
|
||||
elseif command == "add" then
|
||||
pos = vector.new(pos.x, pos.y + 1, pos.z)
|
||||
if pos then
|
||||
local pmin = {x=pos.x-radius, y=pos.y-radius, z=pos.z-radius}
|
||||
local pmax = {x=pos.x+radius, y=pos.y+radius, z=pos.z+radius}
|
||||
local near_nodes = core.find_nodes_in_area(pmin, pmax, "air", true)
|
||||
if near_nodes.air then
|
||||
for _, npos in ipairs(near_nodes.air) do
|
||||
wlight.mt_add_node(npos, {type="node", name=wlight_node})
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif command == "remove" then
|
||||
for _, v in ipairs({"wlight:light", "wlight:light_debug"}) do
|
||||
local point = core.find_node_near(pos, radius, v)
|
||||
while point do
|
||||
wlight.remove_light(nil, point)
|
||||
local oldpoint = point
|
||||
point = core.find_node_near(pos, radius, v)
|
||||
if wlight.poseq(oldpoint, point) then
|
||||
return false, S("Failed... infinite loop detected.")
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
core.chat_send_player(name, "\n" .. S("Unknown command: @1", command))
|
||||
return false
|
||||
end
|
||||
|
||||
return true, S("Done.")
|
||||
end,
|
||||
})
|
38
mods/lighting/wlight/init.lua
Normal file
38
mods/lighting/wlight/init.lua
Normal file
@ -0,0 +1,38 @@
|
||||
|
||||
wlight = {}
|
||||
wlight.modname = core.get_current_modname()
|
||||
wlight.modpath = core.get_modpath(wlight.modname)
|
||||
|
||||
-- override walking_light
|
||||
walking_light = wlight
|
||||
|
||||
function wlight.log(lvl, msg)
|
||||
if not msg then
|
||||
msg = lvl
|
||||
lvl = nil
|
||||
end
|
||||
|
||||
msg = "[" .. wlight.modname .. "] " .. msg
|
||||
if not lvl then
|
||||
core.log(msg)
|
||||
else
|
||||
core.log(lvl, msg)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local scripts = {
|
||||
"settings",
|
||||
"api",
|
||||
"chat",
|
||||
"nodes",
|
||||
}
|
||||
|
||||
for _, sc in ipairs(scripts) do
|
||||
dofile(wlight.modpath .. "/" .. sc .. ".lua")
|
||||
end
|
||||
|
||||
|
||||
if core.registered_items["default:torch"] then
|
||||
wlight.register_item("default:torch")
|
||||
end
|
20
mods/lighting/wlight/locale/template.txt
Normal file
20
mods/lighting/wlight/locale/template.txt
Normal file
@ -0,0 +1,20 @@
|
||||
Translated by:
|
||||
|
||||
|
||||
# chat.lua
|
||||
Manage lighted nodes and debugging.=
|
||||
Commands:=
|
||||
Options:=
|
||||
command=
|
||||
radius=
|
||||
Missing command parameter.=
|
||||
Missing radius parameter.=
|
||||
Add lighting to current position.=
|
||||
Remove lighting from current position.=
|
||||
Toggle illuminated nodes visible mark for debugging.=
|
||||
Area radius (add default: 0, remove default: 20).=
|
||||
Failed... infinite loop detected.=
|
||||
Done.=
|
||||
|
||||
# nodes.lua
|
||||
Megatorch=
|
@ -1,4 +1,5 @@
|
||||
name = walking_light
|
||||
name = wlight
|
||||
description = Adds items that will illuminate area around player when wielded or equipped.
|
||||
version = 1.0
|
||||
author = Echo, petermaloney, Jordan Irwin (AntumDeluge)
|
||||
optional_depends = default
|
||||
optional_depends = default, walking_light
|
@ -1,11 +1,11 @@
|
||||
|
||||
local S = core.get_translator(walking_light.modname)
|
||||
local S = core.get_translator(wlight.modname)
|
||||
|
||||
|
||||
core.register_node("walking_light:light_debug", {
|
||||
drawtype = "glasslike",
|
||||
tiles = {"walking_light_underlay.png"},
|
||||
inventory_image = core.inventorycube("walking_light.png"),
|
||||
core.register_node("wlight:light_debug", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"wlight_inv_underlay.png"},
|
||||
inventory_image = core.inventorycube("wlight_inv_underlay.png"),
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
is_ground_content = true,
|
||||
@ -16,11 +16,12 @@ core.register_node("walking_light:light_debug", {
|
||||
fixed = {0, 0, 0, 0, 0, 0},
|
||||
},
|
||||
})
|
||||
core.register_alias("walking_light:light_debug", "wlight:light_debug")
|
||||
|
||||
core.register_node("walking_light:light", {
|
||||
core.register_node("wlight:light", {
|
||||
drawtype = "glasslike",
|
||||
tiles = {"walking_light.png"},
|
||||
inventory_image = core.inventorycube("walking_light.png"),
|
||||
tiles = {"wlight_light.png"},
|
||||
inventory_image = core.inventorycube("wlight_light.png"),
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
is_ground_content = true,
|
||||
@ -31,9 +32,10 @@ core.register_node("walking_light:light", {
|
||||
fixed = {0, 0, 0, 0, 0, 0},
|
||||
},
|
||||
})
|
||||
core.register_alias("walking_light:light", "wlight:light")
|
||||
|
||||
if walking_light.enable_megatorch and core.get_modpath("default") then
|
||||
core.register_node("walking_light:megatorch", {
|
||||
if wlight.enable_megatorch and core.get_modpath("default") then
|
||||
core.register_node("wlight:megatorch", {
|
||||
description = S("Megatorch"),
|
||||
drawtype = "torchlike",
|
||||
tiles = {
|
||||
@ -83,14 +85,16 @@ if walking_light.enable_megatorch and core.get_modpath("default") then
|
||||
legacy_wallmounted = true,
|
||||
})
|
||||
|
||||
walking_light.register_item("walking_light:megatorch", 10)
|
||||
wlight.register_item("wlight:megatorch", 10)
|
||||
|
||||
core.register_craft({
|
||||
output = "walking_light:megatorch",
|
||||
output = "wlight:megatorch",
|
||||
recipe = {
|
||||
{"default:torch", "default:torch", "default:torch"},
|
||||
{"default:torch", "default:torch", "default:torch"},
|
||||
{"default:torch", "default:torch", "default:torch"},
|
||||
}
|
||||
})
|
||||
|
||||
core.register_alias("walking_light:megatorch", "wlight:megatorch")
|
||||
end
|
Before Width: | Height: | Size: 283 KiB After Width: | Height: | Size: 283 KiB |
12
mods/lighting/wlight/settings.lua
Normal file
12
mods/lighting/wlight/settings.lua
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
--- wlight Settings
|
||||
--
|
||||
-- @topic settings
|
||||
|
||||
|
||||
--- Enables wlight:megatorch item.
|
||||
--
|
||||
-- @setting wlight.enable_megatorch
|
||||
-- @settype bool
|
||||
-- @default true
|
||||
wlight.enable_megatorch = core.settings:get_bool("wlight.enable_megatorch", true)
|
3
mods/lighting/wlight/settingtypes.txt
Normal file
3
mods/lighting/wlight/settingtypes.txt
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
# Enables wlight:megatorch item.
|
||||
wlight.enable_megatorch (Enable megatorch) bool true
|
Before Width: | Height: | Size: 174 B After Width: | Height: | Size: 174 B |
Before Width: | Height: | Size: 128 B After Width: | Height: | Size: 128 B |
@ -992,10 +992,10 @@ slingshot.ammos (Registered ammos) string default:mese_crystal=5
|
||||
trampoline.damage_absorb (Trampoline damage absorption) int 100 0 100
|
||||
|
||||
|
||||
[*walking_light]
|
||||
[*wlight]
|
||||
|
||||
# Enables walking_light:megatorch item.
|
||||
walking_light.enable_megatorch (Enable megatorch) bool true
|
||||
# Enables wlight:megatorch item.
|
||||
wlight.enable_megatorch (Enable megatorch) bool true
|
||||
|
||||
|
||||
[*wardrobe]
|
||||
|
Loading…
x
Reference in New Issue
Block a user