[mod] Lighten wielded item [wielded_light]

bell07
Member
 
Posts: 476
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Lighten wielded item [wielded_light]

by bell07 » Tue May 08, 2018 16:22

Planned is implementation to the sling mod. Or which kind of throwing did you mean?
 

User avatar
Phoenixflo44
Member
 
Posts: 294
Joined: Fri Jul 28, 2017 15:01
Location: Behind my PC, in Germany
GitHub: Phoenixflo44
In-game: Phoenixflo44
 

bell07
Member
 
Posts: 476
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Lighten wielded item [wielded_light]

by bell07 » Tue May 08, 2018 16:33

If you throw the torch using Q button down into a cave, the light follow the torch. ;)
 

User avatar
Phoenixflo44
Member
 
Posts: 294
Joined: Fri Jul 28, 2017 15:01
Location: Behind my PC, in Germany
GitHub: Phoenixflo44
In-game: Phoenixflo44
 

bell07
Member
 
Posts: 476
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Lighten wielded item [wielded_light]

by bell07 » Tue May 08, 2018 20:57

Enhanced throwing mod: https://github.com/minetest-mods/throwing/pull/16
Using enhanced version the shining for throwed items using https://github.com/minetest-mods/sling works out of the box
Image
Image
Attachments
screenshot_20180508_225448.png
(320.34 KiB) Not downloaded yet
screenshot_20180508_225446.png
(372.27 KiB) Not downloaded yet
 

User avatar
texmex
Member
 
Posts: 783
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex
 

sofar
Developer
 
Posts: 1632
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: [mod] Lighten wielded item [wielded_light]

by sofar » Tue May 08, 2018 21:16

bell07 wrote:2. krondor registers only 1 helper node with light level 14. So krondors light is brighter, but with static brightness at maximum 14. My mod registers nodes 1-11. It is more dim but according the brightness of the wielded item.


suggestions:

I prefer to have a wielded item that is 2-3 levels darker than the placed thing, otherwise it's just too easy to always walk around with a lamp or torch all the time.

Also, having 1 node for each light level is not really needed, you can probably do a node for all the odd light levels, so you'd only have 6 nodes: 11, 9, 7, 5, 3 and 1. This won't change much visibly anyway.
 

User avatar
Devy
Member
 
Posts: 115
Joined: Sat Jan 21, 2017 02:31
GitHub: CoderForTheBetter
In-game: devy

Re: [mod] Lighten wielded item [wielded_light]

by Devy » Tue May 08, 2018 21:25

Just thought I'd put this out there. I implemented a similar thing for throwing lit items in my Geominer mod. Here's a glowstick being dropped but there is also one for throwing with your hand: Image

Geominer: https://forum.minetest.net/viewtopic.php?f=9&t=17771
 

bell07
Member
 
Posts: 476
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Lighten wielded item [wielded_light]

by bell07 » Tue May 08, 2018 21:27

sofar wrote:I prefer to have a wielded item that is 2-3 levels darker than the placed thing, otherwise it's just too easy to always walk around with a lamp or torch all the time.

The current setting is 2 levels darker. It is just 1 code line to change them
Code: Select all
local level_delta = 2


sofar wrote:Also, having 1 node for each light level is not really needed, you can probably do a node for all the odd light levels, so you'd only have 6 nodes: 11, 9, 7, 5, 3 and 1. This won't change much visibly anyway.

In the meantime the wielded_light registers all 1-14 nodes because of the level could be set manually using wielded_light.register_item_light().
I do not think to save 8 node definitions does an performance boost. Other mods defines > 100 items oO. I do not see the reason to support an other light levels count then mintest engine does.
 

bell07
Member
 
Posts: 476
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Lighten wielded item [wielded_light]

by bell07 » Tue May 08, 2018 21:36

Devy wrote:Just thought I'd put this out there. I implemented a similar thing for throwing lit items in my Geominer mod.

I did not know that. Looking to the code....

The difference is my mod uses nodetimers to remove the shining node, and does not have flickering if different light sources are in the same coordinates, and also check if shining is neccessary reading current node light level...
 

User avatar
Devy
Member
 
Posts: 115
Joined: Sat Jan 21, 2017 02:31
GitHub: CoderForTheBetter
In-game: devy

Re: [mod] Lighten wielded item [wielded_light]

by Devy » Wed May 09, 2018 02:04

bell07 wrote:
Devy wrote:Just thought I'd put this out there. I implemented a similar thing for throwing lit items in my Geominer mod.

I did not know that. Looking to the code....

The difference is my mod uses nodetimers to remove the shining node, and does not have flickering if different light sources are in the same coordinates, and also check if shining is neccessary reading current node light level...


Yeah, I looked at your code and it seems way better than what I did. Good job!

In fact, I may use this instead of what I did.
 

User avatar
texmex
Member
 
Posts: 783
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex

Re: [mod] Lighten wielded item [wielded_light]

by texmex » Wed May 09, 2018 09:12

I always liked your idea Devy, but applying the effect to any (existing) item is what I really need, instead of new single-purpose items. (Q-dropped torch replaces droppable glowstick, sling-thrown torch replaces throwable glowstick). Multi-purpose ftw!
 

User avatar
Hamlet
Member
 
Posts: 365
Joined: Sat Jul 29, 2017 21:09
Location: Italia

Re: [mod] Lighten wielded item [wielded_light]

by Hamlet » Wed May 09, 2018 10:31

bell07 wrote:Idea taken from torches_wieldlight in https://github.com/minetest-mods/torches, but written from scratch and usable for all shining items.[...]


Reading this thread I've noticed that the mod relies on placing and removing invisible light blocks; I've tried this kind of solution using Hardcore torchs by BrunoMine and I've found that this approach has one issue.

If the invisible light block is placed under a falling node (sand, gravel, etc.) when the said light block is removed it triggers the fall of the nodes above.

Recently I've discovered Opposite Torch by Atreela which relies on "minetest.fix_light": instead of placing invisible nodes it updates the surrounding nodes' light level.

Do you think that it could be used in your mod?
 

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

Re: [mod] Lighten wielded item [wielded_light]

by Astrobe » Wed May 09, 2018 10:38

The attenuation is nice to have, but users should consider weakening the torch itself because it has several positive side effects in my opinion - at least for survival games. And you don't have to "explain" why wielded torches are weaker than wall-mounted ones.

I was worried too before testing this mod that it would make static lights useless, but because my torches were already level 10 -bright, the handheld torches only let you see one or two blocks around.
 

bell07
Member
 
Posts: 476
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Lighten wielded item [wielded_light]

by bell07 » Wed May 09, 2018 11:31

Hamlet wrote:If the invisible light block is placed under a falling node (sand, gravel, etc.) when the said light block is removed it triggers the fall of the nodes above.

Tried shortly and the issue does not appear in wielded_item. I use minetest.swap_node() to remove the block, that does not trigger falling nodes.

Hamlet wrote:Recently I've discovered Opposite Torch by Atreela which relies on "minetest.fix_light": instead of placing invisible nodes it updates the surrounding nodes' light level.

Interessting, I search for an other solution then placing blocks, because I can re-place only the air by shining node. Therefore the shining does not work on stairs, snow, ladders and other "nearly empty nodes".
But how I can set the light level using minetest.fix_light(pos1, pos2)?

Astrobe wrote:I was worried too before testing this mod that it would make static lights useless, but because my torches were already level 10 -bright, the handheld torches only let you see one or two blocks around.
That was the reason why I implemented attenuation, the placing torches should not gets obsolete by this mod. And about realizm: How the shining should be if you wield 99-torches-stack?

PS: If you have issues with to bright items in your subgame (like meselamp) you can override the value using wielded_light.register_item_light(itemname, light_level)
So it is possible to leave meselamp with placed light_level 14 as is, but set wielded item shining to light_level=1
 

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

Re: [mod] Lighten wielded item [wielded_light]

by Astrobe » Wed May 09, 2018 12:09

bell07 wrote:But how I can set the light level using minetest.fix_light(pos1, pos2)?


Actually the real "unlight" is done by make_darkness() or darken_place(), which looks like a heavy process. The author uses some sort of trick not to do it on every activation of the ABM (once per second).

bell07 wrote:That was the reason why I implemented attenuation, the placing torches should not gets obsolete by this mod. And about realizm: How the shining should be if you wield 99-torches-stack?


I don't think light is additive in Minetest, that's why we can't have lazors :-D (Archimedes' Death Ray mod? make a mirror from glass and tin, surround it with eight mese lights, watch the cows burn)
 

bell07
Member
 
Posts: 476
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Lighten wielded item [wielded_light]

by bell07 » Wed May 09, 2018 12:51

Astrobe wrote:Actually the real "unlight" is done by make_darkness() or darken_place(), which looks like a heavy process. The author uses some sort of trick not to do it on every activation of the ABM (once per second).

Looked to the code, it is really a lot of woodo appears, for an area 30x30x30 the light calculation is done manually in lua each second. It is a hack, therefore to reset a "fix" function is needed. For a not moved object it is maybe ok, but the wielded_light requires a lightwight way to "smooth move" the light source if player or item moves. The current setting is update each 0.2 seconds with minimum shining duration x3. The trick I use is to reset the nodetimer if the helper node already in place and should continue shining. So the full node replacement is really on demand only.

But my way is not possible to take opposite shining ...
 

bell07
Member
 
Posts: 476
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07
 

sofar
Developer
 
Posts: 1632
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: [mod] Lighten wielded item [wielded_light]

by sofar » Mon May 14, 2018 20:40

Hamlet wrote:If the invisible light block is placed under a falling node (sand, gravel, etc.) when the said light block is removed it triggers the fall of the nodes above.


This can be avoided. Not sure if `swap_node` avoids the update, but a vmanip will for sure.

Manually updating the entire light map is likely more expensive.
 

User avatar
Hamlet
Member
 
Posts: 365
Joined: Sat Jul 29, 2017 21:09
Location: Italia

Re: [mod] Lighten wielded item [wielded_light]

by Hamlet » Tue May 15, 2018 22:33

sofar wrote:
Hamlet wrote:If the invisible light block is placed under a falling node (sand, gravel, etc.) when the said light block is removed it triggers the fall of the nodes above.


This can be avoided. Not sure if `swap_node` avoids the update, but a vmanip will for sure.

Manually updating the entire light map is likely more expensive.


I've checked both mods for the issue that I've mentioned, none of them has it.
 

User avatar
Lord_Vlad
Member
 
Posts: 81
Joined: Thu Jul 20, 2017 07:58

Re: [mod] Lighten wielded item [wielded_light]

by Lord_Vlad » Thu May 24, 2018 17:12

Geominer had an item that did that, you should look it up an see the code, it may help.
 

Previous

Return to Mod Releases



Who is online

Users browsing this forum: No registered users and 6 guests