[Mod] Moon Flower [moonflower]
- MirceaKitsune
- Member
- Posts: 924
- Joined: Sat May 21, 2011 22:31
- GitHub: MirceaKitsune
- IRC: Taoki
- In-game: MirceaKitsune
- Location: Romania, Bucharest
[Mod] Moon Flower [moonflower]
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
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
Last edited by MirceaKitsune on Sat Apr 06, 2013 21:31, edited 1 time in total.
- MirceaKitsune
- Member
- Posts: 924
- Joined: Sat May 21, 2011 22:31
- GitHub: MirceaKitsune
- IRC: Taoki
- In-game: MirceaKitsune
- Location: Romania, Bucharest
- Mossmanikin
- Member
- Posts: 599
- Joined: Sun May 19, 2013 16:26
- Location: where we don't speak english.
- Mossmanikin
- Member
- Posts: 599
- Joined: Sun May 19, 2013 16:26
- Location: where we don't speak english.
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);
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
- PilzAdam
- Member
- Posts: 4026
- Joined: Fri Jul 20, 2012 16:19
- GitHub: PilzAdam
- IRC: PilzAdam
- Location: Germany
Try adding "default" to depends.txtMossmanikin 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
- Mossmanikin
- Member
- Posts: 599
- Joined: Sun May 19, 2013 16:26
- Location: where we don't speak english.
- Neuromancer
- Member
- Posts: 958
- Joined: Tue Jun 12, 2012 22:28
- GitHub: Neuromancer56
I like this mod, kind of unique. Please make this windows fix part of this mod.Mossmanikin wrote:Thanks!PilzAdam wrote: Try adding "default" to depends.txt
Works just fine now.
Mods:Immersive Sounds
Phonics
Eden Game Natural Beauty Textures
Try out dropbox and get me free space: https://db.tt/JjjTr7fl
Phonics
Eden Game Natural Beauty Textures
Try out dropbox and get me free space: https://db.tt/JjjTr7fl
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).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.
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.
- Dan Duncombe
- Member
- Posts: 904
- Joined: Thu May 09, 2013 21:11
- Location: In the unknown depths of Earth
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.
Last edited by Dan Duncombe on Mon Jun 17, 2013 18:07, edited 1 time in total.
Some Mods: Castles Prefab Camouflage
My Games: Nostalgia Realtest Revamped
Servers: See above games.
My Games: Nostalgia Realtest Revamped
Servers: See above games.
Who is online
Users browsing this forum: No registered users and 26 guests