Execute variable on set turns

Having some thoughts on this in my life simulation that I'm currently building.

How can I write an endless activation each time "day" is increased by 30? Se my if statement, which is currently just a placeholder to show you what I mean.

[[Intro]]:
(Game starts here)
@set day = 1
@set money = 100

[[You wake up]](Morning)

[[Morning]]:

@inc day

You wake up. You have {money}$.

{if day = 30 or 60 or 90: [[Pay bills!]]}{else: [[Wait til evening]](Evening)}


[[Evening]]:

[[End day!]](Morning)

[[Pay bills!]]:

@dec money 10

[[Go back to evening]](Evening)


K.V.

Hello.

If you use backticks when you post code, we'll be able to view the code correctly.

```

CODE GOES HERE

```

Sorry! Didn't know! Fixed.


K.V.

I couldn't figure out how to write this in Squiffy-ese, so I used some Javascript. I am not the best at Squiffy, though, so someone else may have a more simple solution. (This isn't so bad, though.)

I set the day to 28 for debugging purposes, by the way.

[[Intro]]:
(Game starts here)
@set day = 28
@set money = 100

[[You wake up]](Morning)

[[Morning]]:
    squiffy.ui.write("You wake up. You have {money}$.");
    squiffy.set ("day", squiffy.get("day")+1);
    if (squiffy.get("day") % 30 == 0){
        squiffy.ui.write("<a class=\"squiffy-link link-section\" data-section=\"Pay bills!\" role=\"link\" tabindex=\"0\">Pay bills!</a>");}
    else{
        squiffy.ui.write("<a class=\"squiffy-link link-section\" data-section=\"Evening\" role=\"link\" tabindex=\"0\">  Wait til evening</a>")
    };


DEBUGGING: This is day {day}.



[[Evening]]:

[[End day!]](Morning)

[[Pay bills!]]:

@dec money 10

{money}

[[Go back to evening]](Evening)

This does the trick. Thank you!


I've been playing around with the code, and created this:

[[Intro]]:
(Game starts here)
@set day = 28
@set money = 100

[[Start game]](Dreamworld)

[[Dreamworld]]:
    squiffy.set ("day", squiffy.get("day")+1);

[[Wake up]](Morning)

[[Morning]]:
    if (squiffy.get("day") % 30 == 0){
    squiffy.ui.write("There's a fair in town tonight.");
    squiffy.ui.write("<a class=\"squiffy-link link-section\" data-section=\"Visit fair!\" role=\"link\" tabindex=\"0\">Visit fair!</a>");}
<br>
<br>

[Eat breakfast]

[Look in the newspaper]

[[Continue the day...]](Evening)

DEBUGGING: This is day {day}.

[Look in the newspaper]:

You look in the newspaper.

[[Back...]](Morning)

[Eat breakfast]:

You eat breakfast.

[[Back]](Morning)

[[Evening]]:

[[End day!]](Dreamworld)

[[Visit fair!]]:

You spend ten dollars at the fair.

@dec money 10

{money}

[[Go back to evening]](Evening)

I want "Visit fair" to appear at the bottom of the page displayed, not on top. However, the code doesnt work if I place it at the bottom of the page (Morning).

How should I write to make it appear elsewhere?


K.V.

Ooh...

I think you'll have to print your other text with JS as well, but someone else may know a trick.


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

Support

Forums