GOD Half
Member
- Joined
- May 9, 2010
- Messages
- 179
- Reaction score
- 15
Hello everyone, I'm trying to develop a system to summon different types of summons. It is working, but when I have another summoned summon, it identifies as the same, and blocks how much I need each of them. Can someone help me?
Lua:
function onCastSpell(creature, var)
local player = Player(creature)
if not player then
return false
end
local summonName = "Carrion Worm"
local maxsummons = 2
local summonsPlayer = creature:getSummons()
local summon = true
if (#summonsPlayer >= 1) then
for _, SummonID in ipairs(summonsPlayer) do
if (string.lower(getCreatureName(SummonID)) == string.lower(summonName)) then
nameSummon = getCreatureName(SummonID)
summon = false
end
end
end
if (#summonsPlayer < maxsummons) and (summon == true) then
for i = 1, maxsummons - #summonsPlayer do
local mid = Game.createMonster(summonName, creature:getPosition())
if not mid then
return
end
creature:addSummon(mid)
end
doCreatureSay(creature, "Go "..nameSummon.."!", TALKTYPE_ORANGE_1)
elseif (#summonsPlayer >= 1) and (nameSummon == summonName) then
doPlayerSendCancel(creature, "You already have summoned "..summonName..".")
summon = false
return doSendMagicEffect(getThingPos(player), 2) and false
end
return
end