commit cd166a75498d25b51db6d323e129b1c2a29ce694 Author: Auke Kok Date: Fri May 27 23:10:48 2016 -0700 Initial checkin diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..6cf9010 --- /dev/null +++ b/README.txt @@ -0,0 +1,6 @@ + +Description: Adds commands to /lay or /sit. +License: WTFPL +Depends: default + +https://forum.minetest.net/viewtopic.php?f=9&t=14143 diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +default diff --git a/description.txt b/description.txt new file mode 100644 index 0000000..36e7d25 --- /dev/null +++ b/description.txt @@ -0,0 +1 @@ +Adds sitting down, and lying down player animations. diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..dbcf73f --- /dev/null +++ b/init.lua @@ -0,0 +1,54 @@ +minetest.register_globalstep(function(dtime) + local players = minetest.get_connected_players() + for i=1, #players do + local name = players[i]:get_player_name() + if default.player_attached[name] and not players[i]:get_attach() and + (players[i]:get_player_control().up == true or + players[i]:get_player_control().down == true or + players[i]:get_player_control().left == true or + players[i]:get_player_control().right == true or + players[i]:get_player_control().jump == true) then + players[i]:set_eye_offset({x=0, y=0, z=0}, {x=0, y=0, z=0}) + players[i]:set_physics_override(1, 1, 1) + default.player_attached[name] = false + default.player_set_animation(players[i], "stand", 30) + end + end +end) + +minetest.register_chatcommand("sit", { + description = "Sit down", + func = function(name) + local player = minetest.get_player_by_name(name) + if default.player_attached[name] then + player:set_eye_offset({x=0, y=0, z=0}, {x=0, y=0, z=0}) + player:set_physics_override(1, 1, 1) + default.player_attached[name] = false + default.player_set_animation(player, "stand", 30) + else + player:set_eye_offset({x=0, y=-7, z=2}, {x=0, y=0, z=0}) + player:set_physics_override(0, 0, 0) + default.player_attached[name] = true + default.player_set_animation(player, "sit", 30) + end + end +}) + +minetest.register_chatcommand("lay", { + description = "Lay down", + func = function(name) + local player = minetest.get_player_by_name(name) + if default.player_attached[name] then + player:set_eye_offset({x=0, y=0, z=0}, {x=0, y=0, z=0}) + player:set_physics_override(1, 1, 1) + default.player_attached[name] = false + default.player_set_animation(player, "stand", 30) + else + player:set_eye_offset({x=0, y=-13, z=0}, {x=0, y=0, z=0}) + player:set_physics_override(0, 0, 0) + default.player_attached[name] = true + default.player_set_animation(player, "lay", 0) + end + end +}) + diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..48d71d3 --- /dev/null +++ b/mod.conf @@ -0,0 +1 @@ +name = cozy