Friday, May 11, 2012

Scripting system simplifications and other fixes

A lot of behind-the-scene work has been done to the scripting engine lately, as told before, and I must say I'm quite happy with several of the schortcuts added. :)

Namely, the Event and dialogue Managers are the one important pieces there, cleverly thought by Tyler, IIRC.

In a first row, I added mostly support for several shortcuts, using handlers as parameters, instead of Ids.
Permitting to avoid this :

local character = ...
...
local character_id = 1
local dialogue = hoa_map.SpriteDialogue(1)
local text = "My Text";
dialogue:AddLine(text, 1);
DialogueManager:AddDialogueReference(dialogue);
character:AddDialogueReference(1);
...

Imagine now a map with 15 npcs, two important characters, and I didn't speak about events there, yet.
Do you think you can still remember the id used there without making a bunch local variable retaining the important ids?

The equivalent code is now:
local character = ...
...
local dialogue = hoa_map.SpriteDialogue()
local text = "My Text";
dialogue:AddLine(text, character);
DialogueManager:AddDialogueReference(dialogue);
character:AddDialogueReference(dialogue);
...
No more ids, in that case. Same philosophy for events. And it does seem to work quite well so far. :)
Don't worry, I still left the former way of doing it, so that one can go back using it when needed.
EDIT: Note that events still have ids, but they are now string based, and I do think it more readable so far.

The second problem I had to fix is the event chain handling, which appear to not handle chain breaking, and delayed event pausing. This is now done, and permitted to make the hero's mother to stop waking here and here, and come and speak to him when he tries to get out of his house. Sounds quite a simple case, but believe me, that one gave me some hard times.

The hero's mother can now come and speak before he can leave the house.


I, then, started to rework on the maps, and fell on the context handling, which was currently only handling the base context inheritance, which is fine in itself.
As I'm a little bit crazy, and saw that the editor was semi-prepared to welcome the feature of context inheritance for something else than the base context, I hopped on finishing the feature, both in the game app, and in the editor, and while on it, I made the context and its inheritance be declared in the same table in the map files. The context data is still declared at the usual place, but I guess it's fine in the loading logic for now.

With all that so far, we (yes we were two on this.) worked on the three first maps corrections and finally added inhabitants in the village map. (Hurray!)

The village feels less empty now.

No comments:

Post a Comment