[mod] Lighten wielded item [wielded_light]

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

[mod] Lighten wielded item [wielded_light]

by bell07 » Wed Jan 10, 2018 09:22

Idea taken from torches_wieldlight in https://github.com/minetest-mods/torches, but written from scratch and usable for all shining items. The shining does work on player's wielded item, but in addition on dropped items (throw a torch down using Q button) and also on throwed items using minetest-mods/throwing / minetest-mods/sling.

By default the "light_source" value from node definition is used but lower by 2. This way the placing torches is not obsolete because of brighter.
Examle: Torch with placed value 13 does shine with 11 if wielded or dropped.

Image

+ further screenshots

known issues
Does work in "air" nodes only, that means shining does not work on ladders, snow, slabs and other nearly empty or airlike nodes.

For Modders:
In addition further items could get or redefined the light value by:
Code: Select all
wielded_light.register_item_light(itemname, light_level)
This does not change the item/node definition, just the shining from this mod.

As external usable API functions exists to be able to use the shining in other mods, see end of README.md file on github and throwing commit for example.

Dependencies: none
License: GPL-3

Download/Source: https://github.com/minetest-mods/wielded_light
Attachments
screenshot.png
(329.14 KiB) Not downloaded yet
Last edited by bell07 on Thu May 10, 2018 09:11, edited 5 times in total.
 

ChimneySwift
Member
 
Posts: 154
Joined: Fri Sep 22, 2017 06:46
GitHub: ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift

Re: [mod] Lighten wielded item [wielded_light]

by ChimneySwift » Wed Jan 10, 2018 10:13

Yeeees
I've really wanted a mod like this, I'll have to really check it out to see how stable it is (IIRC there were some issues with the other mod?), thanks for doing this.
With great power comes great electricity bill.
 

User avatar
Codesound
Member
 
Posts: 202
Joined: Thu Jun 09, 2016 14:56
 

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

Re: [mod] Lighten wielded item [wielded_light]

by bell07 » Wed Jan 10, 2018 12:31

IIRC there were some issues with the other mod?
The other mod overrides the torch definition. The main goal of the torch mod was to add a 3D torch to the minetest. Since the 3D-torches was added to minetest_game/mods/default, this mod is less maintained as the "default" and seems to be redundant/obsolete. But I still used the separate torch mod without any issues because of optional lightning feature.
With this new mod i is possible to get the lightning feature on all items without any item redefinition.

Note: I did developed it using more newer features like node-timer so maybe my version is less stable as torch mod because of it's a new mod.
The main idea is the same: The wielded item of all players is checked each globalstep and a invisible air-like lightning node is placed at player position if lightning should happen. After some time the node is replaced back to "air". Because of pulling and often node updates around the player maybe performance issues appears. Same risk as in the torches mod.
 

User avatar
azekill_DIABLO
Member
 
Posts: 7342
Joined: Wed Oct 29, 2014 20:05
Location: Under my desk (but I can't see my monitor now X'[ )
GitHub: azekillDIABLO
In-game: azekill_DIABLO
 

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

User avatar
burli
Member
 
Posts: 1605
Joined: Fri Apr 10, 2015 13:18

Re: [mod] Lighten wielded item [wielded_light]

by burli » Thu Jan 11, 2018 17:17

texmex wrote:How does this mod compare to https://github.com/krondor-game/wield_light ?

This version should be better than the version from krondor-game because it use swap_node instead of set_node
 

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

Re: [mod] Lighten wielded item [wielded_light]

by bell07 » Thu Jan 11, 2018 19:52

oh, I did not seen the krondor mod. If I look to the code I see the next differences:

1. krondor mod is 2 years old, should be stable.
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.
3. krondor mod uses register_source() method for compatible items and hardcodes torch, flame and lava source and bucked for light. My mod looks to the item definition for light level and supports all bright items.
4. The case to avoid the light flickers if the player stay on the same position is solved in different way. krondor save position in lua table "positions" to track them, I just reset the timer back to initial value.
5. The already mentioned swap_node vs. set_node/remove_node unsure if it makes a difference for air.
 

User avatar
burli
Member
 
Posts: 1605
Joined: Fri Apr 10, 2015 13:18
 

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

Re: [mod] Lighten wielded item [wielded_light]

by texmex » Fri Jan 12, 2018 14:01

Excellent answers, thanks. Two ideas for further development comes to mind:

Make sure it works on tools as well (perhaps it already does. I'm unsure if light_source can be applied to other things than just nodes definitions). If tool definitions can't have light_source, perhaps offer a small API for registering an item's light level. (This API could also be useful for when you don't want specific lit nodes to emit wield light). Like so:
Code: Select all
wield_light.register_source('default:superpick')
wield_light.unregister_source('default:torch')


Also, could the mod be extended to support light emitting entities as well? So that torches lights up the environment even as dropped items. That would be awesome. Code related to detecting throwing here.
 

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

Re: [mod] Lighten wielded item [wielded_light]

by bell07 » Fri Jan 12, 2018 15:24

Thank you for suggestions. I added to my todo list:
Code: Select all
wielded_light.register_item_light(itemname, light_level)
Allow to add wielded light to items without light_source, or redefine existing light.

Code: Select all
wielded_light.update_light(pos, light_level)
Check/set/update light helper node at position. This method allow to enable light on any position. The function can be used for any entity from on_step function without any conditions.

Unfortunately the '__builtin:item' does not have any callbacks in on_step so I cannot enhance the dropped items without any hacks or builtin-modifications :-(
 

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

Re: [mod] Lighten wielded item [wielded_light]

by texmex » Fri Jan 12, 2018 15:47

Great additions, thanks. Now I'll be able to switch over from wield_light to wielded_light.

Do you think pursuing a Github issue for __builtin:item on_step callback is viable?
 

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

Re: [mod] Lighten wielded item [wielded_light]

by bell07 » Fri Jan 12, 2018 21:01

texmex wrote:Now I'll be able to switch over from wield_light to wielded_light.
I see the name difference comes from my bad english. Maybe I should change the name? Any proposal? wielded_bright? shining?

texmex wrote:Do you think pursuing a Github issue for __builtin:item on_step callback is viable?
I just did it ;-) https://github.com/minetest/minetest/issues/6909
 

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

Re: [mod] Lighten wielded item [wielded_light]

by bell07 » Fri Jan 12, 2018 22:03

Shining API:
`function wielded_light.update_light(pos, light_level)`
Enable or update the shining at pos with light_level for 0.6 seconds. Can be used in any on_step call to get other entitys shining for example

`wielded_light.register_item_light(itemname, light_level)`
Override or set custom light level to an item. This does not change the item/node definition, just the lighting in this mod.

done

Beter mod name proposals still welcome
 

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

Re: [mod] Lighten wielded item [wielded_light]

by texmex » Sat Jan 13, 2018 09:55


Very good!

As for name, I thing wield_light is good. Simple and descriptive. Neoascetic probably wouldn't mind as this is a drop-in replacement.
 

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

Re: [mod] Lighten wielded item [wielded_light]

by bell07 » Sat Jan 13, 2018 12:42

I looked trough different translators and "wielded item" should be ok too. What native speaker means?
I do not like to take over the name from an other existing mod.
 

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

Re: [mod] Lighten wielded item [wielded_light]

by bell07 » Sat Jan 13, 2018 14:21

Just noticed I did not pushed the latest version to github. Now done, the shining-API can be tested now.
 

hajo
Member
 
Posts: 561
Joined: Thu Oct 13, 2016 10:45
Location: DE

Re: [mod] Lighten wielded item [wielded_light]

by hajo » Mon Jan 22, 2018 14:05

texmex wrote:ideas for further development ..
Make sure it works on tools as well (perhaps it already does..)

Like some well-known swords, that glow in the dark ?
Is such a feature in the LotR-subgame already ?
 

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

Re: [mod] Lighten wielded item [wielded_light]

by bell07 » Mon Jan 22, 2018 14:15

Already possible. Just add an
Code: Select all
wielded_light.register_item_light('swordmod:wellknown', 14)
to the corresponding mod or to a small own compatibility mod that depends on both, sword and wielded_light.

swordmod:wellknown: placeholder for your item, the 14 is the light level.

But note: not the sword shines but the player position. And only if environment light is lower then the item 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 14:59

Added support for dropped items shining
https://github.com/bell07/wielded_light/tree/dropped_items_shining

Image

And also new API method
Code: Select all
function wielded_light.update_light_by_item(stack, pos)
that is used internally for both, wielded and dropped items..
Attachments
screenshot_20180508_163521.png
(261.69 KiB) Not downloaded yet
 

User avatar
azekill_DIABLO
Member
 
Posts: 7342
Joined: Wed Oct 29, 2014 20:05
Location: Under my desk (but I can't see my monitor now X'[ )
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: [mod] Lighten wielded item [wielded_light]

by azekill_DIABLO » Tue May 08, 2018 15:46

Wow! does it light stronger if the stack is full?
【Voxellar 2.0】 ; 【MILA】 update ; 【Rec_a_MT】 ; 【BB,HD】 update ; 【▶ Youtube】 This person worked too hard to be forgotten: Feedback me!
 

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:10

azekill_DIABLO wrote:Wow! does it light stronger if the stack is full?

And idea about formula how the stack size should be used to calculate light value? At the time it is just light_source - 2
 

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

Re: [mod] Lighten wielded item [wielded_light]

by Phoenixflo44 » Tue May 08, 2018 16:11

Maybe you can do it that way if you throw a torch that it will continue to shine
 

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:16

Phoenixflo44 wrote:Maybe you can do it that way if you throw a torch that it will continue to shine

Already in discussion on github: https://github.com/minetest-mods/wielded_light/issues/1
Working Prototype exists
 

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

Next

Return to Mod Releases



Who is online

Users browsing this forum: No registered users and 5 guests