From 6c917d3cff1b2a6a6ebdce334f9c343483b8e866 Mon Sep 17 00:00:00 2001 From: rudzik8 Date: Thu, 24 Feb 2022 07:24:56 +0700 Subject: [PATCH] Initial files --- README.md | 6 ++++-- init.lua | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ mod.conf | 3 +++ 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 init.lua create mode 100644 mod.conf diff --git a/README.md b/README.md index 33b78b2..3cbafab 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ -# mcl_cozy +# MineClone2 Get Comfortable +Adds commands to /lay or /sit to the MineClone 2 (5) game -Adds commands to /lay or /sit to the MineClone 2 (5) game (port of the cozy mod for MTG by everamzah) \ No newline at end of file +Port of [cozy mod](https://forum.minetest.net/viewtopic.php?f=11&t=14143) for Minetest Game by everamzah +Currently, just replaced default -> mcl_player so it works, but i think i'll add/change something else in the future diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..8fcb9a3 --- /dev/null +++ b/init.lua @@ -0,0 +1,53 @@ +minetest.register_globalstep(function(dtime) + local players = minetest.get_connected_players() + for i=1, #players do + local name = players[i]:get_player_name() + if mcl_player.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) + mcl_player.player_attached[name] = false + mcl_player.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 mcl_player.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) + mcl_player.player_attached[name] = false + mcl_player.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) + mcl_player.player_attached[name] = true + mcl_player.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 mcl_player.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) + mcl_player.player_attached[name] = false + mcl_player.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) + mcl_player.player_attached[name] = true + mcl_player.player_set_animation(player, "lay", 0) + end + end +}) diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..1ecabcd --- /dev/null +++ b/mod.conf @@ -0,0 +1,3 @@ +name = mcl_cozy +description = Sit and lay using chat commands +depends = mcl_player