Re: [Solved/Item/Spell] Way to tell if party is underwater?
Posted: Tue Dec 16, 2014 5:11 am
Thanks for the suggestion! I went ahead and did as you said - good investigative tool (should have been doing this ages ago)
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!
And instead of hooking it up with onMove, Ive decided to just connect it to the party timer
create initScript (in dungeon) and initCounter set value to 1
partytimer triggers initScript, checks if you have Zarchtons in your party,
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
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!
SpoilerShow
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
}
},
}
SpoilerShow
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
},
}
}
SpoilerShow
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