Merge branch 'master' of git://github.com/celeron55/minetest_game

This commit is contained in:
Vanessa Ezekowitz 2012-12-17 18:33:56 -05:00
commit 0d34766d11
3 changed files with 59 additions and 29 deletions

View File

@ -0,0 +1 @@
default

View File

@ -44,15 +44,7 @@ minetest.after(0, function()
table.sort(creative_list)
inv:set_size("main", #creative_list)
for _,itemstring in ipairs(creative_list) do
local stack = ItemStack(itemstring)
-- Make a stack of the right number of items
local stack2 = nil
if stack:get_stack_max() == 1 then
stack2 = ItemStack(stack:get_name())
else
stack2 = ItemStack(stack:get_name().." "..stack:get_stack_max())
end
inv:add_item("main", stack2)
inv:add_item("main", ItemStack(itemstring))
end
creative_inventory.creative_inventory_size = #creative_list
print("creative inventory size: "..dump(creative_inventory.creative_inventory_size))
@ -129,3 +121,42 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
creative_inventory.set_creative_formspec(player, start_i, start_i / (6*4) + 1)
end)
if minetest.setting_getbool("creative_mode") then
minetest.register_item(":", {
type = "none",
wield_image = "wieldhand.png",
wield_scale = {x=1,y=1,z=2.5},
tool_capabilities = {
full_punch_interval = 0.5,
max_drop_level = 3,
groupcaps = {
crumbly = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
cracky = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
snappy = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
choppy = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
oddly_breakable_by_hand = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
}
}
})
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
return true
end)
function minetest.handle_node_drops(pos, drops, digger)
if not digger or not digger:is_player() then
return
end
local inv = digger:get_inventory()
if inv then
for _,item in ipairs(drops) do
item = ItemStack(item):get_name()
if not inv:contains_item("main", item) then
inv:add_item("main", item)
end
end
end
end
end

View File

@ -3,10 +3,9 @@
stairs = {}
-- Node will be called modname:stair_<subname>
-- Node will be called stairs:stair_<subname>
function stairs.register_stair(subname, recipeitem, groups, images, description, sounds)
local modname = minetest.get_current_modname()
minetest.register_node(modname..":stair_" .. subname, {
minetest.register_node(":stairs:stair_" .. subname, {
description = description,
drawtype = "nodebox",
tiles = images,
@ -30,7 +29,7 @@ function stairs.register_stair(subname, recipeitem, groups, images, description,
local p0 = pointed_thing.under
local p1 = pointed_thing.above
if p0.y-1 == p1.y then
local fakestack = ItemStack(modname..":stair_" .. subname.."upside_down")
local fakestack = ItemStack("stairs:stair_" .. subname.."upside_down")
local ret = minetest.item_place(fakestack, placer, pointed_thing)
if ret:is_empty() then
itemstack:take_item()
@ -43,8 +42,8 @@ function stairs.register_stair(subname, recipeitem, groups, images, description,
end,
})
minetest.register_node(modname..":stair_" .. subname.."upside_down", {
drop = modname..":stair_" .. subname,
minetest.register_node(":stairs:stair_" .. subname.."upside_down", {
drop = "stairs:stair_" .. subname,
drawtype = "nodebox",
tiles = images,
paramtype = "light",
@ -62,7 +61,7 @@ function stairs.register_stair(subname, recipeitem, groups, images, description,
})
minetest.register_craft({
output = modname..':stair_' .. subname .. ' 4',
output = 'stairs:stair_' .. subname .. ' 4',
recipe = {
{recipeitem, "", ""},
{recipeitem, recipeitem, ""},
@ -72,7 +71,7 @@ function stairs.register_stair(subname, recipeitem, groups, images, description,
-- Flipped recipe for the silly minecrafters
minetest.register_craft({
output = modname..':stair_' .. subname .. ' 4',
output = 'stairs:stair_' .. subname .. ' 4',
recipe = {
{"", "", recipeitem},
{"", recipeitem, recipeitem},
@ -81,10 +80,9 @@ function stairs.register_stair(subname, recipeitem, groups, images, description,
})
end
-- Node will be called modname:slab_<subname>
-- Node will be called stairs:slab_<subname>
function stairs.register_slab(subname, recipeitem, groups, images, description, sounds)
local modname = minetest.get_current_modname()
minetest.register_node(modname..":slab_" .. subname, {
minetest.register_node(":stairs:slab_" .. subname, {
description = description,
drawtype = "nodebox",
tiles = images,
@ -112,7 +110,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
local p0 = pointed_thing.under
local p1 = pointed_thing.above
local n0 = minetest.env:get_node(p0)
if n0.name == modname..":slab_" .. subname and
if n0.name == "stairs:slab_" .. subname and
p0.y+1 == p1.y then
slabpos = p0
slabnode = n0
@ -137,7 +135,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
-- Upside down slabs
if p0.y-1 == p1.y then
-- Turn into full block if pointing at a existing slab
if n0.name == modname..":slab_" .. subname.."upside_down" then
if n0.name == "stairs:slab_" .. subname.."upside_down" then
-- Remove the slab at the position of the slab
minetest.env:remove_node(p0)
-- Make a fake stack of a single item and try to place it
@ -155,7 +153,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
end
-- Place upside down slab
local fakestack = ItemStack(modname..":slab_" .. subname.."upside_down")
local fakestack = ItemStack("stairs:slab_" .. subname.."upside_down")
local ret = minetest.item_place(fakestack, placer, pointed_thing)
if ret:is_empty() then
itemstack:take_item()
@ -164,10 +162,10 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
end
-- If pointing at the side of a upside down slab
if n0.name == modname..":slab_" .. subname.."upside_down" and
if n0.name == "stairs:slab_" .. subname.."upside_down" and
p0.y+1 ~= p1.y then
-- Place upside down slab
local fakestack = ItemStack(modname..":slab_" .. subname.."upside_down")
local fakestack = ItemStack("stairs:slab_" .. subname.."upside_down")
local ret = minetest.item_place(fakestack, placer, pointed_thing)
if ret:is_empty() then
itemstack:take_item()
@ -180,8 +178,8 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
end,
})
minetest.register_node(modname..":slab_" .. subname.."upside_down", {
drop = modname..":slab_"..subname,
minetest.register_node(":stairs:slab_" .. subname.."upside_down", {
drop = "stairs:slab_"..subname,
drawtype = "nodebox",
tiles = images,
paramtype = "light",
@ -199,14 +197,14 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
})
minetest.register_craft({
output = modname..':slab_' .. subname .. ' 3',
output = 'stairs:slab_' .. subname .. ' 3',
recipe = {
{recipeitem, recipeitem, recipeitem},
},
})
end
-- Nodes will be called modname:{stair,slab}_<subname>
-- Nodes will be called stairs:{stair,slab}_<subname>
function stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab, sounds)
stairs.register_stair(subname, recipeitem, groups, images, desc_stair, sounds)
stairs.register_slab(subname, recipeitem, groups, images, desc_slab, sounds)