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

This commit is contained in:
Vanessa Ezekowitz 2012-11-25 14:06:00 -05:00
commit 444b565d5d
14 changed files with 5011 additions and 14 deletions

View File

@ -14,11 +14,7 @@ minetest.after(0, function()
end
end,
allow_put = function(inv, listname, index, stack, player)
if minetest.setting_getbool("creative_mode") then
return -1
else
return 0
end
return 0
end,
allow_take = function(inv, listname, index, stack, player)
if minetest.setting_getbool("creative_mode") then
@ -54,8 +50,7 @@ minetest.after(0, function()
if stack:get_stack_max() == 1 then
stack2 = ItemStack(stack:get_name())
else
-- Insert half full so that a taken stack can be put back
stack2 = ItemStack(stack:get_name().." "..(stack:get_stack_max()/2))
stack2 = ItemStack(stack:get_name().." "..stack:get_stack_max())
end
inv:add_item("main", stack2)
end
@ -63,6 +58,24 @@ minetest.after(0, function()
print("creative inventory size: "..dump(creative_inventory.creative_inventory_size))
end)
-- Create the trash field
local trash = minetest.create_detached_inventory("creative_trash", {
-- Allow the stack to be placed and remove it in on_put()
-- This allows the creative inventory to restore the stack
allow_put = function(inv, listname, index, stack, player)
if minetest.setting_getbool("creative_mode") then
return stack:get_count()
else
return 0
end
end,
on_put = function(inv, listname, index, stack, player)
inv:set_stack(listname, index, "")
end,
})
trash:set_size("main", 1)
creative_inventory.set_creative_formspec = function(player, start_i, pagenum)
pagenum = math.floor(pagenum)
local pagemax = math.floor((creative_inventory.creative_inventory_size-1) / (6*4) + 1)
@ -74,7 +87,9 @@ creative_inventory.set_creative_formspec = function(player, start_i, pagenum)
"list[detached:creative;main;0.3,0.5;4,6;"..tostring(start_i).."]"..
"label[2.0,6.55;"..tostring(pagenum).."/"..tostring(pagemax).."]"..
"button[0.3,6.5;1.6,1;creative_prev;<<]"..
"button[2.7,6.5;1.6,1;creative_next;>>]")
"button[2.7,6.5;1.6,1;creative_next;>>]"..
"label[5,1.5;Trash:]"..
"list[detached:creative_trash;main;5,2;1,1;]")
end
minetest.register_on_joinplayer(function(player)
-- If in creative mode, modify player's inventory forms

View File

@ -82,3 +82,9 @@ Calinou's improved default textures (CC BY-SA):
default_clay_brick.png
default_papyrus.png
default_tool_steelsword.png
MirceaKitsune (WTFPL):
character.x
Jordach (CC BY-SA 3.0):
character.png

View File

@ -12,6 +12,7 @@ LIGHT_MAX = 14
default = {}
-- Load other files
dofile(minetest.get_modpath("default").."/player.lua")
dofile(minetest.get_modpath("default").."/mapgen.lua")
dofile(minetest.get_modpath("default").."/leafdecay.lua")
@ -82,6 +83,7 @@ minetest.register_tool("default:pick_mese", {
minetest.register_tool("default:shovel_wood", {
description = "Wooden Shovel",
inventory_image = "default_tool_woodshovel.png",
wield_image = "default_tool_woodshovel.png^[transformR90",
tool_capabilities = {
max_drop_level=0,
groupcaps={
@ -92,6 +94,7 @@ minetest.register_tool("default:shovel_wood", {
minetest.register_tool("default:shovel_stone", {
description = "Stone Shovel",
inventory_image = "default_tool_stoneshovel.png",
wield_image = "default_tool_stoneshovel.png^[transformR90",
tool_capabilities = {
max_drop_level=0,
groupcaps={
@ -102,6 +105,7 @@ minetest.register_tool("default:shovel_stone", {
minetest.register_tool("default:shovel_steel", {
description = "Steel Shovel",
inventory_image = "default_tool_steelshovel.png",
wield_image = "default_tool_steelshovel.png^[transformR90",
tool_capabilities = {
max_drop_level=1,
groupcaps={
@ -402,6 +406,13 @@ minetest.register_craft({
}
})
minetest.register_craft({
output = 'default:sand 4',
recipe = {
{'default:sandstone'},
}
})
minetest.register_craft({
output = 'default:clay',
recipe = {
@ -795,7 +806,6 @@ minetest.register_node("default:sandstone", {
tiles = {"default_sandstone.png"},
is_ground_content = true,
groups = {crumbly=2,cracky=2},
drop = 'default:sand',
sounds = default.node_sound_stone_defaults(),
})
@ -1509,7 +1519,6 @@ minetest.register_node("default:nyancat", {
description = "Nyan Cat",
tiles = {"default_nc_side.png", "default_nc_side.png", "default_nc_side.png",
"default_nc_side.png", "default_nc_back.png", "default_nc_front.png"},
inventory_image = "default_nc_front.png",
paramtype2 = "facedir",
groups = {cracky=2},
legacy_facedir_simple = true,
@ -1519,7 +1528,6 @@ minetest.register_node("default:nyancat", {
minetest.register_node("default:nyancat_rainbow", {
description = "Nyan Cat Rainbow",
tiles = {"default_nc_rb.png"},
inventory_image = "default_nc_rb.png",
groups = {cracky=2},
sounds = default.node_sound_defaults(),
})

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

File diff suppressed because it is too large Load Diff

130
mods/default/player.lua Normal file
View File

@ -0,0 +1,130 @@
-- Minetest 0.4 mod: player
-- See README.txt for licensing and other information.
--
-- Start of configuration area:
--
-- Player animation speed
animation_speed = 30
-- Player animation blending
-- Note: This is currently broken due to a bug in Irrlicht, leave at 0
animation_blend = 0
-- Default player appearance
default_model = "character.x"
default_textures = {"character.png", }
-- Frame ranges for each player model
function player_get_animations(model)
if model == "character.x" then
return {
stand_START = 0,
stand_END = 79,
walk_START = 81,
walk_END = 100,
mine_START = 102,
mine_END = 111,
walk_mine_START = 113,
walk_mine_END = 132,
death_START = 134,
death_END = 153
}
end
end
--
-- End of configuration area.
--
-- Player stats and animations
local player_model = {}
local player_anim = {}
local player_sneak = {}
local ANIM_STAND = 1
local ANIM_WALK = 2
local ANIM_WALK_MINE = 3
local ANIM_MINE = 4
local ANIM_DEATH = 5
-- Called when a player's appearance needs to be updated
function player_update_visuals(pl)
local name = pl:get_player_name()
player_model[name] = default_model
player_anim[name] = 0 -- Animation will be set further below immediately
player_sneak[name] = false
prop = {
mesh = default_model,
textures = default_textures,
visual = "mesh",
visual_size = {x=1, y=1},
}
pl:set_properties(prop)
end
-- Update appearance when the player joins
minetest.register_on_joinplayer(player_update_visuals)
-- Check each player and apply animations
function player_step(dtime)
for _, pl in pairs(minetest.get_connected_players()) do
local name = pl:get_player_name()
local anim = player_get_animations(player_model[name])
local controls = pl:get_player_control()
local walking = false
local animation_speed_mod = animation_speed
-- Determine if the player is walking
if controls.up or controls.down or controls.left or controls.right then
walking = true
end
-- Determine if the player is sneaking, and reduce animation speed if so
if controls.sneak and pl:get_hp() ~= 0 and (walking or controls.LMB) then
animation_speed_mod = animation_speed_mod / 2
-- Refresh player animation below if sneak state changed
if not player_sneak[name] then
player_anim[name] = 0
player_sneak[name] = true
end
else
-- Refresh player animation below if sneak state changed
if player_sneak[name] then
player_anim[name] = 0
player_sneak[name] = false
end
end
-- Apply animations based on what the player is doing
if pl:get_hp() == 0 then
if player_anim[name] ~= ANIM_DEATH then
-- TODO: The death animation currently loops, we must make it play only once then stay at the last frame somehow
pl:set_animation({x=anim.death_START, y=anim.death_END}, animation_speed_mod, animation_blend)
player_anim[name] = ANIM_DEATH
end
elseif walking and controls.LMB then
if player_anim[name] ~= ANIM_WALK_MINE then
pl:set_animation({x=anim.walk_mine_START, y=anim.walk_mine_END}, animation_speed_mod, animation_blend)
player_anim[name] = ANIM_WALK_MINE
end
elseif walking then
if player_anim[name] ~= ANIM_WALK then
pl:set_animation({x=anim.walk_START, y=anim.walk_END}, animation_speed_mod, animation_blend)
player_anim[name] = ANIM_WALK
end
elseif controls.LMB then
if player_anim[name] ~= ANIM_MINE then
pl:set_animation({x=anim.mine_START, y=anim.mine_END}, animation_speed_mod, animation_blend)
player_anim[name] = ANIM_MINE
end
elseif player_anim[name] ~= ANIM_STAND then
pl:set_animation({x=anim.stand_START, y=anim.stand_END}, animation_speed_mod, animation_blend)
player_anim[name] = ANIM_STAND
end
end
end
minetest.register_globalstep(player_step)
-- END

View File

@ -3,7 +3,8 @@
minetest.register_craftitem("vessels:glass_bottle", {
description = "Glass Bottle (empty)",
inventory_image = "vessels_glass_bottle.png",
inventory_image = "vessels_glass_bottle_inv.png",
wield_image = "vessels_glass_bottle.png",
groups = {vessel=1},
})
@ -18,7 +19,8 @@ minetest.register_craft( {
minetest.register_craftitem("vessels:drinking_glass", {
description = "Drinking Glass (empty)",
inventory_image = "vessels_drinking_glass.png",
inventory_image = "vessels_drinking_glass_inv.png",
wield_image = "vessels_drinking_glass.png",
groups = {vessel=1},
})
@ -33,7 +35,8 @@ minetest.register_craft( {
minetest.register_craftitem("vessels:steel_bottle", {
description = "Heavy Steel Bottle (empty)",
inventory_image = "vessels_steel_bottle.png",
inventory_image = "vessels_steel_bottle_inv.png",
wield_image = "vessels_steel_bottle.png",
groups = {vessel=1},
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 338 B

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 405 B

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 B

After

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B