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

[SugarCube 2]Calling a macro or JavaScript inside an

$
0
0
Hey there!

Problem description:
I'm trying to return a value to SugarCube 2 by calling a macro that I made.
Let's see the code:

JS:
var weekdays = new Array();
weekdays[0] = "Sunday";
weekdays[1] = "Monday";
weekdays[2] = "Tuesday";
weekdays[3] = "Wednesday";
weekdays[4] = "Thursday";
weekdays[5] = "Friday";
weekdays[6] = "Saturday";
var date = new Date(2017,2,1,17,30,0);

Macro.add(
{
    "todayis", function()
    {
        return weekdays[time.getUTCDay()];
    }
})
;

Passage:
/% Kiosk Passage: %/
<<linkreplace "Find out the current date by looking at the date of a daily newspaper>>
    <<if <<todayis>> is "Wednesday">>
                Oh my, how is this possible? It's Wednesday. 
                But I thought today is Friday?
                Does that mean my machine worked? 
                I traveled through time?
    <</if>>
<</linkreplace>>

Unfortunately this fails with an error: saying there's an extra << symbol that shouldn't be there.
Help please?

Viewing all articles
Browse latest Browse all 1844

Trending Articles