Sugarcube 2.12
Further to my recent thread about a new type of Twine game, I understand it's possible to 'select' a passage link (rather than having the link take you to another passage) so that a sub menu can be used to interact with the selected link.
I'm a long way from getting this idea off the ground, but I suppose I have to start somewhere and would like to ask how this is done?
Comments
@'s formatted this way specifically to make it appear to be an actual box, otherwise, it oddly just starts to create a container, but never quite 'finishes' it for some reason.
The .inventory is a CSS selector you put in the Stylesheet Section, defining how the 'Inventory' Screen would look like. The CSS example are ripped from my own game.
The Inventory CSS mainly makes it a darkish blue bg with a border around it to distinguish from the standard Sugarcube BG and looks.
I'm sure this probably isn't what you're looking for, but it IS another way to show information then hide it if you need to.
(shrugs)
When the player clicks on chest, I want three options to show up examine / take / open
When they are pressed I want another response relative to which they clicked.
This is what I have but I get an error about no matching selector when I click either of the three options.
So, the player clicks Chest and below this appears: So they click examine and below it appears [the objects description]
But then when they click open, I'd like the objects description to be replaced with the open response, instead of it just appearing below the last response.
Ideally, clicking chest would toggle the three options on and off.
I'm still checking. And congrats on getting it to work - but I am trying to see if I can't figure out how to replace your initial text once you click on it. All I can think of is <<replace>> macro but I'm trying to make it work somehow. It's 'treating' those actions as individual actions. But I'm not sure how to put it in 'one window' so to speak.
Maybe @TheMadExile could help? I keep thinking we should be using <<replace>> or <<linkappend>> and I've been looking at the documentation as well. <<linkreplace>> isn't a good idea since it's a one-time link. Anyway.
For an example of using an ID, something like the following should do what you need: NOTE: I used a <div> for the chest action wrapper, since the custom styles markup cannot be nested.
I tried to have two objects but with the links in the same sentence. I got myself into a right mess and couldn't do it. Is it even possible?
As in:
Both examples assume that only one set of actions should be shown at a time.
EXAMPLE 1: Using separate IDs with each set of actions
EXAMPLE 2: Injecting each set of actions into a single action area
edit: removed because it was similar to one of TME's
... the above has a number of issues:
1. Both of the action lists can be visible at the same time and when they are it is had to distinguish which list belongs to which item. There are many ways to solve this depending on exactly how you want the result to look.
eg. should the action lists appear near the related item, should all actions appear in exactly the same place thus over writing any other list, should the list identify the related item, etc.....
2. The above implementation does not scale very well for a number of reasons.
eg. the link code needs to be copied to everywhere in the current passage the related item is mentioned; the link and display code needs to be copied to each passage the related item is mentioned in; etc...
I believe a more ideal solution would globally define each of the items and their related actions/outcomes, and then use generic macros to display the both the item selection link and the related action links, as well as displaying any outcomes from using an action.
A very basic example of an item definition. note: the above example could also be written in Javascript, and the implementation of the "open" action should really be a block of code that first checks if the item can be opened (eg. you have a key) then generate the relevant String outcome.
@TheMadExile - I think these options work well personally (although the toggle feature doesn't function in the revised versions) and I think any confusion as to what object you're 'examining' could be alleviated by having the 'active' object highlighted.
@greyelf I very much like the idea of globally defining the objects all in one place (much like you do when caching audio), but my knowledge base won't allow me to move on from your idea on my own.
I understand (I think) that I'd create an invisible passage (let's cal lit objects) and then use the above block of code for each object in the game. But what I would then need to do in the passages themselves in order to call this function is very much beyond me.
Here's an updated version using separate IDs which allows toggling the current action set off: CHANGES: I reworked both the chest and sword links so that only the items not being clicked are forcibly hidden, thus allowing the current item's action set to toggle on and off.
It could possibly work in combination with that method greyelf suggested, or an if condition which I know you hate, haha. (If chest is opened - get object, force the option to be erased somehow)
If the box initially contains a key, the open response will need to say so, but after the key is taken that description needs to change to reflect the fact.
Which could be maybe handled with an if condition.
<<if $hasKey>>do the code for the description but for your new updated one<<else>>do the old description? and 'set' the $hasKey to True?<</if>>
I dunno if that'd work - I haven't tested it. Argh. I guess it won't actually work.