StoryTllrC64 – your first project (2)
07
Ok, let’s see how to go from one starting location with no interaction possible to something, still minimal, but playable.
Let’s start adding two rooms, a bedroom (with the game starts) and a living room.
For those two locations, we need to have at least a description, so let’s add it, this way:
- Please note that we can put the part after the : or inline or as text under the same node. In this case, we prefer to have a description, that’s longer, as text on the right, while we keep the name directly visible on the tree structure.
- And please note also that we don’t have msg: command in the description because that’s an attribute, and not “code”.
Let’s go on. Now we change the $start onfirst code so that after a simple initial message we’ll set the game starting point to the bedroom.
- as you can see there are two new commands: waitkey and goto:
- here we’ve used references to the config part (we already had name, now we’re going to add the other two elements)
With these changes we’ll get that:
And, after pressing a key, we’ll go there
That’s not what you expected, is it? why don’t we see any description – and we still have the previous text?
Because my engine doesn’t assume you want something in a specific way. It’s built to be as extendible as I thought it was wise (for a very small one, being designed to run on a 8bit computer)
So, we need to tell it what we want.
And that means that we need (and want) libraries of standard behaviors.
Instead of adding each behavior inside the game script, we can create a stdlibj.hjt (read that as “standard library.hjt”) and “include” it, of course knowing that we can change everything we want if we need it.
Ah, of course a standard “standard library” is provided on GitHub, so you don’t need to understand everything and build your own (for now).
But, let’s fix this thing in our sample game, before including that, so that you can understand better what’s under the hood.
To do so we need to add a verb section and define what we want to achieve for onfirst and onenter events.
We want to have the screen cleared (clear) we want to read the room description and if there are visible, listable objects in the room, we want to read their list.
Added that, we’ll see this:
That’s surely better, isn’t it?
But 1) we still can’t do anything and 2) you may ask: hey, but now we have TWO onfirst, why’s that?
About the 2) – yes, we got two of them. BUT, and this is quite important, we have TWO main level for everything. One is the global level (something that must exist or happen everywhere, with specific limits) and one is the local level (the room we’re in). So we can have a generic, global, verb handling, and an override, in a specific room.
And so, to move from one room to the other, we can choose the second level, and add a specific verb handling in each room, like that:
This way we can move from one room to the other.
BUT if I ask to move east from the living room, nothing happens, not even a message. And that’s why we need to add a global handling for movements – that simply say that we CANNOT move that way.
To do so we can add each verb where we put onfirst with a message, but my engine can do a bit better than that.
We can define classes – we can add a behavior – we can associate verbs to that class.
Like that:
And added that we’ll get this:
(Actually we get this after a small change – if we call a synonym set e|east we must refer everywhere else to that set using (only) the FIRST element. So we need to change the reference in bedroom and living room accordingly)
But, after that, we can move to and from the two rooms without problems. Still not a great game, but now we can interact.