Turns out the problem was
local tile = party.go.map:getAutomapTile(getForward(dir))
when it should have been this...
local tile = party.go.map:getAutomapTile(party.go.x,party.go.y)
Script now works!
Code: Select all
defineObject{
name = "party",
baseObject = "party",
components = {
{
class = "Party",
onMove = function(party,dir)
for i = 1,4 do
local c = party:getChampion(i)
local cRace = c:getRace()
if cRace == "human" then
local tile = party.go.map:getAutomapTile(party.go.x,party.go.y)
print(tile)
if tile == 2 then
if c:hasCondition("water_breathing") == false then
hudPrint(""..c:getName().." can breath underwater.")
c:setCondition("water_breathing")
end
else
if c:hasCondition("water_breathing") == true then
hudPrint(""..c:getName().." is not underwater.")
c:removeCondition("water_breathing")
end
end
end
end
end
}
},
}
Code: Select all
defineObject{
name = "party",
baseObject = "party",
components = {
{
class = "Counter",
name = "partycounter",
},
{
class = "Timer",
name = "partytimer",
timerInterval = 1.0,
triggerOnStart = true,
onActivate = function(self)
self.go.partycounter:increment()
local v = self.go.partycounter:getValue()
if initCounter.counter:getValue() == 1 then
initScript.script.initialize()
initCounter.counter:decrement()
end
return hudPrint("Time = "..v.."")
end
},
}
}
Code: Select all
function initialize()
for i = 1,4 do
local c = party.party:getChampion(i)
local cRace = c:getRace()
if cRace == "zarchton" then
party.partytimer:addConnector("onActivate", "initScript", "waterBreathingCheck")
end
end
end
----------------------------------------------------------------------------------------------waterBreathingCheck()
function waterBreathingCheck()
for i = 1,4 do
local c = party.party:getChampion(i)
local cRace = c:getRace()
if cRace == "zarchton" then
local tile = party.map:getAutomapTile(party.x,party.y)
print(tile)
if tile == 2 then
if c:hasCondition("water_breathing") == false then
hudPrint(""..c:getName().." can breath underwater.")
c:setCondition("water_breathing")
end
else
if c:hasCondition("water_breathing") == true then
hudPrint(""..c:getName().." is not underwater.")
c:removeCondition("water_breathing")
end
end
end
end
end
if so it adds a connector from partytimer to initScript (f waterbreathing) which checks for the automaptile
and from there adds or removes water breathing condition
This way is better than onMove i think
Thanks for your help GoldenShadowGS!
Very happy to get this thing working