Author Topic: Calling a function from a dialog [solved]  (Read 804 times)

Calling a function from a dialog [solved]
« on: 20 Mar 2013, 23:32 »
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
« Last Edit: 21 Mar 2013, 10:23 by HandsFree »

Re: Calling a function from a dialog
« Reply #1 on: 21 Mar 2013, 00:02 »
You have to import the function in GlobalScript.ash:

Code: Adventure Game Studio
  1. 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.
« Last Edit: 21 Mar 2013, 13:33 by Khris »
Fail at Floaty Rog' now!  still having to deal with what games are going through

Re: Calling a function from a dialog
« Reply #2 on: 21 Mar 2013, 10:22 »
Yes, that works of course.
thanks

cat

  • Mittens Baronet
  • AGS Baker
    • cat worked on one or more games that won an AGS Award!
    •  
    • cat worked on one or more games that was nominated for an AGS Award!
Re: Calling a function from a dialog [solved]
« Reply #3 on: 22 Dec 2018, 21:25 »
I know this is quite old, but I just found it useful and wanted to say
- this still works with current AGS
- thanks Khris!