[Solved] Trying to add a group for an existing node

User avatar
yawin
Member
 
Posts: 18
Joined: Fri Dec 30, 2016 17:09
In-game: Yawin

[Solved] Trying to add a group for an existing node

by yawin » Wed Feb 01, 2017 21:58

Hello! I'm trying to add a group to an existing node (without overwriting the groups I already have) and the only way I can think of is this:
minetest.override_item("default:stone", {
groups.magical_tier1 = 1,
})
But it does not work. Does anyone comes up with something?
Last edited by yawin on Thu Feb 02, 2017 19:21, edited 1 time in total.
dynamic_cast<Signature*>(me→signature)
 

User avatar
duane
Member
 
Posts: 776
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r

Re: Trying to add a group for an existing node

by duane » Wed Feb 01, 2017 23:50

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
-- Modify a node to add a group
function minetest.add_group(node, groups)
   local def = minetest.registered_items[node]
   if not def then
      return false
   end
   local def_groups = def.groups or {}
   for group, value in pairs(groups) do
      if value ~= 0 then
         def_groups[group] = value
      else
         def_groups[group] = nil
      end
   end
   minetest.override_item(node, {groups = def_groups})
   return true
end


From Valleys Mapgen (GPL3).
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: Trying to add a group for an existing node

by kaeza » Thu Feb 02, 2017 01:21

Please see my comments here.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
yawin
Member
 
Posts: 18
Joined: Fri Dec 30, 2016 17:09
In-game: Yawin

Re: Trying to add a group for an existing node

by yawin » Thu Feb 02, 2017 15:40

kaeza wrote:Please see my comments here.

Oh!! Lot of thanks!
dynamic_cast<Signature*>(me→signature)
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

cron