Questions about {if

I always find Squiffy's {ifto be very weird. First here are all the comparison symbols that {if understands, as far as I'm aware:

@set x=1

{if seen section_title:The player has visited this section.}
{if x:x is either boolean true or equal to 1} 

{if x=1:x is either boolean true or equal to 1}

{if x:}{else:x could be any value except for 1 or boolean true}

{if x=1:}{else:x could be any value except for 1 or boolean true}

{if not x:x could be non-existent or boolean false or 'null' or 'NaN' or equal to 0 or equal to Infinity}

{if x=@x:x is x even if x doesn't actually exist}

{if x<>2:x is not equal to 2}

{if x>0:{if x<1:x has a decimal value between 0 and 1}}

{if x>0:x is greater than 0}

{if x<2:x is less than 2}

{if x>=0:x is greater than or equal to 0}

{if x<=2:x is less than or equal to 2}

Does anybody know of any other symbol that can be used after {if x?


This isn't a symbol, but it's an operation that meants two values are not comparable.

@set x = 1
@set y = a

{x} {if x>@y:}{else:{if x<@y:}}{else:{if x<>@y:�}}  {y}

I think you covered them all here. One has to be careful since there was an issue on if where a space could throw off some of the operations.

There was a discussion a while back about how to do logical ands and ors. It was kinda cheating but ,as I recall...

{@a}
{@b}

{if a:{if b: AND}}

{if not a:{if not b:}}
{else: OR}

Unfortunately that doesn't work in my copy of Squiffy. I think I have the most update version.

{@b}
{if not a:{if not b:}}{else: OR} <!---OR does not display.--->
{@a}
{if not a:{if not b:}}{else: OR}  <!---OR does display.--->

This takes a little less space:

{if a:{@OR}} {if b:{@OR}}

I'm using this:
Squiffy 5.1.1
Build 5.1.2

I'm not sure why it wouldn't work - can someone else confirm this (I'm pretty screwed if it dosn't work - works for me). Can someone confirm this?

You cut and pasted everything in, right?

The reason I do the longer OR is if the OR section is lengthy - I don't want to do it twice.


BTW, you need to define BOTH variables. A and B must both be set.


 {if not a:{if not b:}}
 {else: OR}

This should not work. The {else: OR} will run if the most recent if to return didn't, based on the value of the internal data.lastIf flag. In this case, that's the {if not a: section. The 'else' clause here doesn't care about the second if statement.

The relevant piece of code is:

				var textResult = result ? process(text, data) : "";

				data.lastIf = result;
				return textResult;

When the first 'if' statement is run, if figures out whether not a is true. If so, it runs the second if block to check if not b is true. However, even if b is true so it sets data.lastIf to false, that happens before the line data.lastIf = result, which sets lastIf back to the result of the not a test.

I've seen people writing scripting languages before where it looks like:

				data.lastIf = result;
				return result ? process(text, data) : "";

but this is often a bug.

In both cases, whether {else displays output is based on whether the closest {if did anything. The difference is that the buggy one picks the closest {if block; while the one Squiffy actually uses looks at the closest } which belongs to an if block.

Unfortunately, your 'or' construct will only work with the buggy version of the 'if' function.

I checked on git, and it seems that this has been the same ever since {else was added.


Instead of using {else:, you could define NOR first, and then say {if not NOR:OR}.

It really sucks to suddenly find a game or tool not working. I feel for you, Bluevoss.

{if not a:{if not b:{@NOR}}}
{if not NOR:{@OR}}

Fortunately I didn't use it anywhere - just was trying to get the AND to work. But I see the problem now. I will now slink off to my dark hole and think about this for a bit.

It's doable - but it should be simple.


It's doable - but it should be simple.

PREACH!


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

Support

Forums