How do i call a function in a function??

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

How do i call a function in a function??

Post 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..
alois
Posts: 112
Joined: Mon Feb 18, 2013 7:29 am

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

Post 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 :)
User avatar
DesperateGames
Posts: 90
Joined: Sun Oct 06, 2013 1:54 pm

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

Post 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?
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

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

Post 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
Post Reply