Add spawn command, fix hand

This commit is contained in:
MoNTE48 2019-05-31 20:58:19 +02:00
parent a43e85636e
commit 6b2c8ca1fd
4 changed files with 96 additions and 58 deletions

View File

@ -992,3 +992,43 @@ minetest.register_chatcommand("killme", {
end
})
local spawn_spawnpos = minetest.setting_get_pos("static_spawnpoint")
minetest.register_chatcommand("spawn", {
params = "",
description = "Teleport to the spawn point",
func = function(name, param)
local player = minetest.get_player_by_name(name)
if not player then
return false, "Player not found"
end
if spawn_spawnpos then
player:setpos(spawn_spawnpos)
return true, "Teleporting to spawn..."
else
return false, "The spawn point is not set!"
end
end,
})
minetest.register_chatcommand("setspawn", {
params = "",
description = "Sets the spawn point to your current position",
privs = {server = true},
func = function(name, param)
local player = minetest.get_player_by_name(name)
if not player then
return false, "Player not found"
end
local pos = player:getpos()
local x = pos.x
local y = pos.y
local z = pos.z
local pos_string = x..","..y..","..z
local pos_string_2 = "Setting spawn point to ("..x..", "..y..", "..z..")"
minetest.setting_set("static_spawnpoint",pos_string)
spawn_spawnpos = pos
minetest.setting_save()
return true, pos_string_2
end,
})

View File

@ -8,35 +8,6 @@ end
dofile(minetest.get_modpath("creative") .. "/inventory.lua")
if creative_mode_cache then
-- Dig time is modified according to difference (leveldiff) between tool
-- 'maxlevel' and node 'level'. Digtime is divided by the larger of
-- leveldiff and 1.
-- To speed up digging in creative, hand 'maxlevel' and 'digtime' have been
-- increased such that nodes of differing levels have an insignificant
-- effect on digtime.
local digtime = 128
local caps = {times = {digtime, digtime, digtime}, uses = 0, maxlevel = 192}
minetest.register_item(":", {
type = "none",
wield_image = "blank.png",
range = 10,
tool_capabilities = {
full_punch_interval = 0.9,
max_drop_level = 3,
groupcaps = {
crumbly = caps,
cracky = caps,
snappy = caps,
choppy = caps,
oddly_breakable_by_hand = caps,
},
damage_groups = {fleshy = 5},
}
})
end
-- Unlimited node placement
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
if placer and placer:is_player() then

View File

@ -1,23 +1,5 @@
-- mods/default/tools.lua
-- The hand
minetest.register_item(":", {
type = "none",
wield_image = "blank.png",
tool_capabilities = {
full_punch_interval = 0.9,
max_drop_level = 0,
groupcaps = {
crumbly = {times={[2]=3.00, [3]=0.70}, uses=0, maxlevel=1},
snappy = {times={[3]=0.40}, uses=0, maxlevel=1},
choppy = {times={[3]=3}},
cracky = {times={[10]=10, [3]=7.5}},
oddly_breakable_by_hand = {times={[0]=90.00,[1]=7.00,[2]=3.00,[3]=3*3.33,[4]=250,[5]=999999.0,[6]=0.5}, uses=0, maxlevel=5}
},
damage_groups = {fleshy=1},
}
})
--
-- Picks
--

View File

@ -1,5 +1,11 @@
dofile(minetest.get_modpath("player_api") .. "/api.lua")
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
function player_api.is_enabled_for(name)
return creative_mode_cache
end
-- Default player appearance
player_api.register_model("character.b3d", {
animation_speed = 30,
@ -18,16 +24,56 @@ player_api.register_model("character.b3d", {
eye_height = 1.47,
})
minetest.register_node("player_api:hand", {
tiles = {"character.png"},
wield_scale = {x = 1, y = 1, z = 0.7},
paramtype = "light",
drawtype = "mesh",
mesh = "hand.b3d",
inventory_image = "blank.png",
drop = "",
node_placement_prediction = "",
if creative_mode_cache then
local digtime = 128
local caps = {times = {digtime, digtime, digtime}, uses = 0, maxlevel = 192}
minetest.register_node("player_api:hand", {
tiles = {"character.png"},
wield_scale = {x = 1, y = 1, z = 0.7},
paramtype = "light",
drawtype = "mesh",
mesh = "hand.b3d",
inventory_image = "blank.png",
drop = "",
node_placement_prediction = "",
range = 10,
tool_capabilities = {
full_punch_interval = 0.9,
max_drop_level = 3,
groupcaps = {
crumbly = caps,
cracky = caps,
snappy = caps,
choppy = caps,
oddly_breakable_by_hand = caps,
},
damage_groups = {fleshy = 5},
}
})
else
minetest.register_node("player_api:hand", {
tiles = {"character.png"},
wield_scale = {x = 1, y = 1, z = 0.7},
paramtype = "light",
drawtype = "mesh",
mesh = "hand.b3d",
inventory_image = "blank.png",
drop = "",
node_placement_prediction = "",
tool_capabilities = {
full_punch_interval = 0.9,
max_drop_level = 0,
groupcaps = {
crumbly = {times={[2]=3.00, [3]=0.70}, uses=0, maxlevel=1},
snappy = {times={[3]=0.40}, uses=0, maxlevel=1},
choppy = {times={[3]=3}},
cracky = {times={[10]=10, [3]=7.5}},
oddly_breakable_by_hand = {times = {[0]=90.00, [1]=7.00, [2]=3.00, [3]=3*3.33, [4]=250, [5]=999999.0, [6]=0.5}, uses = 0, maxlevel = 5}
},
damage_groups = {fleshy = 1},
}
})
end
-- Update appearance when the player joins
minetest.register_on_joinplayer(function(player)
@ -38,8 +84,7 @@ minetest.register_on_joinplayer(function(player)
{x = 168, y = 187},
{x = 189, y = 198},
{x = 200, y = 219},
30
)
30)
player:hud_set_hotbar_itemcount(9)
player:hud_set_hotbar_image("gui_hotbar.png")