Hi there! I was wondering, who is in charge of setting the “sentence line”. Is the script in charge of telling the engine which sentence line to render, or does the engine knows which verb and object are selected and changes it accordingly?
Same with verbs, are they defined in squirrel, or predefined in the engine?
I am loving Thimbleweed Park!
Thank you!
I haven’t insight into the engine, but Ron mentioned in a podcast that most parts are done in Squirrel or that there is a “hook” in the engine for a Squirrel script.
I assume the TWP engine has a small parser that changes the sentence line according to the selected verb and object. That’s not very difficult to implement.
All the UI is done in the engine, so when a player selects and verb, and then an object, the squirrel scrips no nothing about the event. Updating the sentence line is all handle by the engine. Only when the final click is given are the squirrel script called based on the verb and object selected.
If we do another adventure game, I will pull more and more of the UI code into the squirrel scripts, but for a first game, it was easier to do it this way. It was my first time using squirrel and I don’t have a good sense of it’s limitations yet.
Do you had/have any performance problems with Squirrel? If you put many (complex) code into Squirrel scripts, I would assume that the code is slower. That might be of course not an issue on Win/Mac/Linux but on (slow/cheap) mobile devices. AFAIR the data exchange from C to Squirrel (and vice versa) is done via a stack like in Lua. So there might be a little overhead too …
That makes a lot of sense, thank you so much Ron!
Squirrel is just as fast as LUA, unless you’re using the LUA JIT compiler. What we don’t do is continually run Squirrel code. Squirrel code is run based on events happening (like the user clicking), and in those cases, we’ve run into no issues. We didn’t know that going in, so I had the engine deal with more code than I probably needed to.
To make sure I understand (and to answer the original question): The engine keeps track of the verb and object selected. So when a verb is selected it “starts” a new sentence and waits for an object; and when the object is finally selected, the sentence is “complete” and the appropriate Squirrel script is called with this information. The script then handles the command.
Is this somewhat accurate?
Yes, mostly. When objects and verbs are selected, the Squirrel scripts get called, so they have a chance to override default actions. We don’t use this very much (if at all). There are a lot of low level actions that call into script, and the scripts have the option of allowing or overriding the action. For example, if the scripts wanted, every time you selected “push”, they could change it to “open”. We don’t currently do this, but it’s possible.
When the player does the final click on “open door”, and global script function is call with the sentence line, if the function returns true (or doesn’t exist), then the character walks to the door. When they get to the door, another function is called with the sentence line. If it returns true then the object’s OPEN verb is called. This gives the scripts 3 places to override player action. We use this mostly to intercept GIVE commands to keep players from giving away objects. It’s also used to intercept states like when players are pushing on the factory doors.
Each actor has version of these functions that also get called, so Delores could override something and no one else, without peppering the global functions with a bunch of if statements.
Whoa! Sounds very complex, but also like it gives you great power to control the game logic flow.
Thanks for the insight.
-dZ.
Are verbs already implemented in a more generic way or is e.g. Ghost-Franklin actually using the ‘Open’ verb under the hood instead of his custom verbs?
Ah! That’s a good question, I was wondering that myself. From what Mr. Gilbert mentioned above, it sounds like it could go either way. Which is it, Mr. Gilbert?
-dZ.
The verbs are not build into the engine, it could be any nine verbs. There is a command called setVerb() that defines what the verb is, position, hotkeys, function that is called, etc. Franklin doesn’t use OPEN he has his own ZAP verb.