About Scripting with Style

lord_james
Member
 
Posts: 51
Joined: Sun Mar 11, 2012 22:06

About Scripting with Style

by lord_james » Tue Nov 27, 2012 23:12

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?
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Fri Nov 30, 2012 12:12

I once tried it with stack_max = 64 (for MiniTest) but it didnt work.
 

lord_james
Member
 
Posts: 51
Joined: Sun Mar 11, 2012 22:06

by lord_james » Fri Nov 30, 2012 17:54

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.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Fri Nov 30, 2012 18:07

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.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 42 guests

cron