Forum

> > CS2D > Scripts > Call a function from an if entity
Forums overviewCS2D overview Scripts overviewLog in to reply

English Call a function from an if entity

3 replies
To the start Previous 1 Next To the start

old Call a function from an if entity

Mami Tomoe
User Off Offline

Quote
Hi guys, today I have a problem but first let me claim this:
I know 0% about this entity and I never used it, also I searched for a solution but found none (maybe searched for the wrong thing...).

How can I call a function from an if entity?

at, mapname.lua:
1
2
3
function fn()
     msg("test")
end

How to call fn() from the if entity? I don't want the function to be in the if statement I just want to call it.

old Re: Call a function from an if entity

GeoB99
Moderator Off Offline

Quote
You could also use
dofile
to call the script (NOTE: it will trigger every function if you have multiple routines). The syntax has to be in this way:
1
dofile('LuaPath')

old Re: Call a function from an if entity

Mami Tomoe
User Off Offline

Quote
user HPB has written
What? Do you mean cs2d entity trigger_if? Simply write
fn()
on the text box field. The function will called by cs2d entity trigger_if when it's triggered. Don't worry with the
if
statement.


Thanks it worked and that's what I figured out that to use the trigger I need to return true on the function
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview