Armor drop on death

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

Armor drop on death

by mcfan » Sat Mar 29, 2014 12:10

I have a pvp server and I've installed the death mod on it, but when someone dies their armor doesn't drop. I tried copying the code and changing it for each armor slot, but all it does is duplicate the armor. why won't it work?
Love MINECRAFT... will settle for Minetest
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Sat Mar 29, 2014 17:12

Please, is there anyone who can help me?
Love MINECRAFT... will settle for Minetest
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

by Krock » Sat Mar 29, 2014 18:32

mcfan wrote:Please, is there anyone who can help me?

What did you download? From where?
What is the source code? What did you change in it?
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Sat Mar 29, 2014 19:05

Love MINECRAFT... will settle for Minetest
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Sat Mar 29, 2014 19:06

I copied it and added 1 for each armor space and revised it. and tried 100 different ways. one deleted the armor. another duplicated it. and another crashed minetest! lol
Love MINECRAFT... will settle for Minetest
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Sat Mar 29, 2014 19:09

https://forum.minetest.net/viewtopic.php?id=4654 - my armor mod. It is the one that uses shields (which I don't like). lol
Love MINECRAFT... will settle for Minetest
 

User avatar
minermoder27
Member
 
Posts: 127
Joined: Wed Nov 20, 2013 23:24
GitHub: ZNixian
In-game: minermoder27

by minermoder27 » Sun Mar 30, 2014 07:40

If you do not like shields, just delete the folder called shields

As for dropping the armor, get the player's armor inventory with
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
minetest.get_inventory({type="detached", name=player:get_player_name().."_armor"})
and then just call drop() for each item
My best mods:
Buildtest
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Sun Mar 30, 2014 11:17

Isn't there a armor mod just like it with boots though? And thanks, I'll try it.
Love MINECRAFT... will settle for Minetest
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Tue Apr 01, 2014 11:46

Here is what I did. It didn't work though.

minetest.register_on_dieplayer(function(player)

minetest.get_inventory({type="detached", name=player:get_player_name().."_armor"})

local pos = player:getpos()

for i,stack in ipairs(inv:get_list("_armor")) do

local x = math.random(0, 6)/3

local z = math.random(0, 6)/3

pos.x = pos.x + x

pos.z = pos.z + z

minetest.env:add_item(pos, stack)

stack:clear()

inv:set_stack("detached", i, stack)

pos.x = pos.x - x

pos.z = pos.z - z

end

end)
Love MINECRAFT... will settle for Minetest
 

User avatar
minermoder27
Member
 
Posts: 127
Joined: Wed Nov 20, 2013 23:24
GitHub: ZNixian
In-game: minermoder27

by minermoder27 » Wed Apr 02, 2014 19:45

mcfan wrote:Here is what I did. It didn't work though.

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
minetest.register_on_dieplayer(function(player)
   
minetest.get_inventory({type="detached", name=player:get_player_name().."_armor"})
   
    local pos = player:getpos()
   
    for i,stack in ipairs(inv:get_list("_armor")) do
       
        local x = math.random(0, 6)/3
       
        local z = math.random(0, 6)/3
       
        pos.x = pos.x + x
       
        pos.z = pos.z + z
       
        minetest.env:add_item(pos, stack)
       
        stack:clear()
       
        inv:set_stack("detached", i, stack)
       
        pos.x = pos.x - x
       
        pos.z = pos.z - z
   
    end

end)


Firstly, please use the code tags. when you are writing a post, between the " and the email button, there is a <> button. this is for code.

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
minetest.register_on_dieplayer(function(player)
   
minetest.get_inventory({type="detached", name=player:get_player_name().."_armor"})
    local pos = player:getpos()
    local armorTypes = {"head", "torso", "legs", "feet"}
    for i,stackName in ipairs(armorTypes) do
        local stack = inv:get_list(stackName .. "_armor")
        local x = math.random(0, 6)/3
        local z = math.random(0, 6)/3
        pos.x = pos.x + x
        pos.z = pos.z + z
        minetest.env:add_item(pos, stack)
        stack:clear()
        inv:set_stack("detached", i, stack)
        pos.x = pos.x - x
        pos.z = pos.z - z
    end
end)


note the code around the for loop
My best mods:
Buildtest
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Wed Apr 02, 2014 21:27

17:22:19: ERROR[main]: ServerError: LuaError: error: ...sr/share/minetest/games/MiniTest/mods/death/init.lua:56: attempt to index global 'inv' (a nil value)
17:22:19: ERROR[main]: stack traceback:

I got this when I died.
Love MINECRAFT... will settle for Minetest
 

User avatar
minermoder27
Member
 
Posts: 127
Joined: Wed Nov 20, 2013 23:24
GitHub: ZNixian
In-game: minermoder27

by minermoder27 » Wed Apr 02, 2014 22:11

Sorry, didn't notice,
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
minetest.get_inventory({type="detached", name=player:get_player_name().."_armor"})

should be changed to
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
local inv = minetest.get_inventory({type="detached", name=player:get_player_name().."_armor"})


that error is because you didn't set the local variable inv
My best mods:
Buildtest
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Thu Apr 03, 2014 17:22

21:40:38: ERROR[main]: ServerError: LuaError: error: ...sr/share/minetest/games/MiniTest/mods/death/init.lua:56: attempt to index local 'inv' (a nil value)
21:40:38: ERROR[main]: stack traceback:

I got this error now.
Love MINECRAFT... will settle for Minetest
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Fri Apr 04, 2014 11:40

I tried tweaking it but to no avail. Still it has a local 'inv' nil value.
Love MINECRAFT... will settle for Minetest
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Fri Apr 04, 2014 19:30

Can someone help please. I don't know where minermoder27 went and I not sure what is wrong.
Love MINECRAFT... will settle for Minetest
 

User avatar
minermoder27
Member
 
Posts: 127
Joined: Wed Nov 20, 2013 23:24
GitHub: ZNixian
In-game: minermoder27

by minermoder27 » Sat Apr 05, 2014 00:13

(Sorry for going offline so long)

What line is line 56? could you please upload the entire file, as there is no line 56. Also, it this the bottom-most piece of code in the file, or could is be changing something that then makes some code below it fail?

tip: when uploading single files, [url]pastebin.com[/url]
My best mods:
Buildtest
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Mon Apr 07, 2014 13:42

minetest.register_on_dieplayer(function(player)
local inv = player:get_inventory()
local pos = player:getpos()
for i,stack in ipairs(inv:get_list("main")) do
local x = math.random(0, 6)/3
local z = math.random(0, 6)/3
pos.x = pos.x + x
pos.z = pos.z + z
minetest.env:add_item(pos, stack)
stack:clear()
inv:set_stack("main", i, stack)
pos.x = pos.x - x
pos.z = pos.z - z
end
end)

minetest.register_on_dieplayer( function (player)
local pos = player:getpos()
local x = math.random(0, 15)/10 - 1.25
local z = math.random(0, 15)/10 - 1.25
pos.x = pos.x + x
pos.z = pos.z + z
pos.y = pos.y + .25
local obj = minetest.add_item(pos, "default:apple_golden")
if obj then
obj:get_luaentity().collect = true
end
end )

minetest.register_on_dieplayer( function (player)
local dropItem = ""
if math.random(0,3) == 1 then
dropItem = "default:creeperhead"
else
dropItem = "default:head"
end

local pos = player:getpos()
local x = math.random(0, 15)/10 - 1.25
local z = math.random(0, 15)/10 - 1.25
pos.x = pos.x + x
pos.z = pos.z + z
pos.y = pos.y + .25
local obj = minetest.add_item(pos, dropItem)
if obj then
obj:get_luaentity().collect = true
end
end )

minetest.register_on_dieplayer(function(player)

local inv = minetest.get_inventory({type="detached", name=player:get_player_name().."_armor"})
local pos = player:getpos()
local armorTypes = {"head", "torso", "legs", "feet"}
for i,stackName in ipairs(armorTypes) do
local stack = inv:get_list(stackName .. "_armor")
local x = math.random(0, 6)/3
local z = math.random(0, 6)/3
pos.x = pos.x + x
pos.z = pos.z + z
minetest.env:add_item(pos, stack)
stack:clear()
inv:set_stack("detached", i, stack)
pos.x = pos.x - x
pos.z = pos.z - z
end
end)


So yours is the last paragraph in the list.
Love MINECRAFT... will settle for Minetest
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Mon Apr 07, 2014 13:43

For some reason the code thing didn't work. I tried it with this.
Love MINECRAFT... will settle for Minetest
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

by Krock » Mon Apr 07, 2014 13:50

mcfan wrote:For some reason the code thing didn't work. I tried it with 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
local inv = minetest.get_inventory({type="detached", name=player:get_player_name().."_armor"})
    local pos = player:getpos()
    local armorTypes = {"head", "torso", "legs", "feet"}
    for i,stackName in ipairs(armorTypes) do
---> local stack = inv:get_list(stackName .. "_armor")

get_list = stack? I don't get it.
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Mon Apr 07, 2014 14:34

I don't know. minermoder17 programmed it. Do you know how to fix it?
Love MINECRAFT... will settle for Minetest
 

User avatar
stu
Member
 
Posts: 737
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11

by stu » Tue Apr 08, 2014 21:07

mcfan wrote:I don't know. minermoder17 programmed it. Do you know how to fix it?

I have just added support for the bones mod, maybe this can help you.

#2786a81
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Wed Apr 09, 2014 11:37

Not to be mean, but I don't like the bones mod. I like it to be more like MC and drop stuff when you die. If you did that are you able to fix the error I'm getting?
Love MINECRAFT... will settle for Minetest
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Thu Apr 10, 2014 11:21

Does anyone know how to fix this error?
Love MINECRAFT... will settle for Minetest
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

by Krock » Thu Apr 10, 2014 11:26

mcfan wrote:Does anyone know how to fix this error?

Which error?
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Thu Apr 10, 2014 13:32

This one:

21:40:38: ERROR[main]: ServerError: LuaError: error: ...sr/share/minetest/games/MiniTest/mods/death/init.lua:56: attempt to index local 'inv' (a nil value)
21:40:38: ERROR[main]: stack traceback:

It is in the armor drop section.
Love MINECRAFT... will settle for Minetest
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Fri Apr 11, 2014 12:31

I couldn't figure out how to fix this error. Could someone help me please?
Love MINECRAFT... will settle for Minetest
 

User avatar
Achilles
Member
 
Posts: 246
Joined: Sun Dec 15, 2013 11:55
In-game: Achilles

by Achilles » Fri Apr 11, 2014 15:45

This is a good idea... Armor lasts ages... Will be good to have it drop when you die.
The Ironic Thing About Common Sense Is That It Isn't Very Common
 

User avatar
Achilles
Member
 
Posts: 246
Joined: Sun Dec 15, 2013 11:55
In-game: Achilles

by Achilles » Fri Apr 11, 2014 15:45

Even better if it gets pulverizes when you die
The Ironic Thing About Common Sense Is That It Isn't Very Common
 

User avatar
Achilles
Member
 
Posts: 246
Joined: Sun Dec 15, 2013 11:55
In-game: Achilles

by Achilles » Fri Apr 11, 2014 15:46

Any chance of that happening?
The Ironic Thing About Common Sense Is That It Isn't Very Common
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Fri Apr 11, 2014 18:21

It is better dropping than being pulverized because the player who killed you can then get the armor and use it.
Love MINECRAFT... will settle for Minetest
 

Next

Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 13 guests

cron