Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How do I define a fallback function for external functions? #152

Closed
rockobonaparte opened this issue Aug 15, 2016 · 2 comments
Closed

Comments

@rockobonaparte
Copy link

rockobonaparte commented Aug 15, 2016

I have this test script for experimenting with embedding the engine with a Unity project I am doing:
[It seems like the "insert code" formatting is choking on the script, but I assume you can see what I'm doing]

EXTERNAL multiply(x,y)

- Hello world!
*   Hello back!
    - - Yay!
*   Derp Derp!
    - - What?

- Well, Nice to hear from you! Fun fact: 2 x 2 = {multiply(2, 2)}
-> END

It works fine in-game. The Ink editor is angry about that multiply function though:
Ink.Runtime.StoryException: Missing function binding for external 'multiply', and no fallback ink function found.

I mean, of course it would complain. It's externally defined! But I was intrigued by defining a fallback ink function so I could keep getting syntax help from the editor--instead of it choking on that whenever I type anything. I didn't see that mentioned in the documentation, namely:

https://github.com/inkle/ink/blob/master/Documentation/RunningYourInk.md#exernal-functions

It implies this is a thing I can do, so I'd like to know how that's done.

@joethephish
Copy link
Member

It should just be a matter of creating an ink function with the same name / declaration. So, if you have EXTERNAL multiply(x,y) at the top of your ink file, make sure you have something like:

== function multiply(x,y) ==
~ return 1 // placeholder result

@rockobonaparte
Copy link
Author

That looks to have done it, but it wasn't happy with the function declaration unless I stuffed it at the bottom of the file, for whatever reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants