Compare commits
5 Commits
4bd6bce86e
...
a5a59e3552
Author | SHA1 | Date |
---|---|---|
kwolekr | a5a59e3552 | |
kwolekr | bdd22db33d | |
PilzAdam | 51de4236ab | |
PilzAdam | 5d0795a1a7 | |
kaeza | 4c0c7ae146 |
|
@ -28,9 +28,10 @@ minetest.after(0, function()
|
|||
on_put = function(inv, listname, index, stack, player)
|
||||
end,
|
||||
on_take = function(inv, listname, index, stack, player)
|
||||
print(player:get_player_name().." takes item from creative inventory; listname="..dump(listname)..", index="..dump(index)..", stack="..dump(stack))
|
||||
--print(player:get_player_name().." takes item from creative inventory; listname="..dump(listname)..", index="..dump(index)..", stack="..dump(stack))
|
||||
if stack then
|
||||
print("stack:get_name()="..dump(stack:get_name())..", stack:get_count()="..dump(stack:get_count()))
|
||||
minetest.log("action", player:get_player_name().." takes "..dump(stack:get_name()).." from creative inventory")
|
||||
--print("stack:get_name()="..dump(stack:get_name())..", stack:get_count()="..dump(stack:get_count()))
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
@ -47,7 +48,7 @@ minetest.after(0, function()
|
|||
inv:add_item("main", ItemStack(itemstring))
|
||||
end
|
||||
creative_inventory.creative_inventory_size = #creative_list
|
||||
print("creative inventory size: "..dump(creative_inventory.creative_inventory_size))
|
||||
--print("creative inventory size: "..dump(creative_inventory.creative_inventory_size))
|
||||
end)
|
||||
|
||||
-- Create the trash field
|
||||
|
|
|
@ -132,41 +132,49 @@ minetest.register_on_punchnode(on_punchnode)
|
|||
--
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:sapling"},
|
||||
interval = 10,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
local is_soil = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil
|
||||
if is_soil == nil or is_soil == 0 then return end
|
||||
print("A sapling grows into a tree at "..minetest.pos_to_string(pos))
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local minp, maxp = vm:read_from_map({x=pos.x-16, y=pos.y, z=pos.z-16}, {x=pos.x+16, y=pos.y+16, z=pos.z+16})
|
||||
local a = VoxelArea:new{MinEdge=minp, MaxEdge=maxp}
|
||||
local data = vm:get_data()
|
||||
default.grow_tree(data, a, pos, math.random(1, 4) == 1, math.random(1,100000))
|
||||
vm:set_data(data)
|
||||
vm:write_to_map(data)
|
||||
vm:update_map()
|
||||
end
|
||||
nodenames = {"default:sapling"},
|
||||
interval = 10,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
local nu = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
local is_soil = minetest.get_item_group(nu, "soil")
|
||||
if is_soil == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.log("action", "A sapling grows into a tree at "..minetest.pos_to_string(pos))
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local minp, maxp = vm:read_from_map({x=pos.x-16, y=pos.y, z=pos.z-16}, {x=pos.x+16, y=pos.y+16, z=pos.z+16})
|
||||
local a = VoxelArea:new{MinEdge=minp, MaxEdge=maxp}
|
||||
local data = vm:get_data()
|
||||
default.grow_tree(data, a, pos, math.random(1, 4) == 1, math.random(1,100000))
|
||||
vm:set_data(data)
|
||||
vm:write_to_map(data)
|
||||
vm:update_map()
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:junglesapling"},
|
||||
interval = 10,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
local is_soil = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil
|
||||
if is_soil == nil or is_soil == 0 then return end
|
||||
print("A jungle sapling grows into a tree at "..minetest.pos_to_string(pos))
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local minp, maxp = vm:read_from_map({x=pos.x-16, y=pos.y-1, z=pos.z-16}, {x=pos.x+16, y=pos.y+16, z=pos.z+16})
|
||||
local a = VoxelArea:new{MinEdge=minp, MaxEdge=maxp}
|
||||
local data = vm:get_data()
|
||||
default.grow_jungletree(data, a, pos, math.random(1,100000))
|
||||
vm:set_data(data)
|
||||
vm:write_to_map(data)
|
||||
vm:update_map()
|
||||
end
|
||||
nodenames = {"default:junglesapling"},
|
||||
interval = 10,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
local nu = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
local is_soil = minetest.get_item_group(nu, "soil")
|
||||
if is_soil == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.log("action", "A jungle sapling grows into a tree at "..minetest.pos_to_string(pos))
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local minp, maxp = vm:read_from_map({x=pos.x-16, y=pos.y-1, z=pos.z-16}, {x=pos.x+16, y=pos.y+16, z=pos.z+16})
|
||||
local a = VoxelArea:new{MinEdge=minp, MaxEdge=maxp}
|
||||
local data = vm:get_data()
|
||||
default.grow_jungletree(data, a, pos, math.random(1,100000))
|
||||
vm:set_data(data)
|
||||
vm:write_to_map(data)
|
||||
vm:update_map()
|
||||
end
|
||||
})
|
||||
|
||||
--
|
||||
|
|
|
@ -362,7 +362,7 @@ function default.make_nyancat(pos, facedir, length)
|
|||
elseif facedir == 3 then
|
||||
tailvec.x = -1
|
||||
else
|
||||
print("default.make_nyancat(): Invalid facedir: "+dump(facedir))
|
||||
--print("default.make_nyancat(): Invalid facedir: "+dump(facedir))
|
||||
facedir = 0
|
||||
tailvec.z = 1
|
||||
end
|
||||
|
|
|
@ -220,6 +220,7 @@ minetest.register_node("default:clay", {
|
|||
minetest.register_node("default:brick", {
|
||||
description = "Brick Block",
|
||||
tiles = {"default_brick.png"},
|
||||
is_ground_content = false,
|
||||
groups = {cracky=3},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
@ -228,6 +229,7 @@ minetest.register_node("default:tree", {
|
|||
description = "Tree",
|
||||
tiles = {"default_tree_top.png", "default_tree_top.png", "default_tree.png"},
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_place = minetest.rotate_node
|
||||
|
@ -237,6 +239,7 @@ minetest.register_node("default:jungletree", {
|
|||
description = "Jungle Tree",
|
||||
tiles = {"default_jungletree_top.png", "default_jungletree_top.png", "default_jungletree.png"},
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_place = minetest.rotate_node
|
||||
|
@ -255,6 +258,7 @@ minetest.register_node("default:jungleleaves", {
|
|||
visual_scale = 1.3,
|
||||
tiles = {"default_jungleleaves.png"},
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
groups = {snappy=3, leafdecay=3, flammable=2, leaves=1},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
|
@ -316,6 +320,7 @@ minetest.register_node("default:leaves", {
|
|||
visual_scale = 1.3,
|
||||
tiles = {"default_leaves.png"},
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
groups = {snappy=3, leafdecay=3, flammable=2, leaves=1},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
|
@ -365,6 +370,7 @@ minetest.register_node("default:papyrus", {
|
|||
minetest.register_node("default:bookshelf", {
|
||||
description = "Bookshelf",
|
||||
tiles = {"default_wood.png", "default_wood.png", "default_bookshelf.png"},
|
||||
is_ground_content = false,
|
||||
groups = {choppy=3,oddly_breakable_by_hand=2,flammable=3},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
@ -376,6 +382,7 @@ minetest.register_node("default:glass", {
|
|||
inventory_image = minetest.inventorycube("default_glass.png"),
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {cracky=3,oddly_breakable_by_hand=3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
})
|
||||
|
@ -387,6 +394,7 @@ minetest.register_node("default:fence_wood", {
|
|||
inventory_image = "default_fence.png",
|
||||
wield_image = "default_fence.png",
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
|
||||
|
@ -403,6 +411,7 @@ minetest.register_node("default:rail", {
|
|||
wield_image = "default_rail.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
is_ground_content = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
-- but how to specify the dimensions for curved and sideways rails?
|
||||
|
@ -421,6 +430,7 @@ minetest.register_node("default:ladder", {
|
|||
paramtype2 = "wallmounted",
|
||||
walkable = false,
|
||||
climbable = true,
|
||||
is_ground_content = false,
|
||||
selection_box = {
|
||||
type = "wallmounted",
|
||||
--wall_top = = <default>
|
||||
|
@ -596,6 +606,7 @@ minetest.register_node("default:torch", {
|
|||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
light_source = LIGHT_MAX-1,
|
||||
selection_box = {
|
||||
|
@ -618,6 +629,7 @@ minetest.register_node("default:sign_wall", {
|
|||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
selection_box = {
|
||||
type = "wallmounted",
|
||||
|
@ -638,7 +650,7 @@ minetest.register_node("default:sign_wall", {
|
|||
--print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
|
||||
local meta = minetest.get_meta(pos)
|
||||
fields.text = fields.text or ""
|
||||
print((sender:get_player_name() or "").." wrote \""..fields.text..
|
||||
minetest.log("action", (sender:get_player_name() or "").." wrote \""..fields.text..
|
||||
"\" to sign at "..minetest.pos_to_string(pos))
|
||||
meta:set_string("text", fields.text)
|
||||
meta:set_string("infotext", '"'..fields.text..'"')
|
||||
|
@ -667,6 +679,7 @@ minetest.register_node("default:chest", {
|
|||
paramtype2 = "facedir",
|
||||
groups = {choppy=2,oddly_breakable_by_hand=2},
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -708,6 +721,7 @@ minetest.register_node("default:chest_locked", {
|
|||
paramtype2 = "facedir",
|
||||
groups = {choppy=2,oddly_breakable_by_hand=2},
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -811,6 +825,7 @@ minetest.register_node("default:furnace", {
|
|||
paramtype2 = "facedir",
|
||||
groups = {cracky=2},
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -881,6 +896,7 @@ minetest.register_node("default:furnace_active", {
|
|||
drop = "default:furnace",
|
||||
groups = {cracky=2, not_in_creative_inventory=1,hot=1},
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -997,7 +1013,7 @@ minetest.register_abm({
|
|||
-- take stuff from "src" list
|
||||
inv:set_stack("src", 1, aftercooked.items[1])
|
||||
else
|
||||
print("Could not insert '"..cooked.item:to_string().."'")
|
||||
--print("Could not insert '"..cooked.item:to_string().."'")
|
||||
end
|
||||
meta:set_string("src_time", 0)
|
||||
end
|
||||
|
@ -1126,6 +1142,7 @@ minetest.register_node("default:obsidian_glass", {
|
|||
drawtype = "glasslike",
|
||||
tiles = {"default_obsidian_glass.png"},
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
sunlight_propagates = true,
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
groups = {cracky=3,oddly_breakable_by_hand=3},
|
||||
|
@ -1145,6 +1162,7 @@ minetest.register_node("default:nyancat", {
|
|||
"default_nc_side.png", "default_nc_back.png", "default_nc_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2},
|
||||
is_ground_content = false,
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
@ -1155,6 +1173,7 @@ minetest.register_node("default:nyancat_rainbow", {
|
|||
"default_nc_rb.png", "default_nc_rb.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
||||
|
@ -1167,6 +1186,7 @@ minetest.register_node("default:sapling", {
|
|||
wield_image = "default_sapling.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
is_ground_content = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
|
||||
|
@ -1184,6 +1204,7 @@ minetest.register_node("default:apple", {
|
|||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
is_ground_content = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
|
||||
|
@ -1207,6 +1228,7 @@ minetest.register_node("default:dry_shrub", {
|
|||
wield_image = "default_dry_shrub.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
is_ground_content = true,
|
||||
buildable_to = true,
|
||||
groups = {snappy=3,flammable=3,attached_node=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
|
@ -1225,6 +1247,7 @@ minetest.register_node("default:grass_1", {
|
|||
wield_image = "default_grass_3.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
is_ground_content = true,
|
||||
buildable_to = true,
|
||||
groups = {snappy=3,flammable=3,flora=1,attached_node=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
|
|
|
@ -1,132 +1,190 @@
|
|||
-- Minetest 0.4 mod: player
|
||||
-- See README.txt for licensing and other information.
|
||||
|
||||
--
|
||||
-- Start of configuration area:
|
||||
--
|
||||
--[[
|
||||
|
||||
-- Player animation speed
|
||||
animation_speed = 30
|
||||
API
|
||||
---
|
||||
|
||||
default.player_register_model(name, def)
|
||||
^ Register a new model to be used by players.
|
||||
^ <name> is the model filename such as "character.x", "foo.b3d", etc.
|
||||
^ See Model Definition below for format of <def>.
|
||||
|
||||
default.registered_player_models[name]
|
||||
^ See Model Definition below for format.
|
||||
|
||||
default.player_set_model(player, model_name)
|
||||
^ <player> is a PlayerRef.
|
||||
^ <model_name> is a model registered with player_register_model.
|
||||
|
||||
default.player_set_animation(player, anim_name [, speed])
|
||||
^ <player> is a PlayerRef.
|
||||
^ <anim_name> is the name of the animation.
|
||||
^ <speed> is in frames per second. If nil, default from the model is used
|
||||
|
||||
default.player_set_textures(player, textures)
|
||||
^ <player> is a PlayerRef.
|
||||
^ <textures> is an array of textures
|
||||
^ If <textures> is nil, the default textures from the model def are used
|
||||
|
||||
default.player_get_animation(player)
|
||||
^ <player> is a PlayerRef.
|
||||
^ Returns a table containing fields "model", "textures" and "animation".
|
||||
^ Any of the fields of the returned table may be nil.
|
||||
|
||||
Model Definition
|
||||
----------------
|
||||
|
||||
model_def = {
|
||||
animation_speed = 30, -- Default animation speed, in FPS.
|
||||
textures = {"character.png", }, -- Default array of textures.
|
||||
visual_size = {x=1, y=1,}, -- Used to scale the model.
|
||||
animations = {
|
||||
-- <anim_name> = { x=<start_frame>, y=<end_frame>, },
|
||||
foo = { x= 0, y=19, },
|
||||
bar = { x=20, y=39, },
|
||||
-- ...
|
||||
},
|
||||
}
|
||||
|
||||
]]
|
||||
|
||||
-- Player animation blending
|
||||
-- Note: This is currently broken due to a bug in Irrlicht, leave at 0
|
||||
animation_blend = 0
|
||||
local animation_blend = 0
|
||||
|
||||
-- Default player appearance
|
||||
default_model = "character.x"
|
||||
default_textures = {"character.png", }
|
||||
default.registered_player_models = { }
|
||||
|
||||
-- Frame ranges for each player model
|
||||
function player_get_animations(model)
|
||||
if model == "character.x" then
|
||||
return {
|
||||
stand_START = 0,
|
||||
stand_END = 79,
|
||||
sit_START = 81,
|
||||
sit_END = 160,
|
||||
lay_START = 162,
|
||||
lay_END = 166,
|
||||
walk_START = 168,
|
||||
walk_END = 187,
|
||||
mine_START = 189,
|
||||
mine_END = 198,
|
||||
walk_mine_START = 200,
|
||||
walk_mine_END = 219
|
||||
}
|
||||
end
|
||||
-- Local for speed.
|
||||
local models = default.registered_player_models
|
||||
|
||||
function default.player_register_model(name, def)
|
||||
models[name] = def
|
||||
end
|
||||
|
||||
--
|
||||
-- End of configuration area.
|
||||
--
|
||||
-- Default player appearance
|
||||
default.player_register_model("character.x", {
|
||||
animation_speed = 30,
|
||||
textures = {"character.png", },
|
||||
animations = {
|
||||
-- Standard animations.
|
||||
stand = { x= 0, y= 79, },
|
||||
lay = { x=162, y=166, },
|
||||
walk = { x=168, y=187, },
|
||||
mine = { x=189, y=198, },
|
||||
walk_mine = { x=200, y=219, },
|
||||
-- Extra animations (not currently used by the game).
|
||||
sit = { x= 81, y=160, },
|
||||
},
|
||||
})
|
||||
|
||||
-- Player stats and animations
|
||||
local player_model = {}
|
||||
local player_textures = {}
|
||||
local player_anim = {}
|
||||
local player_sneak = {}
|
||||
local ANIM_STAND = 1
|
||||
local ANIM_SIT = 2
|
||||
local ANIM_LAY = 3
|
||||
local ANIM_WALK = 4
|
||||
local ANIM_WALK_MINE = 5
|
||||
local ANIM_MINE = 6
|
||||
|
||||
function default.player_get_animation(player)
|
||||
local name = player:get_player_name()
|
||||
return {
|
||||
model = player_model[name],
|
||||
textures = player_textures[name],
|
||||
animation = player_anim[name],
|
||||
}
|
||||
end
|
||||
|
||||
-- Called when a player's appearance needs to be updated
|
||||
function player_update_visuals(pl)
|
||||
local name = pl:get_player_name()
|
||||
function default.player_set_model(player, model_name)
|
||||
local name = player:get_player_name()
|
||||
local model = models[model_name]
|
||||
if model then
|
||||
if player_model[name] == model_name then
|
||||
return
|
||||
end
|
||||
player:set_properties({
|
||||
mesh = model_name,
|
||||
textures = player_textures[name] or model.textures,
|
||||
visual = "mesh",
|
||||
visual_size = model.visual_size or {x=1, y=1},
|
||||
})
|
||||
default.player_set_animation(player, "stand")
|
||||
else
|
||||
player:set_properties({
|
||||
textures = { "player.png", "player_back.png", },
|
||||
visual = "upright_sprite",
|
||||
})
|
||||
end
|
||||
player_model[name] = model_name
|
||||
end
|
||||
|
||||
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)
|
||||
function default.player_set_textures(player, textures)
|
||||
local name = player:get_player_name()
|
||||
player_textures[name] = textures
|
||||
player:set_properties({textures = textures,})
|
||||
end
|
||||
|
||||
function default.player_set_animation(player, anim_name, speed)
|
||||
local name = player:get_player_name()
|
||||
if player_anim[name] == anim_name then
|
||||
return
|
||||
end
|
||||
local model = player_model[name] and models[player_model[name]]
|
||||
if not (model and model.animations[anim_name]) then
|
||||
return
|
||||
end
|
||||
local anim = model.animations[anim_name]
|
||||
player_anim[name] = anim_name
|
||||
player:set_animation(anim, speed or model.animation_speed, animation_blend)
|
||||
end
|
||||
|
||||
-- Update appearance when the player joins
|
||||
minetest.register_on_joinplayer(player_update_visuals)
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
default.player_set_model(player, "character.x")
|
||||
end)
|
||||
|
||||
-- Localize for better performance.
|
||||
local player_set_animation = default.player_set_animation
|
||||
|
||||
-- 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
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local name = player:get_player_name()
|
||||
local model_name = player_model[name]
|
||||
local model = model_name and models[model_name]
|
||||
if model then
|
||||
local controls = player:get_player_control()
|
||||
local walking = false
|
||||
local animation_speed_mod = model.animation_speed or 30
|
||||
|
||||
-- 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 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
|
||||
-- Determine if the player is sneaking, and reduce animation speed if so
|
||||
if controls.sneak then
|
||||
animation_speed_mod = animation_speed_mod / 2
|
||||
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_LAY then
|
||||
pl:set_animation({x=anim.lay_START, y=anim.lay_END}, animation_speed_mod, animation_blend)
|
||||
player_anim[name] = ANIM_LAY
|
||||
-- Apply animations based on what the player is doing
|
||||
if player:get_hp() == 0 then
|
||||
player_set_animation(player, "lay")
|
||||
elseif walking then
|
||||
if player_sneak[name] ~= controls.sneak then
|
||||
player_anim[name] = nil
|
||||
player_sneak[name] = controls.sneak
|
||||
end
|
||||
if controls.LMB then
|
||||
player_set_animation(player, "walk_mine", animation_speed_mod)
|
||||
else
|
||||
player_set_animation(player, "walk", animation_speed_mod)
|
||||
end
|
||||
elseif controls.LMB then
|
||||
player_set_animation(player, "mine")
|
||||
else
|
||||
player_set_animation(player, "stand", animation_speed_mod)
|
||||
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
|
||||
end)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
minetest.register_on_newplayer(function(player)
|
||||
print("on_newplayer")
|
||||
--print("on_newplayer")
|
||||
if minetest.setting_getbool("give_initial_stuff") then
|
||||
print("giving give_initial_stuff to player")
|
||||
minetest.log("action", "Giving initial stuff to player "..player:get_player_name())
|
||||
player:get_inventory():add_item('main', 'default:pick_steel')
|
||||
player:get_inventory():add_item('main', 'default:torch 99')
|
||||
player:get_inventory():add_item('main', 'default:axe_steel')
|
||||
|
|
Loading…
Reference in New Issue