Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

[Twine 2.1.1] [SugarCube 2.14] Passages and interactable objects.

$
0
0
Hi there,

I'm looking for best practices and solutions to the following problem:

Let's say I have a passage, in which I want a treasure chest and a person. When the player enters the room, I want to have options poping up that enable me to interact with these two objects. These objects are defined in JavaScript, where I declare the type, count, name and possible actions that can be carried out by the player on a given object.

Now, of course you could put in IFs into each passage, but thats too tedious of a work.
What I want is some way to identify objects in the room and print the actions that can be taken on them by default.

The printing part has already been figured out, now I'm trying to come up with an idea that allows me to track these objects when traversing.

Here's the idea that I have and going to try out:

Add the object names as Tags to the passage in question and when always when entering the passage (by defining a task in JavaScript, once a room has been created) compare the Tags that are assigned to the current room and match them with an array of interactable objects. If the object is on the list then the passage will show the actions that can be taken.

Now, this solution requires me to specify the objects that I want to interact with on a list (or separate lists) and do the comparison against the tags each time I enter a passage.

My question is: is there a better way of doing this? Can the Tags that are assigned to the passage can be used to implement something like this? Would the names of the objects and the tags collide with other names that SugarCube uses and if so which ones?

I know that 'widget' is already taken, but i guess 'treasure chest' and 'pirate' aren't :)

Viewing all articles
Browse latest Browse all 1844

Trending Articles