"Default mod" redefinitions

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

"Default mod" redefinitions

by Garrosh » Tue Jan 10, 2012 18:31

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 » Tue Jan 10, 2012 19:11

try defining it with :default:dirt as name
 

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

by Garrosh » Wed Jan 11, 2012 02:44

It works, thanks.

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

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

by randomproof » Wed Jan 11, 2012 15:35

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
 

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

by Garrosh » Wed Jan 18, 2012 01:28

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 » Wed Jan 18, 2012 07:32

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

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

by Garrosh » Thu Jan 19, 2012 19:00

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.
 


Return to Partly official engine development



Who is online

Users browsing this forum: MSN [Bot] and 1 guest