Page 1 of 1

New Node API registering system in my game Minetest TNG

PostPosted: Sat Mar 26, 2016 11:13
by LNJ
I created a new way to register fences, walls, stairs, slabs, ... in my game Minetest TNG: viewtopic.php?f=15&t=14145!
I just want to present it and would like to hear what do you think about it! :)

Code in Minetest TNG:
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
default.register_node("default:wood", {
   description = "Wooden Planks",
   tiles = {"default_wood.png"},
   is_ground_content = false,
   groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1, fuel = 8},
   sounds = default.node_sound_wood_defaults(),
   register = {stair = true, slab = true, table = true, fence = true, fencegate = true},
   stair = {
      legacy_alias = "stairs:stair_wood",
      description = "Wooden Stair", -- if I don't change this the description would be "Wooden Planks Stair"
   },
   slab = {
      legacy_alias = "stairs:slab_wood",
      description = "Wooden Slab",
   },
   fence = {
      description = "Wooden Fence",
   },
   fencegate = {
      description = "Wooden Fence Gate",
   },
   table = {
      description = "Wooden Table",
   },
})


The same code without this system:
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.register_node("default:wood", {
   description = "Wooden Planks",
   tiles = {"default_wood.png"},
   is_ground_content = false,
   groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1, fuel = 8},
   sounds = default.node_sound_wood_defaults(),
})
-- I moved the stairs and slabs API to default
default.register_stair("default:stair_wood", {
   description = "Wooden Stair",
   tiles = {"default_wood.png"},
   material = "default:wood",
   groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1, fuel = 8},
   sounds = default.node_sound_wood_defaults(),
})

default.register_slab("default:slab_wood", {
   description = "Wooden Slab",
   tiles = {"default_wood.png"},
   material = "default:wood",
   groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1, fuel = 8},
   sounds = default.node_sound_wood_defaults(),
})

default.register_fence("default:fence_wood", {
   description = "Wooden Fence",
   tiles = {"default_wood.png"},
   material = "default:wood",
   groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1, fuel = 4},
   sounds = default.node_sound_wood_defaults(),
})

default.register_fencegate("default:fencegate_wood", {
   description = "Wooden Fence Gate",
   tiles = {"default_wood.png"},
   material = "default:wood",
   groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1, fuel = 4},
   sounds = default.node_sound_wood_defaults(),
})

default.register_table("default:table_wood", {
   description = "Wooden Table",
   tiles = {"default_wood.png"},
   material = "default:wood",
   groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, fuel = 4},
   sounds = default.node_sound_wood_defaults(),
})


It's GPLv3+. So it's not compatible with MTG. (But in certain circumstances I would relicense it)

Re: New Node API registering system in my game Minetest TNG

PostPosted: Sat Mar 26, 2016 11:33
by jp
Wow, so uncommon. I created a way for additioning a variable.

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
local function count(a, b)
     a = a + b
     return a
end

That's GPLv3+ and incompatible with minetest_game as well.

Re: New Node API registering system in my game Minetest TNG

PostPosted: Sat Mar 26, 2016 14:00
by LNJ
jp wrote:Wow, so uncommon. I created a way for additioning a variable.

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
local function count(a, b)
     a = a + b
     return a
end

That's GPLv3+ and incompatible with minetest_game as well.

I just mean that my game is GPLv3+! :D
The code I wrote above is Idk, WTFPL.