[Mod] Wand of Illumination [wand_of_illumination]

Post Reply
kestral
Member
Posts: 96
Joined: Mon Mar 27, 2017 21:56
GitHub: kestral246

[Mod] Wand of Illumination [wand_of_illumination]

by kestral » Post

Not just a wand anymore.
Provides a wand, a flash_lamp, or a super_lamp that when used, light up what's in front—but only for a moment.

Image

Features
  • New: Choice of wand, 1900-era flash-lamp, or mese-powered super_lamp.
  • New: Now just lights up 120° cone in direction player's pointed.
  • On left click, places a cone of invisible lights in front of the player.
  • On shift-left-click (or aux-left-click), creates an extended cone of lights.
  • Wear added, so all lamps only work for a limited number of uses.
  • Uses node_timers to cause these light nodes to gradually fade away.
  • Uses mana mod for wand if available.
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.
  • Crafting recipes—updated.
  • Optimize wear cost—updated.
  • Optimize mana cost.
  • Tune light generated: brightness, spacing, radius, and decay rate—updated.
  • Textures—updated.
Dependencies
  • Optionally depends on default and tnt to enable craft recipes.
  • Optionally depends on Wuzzy's mana mod.
Licenses
  • Source code: The MIT License (MIT)
  • Media (textures): Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
Get it at: https://github.com/kestral246/wand_of_illumination
Last edited by kestral on Mon Mar 30, 2020 21:20, edited 2 times in total.

Astrobe
Member
Posts: 577
Joined: Sun Apr 01, 2018 10:46

Re: [Mod] Wand of Illumination [wand_of_illumination]

by Astrobe » Post

Funny, I have a similar wand that creates a brief light where the missile hits.

Definitely use node timers for this. It is not more difficult than an ABM.


In the wand def, on_place and on_secondary_use are the same functions. It would be nicer to make a single separate local function.

In the other utility functions, I may be wrong but I don't see the use of hash_node_position as beneficial: at this point the "pos" object already exists in memory, so if you push it into a table you really are just pushing a reference to it (same when passing it to a function), which should be the same size as a hash. It seems to me that you are actually creating a second object for no apparent benefit.
Well that's nitpicking anyway since we are speaking about a few dozens nodes here.

kestral
Member
Posts: 96
Joined: Mon Mar 27, 2017 21:56
GitHub: kestral246

Re: [Mod] Wand of Illumination [wand_of_illumination]

by kestral » Post

I updated the mod to use an extended range when used with sneak-right-click or aux-right-click—currently set to radius = 30, and mana cost = 200, but these values are all easily changed at the top of the init.lua file.

While I was at it, I merged all the rest of the logic in on_place and on_secondary_use to the use_wand function.
… since we are speaking about a few dozens nodes here.
With my fixed spacing of four nodes for all my lights, I'm dealing with a few more nodes than that. I did some tests in the sky, which gives the worst case numbers, and this is what I'm seeing:
  • With r = 15, 14000 nodes scanned, 230 lights placed
  • With r = 30, 113000 nodes scanned, 1760 lights placed
  • With r = 50, 523000 nodes scanned, 8100 lights placed
Here's a screenshot comparing r=15 with r=50 (using meselamps to make the lights visible):

Image

To get reasonable light coverage in the narrow winding tunnels, the largest spacing I wanted to use was 4 nodes, but this is way overkill for large open spaces. However, this seems to be working well enough at the smaller sizes, so I don't want to try and deal with all the complexities of having a variable pitch for the lights.

kestral
Member
Posts: 96
Joined: Mon Mar 27, 2017 21:56
GitHub: kestral246

Re: [Mod] Wand of Illumination [wand_of_illumination]

by kestral » Post

I've added a non-magical 1900-era flash-lamp with wear and a craft recipe.
Details in the first post.

kestral
Member
Posts: 96
Joined: Mon Mar 27, 2017 21:56
GitHub: kestral246

Re: [Mod] Wand of Illumination [wand_of_illumination]

by kestral » Post

Quite a few new changes.
  • Choice between wand, flash_lamp, or super_lamp.
  • Now just lights up 120° cone in direction player is pointed. (Improved range using less resources.)
  • Crafting recipes updated.
  • Textures updated.
  • Usage wear numbers updated.
Details in first post and/or github readme.

Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests