Page 1 of 1

About Scripting with Style

PostPosted: Tue Nov 27, 2012 23:12
by lord_james
If I create a new game, It could be possible that I want edit some features from the builtin folder (for example item.lua). This isn't a good idea for the finel user who doesn't want edit some files. I research and could it possible edit some tables like minetest.nodedef_default:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.nodedef_default.post_effect_color = {a=250, r=0, g=0, b=0}
minetest.nodedef_default.on_dig = default.node_dig(0)


With this, we can code some common features in all nodes without edit item.lua. But... Is it a suitable scripting practise?

PostPosted: Fri Nov 30, 2012 12:12
by PilzAdam
I once tried it with stack_max = 64 (for MiniTest) but it didnt work.

PostPosted: Fri Nov 30, 2012 17:54
by lord_james
I have discovered a strange feature/bug. I added in default begin and after of the default:stone. In the first case, works on the box. In the second case all nodes work on the box, but not default:stone. Add the code at the begining of all code and tell me.

PostPosted: Fri Nov 30, 2012 18:07
by PilzAdam
The problem is that the default settings are read when the node is registered. So only nodes that load after the mod that changes the default settings have the changed value.
So it is not good style.