English Call a function from an if entity

3 replies
Goto Page
To the start Previous 1 Next To the start
Up
Mami Tomoe
User
Offline Off
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:
Code:
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.
It's hard being the best girl in the whole entire world
25.07.16 12:20:48 pm
Up
HPB
User
Offline Off
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.
25.07.16 12:25:13 pm
Up
GeoB99
Moderator
Offline Off
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:
Code:
1
dofile('LuaPath')
26.07.16 10:42:19 pm
Up
Mami Tomoe
User
Offline Off
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
It's hard being the best girl in the whole entire world
To the start Previous 1 Next To the start