Rename "NodeItem"/"ToolItem"/"CraftItem" to "node"/"tool"/"craft"

This commit is contained in:
Perttu Ahola 2011-12-02 12:12:07 +02:00
parent a17efe6e8f
commit 69bc9224db
7 changed files with 210 additions and 210 deletions

@ -156,9 +156,9 @@ minetest.register_node("ignore", {
-- --
-- stackstring manipulation functions -- stackstring manipulation functions
-- example stackstring: 'CraftItem "apple" 4' -- example stackstring: 'craft "apple" 4'
-- example item: {type="CraftItem", name="apple"} -- example item: {type="craft", name="apple"}
-- example item: {type="ToolItem", name="SteelPick", wear="23272"} -- example item: {type="tool", name="SteelPick", wear="23272"}
-- --
function stackstring_take_item(stackstring) function stackstring_take_item(stackstring)
@ -167,13 +167,13 @@ function stackstring_take_item(stackstring)
end end
local stacktype = nil local stacktype = nil
stacktype = string.match(stackstring, stacktype = string.match(stackstring,
'([%a%d]+Item[%a%d]*)') '([%a%d]+)')
if stacktype == "NodeItem" or stacktype == "CraftItem" then if stacktype == "node" or stacktype == "craft" then
local itemtype = nil local itemtype = nil
local itemname = nil local itemname = nil
local itemcount = nil local itemcount = nil
itemtype, itemname, itemcount = string.match(stackstring, itemtype, itemname, itemcount = string.match(stackstring,
'([%a%d]+Item[%a%d]*) "([^"]*)" (%d+)') '([%a%d]+) "([^"]*)" (%d+)')
itemcount = tonumber(itemcount) itemcount = tonumber(itemcount)
if itemcount == 0 then if itemcount == 0 then
return '', nil return '', nil
@ -183,12 +183,12 @@ function stackstring_take_item(stackstring)
return itemtype.." \""..itemname.."\" "..(itemcount-1), return itemtype.." \""..itemname.."\" "..(itemcount-1),
{type=itemtype, name=itemname} {type=itemtype, name=itemname}
end end
elseif stacktype == "ToolItem" then elseif stacktype == "tool" then
local itemtype = nil local itemtype = nil
local itemname = nil local itemname = nil
local itemwear = nil local itemwear = nil
itemtype, itemname, itemwear = string.match(stackstring, itemtype, itemname, itemwear = string.match(stackstring,
'([%a%d]+Item[%a%d]*) "([^"]*)" (%d+)') '([%a%d]+) "([^"]*)" (%d+)')
itemwear = tonumber(itemwear) itemwear = tonumber(itemwear)
return '', {type=itemtype, name=itemname, wear=itemwear} return '', {type=itemtype, name=itemname, wear=itemwear}
end end
@ -201,17 +201,17 @@ function stackstring_put_item(stackstring, item)
stackstring = stackstring or '' stackstring = stackstring or ''
local stacktype = nil local stacktype = nil
stacktype = string.match(stackstring, stacktype = string.match(stackstring,
'([%a%d]+Item[%a%d]*)') '([%a%d]+)')
stacktype = stacktype or '' stacktype = stacktype or ''
if stacktype ~= '' and stacktype ~= item.type then if stacktype ~= '' and stacktype ~= item.type then
return stackstring, false return stackstring, false
end end
if item.type == "NodeItem" or item.type == "CraftItem" then if item.type == "node" or item.type == "craft" then
local itemtype = nil local itemtype = nil
local itemname = nil local itemname = nil
local itemcount = nil local itemcount = nil
itemtype, itemname, itemcount = string.match(stackstring, itemtype, itemname, itemcount = string.match(stackstring,
'([%a%d]+Item[%a%d]*) "([^"]*)" (%d+)') '([%a%d]+) "([^"]*)" (%d+)')
itemtype = itemtype or item.type itemtype = itemtype or item.type
itemname = itemname or item.name itemname = itemname or item.name
if itemcount == nil then if itemcount == nil then
@ -219,7 +219,7 @@ function stackstring_put_item(stackstring, item)
end end
itemcount = itemcount + 1 itemcount = itemcount + 1
return itemtype.." \""..itemname.."\" "..itemcount, true return itemtype.." \""..itemname.."\" "..itemcount, true
elseif item.type == "ToolItem" then elseif item.type == "tool" then
if stacktype ~= nil then if stacktype ~= nil then
return stackstring, false return stackstring, false
end end
@ -227,7 +227,7 @@ function stackstring_put_item(stackstring, item)
local itemname = nil local itemname = nil
local itemwear = nil local itemwear = nil
itemtype, itemname, itemwear = string.match(stackstring, itemtype, itemname, itemwear = string.match(stackstring,
'([%a%d]+Item[%a%d]*) "([^"]*)" (%d+)') '([%a%d]+) "([^"]*)" (%d+)')
itemwear = tonumber(itemwear) itemwear = tonumber(itemwear)
return itemtype.." \""..itemname.."\" "..itemwear, true return itemtype.." \""..itemname.."\" "..itemwear, true
end end
@ -253,53 +253,53 @@ function test_stackstring()
local item local item
local success local success
stack, item = stackstring_take_item('NodeItem "TNT" 3') stack, item = stackstring_take_item('node "TNT" 3')
assert(stack == 'NodeItem "TNT" 2') assert(stack == 'node "TNT" 2')
assert(item.type == 'NodeItem') assert(item.type == 'node')
assert(item.name == 'TNT') assert(item.name == 'TNT')
stack, item = stackstring_take_item('CraftItem "with spaces" 2') stack, item = stackstring_take_item('craft "with spaces" 2')
assert(stack == 'CraftItem "with spaces" 1') assert(stack == 'craft "with spaces" 1')
assert(item.type == 'CraftItem') assert(item.type == 'craft')
assert(item.name == 'with spaces') assert(item.name == 'with spaces')
stack, item = stackstring_take_item('CraftItem "with spaces" 1') stack, item = stackstring_take_item('craft "with spaces" 1')
assert(stack == '') assert(stack == '')
assert(item.type == 'CraftItem') assert(item.type == 'craft')
assert(item.name == 'with spaces') assert(item.name == 'with spaces')
stack, item = stackstring_take_item('CraftItem "s8df2kj3" 0') stack, item = stackstring_take_item('craft "s8df2kj3" 0')
assert(stack == '') assert(stack == '')
assert(item == nil) assert(item == nil)
stack, item = stackstring_take_item('ToolItem "With Spaces" 32487') stack, item = stackstring_take_item('tool "With Spaces" 32487')
assert(stack == '') assert(stack == '')
assert(item.type == 'ToolItem') assert(item.type == 'tool')
assert(item.name == 'With Spaces') assert(item.name == 'With Spaces')
assert(item.wear == 32487) assert(item.wear == 32487)
stack, success = stackstring_put_item('NodeItem "With Spaces" 40', stack, success = stackstring_put_item('node "With Spaces" 40',
{type='NodeItem', name='With Spaces'}) {type='node', name='With Spaces'})
assert(stack == 'NodeItem "With Spaces" 41') assert(stack == 'node "With Spaces" 41')
assert(success == true) assert(success == true)
stack, success = stackstring_put_item('CraftItem "With Spaces" 40', stack, success = stackstring_put_item('craft "With Spaces" 40',
{type='CraftItem', name='With Spaces'}) {type='craft', name='With Spaces'})
assert(stack == 'CraftItem "With Spaces" 41') assert(stack == 'craft "With Spaces" 41')
assert(success == true) assert(success == true)
stack, success = stackstring_put_item('ToolItem "With Spaces" 32487', stack, success = stackstring_put_item('tool "With Spaces" 32487',
{type='ToolItem', name='With Spaces'}) {type='tool', name='With Spaces'})
assert(stack == 'ToolItem "With Spaces" 32487') assert(stack == 'tool "With Spaces" 32487')
assert(success == false) assert(success == false)
stack, success = stackstring_put_item('NodeItem "With Spaces" 40', stack, success = stackstring_put_item('node "With Spaces" 40',
{type='ToolItem', name='With Spaces'}) {type='tool', name='With Spaces'})
assert(stack == 'NodeItem "With Spaces" 40') assert(stack == 'node "With Spaces" 40')
assert(success == false) assert(success == false)
assert(stackstring_put_stackstring('NodeItem "With Spaces" 2', assert(stackstring_put_stackstring('node "With Spaces" 2',
'NodeItem "With Spaces" 1') == 'NodeItem "With Spaces" 3') 'node "With Spaces" 1') == 'node "With Spaces" 3')
end end
test_stackstring() test_stackstring()
@ -312,7 +312,7 @@ minetest.craftitem_place_item = function(item, placer, pos)
--print("item: " .. dump(item)) --print("item: " .. dump(item))
--print("placer: " .. dump(placer)) --print("placer: " .. dump(placer))
--print("pos: " .. dump(pos)) --print("pos: " .. dump(pos))
minetest.env:add_item(pos, 'CraftItem "' .. item .. '" 1') minetest.env:add_item(pos, 'craft "' .. item .. '" 1')
return true return true
end end

@ -1,8 +1,8 @@
minetest.register_craft({ minetest.register_craft({
output = 'CraftItem "bucket" 1', output = 'craft "bucket" 1',
recipe = { recipe = {
{'CraftItem "steel_ingot"', '', 'CraftItem "steel_ingot"'}, {'craft "steel_ingot"', '', 'craft "steel_ingot"'},
{'', 'CraftItem "steel_ingot"', ''}, {'', 'craft "steel_ingot"', ''},
} }
}) })
@ -16,11 +16,11 @@ minetest.register_craftitem("bucket", {
n = minetest.env:get_node(pointed_thing.under) n = minetest.env:get_node(pointed_thing.under)
if n.name == "water_source" then if n.name == "water_source" then
minetest.env:add_node(pointed_thing.under, {name="air"}) minetest.env:add_node(pointed_thing.under, {name="air"})
player:add_to_inventory_later('CraftItem "bucket_water" 1') player:add_to_inventory_later('craft "bucket_water" 1')
return true return true
elseif n.name == "lava_source" then elseif n.name == "lava_source" then
minetest.env:add_node(pointed_thing.under, {name="air"}) minetest.env:add_node(pointed_thing.under, {name="air"})
player:add_to_inventory_later('CraftItem "bucket_lava" 1') player:add_to_inventory_later('craft "bucket_lava" 1')
return true return true
end end
end end
@ -43,7 +43,7 @@ minetest.register_craftitem("bucket_water", {
else else
minetest.env:add_node(pointed_thing.above, {name="water_source"}) minetest.env:add_node(pointed_thing.above, {name="water_source"})
end end
player:add_to_inventory_later('CraftItem "bucket" 1') player:add_to_inventory_later('craft "bucket" 1')
return true return true
end end
return false return false
@ -65,7 +65,7 @@ minetest.register_craftitem("bucket_lava", {
else else
minetest.env:add_node(pointed_thing.above, {name="lava_source"}) minetest.env:add_node(pointed_thing.above, {name="lava_source"})
end end
player:add_to_inventory_later('CraftItem "bucket" 1') player:add_to_inventory_later('craft "bucket" 1')
return true return true
end end
return false return false

@ -14,16 +14,16 @@
-- {x=num, y=num, z=num} -- {x=num, y=num, z=num}
-- --
-- stackstring/itemstring: A stack of items in serialized format. -- stackstring/itemstring: A stack of items in serialized format.
-- eg. 'NodeItem "dirt" 5' -- eg. 'node "dirt" 5'
-- eg. 'ToolItem "WPick" 21323' -- eg. 'tool "WPick" 21323'
-- eg. 'CraftItem "apple" 2' -- eg. 'craft "apple" 2'
-- --
-- item: A single item in Lua table format. -- item: A single item in Lua table format.
-- eg. {type="NodeItem", name="dirt"} -- eg. {type="node", name="dirt"}
-- ^ a single dirt node -- ^ a single dirt node
-- eg. {type="ToolItem", name="WPick", wear=21323} -- eg. {type="tool", name="WPick", wear=21323}
-- ^ a wooden pick about 1/3 weared out -- ^ a wooden pick about 1/3 weared out
-- eg. {type="CraftItem", name="apple"} -- eg. {type="craft", name="apple"}
-- ^ an apple. -- ^ an apple.
-- --
-- Global functions: -- Global functions:
@ -235,11 +235,11 @@
-- --
-- Recipe: -- Recipe:
-- { -- {
-- output = 'ToolItem "STPick"', -- output = 'tool "STPick"',
-- recipe = { -- recipe = {
-- {'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'}, -- {'node "cobble"', 'node "cobble"', 'node "cobble"'},
-- {'', 'CraftItem "Stick"', ''}, -- {'', 'craft "Stick"', ''},
-- {'', 'CraftItem "Stick"', ''}, -- {'', 'craft "Stick"', ''},
-- } -- }
-- } -- }
-- --
@ -444,270 +444,270 @@ minetest.register_tool("", {
-- --
minetest.register_craft({ minetest.register_craft({
output = 'NodeItem "wood" 4', output = 'node "wood" 4',
recipe = { recipe = {
{'NodeItem "tree"'}, {'node "tree"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'CraftItem "Stick" 4', output = 'craft "Stick" 4',
recipe = { recipe = {
{'NodeItem "wood"'}, {'node "wood"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'NodeItem "wooden_fence" 2', output = 'node "wooden_fence" 2',
recipe = { recipe = {
{'CraftItem "Stick"', 'CraftItem "Stick"', 'CraftItem "Stick"'}, {'craft "Stick"', 'craft "Stick"', 'craft "Stick"'},
{'CraftItem "Stick"', 'CraftItem "Stick"', 'CraftItem "Stick"'}, {'craft "Stick"', 'craft "Stick"', 'craft "Stick"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'NodeItem "sign_wall" 1', output = 'node "sign_wall" 1',
recipe = { recipe = {
{'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'}, {'node "wood"', 'node "wood"', 'node "wood"'},
{'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'}, {'node "wood"', 'node "wood"', 'node "wood"'},
{'', 'CraftItem "Stick"', ''}, {'', 'craft "Stick"', ''},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'NodeItem "torch" 4', output = 'node "torch" 4',
recipe = { recipe = {
{'CraftItem "lump_of_coal"'}, {'craft "lump_of_coal"'},
{'CraftItem "Stick"'}, {'craft "Stick"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'ToolItem "WPick"', output = 'tool "WPick"',
recipe = { recipe = {
{'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'}, {'node "wood"', 'node "wood"', 'node "wood"'},
{'', 'CraftItem "Stick"', ''}, {'', 'craft "Stick"', ''},
{'', 'CraftItem "Stick"', ''}, {'', 'craft "Stick"', ''},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'ToolItem "STPick"', output = 'tool "STPick"',
recipe = { recipe = {
{'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'}, {'node "cobble"', 'node "cobble"', 'node "cobble"'},
{'', 'CraftItem "Stick"', ''}, {'', 'craft "Stick"', ''},
{'', 'CraftItem "Stick"', ''}, {'', 'craft "Stick"', ''},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'ToolItem "SteelPick"', output = 'tool "SteelPick"',
recipe = { recipe = {
{'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'}, {'craft "steel_ingot"', 'craft "steel_ingot"', 'craft "steel_ingot"'},
{'', 'CraftItem "Stick"', ''}, {'', 'craft "Stick"', ''},
{'', 'CraftItem "Stick"', ''}, {'', 'craft "Stick"', ''},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'ToolItem "MesePick"', output = 'tool "MesePick"',
recipe = { recipe = {
{'NodeItem "mese"', 'NodeItem "mese"', 'NodeItem "mese"'}, {'node "mese"', 'node "mese"', 'node "mese"'},
{'', 'CraftItem "Stick"', ''}, {'', 'craft "Stick"', ''},
{'', 'CraftItem "Stick"', ''}, {'', 'craft "Stick"', ''},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'ToolItem "WShovel"', output = 'tool "WShovel"',
recipe = { recipe = {
{'NodeItem "wood"'}, {'node "wood"'},
{'CraftItem "Stick"'}, {'craft "Stick"'},
{'CraftItem "Stick"'}, {'craft "Stick"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'ToolItem "STShovel"', output = 'tool "STShovel"',
recipe = { recipe = {
{'NodeItem "cobble"'}, {'node "cobble"'},
{'CraftItem "Stick"'}, {'craft "Stick"'},
{'CraftItem "Stick"'}, {'craft "Stick"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'ToolItem "SteelShovel"', output = 'tool "SteelShovel"',
recipe = { recipe = {
{'CraftItem "steel_ingot"'}, {'craft "steel_ingot"'},
{'CraftItem "Stick"'}, {'craft "Stick"'},
{'CraftItem "Stick"'}, {'craft "Stick"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'ToolItem "WAxe"', output = 'tool "WAxe"',
recipe = { recipe = {
{'NodeItem "wood"', 'NodeItem "wood"'}, {'node "wood"', 'node "wood"'},
{'NodeItem "wood"', 'CraftItem "Stick"'}, {'node "wood"', 'craft "Stick"'},
{'', 'CraftItem "Stick"'}, {'', 'craft "Stick"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'ToolItem "STAxe"', output = 'tool "STAxe"',
recipe = { recipe = {
{'NodeItem "cobble"', 'NodeItem "cobble"'}, {'node "cobble"', 'node "cobble"'},
{'NodeItem "cobble"', 'CraftItem "Stick"'}, {'node "cobble"', 'craft "Stick"'},
{'', 'CraftItem "Stick"'}, {'', 'craft "Stick"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'ToolItem "SteelAxe"', output = 'tool "SteelAxe"',
recipe = { recipe = {
{'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'}, {'craft "steel_ingot"', 'craft "steel_ingot"'},
{'CraftItem "steel_ingot"', 'CraftItem "Stick"'}, {'craft "steel_ingot"', 'craft "Stick"'},
{'', 'CraftItem "Stick"'}, {'', 'craft "Stick"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'ToolItem "WSword"', output = 'tool "WSword"',
recipe = { recipe = {
{'NodeItem "wood"'}, {'node "wood"'},
{'NodeItem "wood"'}, {'node "wood"'},
{'CraftItem "Stick"'}, {'craft "Stick"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'ToolItem "STSword"', output = 'tool "STSword"',
recipe = { recipe = {
{'NodeItem "cobble"'}, {'node "cobble"'},
{'NodeItem "cobble"'}, {'node "cobble"'},
{'CraftItem "Stick"'}, {'craft "Stick"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'ToolItem "SteelSword"', output = 'tool "SteelSword"',
recipe = { recipe = {
{'CraftItem "steel_ingot"'}, {'craft "steel_ingot"'},
{'CraftItem "steel_ingot"'}, {'craft "steel_ingot"'},
{'CraftItem "Stick"'}, {'craft "Stick"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'NodeItem "rail" 15', output = 'node "rail" 15',
recipe = { recipe = {
{'CraftItem "steel_ingot"', '', 'CraftItem "steel_ingot"'}, {'craft "steel_ingot"', '', 'craft "steel_ingot"'},
{'CraftItem "steel_ingot"', 'CraftItem "Stick"', 'CraftItem "steel_ingot"'}, {'craft "steel_ingot"', 'craft "Stick"', 'craft "steel_ingot"'},
{'CraftItem "steel_ingot"', '', 'CraftItem "steel_ingot"'}, {'craft "steel_ingot"', '', 'craft "steel_ingot"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'NodeItem "chest" 1', output = 'node "chest" 1',
recipe = { recipe = {
{'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'}, {'node "wood"', 'node "wood"', 'node "wood"'},
{'NodeItem "wood"', '', 'NodeItem "wood"'}, {'node "wood"', '', 'node "wood"'},
{'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'}, {'node "wood"', 'node "wood"', 'node "wood"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'NodeItem "locked_chest" 1', output = 'node "locked_chest" 1',
recipe = { recipe = {
{'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'}, {'node "wood"', 'node "wood"', 'node "wood"'},
{'NodeItem "wood"', 'CraftItem "steel_ingot"', 'NodeItem "wood"'}, {'node "wood"', 'craft "steel_ingot"', 'node "wood"'},
{'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'}, {'node "wood"', 'node "wood"', 'node "wood"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'NodeItem "furnace" 1', output = 'node "furnace" 1',
recipe = { recipe = {
{'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'}, {'node "cobble"', 'node "cobble"', 'node "cobble"'},
{'NodeItem "cobble"', '', 'NodeItem "cobble"'}, {'node "cobble"', '', 'node "cobble"'},
{'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'}, {'node "cobble"', 'node "cobble"', 'node "cobble"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'NodeItem "steelblock" 1', output = 'node "steelblock" 1',
recipe = { recipe = {
{'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'}, {'craft "steel_ingot"', 'craft "steel_ingot"', 'craft "steel_ingot"'},
{'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'}, {'craft "steel_ingot"', 'craft "steel_ingot"', 'craft "steel_ingot"'},
{'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'}, {'craft "steel_ingot"', 'craft "steel_ingot"', 'craft "steel_ingot"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'NodeItem "sandstone" 1', output = 'node "sandstone" 1',
recipe = { recipe = {
{'NodeItem "sand"', 'NodeItem "sand"'}, {'node "sand"', 'node "sand"'},
{'NodeItem "sand"', 'NodeItem "sand"'}, {'node "sand"', 'node "sand"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'NodeItem "clay" 1', output = 'node "clay" 1',
recipe = { recipe = {
{'CraftItem "lump_of_clay"', 'CraftItem "lump_of_clay"'}, {'craft "lump_of_clay"', 'craft "lump_of_clay"'},
{'CraftItem "lump_of_clay"', 'CraftItem "lump_of_clay"'}, {'craft "lump_of_clay"', 'craft "lump_of_clay"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'NodeItem "brick" 1', output = 'node "brick" 1',
recipe = { recipe = {
{'CraftItem "clay_brick"', 'CraftItem "clay_brick"'}, {'craft "clay_brick"', 'craft "clay_brick"'},
{'CraftItem "clay_brick"', 'CraftItem "clay_brick"'}, {'craft "clay_brick"', 'craft "clay_brick"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'CraftItem "paper" 1', output = 'craft "paper" 1',
recipe = { recipe = {
{'NodeItem "papyrus"', 'NodeItem "papyrus"', 'NodeItem "papyrus"'}, {'node "papyrus"', 'node "papyrus"', 'node "papyrus"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'CraftItem "book" 1', output = 'craft "book" 1',
recipe = { recipe = {
{'CraftItem "paper"'}, {'craft "paper"'},
{'CraftItem "paper"'}, {'craft "paper"'},
{'CraftItem "paper"'}, {'craft "paper"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'NodeItem "bookshelf" 1', output = 'node "bookshelf" 1',
recipe = { recipe = {
{'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'}, {'node "wood"', 'node "wood"', 'node "wood"'},
{'CraftItem "book"', 'CraftItem "book"', 'CraftItem "book"'}, {'craft "book"', 'craft "book"', 'craft "book"'},
{'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'}, {'node "wood"', 'node "wood"', 'node "wood"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'NodeItem "ladder" 1', output = 'node "ladder" 1',
recipe = { recipe = {
{'CraftItem "Stick"', '', 'CraftItem "Stick"'}, {'craft "Stick"', '', 'craft "Stick"'},
{'CraftItem "Stick"', 'CraftItem "Stick"', 'CraftItem "Stick"'}, {'craft "Stick"', 'craft "Stick"', 'craft "Stick"'},
{'CraftItem "Stick"', '', 'CraftItem "Stick"'}, {'craft "Stick"', '', 'craft "Stick"'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'CraftItem "apple_iron" 1', output = 'craft "apple_iron" 1',
recipe = { recipe = {
{'', 'CraftItem "steel_ingot"', ''}, {'', 'craft "steel_ingot"', ''},
{'CraftItem "steel_ingot"', 'CraftItem "apple"', 'CraftItem "steel_ingot"'}, {'craft "steel_ingot"', 'craft "apple"', 'craft "steel_ingot"'},
{'', 'CraftItem "steel_ingot"', ''}, {'', 'craft "steel_ingot"', ''},
} }
}) })
@ -800,7 +800,7 @@ minetest.register_node("stone", {
is_ground_content = true, is_ground_content = true,
often_contains_mineral = true, -- Texture atlas hint often_contains_mineral = true, -- Texture atlas hint
material = digprop_stonelike(1.0), material = digprop_stonelike(1.0),
dug_item = 'NodeItem "cobble" 1', dug_item = 'node "cobble" 1',
}) })
minetest.register_node("dirt_with_grass", { minetest.register_node("dirt_with_grass", {
@ -808,7 +808,7 @@ minetest.register_node("dirt_with_grass", {
inventory_image = inventorycube("mud.png^grass_side.png"), inventory_image = inventorycube("mud.png^grass_side.png"),
is_ground_content = true, is_ground_content = true,
material = digprop_dirtlike(1.0), material = digprop_dirtlike(1.0),
dug_item = 'NodeItem "dirt" 1', dug_item = 'node "dirt" 1',
}) })
minetest.register_node("dirt_with_grass_footsteps", { minetest.register_node("dirt_with_grass_footsteps", {
@ -816,7 +816,7 @@ minetest.register_node("dirt_with_grass_footsteps", {
inventory_image = "grass_footsteps.png", inventory_image = "grass_footsteps.png",
is_ground_content = true, is_ground_content = true,
material = digprop_dirtlike(1.0), material = digprop_dirtlike(1.0),
dug_item = 'NodeItem "dirt" 1', dug_item = 'node "dirt" 1',
}) })
minetest.register_node("dirt", { minetest.register_node("dirt", {
@ -831,7 +831,7 @@ minetest.register_node("sand", {
inventory_image = inventorycube("sand.png"), inventory_image = inventorycube("sand.png"),
is_ground_content = true, is_ground_content = true,
material = digprop_dirtlike(1.0), material = digprop_dirtlike(1.0),
cookresult_item = 'NodeItem "glass" 1', cookresult_item = 'node "glass" 1',
}) })
minetest.register_node("gravel", { minetest.register_node("gravel", {
@ -846,7 +846,7 @@ minetest.register_node("sandstone", {
inventory_image = inventorycube("sandstone.png"), inventory_image = inventorycube("sandstone.png"),
is_ground_content = true, is_ground_content = true,
material = digprop_dirtlike(1.0), -- FIXME should this be stonelike? material = digprop_dirtlike(1.0), -- FIXME should this be stonelike?
dug_item = 'NodeItem "sand" 1', -- FIXME is this intentional? dug_item = 'node "sand" 1', -- FIXME is this intentional?
}) })
minetest.register_node("clay", { minetest.register_node("clay", {
@ -854,7 +854,7 @@ minetest.register_node("clay", {
inventory_image = inventorycube("clay.png"), inventory_image = inventorycube("clay.png"),
is_ground_content = true, is_ground_content = true,
material = digprop_dirtlike(1.0), material = digprop_dirtlike(1.0),
dug_item = 'CraftItem "lump_of_clay" 4', dug_item = 'craft "lump_of_clay" 4',
}) })
minetest.register_node("brick", { minetest.register_node("brick", {
@ -862,7 +862,7 @@ minetest.register_node("brick", {
inventory_image = inventorycube("brick.png"), inventory_image = inventorycube("brick.png"),
is_ground_content = true, is_ground_content = true,
material = digprop_stonelike(1.0), material = digprop_stonelike(1.0),
dug_item = 'CraftItem "clay_brick" 4', dug_item = 'craft "clay_brick" 4',
}) })
minetest.register_node("tree", { minetest.register_node("tree", {
@ -870,7 +870,7 @@ minetest.register_node("tree", {
inventory_image = inventorycube("tree_top.png", "tree.png", "tree.png"), inventory_image = inventorycube("tree_top.png", "tree.png", "tree.png"),
is_ground_content = true, is_ground_content = true,
material = digprop_woodlike(1.0), material = digprop_woodlike(1.0),
cookresult_item = 'CraftItem "lump_of_coal" 1', cookresult_item = 'craft "lump_of_coal" 1',
furnace_burntime = 30, furnace_burntime = 30,
}) })
@ -879,7 +879,7 @@ minetest.register_node("jungletree", {
inventory_image = inventorycube("jungletree_top.png", "jungletree.png", "jungletree.png"), inventory_image = inventorycube("jungletree_top.png", "jungletree.png", "jungletree.png"),
is_ground_content = true, is_ground_content = true,
material = digprop_woodlike(1.0), material = digprop_woodlike(1.0),
cookresult_item = 'CraftItem "lump_of_coal" 1', cookresult_item = 'craft "lump_of_coal" 1',
furnace_burntime = 30, furnace_burntime = 30,
}) })
@ -903,7 +903,7 @@ minetest.register_node("leaves", {
light_propagates = true, light_propagates = true,
paramtype = "light", paramtype = "light",
material = digprop_leaveslike(1.0), material = digprop_leaveslike(1.0),
extra_dug_item = 'NodeItem "sapling" 1', extra_dug_item = 'node "sapling" 1',
extra_dug_item_rarity = 20, extra_dug_item_rarity = 20,
furnace_burntime = 1, furnace_burntime = 1,
}) })
@ -1193,7 +1193,7 @@ minetest.register_node("cobble", {
tile_images = {"cobble.png"}, tile_images = {"cobble.png"},
inventory_image = inventorycube("cobble.png"), inventory_image = inventorycube("cobble.png"),
is_ground_content = true, is_ground_content = true,
cookresult_item = 'NodeItem "stone" 1', cookresult_item = 'node "stone" 1',
material = digprop_stonelike(0.9), material = digprop_stonelike(0.9),
}) })
@ -1248,7 +1248,7 @@ minetest.register_node("apple", {
light_propagates = true, light_propagates = true,
sunlight_propagates = true, sunlight_propagates = true,
walkable = false, walkable = false,
dug_item = 'CraftItem "apple" 1', dug_item = 'craft "apple" 1',
material = digprop_constanttime(0.0), material = digprop_constanttime(0.0),
furnace_burntime = 3, furnace_burntime = 3,
}) })
@ -1281,13 +1281,13 @@ minetest.register_craftitem("lump_of_coal", {
minetest.register_craftitem("lump_of_iron", { minetest.register_craftitem("lump_of_iron", {
image = "lump_of_iron.png", image = "lump_of_iron.png",
cookresult_item = 'CraftItem "steel_ingot" 1', cookresult_item = 'craft "steel_ingot" 1',
on_place_on_ground = minetest.craftitem_place_item, on_place_on_ground = minetest.craftitem_place_item,
}) })
minetest.register_craftitem("lump_of_clay", { minetest.register_craftitem("lump_of_clay", {
image = "lump_of_clay.png", image = "lump_of_clay.png",
cookresult_item = 'CraftItem "clay_brick" 1', cookresult_item = 'craft "clay_brick" 1',
on_place_on_ground = minetest.craftitem_place_item, on_place_on_ground = minetest.craftitem_place_item,
}) })
@ -1303,7 +1303,7 @@ minetest.register_craftitem("clay_brick", {
minetest.register_craftitem("rat", { minetest.register_craftitem("rat", {
image = "rat.png", image = "rat.png",
cookresult_item = 'CraftItem "cooked_rat" 1', cookresult_item = 'craft "cooked_rat" 1',
on_drop = function(item, dropper, pos) on_drop = function(item, dropper, pos)
minetest.env:add_rat(pos) minetest.env:add_rat(pos)
return true return true
@ -1312,7 +1312,7 @@ minetest.register_craftitem("rat", {
minetest.register_craftitem("cooked_rat", { minetest.register_craftitem("cooked_rat", {
image = "cooked_rat.png", image = "cooked_rat.png",
cookresult_item = 'CraftItem "scorched_stuff" 1', cookresult_item = 'craft "scorched_stuff" 1',
on_place_on_ground = minetest.craftitem_place_item, on_place_on_ground = minetest.craftitem_place_item,
on_use = minetest.craftitem_eat(6), on_use = minetest.craftitem_eat(6),
}) })

@ -56,7 +56,7 @@ minetest.register_abm({
_, srcitem = stackstring_take_item(srclist[1]) _, srcitem = stackstring_take_item(srclist[1])
_, fuelitem = stackstring_take_item(fuellist[1]) _, fuelitem = stackstring_take_item(fuellist[1])
if not srcitem or not fuelitem then return end if not srcitem or not fuelitem then return end
if fuelitem.type == "NodeItem" then if fuelitem.type == "node" then
local prop = minetest.registered_nodes[fuelitem.name] local prop = minetest.registered_nodes[fuelitem.name]
if prop == nil then return end if prop == nil then return end
if prop.furnace_burntime < 0 then return end if prop.furnace_burntime < 0 then return end
@ -64,7 +64,7 @@ minetest.register_abm({
return return
end end
local resultstack = nil local resultstack = nil
if srcitem.type == "NodeItem" then if srcitem.type == "node" then
local prop = minetest.registered_nodes[srcitem.name] local prop = minetest.registered_nodes[srcitem.name]
if prop == nil then return end if prop == nil then return end
if prop.cookresult_item == "" then return end if prop.cookresult_item == "" then return end
@ -97,11 +97,11 @@ minetest.register_abm({
}) })
minetest.register_craft({ minetest.register_craft({
output = 'NodeItem "luafurnace" 1', output = 'node "luafurnace" 1',
recipe = { recipe = {
{'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'}, {'node "cobble"', 'node "cobble"', 'node "cobble"'},
{'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'}, {'node "cobble"', 'node "cobble"', 'node "cobble"'},
{'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'}, {'node "cobble"', 'node "cobble"', 'node "cobble"'},
} }
}) })
@ -126,9 +126,9 @@ minetest.register_tool("horribletool", {
--]] --]]
minetest.register_craft({ minetest.register_craft({
output = 'NodeItem "somenode" 4', output = 'node "somenode" 4',
recipe = { recipe = {
{'CraftItem "Stick" 1'}, {'craft "Stick" 1'},
} }
}) })
@ -151,11 +151,11 @@ minetest.register_node("somenode", {
-- --
minetest.register_craft({ minetest.register_craft({
output = 'NodeItem "TNT" 4', output = 'node "TNT" 4',
recipe = { recipe = {
{'NodeItem "wood" 1'}, {'node "wood" 1'},
{'CraftItem "lump_of_coal" 1'}, {'craft "lump_of_coal" 1'},
{'NodeItem "wood" 1'} {'node "wood" 1'}
} }
}) })
@ -213,7 +213,7 @@ function TNT:on_punch(hitter)
self.health = self.health - 1 self.health = self.health - 1
if self.health <= 0 then if self.health <= 0 then
self.object:remove() self.object:remove()
hitter:add_to_inventory("NodeItem TNT 1") hitter:add_to_inventory("node TNT 1")
hitter:set_hp(hitter:get_hp() - 1) hitter:set_hp(hitter:get_hp() - 1)
end end
end end
@ -259,7 +259,7 @@ minetest.register_entity("testentity", {
on_punch = function(self, hitter) on_punch = function(self, hitter)
self.object:remove() self.object:remove()
hitter:add_to_inventory('CraftItem testobject1 1') hitter:add_to_inventory('craft testobject1 1')
end, end,
}) })

@ -2,11 +2,11 @@ minetest.register_on_newplayer(function(player)
print("on_newplayer") print("on_newplayer")
if minetest.setting_getbool("give_initial_stuff") then if minetest.setting_getbool("give_initial_stuff") then
print("giving give_initial_stuff to player") print("giving give_initial_stuff to player")
player:add_to_inventory('ToolItem "SteelPick" 0') player:add_to_inventory('tool "SteelPick" 0')
player:add_to_inventory('NodeItem "torch" 99') player:add_to_inventory('node "torch" 99')
player:add_to_inventory('ToolItem "SteelAxe" 0') player:add_to_inventory('tool "SteelAxe" 0')
player:add_to_inventory('ToolItem "SteelShovel" 0') player:add_to_inventory('tool "SteelShovel" 0')
player:add_to_inventory('NodeItem "cobble" 99') player:add_to_inventory('node "cobble" 99')
end end
end) end)

@ -99,7 +99,7 @@ InventoryItem* InventoryItem::deSerialize(std::istream &is, IGameDef *gamedef)
throw SerializationError("Too large material number"); throw SerializationError("Too large material number");
return new MaterialItem(gamedef, material, count); return new MaterialItem(gamedef, material, count);
} }
else if(name == "NodeItem" || name == "MaterialItem3") else if(name == "node" || name == "NodeItem" || name == "MaterialItem3")
{ {
std::string all; std::string all;
std::getline(is, all, '\n'); std::getline(is, all, '\n');
@ -126,7 +126,7 @@ InventoryItem* InventoryItem::deSerialize(std::istream &is, IGameDef *gamedef)
std::getline(is, inventorystring, '|'); std::getline(is, inventorystring, '|');
throw SerializationError("MBOItem not supported anymore"); throw SerializationError("MBOItem not supported anymore");
} }
else if(name == "CraftItem") else if(name == "craft" || name == "CraftItem")
{ {
std::string all; std::string all;
std::getline(is, all, '\n'); std::getline(is, all, '\n');
@ -148,7 +148,7 @@ InventoryItem* InventoryItem::deSerialize(std::istream &is, IGameDef *gamedef)
count = 1; count = 1;
return new CraftItem(gamedef, subname, count); return new CraftItem(gamedef, subname, count);
} }
else if(name == "ToolItem") else if(name == "tool" || name == "ToolItem")
{ {
std::string all; std::string all;
std::getline(is, all, '\n'); std::getline(is, all, '\n');

@ -158,7 +158,7 @@ public:
} }
virtual void serialize(std::ostream &os) const virtual void serialize(std::ostream &os) const
{ {
os<<"NodeItem"; os<<"node";
os<<" \""; os<<" \"";
os<<m_nodename; os<<m_nodename;
os<<"\" "; os<<"\" ";
@ -249,7 +249,7 @@ public:
} }
virtual void serialize(std::ostream &os) const virtual void serialize(std::ostream &os) const
{ {
os<<getName(); os<<"craft";
os<<" \""; os<<" \"";
os<<m_subname; os<<m_subname;
os<<"\" "; os<<"\" ";
@ -345,7 +345,7 @@ public:
} }
virtual void serialize(std::ostream &os) const virtual void serialize(std::ostream &os) const
{ {
os<<getName(); os<<"tool";
os<<" \""; os<<" \"";
os<<m_toolname; os<<m_toolname;
os<<"\" "; os<<"\" ";