increase or decrease an attribute value from a link: is it possible?

Siddone

You can set an attribute value from a link, but can you just increase or decrease it?

[[increase Value]](start, value+=1) or [[decrease Value]](start, value-=1)?

[[start]]:
Your choice has been recorded.

As it is, it doesn' work. What's wrong with it?


Siddone

Then there is another question related to this one. When I set or change a variable in a section, it appears that the change is "acquired" by the system only after I move on the next section; if I want to show it in the same page, it shows the old value. But is there some way to make the system "update" the value during the view of the same section in which the value was set or modified? I have this feeling that it may be related to the command "get" but I'm not sure where I heard of it, I'm not even sure a "get" command exists in Squiffy.


Padrinos

Are you taking about after setting an attribute, like set strength = 10 then adding or decreasing
@inc strength 1
or
@dec strength 1


Siddone

Yes, I wanted to increase or decrease attributes in the same way you can set them, inside the link.

This is the exemple given in the guide:
[[text of the link: set attribute]](start, attribute=1)
[[start]]:
Your choice has been recorded.

This is what I would like to do:
[[text of the link: increase attribute]](start, attribute+1)
[[start]]:
Your choice has been recorded.

Of course I understand that writing "attribute+1" won't increase the attribute by 1. Is there any commnd to do that?


hogart

Actually, it works as you suggested, take a look.


thetruespin

Thinking about the above, is it possible through Squiffy's markup language to do something like this?

@set variable = 1

{label:1=[[Option 1]](start, value=opt1, variable=+1)}  // I've checked and you can modify 2 attributes at same time

{label:2=[[Option 2]](start, value=opt2)}

[[start]]:

{if value=opt1: @replace 2 =}  // this doesn't work

{if value=opt2: @replace 1 =}   // this doesn't work

Getting rid of previously selected options is pretty easy, but reliant on the two links going to different sections and then using the replace function. However, I might actually want both links to go to the same bit of the story, but using the above solution use one link to increase or decrease an attribute (which I might then use later on in the story).

Sadly the replace function doesn't appear to work within an if statement.


thetruespin

Actually, I'm being stupid. The above can easily be accomplished via:

@set test = 0

{label:1=[[new section]](next, test=+10, @replace 2=)}
{label:2=[[new section]](next, @replace 1=)}

Talk about massively over-complicating something :)


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums