[MOD] Lose Items on Death
[MOD] Lose Items on Death
Description
When a player dies, he rolls for every item. If the roll succeed he keeps his item, otherwise the item is removed or the amount dramatically decreased.
Latest master branch from 20120106 is required.
Code
https://github.com/basicinside/dev-mine ... s/die_hard
Download ZIP
Download TAR.GZ
Updates
Fix: Wrong Interval due to rounding. Thanks redcrab.
When a player dies, he rolls for every item. If the roll succeed he keeps his item, otherwise the item is removed or the amount dramatically decreased.
Latest master branch from 20120106 is required.
Code
https://github.com/basicinside/dev-mine ... s/die_hard
Download ZIP
Download TAR.GZ
Updates
Fix: Wrong Interval due to rounding. Thanks redcrab.
Last edited by robin on Fri Jan 06, 2012 13:21, edited 1 time in total.
- Hackeridze
- Member
- Posts: 310
- Joined: Thu Nov 03, 2011 13:35
Very good idea! This will make players think twice before going to death)robin wrote:Description: When a player dies, he rolls for every item. If the roll succeed he keeps his item, otherwise the item is removed or the amount dramatically decreased.
Code: data/mods/die/init.luaThis works only with the suggested patch in the Development Section.Code: Select all
-- Minetest Die Mod math.randomseed(os.time()) -- You need to roll ONE out of ITEM_LOSE_DICE local ITEM_LOSE_DICE = 4 minetest.register_on_dieplayer(function(player) local inventorylist=player:inventory_get_list("main") local i=1 while inventorylist[i]~=nil do if math.random(1, ITEM_LOSE_DICE) ~= 1 and (inventorylist[i]~="") then print(inventorylist[i]) local bnumbeg, bnumend=string.find(inventorylist[i], '" ') local oldvalue=tonumber(string.sub(inventorylist[i], bnumend)) oldvalue=math.random(0,(oldvalue/3)-1) local newstring=string.sub(inventorylist[i], 1, bnumend) newstring=(newstring..tostring(oldvalue)) if oldvalue == 0 then inventorylist[i]="" else inventorylist[i]=newstring end end i=i+1 end player:inventory_set_list("main", inventorylist) return end)
Waiting for adding patch in upstream.
Last edited by Hackeridze on Thu Jan 05, 2012 17:32, edited 1 time in total.
My game: RTMG
GENTOO USER
GENTOO USER
+1
Death is now somethething else that only a "teleport to spawn location"
Should be part of default mods
Death is now somethething else that only a "teleport to spawn location"
Should be part of default mods
0.4 for serious builder click here
Dedicated Minetest redcrab server forum at http://minetestbb.suret.net
It's nice to be important but it is more important to be nice.
Dedicated Minetest redcrab server forum at http://minetestbb.suret.net
It's nice to be important but it is more important to be nice.
failed to execute on latest git (06/01/2012)
"/data/mods/die/init.lua:16: bad argument #2 to 'random' (interval is empty)"
"/data/mods/die/init.lua:16: bad argument #2 to 'random' (interval is empty)"
Code: Select all
09:39:22: ACTION[ServerThread]: redcrab damaged by 43 hp at (-10.462,5.579,-14.641)
09:39:22: INFO[ServerThread]: Server::HandlePlayerHP(): Player redcrab dies
09:39:22: INFO[ServerThread]: Deprecated: inventory_get_list
09:39:22: ERROR[ServerThread]: ERROR: An unhandled exception occurred: LuaError: error: ...jects/Minetest-staging/bin/../data/mods/die/init.lua:16: bad argument #2 to 'random' (interval is empty)
09:39:22: ERROR[ServerThread]: stack traceback:
In thread b67ffb70:
/home/xxx/Projects/Minetest-staging/src/server.cpp:115: virtual void* ServerThread::Thread(): Assertion '0' failed.
Debug stacks:
DEBUG STACK FOR THREAD b67ffb70:
#0 virtual void* ServerThread::Thread()
(Leftover data: #1 void Server::Receive())
(Leftover data: #2 void Server::ProcessData(irr::u8*, irr::u32, irr::u16))
(Leftover data: #3 RemoteClient* Server::getClient(irr::u16))
(Leftover data: #4 void BlockEmergeQueue::addBlock(irr::u16, v3s16, irr::u8))
DEBUG STACK FOR THREAD b74786d0:
#0 int main(int, char**)
#1 void dedicated_server_loop(Server&, bool&)
(Leftover data: #2 void Server::step(float))
Last edited by redcrab on Fri Jan 06, 2012 08:44, edited 1 time in total.
0.4 for serious builder click here
Dedicated Minetest redcrab server forum at http://minetestbb.suret.net
It's nice to be important but it is more important to be nice.
Dedicated Minetest redcrab server forum at http://minetestbb.suret.net
It's nice to be important but it is more important to be nice.
Thanks redcrab. It was a wrong interval for math.random given. it should work now.
Thanks Jeija. You're right I looked up inventory handling from your mod and copied the code with some small modifications.
Thanks Jeija. You're right I looked up inventory handling from your mod and copied the code with some small modifications.
Last edited by robin on Fri Jan 06, 2012 11:46, edited 1 time in total.
- Hackeridze
- Member
- Posts: 310
- Joined: Thu Nov 03, 2011 13:35
unknown wrote: but I do not see any differences in your first post code... ? where is the fix ?
Code: Select all
oldvalue=math.random(0,(oldvalue/3)-1)
Code: Select all
oldvalue=math.random(0,(oldvalue/3))
Sorry but same issue, I compare and the file is identical as before ... where is the fix ?robin wrote:Thanks redcrab. It was a wrong interval for math.random given. it should work now.
Thanks Jeija. You're right I looked up inventory handling from your mod and copied the code with some small modifications.
0.4 for serious builder click here
Dedicated Minetest redcrab server forum at http://minetestbb.suret.net
It's nice to be important but it is more important to be nice.
Dedicated Minetest redcrab server forum at http://minetestbb.suret.net
It's nice to be important but it is more important to be nice.
- Hackeridze
- Member
- Posts: 310
- Joined: Thu Nov 03, 2011 13:35
You can get fixed version from RTMMP. Maybe robin just forgot to git push.redcrab wrote:Sorry but same issue, I compare and the file is identical as before ... where is the fix ?robin wrote:Thanks redcrab. It was a wrong interval for math.random given. it should work now.
Thanks Jeija. You're right I looked up inventory handling from your mod and copied the code with some small modifications.
Last edited by Hackeridze on Fri Jan 06, 2012 23:14, edited 1 time in total.
My game: RTMG
GENTOO USER
GENTOO USER
Thx it works nowrobin wrote:Argh. Somehow the patch did not make it into git. I'm sorry. It should work now.
0.4 for serious builder click here
Dedicated Minetest redcrab server forum at http://minetestbb.suret.net
It's nice to be important but it is more important to be nice.
Dedicated Minetest redcrab server forum at http://minetestbb.suret.net
It's nice to be important but it is more important to be nice.
+1hijera wrote:cool mod... But what it could be better if things will be dropped on death place, like in MC.
0.4 for serious builder click here
Dedicated Minetest redcrab server forum at http://minetestbb.suret.net
It's nice to be important but it is more important to be nice.
Dedicated Minetest redcrab server forum at http://minetestbb.suret.net
It's nice to be important but it is more important to be nice.
Who is online
Users browsing this forum: No registered users and 47 guests