cleaned up files and added some missing crafting stuff

This commit is contained in:
kaadmy 2015-10-03 17:07:04 -07:00
parent 6086e888b1
commit fc63f53963
4 changed files with 405 additions and 356 deletions

View File

@ -165,7 +165,7 @@ minetest.register_craft(
}
})
-- Nodes
-- Nodes/Items
minetest.register_craft(
{
@ -496,7 +496,7 @@ minetest.register_craft(
})
--
-- Crafting (tool repair)
-- Tool repair
--
minetest.register_craft(
{
@ -505,7 +505,7 @@ minetest.register_craft(
})
--
-- Cooking recipes
-- Cooking
--
minetest.register_craft(
@ -563,8 +563,64 @@ minetest.register_craft(
minetest.register_craft(
{
type = "fuel",
recipe = "group:tree",
burntime = 20,
recipe = "group:leaves",
burntime = 1,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:dry_grass",
burntime = 1,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:papyrus",
burntime = 2,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:apple",
burntime = 3,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:ladder",
burntime = 5,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:rope",
burntime = 5,
})
minetest.register_craft(
{
type = "fuel",
recipe = "group:planks",
burntime = 5,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:torch",
burntime = 5,
})
minetest.register_craft(
{
type = "fuel",
recipe = "group:sapling",
burntime = 7,
})
minetest.register_craft(
@ -574,6 +630,41 @@ minetest.register_craft(
burntime = 9,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:sign",
burntime = 10,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:cactus",
burntime = 10,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:fence",
burntime = 10,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:fence_oak",
burntime = 11,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:fence_birch",
burntime = 11,
})
minetest.register_craft(
{
type = "fuel",
@ -605,22 +696,15 @@ minetest.register_craft(
minetest.register_craft(
{
type = "fuel",
recipe = "group:leaves",
burntime = 1,
recipe = "group:tree",
burntime = 20,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:cactus",
burntime = 10,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:papyrus",
burntime = 2,
recipe = "default:chest",
burntime = 24,
})
minetest.register_craft(
@ -630,62 +714,6 @@ minetest.register_craft(
burntime = 30,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:fence",
burntime = 10,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:ladder",
burntime = 5,
})
minetest.register_craft(
{
type = "fuel",
recipe = "group:planks",
burntime = 5,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:torch",
burntime = 5,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:sign",
burntime = 10,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:chest",
burntime = 20,
})
minetest.register_craft(
{
type = "fuel",
recipe = "group:sapling",
burntime = 7,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:apple",
burntime = 3,
})
minetest.register_craft(
{
type = "fuel",
@ -700,281 +728,4 @@ minetest.register_craft(
burntime = 270,
})
--
-- Crafting items
--
minetest.register_craftitem(
"default:fiber",
{
description = "Fiber",
inventory_image = "default_fiber.png",
})
minetest.register_craftitem(
"default:bucket_water",
{
description = "Water Bucket",
inventory_image = "default_bucket_water.png",
stack_max = 1,
wield_scale = {x=1,y=1,z=2},
liquids_pointable = true,
on_place = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end
itemstack:take_item()
local inv=user:get_inventory()
if inv:room_for_item("main", {name="default:bucket"}) then
inv:add_item("main", "default:bucket")
else
local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5)
minetest.add_item(pos, "default:bucket")
end
local pos = pointed_thing.above
if minetest.registered_nodes[minetest.get_node(pointed_thing.under).name].buildable_to then
pos=pointed_thing.under
end
minetest.add_node(pos, {name = "default:water_source"})
return itemstack
end
})
minetest.register_craftitem(
"default:bucket_river_water",
{
description = "River Water Bucket",
inventory_image = "default_bucket_river_water.png",
stack_max = 1,
wield_scale = {x=1,y=1,z=2},
liquids_pointable = true,
on_place = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end
itemstack:take_item()
local inv=user:get_inventory()
if inv:room_for_item("main", {name="default:bucket"}) then
inv:add_item("main", "default:bucket")
else
local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5)
minetest.add_item(pos, "default:bucket")
end
local pos = pointed_thing.above
if minetest.registered_nodes[minetest.get_node(pointed_thing.under).name].buildable_to then
pos=pointed_thing.under
end
minetest.add_node(pos, {name = "default:river_water_source"})
return itemstack
end
})
minetest.register_craftitem(
"default:bucket_swamp_water",
{
description = "Swamp Water Bucket",
inventory_image = "default_bucket_swamp_water.png",
stack_max = 1,
wield_scale = {x=1,y=1,z=2},
liquids_pointable = true,
on_place = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end
itemstack:take_item()
local inv=user:get_inventory()
if inv:room_for_item("main", {name="default:bucket"}) then
inv:add_item("main", "default:bucket")
else
local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5)
minetest.add_item(pos, "default:bucket")
end
local pos = pointed_thing.above
if minetest.registered_nodes[minetest.get_node(pointed_thing.under).name].buildable_to then
pos=pointed_thing.under
end
minetest.add_node(pos, {name = "default:swamp_water_source"})
return itemstack
end
})
minetest.register_craftitem(
"default:bucket",
{
description = "Empty Bucket",
inventory_image = "default_bucket.png",
stack_max = 10,
wield_scale = {x=1,y=1,z=2},
liquids_pointable = true,
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end
local nodename=minetest.get_node(pointed_thing.under).name
if nodename == "default:water_source" then
itemstack:take_item()
local inv=user:get_inventory()
if inv:room_for_item("main", {name="default:bucket_water"}) then
inv:add_item("main", "default:bucket_water")
else
local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5)
minetest.add_item(pos, "default:bucket_water")
end
minetest.remove_node(pointed_thing.under)
elseif nodename == "default:river_water_source" then
itemstack:take_item()
local inv=user:get_inventory()
if inv:room_for_item("main", {name="default:bucket_river_water"}) then
inv:add_item("main", "default:bucket_river_water")
else
local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5)
minetest.add_item(pos, "default:bucket_river_water")
end
minetest.remove_node(pointed_thing.under)
elseif nodename == "default:swamp_water_source" then
itemstack:take_item()
local inv=user:get_inventory()
if inv:room_for_item("main", {name="default:bucket_swamp_water"}) then
inv:add_item("main", "default:bucket_swamp_water")
else
local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5)
minetest.add_item(pos, "default:bucket_swamp_water")
end
minetest.remove_node(pointed_thing.under)
end
return itemstack
end
})
minetest.register_craftitem(
"default:stick",
{
description = "Stick",
inventory_image = "default_stick.png",
groups = {stick = 1}
})
minetest.register_craftitem(
"default:paper",
{
description = "Paper",
inventory_image = "default_paper.png",
})
minetest.register_craftitem(
"default:book",
{
description = "Book",
inventory_image = "default_book.png",
wield_scale = {x=1,y=1,z=2},
})
minetest.register_craftitem(
"default:lump_coal",
{
description = "Coal Lump",
inventory_image = "default_lump_coal.png",
})
minetest.register_craftitem(
"default:lump_iron",
{
description = "Iron Lump",
inventory_image = "default_lump_iron.png",
})
minetest.register_craftitem(
"default:dust_carbonsteel",
{
description = "Carbon Steel Dust",
inventory_image = "default_dust_carbonsteel.png",
})
minetest.register_craftitem(
"default:ingot_steel",
{
description = "Steel Ingot",
inventory_image = "default_ingot_steel.png",
})
minetest.register_craftitem(
"default:ingot_carbonsteel",
{
description = "Carbon Steel Ingot",
inventory_image = "default_ingot_carbonsteel.png",
})
minetest.register_craftitem(
"default:lump_sugar",
{
description = "Sugar lump",
inventory_image = "default_lump_sugar.png",
on_use = minetest.item_eat({hp = 1, sat = 10})
})
minetest.register_craftitem(
"default:flint",
{
description = "Flint Shard",
inventory_image = "default_flint.png",
})
minetest.register_tool(
"default:flint_and_steel",
{
description = "Flint and Steel",
inventory_image = "default_flint_and_steel.png",
on_use = function(itemstack, user, pointed_thing)
if pointed_thing == nil then return end
if pointed_thing.type ~= "node" then return end
local pos = pointed_thing.under
local node = minetest.get_node(pos)
local nodename = node.name
if nodename == "default:torch_weak" then
minetest.set_node(pos, {name = "default:torch", param = node.param, param2 = node.param2})
itemstack:add_wear(800)
elseif nodename == "default:torch_dead" then
minetest.set_node(pos, {name = "default:torch_weak", param = node.param, param2 = node.param2})
itemstack:add_wear(800)
elseif nodename == "tnt:tnt" then
local y = minetest.registered_nodes["tnt:tnt"]
if y ~= nil then
y.on_punch(pos, node, user)
itemstack:add_wear(800)
end
end
return itemstack
end,
})
default.log("crafting", "loaded")

279
mods/default/craftitems.lua Normal file
View File

@ -0,0 +1,279 @@
--
-- Crafting items
--
minetest.register_craftitem(
"default:fiber",
{
description = "Fiber",
inventory_image = "default_fiber.png",
})
minetest.register_craftitem(
"default:stick",
{
description = "Stick",
inventory_image = "default_stick.png",
groups = {stick = 1}
})
minetest.register_craftitem(
"default:paper",
{
description = "Paper",
inventory_image = "default_paper.png",
})
minetest.register_craftitem(
"default:book",
{
description = "Book",
inventory_image = "default_book.png",
wield_scale = {x=1,y=1,z=2},
})
minetest.register_craftitem(
"default:lump_coal",
{
description = "Coal Lump",
inventory_image = "default_lump_coal.png",
})
minetest.register_craftitem(
"default:lump_iron",
{
description = "Iron Lump",
inventory_image = "default_lump_iron.png",
})
minetest.register_craftitem(
"default:dust_carbonsteel",
{
description = "Carbon Steel Dust",
inventory_image = "default_dust_carbonsteel.png",
})
minetest.register_craftitem(
"default:ingot_steel",
{
description = "Steel Ingot",
inventory_image = "default_ingot_steel.png",
})
minetest.register_craftitem(
"default:ingot_carbonsteel",
{
description = "Carbon Steel Ingot",
inventory_image = "default_ingot_carbonsteel.png",
})
minetest.register_craftitem(
"default:lump_sugar",
{
description = "Sugar lump",
inventory_image = "default_lump_sugar.png",
on_use = minetest.item_eat({hp = 1, sat = 10})
})
minetest.register_craftitem(
"default:flint",
{
description = "Flint Shard",
inventory_image = "default_flint.png",
})
minetest.register_tool(
"default:flint_and_steel",
{
description = "Flint and Steel",
inventory_image = "default_flint_and_steel.png",
on_use = function(itemstack, user, pointed_thing)
if pointed_thing == nil then return end
if pointed_thing.type ~= "node" then return end
local pos = pointed_thing.under
local node = minetest.get_node(pos)
local nodename = node.name
if nodename == "default:torch_weak" then
minetest.set_node(pos, {name = "default:torch", param = node.param, param2 = node.param2})
itemstack:add_wear(800)
elseif nodename == "default:torch_dead" then
minetest.set_node(pos, {name = "default:torch_weak", param = node.param, param2 = node.param2})
itemstack:add_wear(800)
elseif nodename == "tnt:tnt" then
local y = minetest.registered_nodes["tnt:tnt"]
if y ~= nil then
y.on_punch(pos, node, user)
itemstack:add_wear(800)
end
end
return itemstack
end,
})
minetest.register_craftitem(
"default:bucket_water",
{
description = "Water Bucket",
inventory_image = "default_bucket_water.png",
stack_max = 1,
wield_scale = {x=1,y=1,z=2},
liquids_pointable = true,
on_place = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end
itemstack:take_item()
local inv=user:get_inventory()
if inv:room_for_item("main", {name="default:bucket"}) then
inv:add_item("main", "default:bucket")
else
local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5)
minetest.add_item(pos, "default:bucket")
end
local pos = pointed_thing.above
if minetest.registered_nodes[minetest.get_node(pointed_thing.under).name].buildable_to then
pos=pointed_thing.under
end
minetest.add_node(pos, {name = "default:water_source"})
return itemstack
end
})
minetest.register_craftitem(
"default:bucket_river_water",
{
description = "River Water Bucket",
inventory_image = "default_bucket_river_water.png",
stack_max = 1,
wield_scale = {x=1,y=1,z=2},
liquids_pointable = true,
on_place = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end
itemstack:take_item()
local inv=user:get_inventory()
if inv:room_for_item("main", {name="default:bucket"}) then
inv:add_item("main", "default:bucket")
else
local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5)
minetest.add_item(pos, "default:bucket")
end
local pos = pointed_thing.above
if minetest.registered_nodes[minetest.get_node(pointed_thing.under).name].buildable_to then
pos=pointed_thing.under
end
minetest.add_node(pos, {name = "default:river_water_source"})
return itemstack
end
})
minetest.register_craftitem(
"default:bucket_swamp_water",
{
description = "Swamp Water Bucket",
inventory_image = "default_bucket_swamp_water.png",
stack_max = 1,
wield_scale = {x=1,y=1,z=2},
liquids_pointable = true,
on_place = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end
itemstack:take_item()
local inv=user:get_inventory()
if inv:room_for_item("main", {name="default:bucket"}) then
inv:add_item("main", "default:bucket")
else
local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5)
minetest.add_item(pos, "default:bucket")
end
local pos = pointed_thing.above
if minetest.registered_nodes[minetest.get_node(pointed_thing.under).name].buildable_to then
pos=pointed_thing.under
end
minetest.add_node(pos, {name = "default:swamp_water_source"})
return itemstack
end
})
minetest.register_craftitem(
"default:bucket",
{
description = "Empty Bucket",
inventory_image = "default_bucket.png",
stack_max = 10,
wield_scale = {x=1,y=1,z=2},
liquids_pointable = true,
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end
local nodename=minetest.get_node(pointed_thing.under).name
if nodename == "default:water_source" then
itemstack:take_item()
local inv=user:get_inventory()
if inv:room_for_item("main", {name="default:bucket_water"}) then
inv:add_item("main", "default:bucket_water")
else
local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5)
minetest.add_item(pos, "default:bucket_water")
end
minetest.remove_node(pointed_thing.under)
elseif nodename == "default:river_water_source" then
itemstack:take_item()
local inv=user:get_inventory()
if inv:room_for_item("main", {name="default:bucket_river_water"}) then
inv:add_item("main", "default:bucket_river_water")
else
local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5)
minetest.add_item(pos, "default:bucket_river_water")
end
minetest.remove_node(pointed_thing.under)
elseif nodename == "default:swamp_water_source" then
itemstack:take_item()
local inv=user:get_inventory()
if inv:room_for_item("main", {name="default:bucket_swamp_water"}) then
inv:add_item("main", "default:bucket_swamp_water")
else
local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5)
minetest.add_item(pos, "default:bucket_swamp_water")
end
minetest.remove_node(pointed_thing.under)
end
return itemstack
end
})
default.log("craftitems", "loaded")

View File

@ -35,6 +35,7 @@ dofile(minetest.get_modpath("default").."/formspec.lua")
dofile(minetest.get_modpath("default").."/functions.lua")
dofile(minetest.get_modpath("default").."/sounds.lua")
dofile(minetest.get_modpath("default").."/nodes.lua")
dofile(minetest.get_modpath("default").."/craftitems.lua")
dofile(minetest.get_modpath("default").."/crafting.lua")
dofile(minetest.get_modpath("default").."/tools.lua")
dofile(minetest.get_modpath("default").."/furnace.lua")

View File

@ -5,7 +5,7 @@
partialblocks = {}
function partialblocks.register_material(name, desc, node)
function partialblocks.register_material(name, desc, node, can_burn)
local nodedef = minetest.registered_nodes[node]
if nodedef == nil then
@ -48,6 +48,15 @@ function partialblocks.register_material(name, desc, node)
recipe = {"partialblocks:" .. name .. "_slab"},
})
if can_burn then
minetest.register_craft( -- Fuel
{
type = "fuel",
recipe = "partialblocks:" .. name .. "_slab",
burntime = 7,
})
end
-- Stair
minetest.register_node(
"partialblocks:" .. name .. "_stair",
@ -85,15 +94,24 @@ function partialblocks.register_material(name, desc, node)
type = "shapeless",
recipe = {"partialblocks:" .. name .. "_stair"},
})
if can_burn then
minetest.register_craft( -- Fuel
{
type = "fuel",
recipe = "partialblocks:" .. name .. "_stair",
burntime = 7,
})
end
end
-- Register some default node partials
partialblocks.register_material("cobble", "Cobble", "default:cobble")
partialblocks.register_material("stone", "Stone", "default:stone")
partialblocks.register_material("brick", "Brick", "default:brick")
partialblocks.register_material("cobble", "Cobble", "default:cobble", false)
partialblocks.register_material("stone", "Stone", "default:stone", false)
partialblocks.register_material("brick", "Brick", "default:brick", false)
partialblocks.register_material("wood", "Wood", "default:planks")
partialblocks.register_material("oak", "Oak", "default:planks_oak")
partialblocks.register_material("birch", "Birch", "default:planks_birch")
partialblocks.register_material("wood", "Wood", "default:planks", true)
partialblocks.register_material("oak", "Oak", "default:planks_oak", true)
partialblocks.register_material("birch", "Birch", "default:planks_birch", true)
default.log("mod:partialblocks", "loaded")