Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
8ca285c9f5 | |||
|
a443cb4358 | ||
|
de5fc3240c | ||
|
da8ecc1d68 | ||
|
1965e21b1e | ||
|
7d2827522c | ||
|
d151ba7ec9 | ||
|
b93bc0673a | ||
|
19c120b5b7 |
13
README.txt
13
README.txt
@@ -4,6 +4,7 @@ See license.txt for license information.
|
|||||||
|
|
||||||
Provides an API to allow multiple mods to set player models and textures.
|
Provides an API to allow multiple mods to set player models and textures.
|
||||||
Also sets the default model, texture, and player flags.
|
Also sets the default model, texture, and player flags.
|
||||||
|
This mod is only for content related to the Player API and the player object.
|
||||||
|
|
||||||
Authors of source code
|
Authors of source code
|
||||||
----------------------
|
----------------------
|
||||||
@@ -16,17 +17,13 @@ stujones11 (CC BY-SA 3.0):
|
|||||||
character.b3d
|
character.b3d
|
||||||
character.blend -- Both derived from a model by MirceaKitsune (CC BY-SA 3.0)
|
character.blend -- Both derived from a model by MirceaKitsune (CC BY-SA 3.0)
|
||||||
|
|
||||||
|
An0n3m0us (CC BY-SA 3.0):
|
||||||
|
character.b3d
|
||||||
|
character.blend -- Player animation improvement
|
||||||
|
|
||||||
Jordach (CC BY-SA 3.0):
|
Jordach (CC BY-SA 3.0):
|
||||||
character.png
|
character.png
|
||||||
|
|
||||||
paramat (CC BY-SA 3.0):
|
|
||||||
gui_hotbar.png
|
|
||||||
gui_hotbar_selected.png
|
|
||||||
|
|
||||||
celeron55, Perttu Ahola <celeron55@gmail.com> (CC BY-SA 3.0):
|
celeron55, Perttu Ahola <celeron55@gmail.com> (CC BY-SA 3.0):
|
||||||
player.png
|
player.png
|
||||||
player_back.png
|
player_back.png
|
||||||
|
|
||||||
sonictechtonic (CC BY 3.0):
|
|
||||||
https://www.freesound.org/people/sonictechtonic/sounds/241872/
|
|
||||||
player_damage.ogg
|
|
||||||
|
27
api.lua
27
api.lua
@@ -54,6 +54,7 @@ function player_api.set_model(player, model_name)
|
|||||||
player:set_properties({
|
player:set_properties({
|
||||||
textures = {"player.png", "player_back.png"},
|
textures = {"player.png", "player_back.png"},
|
||||||
visual = "upright_sprite",
|
visual = "upright_sprite",
|
||||||
|
visual_size = {x = 1, y = 2},
|
||||||
collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.75, 0.3},
|
collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.75, 0.3},
|
||||||
stepheight = 0.6,
|
stepheight = 0.6,
|
||||||
eye_height = 1.625,
|
eye_height = 1.625,
|
||||||
@@ -95,22 +96,25 @@ end)
|
|||||||
local player_set_animation = player_api.set_animation
|
local player_set_animation = player_api.set_animation
|
||||||
local player_attached = player_api.player_attached
|
local player_attached = player_api.player_attached
|
||||||
|
|
||||||
|
-- Prevent knockback for attached players
|
||||||
|
local old_calculate_knockback = minetest.calculate_knockback
|
||||||
|
function minetest.calculate_knockback(player, ...)
|
||||||
|
if player_attached[player:get_player_name()] then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return old_calculate_knockback(player, ...)
|
||||||
|
end
|
||||||
|
|
||||||
-- Check each player and apply animations
|
-- Check each player and apply animations
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function()
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local model_name = player_model[name]
|
local model_name = player_model[name]
|
||||||
local model = model_name and models[model_name]
|
local model = model_name and models[model_name]
|
||||||
if model and not player_attached[name] then
|
if model and not player_attached[name] then
|
||||||
local controls = player:get_player_control()
|
local controls = player:get_player_control()
|
||||||
local walking = false
|
|
||||||
local animation_speed_mod = model.animation_speed or 30
|
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 sneaking, and reduce animation speed if so
|
-- Determine if the player is sneaking, and reduce animation speed if so
|
||||||
if controls.sneak then
|
if controls.sneak then
|
||||||
animation_speed_mod = animation_speed_mod / 2
|
animation_speed_mod = animation_speed_mod / 2
|
||||||
@@ -119,18 +123,19 @@ minetest.register_globalstep(function(dtime)
|
|||||||
-- Apply animations based on what the player is doing
|
-- Apply animations based on what the player is doing
|
||||||
if player:get_hp() == 0 then
|
if player:get_hp() == 0 then
|
||||||
player_set_animation(player, "lay")
|
player_set_animation(player, "lay")
|
||||||
elseif walking then
|
-- Determine if the player is walking
|
||||||
|
elseif controls.up or controls.down or controls.left or controls.right then
|
||||||
if player_sneak[name] ~= controls.sneak then
|
if player_sneak[name] ~= controls.sneak then
|
||||||
player_anim[name] = nil
|
player_anim[name] = nil
|
||||||
player_sneak[name] = controls.sneak
|
player_sneak[name] = controls.sneak
|
||||||
end
|
end
|
||||||
if controls.LMB then
|
if controls.LMB or controls.RMB then
|
||||||
player_set_animation(player, "walk_mine", animation_speed_mod)
|
player_set_animation(player, "walk_mine", animation_speed_mod)
|
||||||
else
|
else
|
||||||
player_set_animation(player, "walk", animation_speed_mod)
|
player_set_animation(player, "walk", animation_speed_mod)
|
||||||
end
|
end
|
||||||
elseif controls.LMB then
|
elseif controls.LMB or controls.RMB then
|
||||||
player_set_animation(player, "mine")
|
player_set_animation(player, "mine", animation_speed_mod)
|
||||||
else
|
else
|
||||||
player_set_animation(player, "stand", animation_speed_mod)
|
player_set_animation(player, "stand", animation_speed_mod)
|
||||||
end
|
end
|
||||||
|
4
init.lua
4
init.lua
@@ -1,3 +1,5 @@
|
|||||||
|
-- player/init.lua
|
||||||
|
|
||||||
dofile(minetest.get_modpath("player_api") .. "/api.lua")
|
dofile(minetest.get_modpath("player_api") .. "/api.lua")
|
||||||
|
|
||||||
-- Default player appearance
|
-- Default player appearance
|
||||||
@@ -29,6 +31,4 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
{x = 200, y = 219},
|
{x = 200, y = 219},
|
||||||
30
|
30
|
||||||
)
|
)
|
||||||
player:hud_set_hotbar_image("gui_hotbar.png")
|
|
||||||
player:hud_set_hotbar_selected_image("gui_hotbar_selected.png")
|
|
||||||
end)
|
end)
|
||||||
|
33
license.txt
33
license.txt
@@ -22,7 +22,7 @@ Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
|||||||
Copyright (C) 2011-2018 celeron55, Perttu Ahola <celeron55@gmail.com>
|
Copyright (C) 2011-2018 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||||
Copyright (C) 2012-2018 Jordach
|
Copyright (C) 2012-2018 Jordach
|
||||||
Copyright (C) 2018 stujones11
|
Copyright (C) 2018 stujones11
|
||||||
Copyright (C) 2018 paramat
|
Copyright (C) 2019 An0n3m0us
|
||||||
|
|
||||||
You are free to:
|
You are free to:
|
||||||
Share — copy and redistribute the material in any medium or format.
|
Share — copy and redistribute the material in any medium or format.
|
||||||
@@ -51,34 +51,3 @@ rights may limit how you use the material.
|
|||||||
|
|
||||||
For more details:
|
For more details:
|
||||||
http://creativecommons.org/licenses/by-sa/3.0/
|
http://creativecommons.org/licenses/by-sa/3.0/
|
||||||
|
|
||||||
------------------------------------
|
|
||||||
|
|
||||||
Attribution 3.0 Unported (CC BY 3.0)
|
|
||||||
Copyright (C) 2014-2018 sonictechtonic
|
|
||||||
|
|
||||||
You are free to:
|
|
||||||
Share — copy and redistribute the material in any medium or format.
|
|
||||||
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
|
|
||||||
The licensor cannot revoke these freedoms as long as you follow the license terms.
|
|
||||||
|
|
||||||
Under the following terms:
|
|
||||||
|
|
||||||
Attribution — You must give appropriate credit, provide a link to the license, and
|
|
||||||
indicate if changes were made. You may do so in any reasonable manner, but not in any way
|
|
||||||
that suggests the licensor endorses you or your use.
|
|
||||||
|
|
||||||
No additional restrictions — You may not apply legal terms or technological measures that
|
|
||||||
legally restrict others from doing anything the license permits.
|
|
||||||
|
|
||||||
Notices:
|
|
||||||
|
|
||||||
You do not have to comply with the license for elements of the material in the public
|
|
||||||
domain or where your use is permitted by an applicable exception or limitation.
|
|
||||||
No warranties are given. The license may not give you all of the permissions necessary
|
|
||||||
for your intended use. For example, other rights such as publicity, privacy, or moral
|
|
||||||
rights may limit how you use the material.
|
|
||||||
|
|
||||||
For more details:
|
|
||||||
http://creativecommons.org/licenses/by/3.0/
|
|
||||||
|
|
||||||
|
2
mod.conf
Normal file
2
mod.conf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
name = player_api
|
||||||
|
description = Minetest Game mod: player_api
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 411 B |
Binary file not shown.
Before Width: | Height: | Size: 175 B |
Reference in New Issue
Block a user