"Default mod" redefinitions

For people working on the C++ code.
Post Reply
User avatar
Garrosh
New member
Posts: 6
Joined: Wed Nov 23, 2011 15:16

"Default mod" redefinitions

by Garrosh » Post

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.

User avatar
xyz
Member
Posts: 450
Joined: Thu Nov 10, 2011 14:25

by xyz » Post

try defining it with :default:dirt as name

User avatar
Garrosh
New member
Posts: 6
Joined: Wed Nov 23, 2011 15:16

by Garrosh » Post

It works, thanks.

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

User avatar
randomproof
Member
Posts: 214
Joined: Thu Nov 17, 2011 06:31
Location: California, USA

by randomproof » Post

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.

kahrl
Member
Posts: 236
Joined: Fri Sep 02, 2011 07:51
Location: Rös̓̇chenhof

by kahrl » Post

My patch changes cooking and fuel definitions into crafting recipes:
http://celeron.55.lt/~celeron55/minetes ... s#crafting

User avatar
Garrosh
New member
Posts: 6
Joined: Wed Nov 23, 2011 15:16

by Garrosh » Post

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.

kahrl
Member
Posts: 236
Joined: Fri Sep 02, 2011 07:51
Location: Rös̓̇chenhof

by kahrl » Post

@Garrosh
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 :)

User avatar
Garrosh
New member
Posts: 6
Joined: Wed Nov 23, 2011 15:16

by Garrosh » Post

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest