Page 1 of 1

"Default mod" redefinitions

Posted: Tue Jan 10, 2012 18:31
by Garrosh
I was writing myself a mod that allowed me to burn dirt into gravel, gravel into stone and such things. In order to make it work, however, I've had to do a lot of gymnastics.

1 - When redefining a node it only works when using the ":" prefix. ie

Code: Select all

minetest.register_node(":dirt", {redefinition})
2 - This redefinition can only be referenced through the item's alias!

Meaning that all of the modifications I included inside my_mod were valid, but could not be referenced in the code other than by calling the "dirt" alias. Calling "default:dirt" was calling unmodified dirt instances and trying to write ":dirt" inside a code block threw errors. The only way was to write "dirt", meaning the alias was being referenced.

Posted: Tue Jan 10, 2012 19:11
by xyz
try defining it with :default:dirt as name

Posted: Wed Jan 11, 2012 02:44
by Garrosh
It works, thanks.

Without that helpful tip, I had to create a craftitem dirt which converts back to the aliased dirt version when dropped.

Posted: Wed Jan 11, 2012 15:35
by randomproof
Just a FYI

If you are going to redefine something (or for that matter, use any of the register functions) you have to do it when your init.lua file is loaded. You can't register/change things after the server is loaded and running.

Posted: Thu Jan 12, 2012 18:50
by kahrl
My patch changes cooking and fuel definitions into crafting recipes: ... s#crafting

Posted: Wed Jan 18, 2012 01:28
by Garrosh
About the FYI: I already knew that, thanks anyways :)

about the patch: You're saying that what the items burns into and how much time it burns in the furnace have been taken out of the object definition? So instead of redefining the items, I could just define crafting recipes if I want new ones... Interesting.

I don't know if that's in your alley or not, but being able to craft more than one item at once would be a big bonus.

Posted: Wed Jan 18, 2012 07:32
by kahrl
Yep, this and similar threads were the inspriration for that change.

About crafting more than one item at once, have any idea how the GUI interface for that could work? I know in minecraft you can shift + left-click the craft preview to craft as many items as possible, but I find I often make mistakes with that system. I've also seen other people make similar mistakes in youtube videos :)

Posted: Thu Jan 19, 2012 19:00
by Garrosh
A simple modifier key to make as many as possible isn't ideal, but control over how many items are made when clicking is good. What I'm thinking is somethink like shift+click the craft preview, but instead of just stupidly crafting as many as possible, a simple prompt would allow the user to input a number, defaulted at the last value used or the maximum possible if it's the first time or the last value is higher than what's achievable.