OldCoder wrote:
Gunship Penguin, thank you.
1. Here's a patch for "hungry_games" git-current that may be useful. I learned about two problems fairly quickly: (a) there were random teleports to underground (b) inventory accumulated from match to match; this made a "cheat" possible.
The "cheat" involved quitting immediately before dying. By doing this, players were able to build up large inventories.
This patch is an attempt to fix both problems.
2. I'd like to reset armor as well as inventory. However, I haven't learned enough about the 3D Armor mod yet to attempt this.Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
--- hungry_games-git-150522.old/mods/hungry_games/engine.lua
+++ hungry_games-git-150522/mods/hungry_games/engine.lua
@@ -23,6 +23,12 @@
minetest.set_player_privs(name, privs)
player:set_hp(20)
spawning.spawn(player, "lobby")
+
+ -- Experimental code to reset inventory
+ inv = player:get_inventory()
+ if inv then
+ inv:set_list("main", {})
+ end
end)
end
registrants = {}
@@ -233,7 +239,7 @@
return true
end)
-minetest.register_on_joinplayer(function(player)
+function joinmove (player)
local name = player:get_player_name()
local privs = minetest.get_player_privs(name)
privs.vote = true
@@ -244,6 +250,10 @@
minetest.set_player_privs(name, privs)
minetest.chat_send_player(name, "You are now spectating")
spawning.spawn(player, "lobby")
+end
+
+minetest.register_on_joinplayer(function(player)
+ minetest.after (2, joinmove, player)
end)
minetest.register_on_newplayer(function(player)
Problems 1 and 2 have already both been fixed in my fork of hungry_games. Player inventories (Including crafting and armor inventories) are cleared after a player dies, and just before a match starts. Their inventories are also dropped if they leave the game, making it impossible to build up a large inventory by closing minetest.
See here => https://github.com/gunshippenguin/hungry_games