Add flash-lamp and wear.
parent
56df2c2046
commit
5319d1ed9a
45
README.md
45
README.md
|
@ -1,32 +1,38 @@
|
|||
Wand of Illumination [wand\_of\_illumination]
|
||||
===========================================
|
||||
Provides a wand that when used lights up an entire room, but only for a moment.
|
||||
Provides a wand that when used, lights up an entire room—but only for a moment.
|
||||
|
||||
Alternatively, provides a 1900-era flash-lamp, for those without a sense of magic.
|
||||
|
||||
|
||||
![Wand of Illumination Screenshot](screenshot.png "Wand of Illumination")
|
||||
![Wand of Illumination Screenshot](compare.gif "Torch vs Normal vs Extended Range")
|
||||
|
||||
**Picture:** Torch vs Normal vs Extended Range (smooth lighting off)
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
- On right click, places an array of invisible light nodes around the player, in a sphere with a current radius of 15 nodes, and with a light spacing of four nodes.
|
||||
- On shift-right-click (or aux-right-click), creates an extended sphere of lights with a radius of 30 nodes.
|
||||
- **New:** Doesn't place lights where already brightly lit.
|
||||
- Uses node_timers to cause these light nodes to revert back to air nodes after a short amount of time. (However, I left the ABM in as a config option.)
|
||||
- Uses mana mod if available. Current cost for use is 100 mana (normal), or 200 mana (extended).
|
||||
- Note that narrow passages, like dungeon corridors, may not light up, if they don't fall on the 4x light spacing grid.
|
||||
- **New:** Now with choice of original magic wand or new 1900-era flash-lamp.
|
||||
- **New:** Changed activation to standard left-click.
|
||||
- On **left** click, places a sphere of invisible lights around the player with a radius of 15 nodes.
|
||||
- On shift-**left**-click (or aux-**left**-click), creates an extended sphere of lights with a radius of 30 nodes.
|
||||
- Doesn't place lights where already brightly lit.
|
||||
- Uses node_timers to cause these light nodes to gradually fade away.
|
||||
- **New:** Wear added, so wand and fill-light only work for a limited number of uses. (Currently 20 normal uses, or 10 extended uses.)
|
||||
- Uses mana mod for wand if available. Current cost for use is 100 mana (normal), or 200 mana (extended).
|
||||
|
||||
*(Note that narrow passages, like dungeon corridors, may not light up, if they don't fall on the 4x light spacing grid.)*
|
||||
|
||||
|
||||
|
||||
WIP—Things that still need to be done.
|
||||
----------------------------------
|
||||
|
||||
- Come up with a crafting recipe.
|
||||
- **(Done)** Determine if I should be using an abm or something else.
|
||||
- Come up with a crafting recipe. **(Done)** for flash-lamp.
|
||||
- Optimize number of uses before wearing out.
|
||||
- Optimize mana cost.
|
||||
- Tune light generated: brightness, spacing, radius, and decay rate.
|
||||
- Come up with a better wand texture.
|
||||
- **(Done)** Maybe add option to give bigger sphere of light on shift-right-click, at the cost of more mana.
|
||||
- Come up with a better textures.
|
||||
|
||||
|
||||
Note about number of lights used
|
||||
|
@ -49,9 +55,18 @@ Here's a screenshot with r=15 and r=50 (using meselamps to make the lights visib
|
|||
Dependencies
|
||||
------------
|
||||
|
||||
- Currently has no default dependency. *(However, I'll probably have to add default when a crafting recipe is added.)*
|
||||
- Optionally depends on Wuzzy's mana mod. *(Thanks to his Mirror of Returning mod, it was easy to figure out how to add mana support.)*
|
||||
- Craft recipe for flash-lamp needs default and tnt mods.
|
||||
- Craft recipe for wand still TBD.
|
||||
- Optionally depends on Wuzzy's mana mod, for wand.
|
||||
|
||||
Craft Recipe
|
||||
------------
|
||||
|
||||
wand = TBD
|
||||
|
||||
flash-lamp =
|
||||
|
||||
![Flash-Lamp Craft Recipe](crafting2.png "Flash-Lamp Craft Recipe")
|
||||
|
||||
Licenses
|
||||
--------
|
||||
|
@ -64,4 +79,4 @@ Media (textures)
|
|||
|
||||
> Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
|
||||
Current wand texture based on farming\_tool\_stonehoe.png by BlockMen
|
||||
Current textures based on farming\_tool\_stonehoe.png by BlockMen
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 363 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.9 KiB |
71
init.lua
71
init.lua
|
@ -1,14 +1,17 @@
|
|||
-- Wand of Illumination [wand_of_illumination]
|
||||
-- by David G (kestral246@gmail.com)
|
||||
-- 2020-01-28
|
||||
-- 2020-02-10
|
||||
|
||||
-- Provides a wand that when used lights up an entire room, but only for a moment.
|
||||
-- Also provides a flash-lamp for those without magic.
|
||||
|
||||
local brightness_value = 10 -- How bright to make lights.
|
||||
local NORMAL_RADIUS_SQUARED = 15^2 -- Radius of sphere (squared).
|
||||
local NORMAL_COST = 100
|
||||
local NORMAL_USES = 20
|
||||
local EXTENDED_RADIUS_SQUARED = 30^2
|
||||
local EXTENDED_COST = 200
|
||||
local EXTENDED_USES = 10
|
||||
local maxcount = 120000 -- Maximum number of nodes to check ((4/3)*pi*r^3).
|
||||
|
||||
-- Setting to allow optional use of ABM for light decay.
|
||||
|
@ -21,9 +24,10 @@ end
|
|||
-- Set to true to print debug statistics.
|
||||
local debug = false
|
||||
|
||||
local using_mana = false
|
||||
-- Check for mana mod
|
||||
local using_mana_mod = false
|
||||
if minetest.get_modpath("mana") ~= nil then
|
||||
using_mana = true
|
||||
using_mana_mod = true
|
||||
end
|
||||
|
||||
local scanned = {} -- Set containing scanned nodes, so they don't get scanned multiple times.
|
||||
|
@ -44,18 +48,22 @@ minetest.register_on_leaveplayer(function(player)
|
|||
tolight[pname] = nil
|
||||
end)
|
||||
|
||||
local mana_check = function(player, cost)
|
||||
local mana_check = function(player, cost, use_mana)
|
||||
local allowed
|
||||
if using_mana then
|
||||
if mana.subtract(player:get_player_name(), cost) then
|
||||
allowed = true
|
||||
if use_mana then
|
||||
if using_mana_mod then
|
||||
if mana.subtract(player:get_player_name(), cost) then
|
||||
allowed = true
|
||||
else
|
||||
allowed = false
|
||||
end
|
||||
else
|
||||
allowed = false
|
||||
allowed = true
|
||||
end
|
||||
else
|
||||
allowed = true
|
||||
return allowed
|
||||
else -- always allowed when not using mana
|
||||
return true
|
||||
end
|
||||
return allowed
|
||||
end
|
||||
|
||||
minetest.register_node("wand_of_illumination:light", {
|
||||
|
@ -128,17 +136,19 @@ local check_node = function(pname, pos, origin, maxdist2)
|
|||
end
|
||||
end
|
||||
|
||||
local use_wand = function(player)
|
||||
local use_wand = function(player, itemstack, use_mana)
|
||||
local pname = player:get_player_name()
|
||||
local pos = vector.add(vector.round(player:get_pos()), {x=0,y=1,z=0}) -- position of wand
|
||||
local key_stats = player:get_player_control()
|
||||
local radius2 = NORMAL_RADIUS_SQUARED -- normal
|
||||
local cost = NORMAL_COST
|
||||
local wear = math.floor(65535/NORMAL_USES)
|
||||
if key_stats.sneak or key_stats.aux1 then -- extended
|
||||
radius2 = EXTENDED_RADIUS_SQUARED
|
||||
cost = EXTENDED_COST
|
||||
wear = math.floor(65535/EXTENDED_USES)
|
||||
end
|
||||
if mana_check(player, cost) then
|
||||
if mana_check(player, cost, use_mana) then
|
||||
-- Initialize temporary tables for safety.
|
||||
scanned[pname] = {}
|
||||
tocheck[pname] = {}
|
||||
|
@ -170,6 +180,9 @@ local use_wand = function(player)
|
|||
scanned[pname] = {}
|
||||
tocheck[pname] = {}
|
||||
tolight[pname] = {}
|
||||
-- Add wear to wand
|
||||
itemstack:add_wear(wear)
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -177,10 +190,32 @@ minetest.register_tool("wand_of_illumination:wand", {
|
|||
description = "Wand of Illumination",
|
||||
inventory_image = "wand_of_illumination.png",
|
||||
stack_max = 1,
|
||||
on_place = function(itemstack, player, pointed_thing)
|
||||
use_wand(player)
|
||||
end,
|
||||
on_secondary_use = function(itemstack, player, pointed_thing)
|
||||
use_wand(player)
|
||||
on_use = function(itemstack, player, pointed_thing)
|
||||
local use_mana = true
|
||||
local worn_item = use_wand(player, itemstack, use_mana)
|
||||
return worn_item
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_tool("wand_of_illumination:flash_lamp", {
|
||||
description = "Flash Lamp",
|
||||
inventory_image = "flash_lamp.png",
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack, player, pointed_thing)
|
||||
local use_mana = false
|
||||
local worn_item = use_wand(player, itemstack, use_mana)
|
||||
return worn_item
|
||||
end,
|
||||
})
|
||||
|
||||
-- Need default and tnt mods for crafting recipe.
|
||||
if minetest.get_modpath("default") ~= nil and minetest.get_modpath("tnt") ~= nil then
|
||||
minetest.register_craft({
|
||||
output = "wand_of_illumination:flash_lamp",
|
||||
recipe = {
|
||||
{"tnt:gunpowder", "tnt:gunpowder", "tnt:gunpowder"},
|
||||
{"", "group:stick", ""},
|
||||
{"", "group:stick", ""}
|
||||
}
|
||||
})
|
||||
end
|
||||
|
|
2
mod.conf
2
mod.conf
|
@ -1,3 +1,3 @@
|
|||
name = wand_of_illumination
|
||||
description = Light up an entire room, but only for a moment.
|
||||
optional_depends = mana
|
||||
optional_depends = mana, default, tnt
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Loading…
Reference in New Issue