Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: HandsFree on Wed 20/03/2013 23:32:13

Title: Calling a function from a dialog [solved]
Post by: HandsFree on Wed 20/03/2013 23:32:13
I have a function view_from_tree() that I want to call from a dialog.
@3
  view_from_tree();
return

I thought the function should be in the global script, but when I put it there I got error in dialog: Undefined token view_from_tree(). So I tried putting the function in the room script from where the dialog is called, but that gives the same error.

How should I do this?
thanks
Title: Re: Calling a function from a dialog
Post by: Khris on Thu 21/03/2013 00:02:15
You have to import the function in GlobalScript.ash:

Code (ags) Select
import function view_from_tree();

In the global dialog script, when you type "vie", the auto-complete window should pop up and suggest your function, among others.
If it doesn't, at that point you already know there's going to be the undefined token error.
Title: Re: Calling a function from a dialog
Post by: HandsFree on Thu 21/03/2013 10:22:50
Yes, that works of course.
thanks
Title: Re: Calling a function from a dialog [solved]
Post by: cat on Sat 22/12/2018 21:25:07
I know this is quite old, but I just found it useful and wanted to say
- this still works with current AGS
- thanks Khris!