Page 1 of 1
SOLVED - item check script
Posted: Thu Jan 03, 2013 12:51 am
by Drakkan
If somebody will have some time to help me with this one I will definitely credit him
1. I have button (button1) opening door (door1). When pushed, party is killed by ton of spawned fireballs.
2. There are 4 items (lets call them Orb1-Orb4)
3. What i need script to do, is if you have all 4 orbs (idealy each member of party should have one, but if that would be too much complicated one inventory is fine) party is not killed after pushing button, but instead get teleported
Re: item check script help pls
Posted: Thu Jan 03, 2013 1:54 am
by Komag
that's definitely doable and not too much more complex to require they each have one separately. check the script repository for some example "search/check inventory for an item" scripts, then it's just a couple more steps to check for four and require one each champion
Re: item check script help pls
Posted: Thu Jan 03, 2013 1:57 am
by hyteria
what do you mean by doable?
Re: item check script help pls
Posted: Thu Jan 03, 2013 2:10 am
by Neikun
doable->do-able->Can be done
Re: item check script help pls
Posted: Thu Jan 03, 2013 4:48 am
by Drakkan
ok spent about one hour with it, but at the end its woriking how I wanted. Perhaps solution is not the best one, but does not matter, it is working :d
I have set counter for 4 and button connect to checkOrb function. When every character has orb in its hand, teleport is activated and party escape. if not fireball kill all.
Code: Select all
function itemCheck(item)
-- checks for the item in champions hands
for champ = 1,2 do
for slot = 7,8 do
x = party:getChampion(champ):getItem(slot)
if x ~= nil then
if x.name == item then
orbcounter:decrease ()
end
end
end
end
end
function itemCheck(item)
-- checks for the item in champions hands
for champ = 1,2 do
for slot = 7,8 do
x = party:getChampion(champ):getItem(slot)
if x ~= nil then
if x.name == item then
orbcounter:decrement ()
end
end
end
end
end
function itemCheck(item)
-- checks for the item in champions hands
for champ = 3,4 do
for slot = 7,8 do
x = party:getChampion(champ):getItem(slot)
if x ~= nil then
if x.name == item then
orbcounter:decrement ()
end
end
end
end
end
function itemCheck(item)
-- checks for the item in champions hands
for champ = 3,4 do
for slot = 7,8 do
x = party:getChampion(champ):getItem(slot)
if x ~= nil then
if x.name == item then
orbcounter:decrement ()
end
end
end
end
end
function checkOrb()
itemCheck("water_orb")
end
Re: item check script help pls
Posted: Mon Jan 07, 2013 7:36 pm
by hyteria
thx neikun )
Re: item check script help pls
Posted: Mon Jan 07, 2013 8:41 pm
by Komag
Why do you have so many repetitions? You can only have one function of the same name, you probably want:
for champ = 1,4 do
Also, if only one person has one but you press the button four times, it will trigger the counter, so you probably should reset the counter at the start of the function so that it has to be all at once:
Code: Select all
function itemCheck(item)
orbcounter:reset()
for champ = 1,4 do
for slot = 7,8 do
local x = party:getChampion(champ):getItem(slot)
if x ~= nil then
if x.name == item then
orbcounter:decrement()
end
end
end
end
end
SOLVED item check script
Posted: Fri Jan 11, 2013 11:44 pm
by Drakkan
Komag wrote:Why do you have so many repetitions? You can only have one function of the same name, you probably want:
for champ = 1,4 do
Also, if only one person has one but you press the button four times, it will trigger the counter, so you probably should reset the counter at the start of the function so that it has to be all at once:
Code: Select all
function itemCheck(item)
orbcounter:reset()
for champ = 1,4 do
for slot = 7,8 do
local x = party:getChampion(champ):getItem(slot)
if x ~= nil then
if x.name == item then
orbcounter:decrement()
end
end
end
end
end
wonderfull thanks, will use this one.