Page 1 of 1

How do i call a function in a function??

Posted: Mon Oct 14, 2013 10:22 am
by Eleven Warrior
Hi all

This is what I have ATM

function onDie(self)

local x , y = getForward( ( self.facing + 2 ) % 4 )
x = x + self.x
y = y + self.y
if killcounter:getValue() == 1 then
if not isWall( self.level , x , y ) then
spawn("spider",party.level,x,y,self.facing)
end

elseif killcounter:getValue() == 2 then
sd1:open()
---- Here I want to call (function addMoney) from the (rewardslvl1) Script in the Editor (see Below) --
end
end

1 - Script Entity Name: rewardslvl1
2 - The Script function I want to call: (its from the Shop Frame work, Magnus wrote)

function addMoney()-- adds money to the party
hudPrint("Guard: Good show! Here is an added bonus for cleaning the mess up! 20 Money added.")
gui.globalVars["totalMoney"] = gui.globalVars["totalMoney"] + 20
end

Thxs for any help..

Re: How do i call a function in a function??

Posted: Mon Oct 14, 2013 11:04 am
by alois
rewardslvl1.addMoney() does not work? (it's pretty much the same syntax as "gui.setVar()", or "gui.globalVars[]", i.e., nameOfScript.nameOfFunction)

alois :)

Re: How do i call a function in a function??

Posted: Mon Oct 14, 2013 11:12 am
by DesperateGames
I agree with alois rewardslvl1.addMoney() should work. Are you sure the function is not called? Or do you get an error message?

Re: How do i call a function in a function??

Posted: Mon Oct 14, 2013 2:26 pm
by Eleven Warrior
Thxs guys ill give it a go.

This is what i was looking for rewardslvl1.addMoney() i just didnt know (remember how to call a function from another Script.. It was in front of me the whole time.. I thought it would be as you said Alois..

Thxs again guys