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

How to deal with condition and func things in a single file? #11

Open
JerryXu321 opened this issue Jan 6, 2020 · 1 comment
Open

How to deal with condition and func things in a single file? #11

JerryXu321 opened this issue Jan 6, 2020 · 1 comment

Comments

@JerryXu321
Copy link

Hi there!
I am tied to use whiskers-parser in my own project. I add a Control node named HUD, and a child Control node named Dialogue. The Dialogue node is as same as the node was used in whiskers project. Basic_dave.json and jump_dave.json was work in that way. However, condition_dave.json and other file that used condition node just cannot work.
I guess it happens because there is no func and variables into script. I could not found any useful documents on the gihub lol. How can I add the func and variables into it?
error output:

Invalid get index 'key' (on base: 'Dictionary').

and

E 0:00:00:0474   self can't be used because instance is null (not passed)
  core/math/expression.cpp:2147 @ execute()
                 WhiskersParser.gd:152 @ execute_expression()
                 WhiskersParser.gd:110 @ handle_condition()
                 WhiskersParser.gd:222 @ generate_block()
                 WhiskersParser.gd:42 @ start_dialogue()
                 Dialogue.gd:37 @ init()
                 HUD.gd:10 @ _ready()
@Peatral
Copy link

Peatral commented Apr 18, 2020

I just was confused too, but then I realized you must pass an object as context when instancing the parser. Without this object the parser doesnt know how where to look up the variables or call the functions. So if you want it to wirk you have to instance the parser like so: WhiskersParser.new(context) where context is an object holding the functions and variables used in the dialogue. In the case of condition_dave.json it must have a variable called littleMouse which has to be a String. I don't know how you want to use it but for testing purposes you can pass self as a parameter and have the variable littleMouse in the same script. The whole thing is mentioned as the first thing in the readme.

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