Page 1 of 1

[Mod] Moon Flower [moonflower]

Posted: Sat Apr 06, 2013 21:30
by MirceaKitsune
Although I've made several code changes to MineTest, I never created my own mod or worked with the Lua API before. I decided to change that today, and start with putting in practice a simple idea I had in mind.

The Moon Flower is an unique flower created for Minetest. It spawns on grass and can be pretty rare to find (5 spawn attempts of 0.1 probability per chunk). Compared to simple decorative flowers, it has a special property: It opens up and casts lighting when under the influence of the moon. This is done by checking that its location is affected by sky light and the time of day is right. This was mainly its purpose, since I thought a plant that spawns naturally and emits lighting at night could be a beautiful sight.

This is also intended to become part of MineTest by default, but I'd rather it's included as part of the complete flowers mod. The texture and code are free to use, and I guess they're licensed GPL or WTFPL if that works best. Since this is my first Lua mod, I'd like to know what you think of the coding too and if my approach is generally correct (some of the code was inspired from VanessaE's old Flowers mod).

Mod available on Github

Image

Image

Posted: Sat Apr 06, 2013 21:32
by jojoa1997
could you have it change tyhe gravity. i know someone added that to dev

Posted: Sat Apr 06, 2013 21:36
by MirceaKitsune
jojoa1997 wrote:could you have it change tyhe gravity. i know someone added that to dev
I added that to dev yesterday :P But that goes beyond its purpose. I'm considering lower gravity for floatlands instead, but that's a different story.

Posted: Sat Apr 06, 2013 21:39
by Jouster27
I really like the idea of this mod. I'm currently trying to map a world with landup, chasm and canyons (and it's literally taking all day) but as soon as I find a stopping-point, i plan to try this one out!

Posted: Sat Apr 06, 2013 21:47
by paramat
Very cool idea.

Posted: Sun Apr 07, 2013 13:23
by 12Me21
I think I will make a sun flower, that only opens during the day

Posted: Fri Apr 12, 2013 14:19
by Jouster27
I tried the mod. My daughters and I love the moon flowers. Thank you for making this mod.

Posted: Fri May 24, 2013 14:07
by Mossmanikin
Love it!
reminds me of Terraria.

Posted: Sat May 25, 2013 17:16
by Mossmanikin
Seems to work fine on stable 0.4.6.
Unfortunately it does not on the version of 0.4.6dev I've got (no other mods installed);

Code: Select all

GUIConfigureWorld: Not allowing focus change.
GUIConfigureWorld: Not allowing focus change.
18:37:20: ERROR[main]: ========== ERROR FROM LUA ===========
18:37:20: ERROR[main]: Failed to load and run script from 
18:37:20: ERROR[main]: C:\Games\minetest-0.4.6-e57dc4e-farming-win32\bin\..\mods\moonflower\init.lua:
18:37:20: ERROR[main]: ....6-e57dc4e-farming-win32\bin\..\mods\moonflower\init.lua:20: attempt to index global 'default' (a nil value)
18:37:20: ERROR[main]: stack traceback:
18:37:20: ERROR[main]:     ....6-e57dc4e-farming-win32\bin\..\mods\moonflower\init.lua:20: in main chunk
18:37:20: ERROR[main]: =======END OF ERROR FROM LUA ========
18:37:20: ERROR[main]: Server: Failed to load and run C:\Games\minetest-0.4.6-e57dc4e-farming-win32\bin\..\mods\moonflower\init.lua
18:37:20: ERROR[main]: ModError: Failed to load and run C:\Games\minetest-0.4.6-e57dc4e-farming-win32\bin\..\mods\moonflower\init.lua

Posted: Sat May 25, 2013 17:18
by PilzAdam
Mossmanikin wrote:Seems to work fine on stable 0.4.6.
Unfortunately it does not on the version of 0.4.6dev I've got (no other mods installed);

Code: Select all

GUIConfigureWorld: Not allowing focus change.
GUIConfigureWorld: Not allowing focus change.
18:37:20: ERROR[main]: ========== ERROR FROM LUA ===========
18:37:20: ERROR[main]: Failed to load and run script from 
18:37:20: ERROR[main]: C:\Games\minetest-0.4.6-e57dc4e-farming-win32\bin\..\mods\moonflower\init.lua:
18:37:20: ERROR[main]: ....6-e57dc4e-farming-win32\bin\..\mods\moonflower\init.lua:20: attempt to index global 'default' (a nil value)
18:37:20: ERROR[main]: stack traceback:
18:37:20: ERROR[main]:     ....6-e57dc4e-farming-win32\bin\..\mods\moonflower\init.lua:20: in main chunk
18:37:20: ERROR[main]: =======END OF ERROR FROM LUA ========
18:37:20: ERROR[main]: Server: Failed to load and run C:\Games\minetest-0.4.6-e57dc4e-farming-win32\bin\..\mods\moonflower\init.lua
18:37:20: ERROR[main]: ModError: Failed to load and run C:\Games\minetest-0.4.6-e57dc4e-farming-win32\bin\..\mods\moonflower\init.lua
Try adding "default" to depends.txt

Posted: Sat May 25, 2013 23:20
by Mossmanikin
PilzAdam wrote: Try adding "default" to depends.txt
Thanks! :)
Works just fine now.

Posted: Sun Jun 16, 2013 16:45
by Neuromancer
Mossmanikin wrote:
PilzAdam wrote: Try adding "default" to depends.txt
Thanks! :)
Works just fine now.
I like this mod, kind of unique. Please make this windows fix part of this mod.

Posted: Mon Jun 17, 2013 10:06
by bdjnk
MirceaKitsune wrote:Since this is my first Lua mod, I'd like to know what you think of the coding too and if my approach is generally correct.
I don't know whether what you've done is "correct", but it is different in an interesting way from what I've done (in similar circumstances).

You use a register_abm to create a timer, as explained here. I use on_timer in register_node, as explained here and here.

I've heard tell in ancient times of the potential evils of ABMs. Which is to say, I've seen people on the forum saying you shouldn't have too many, or something like that.

Maybe someone who knows what they're talking about can jump in and explain some details.

Posted: Mon Jun 17, 2013 18:07
by Dan Duncombe
Adding lots of ABMs can cause a lot of lag- So they are fine to use, but if you have, say, 10 or more, lag will definitely start to occur.

Re: [Mod] Moon Flower [moonflower]

Posted: Mon Apr 27, 2020 05:21
by LordVlad
Awesome mod... simple and original!