[[start]]:
var rnd=Math.ceil(Math.random()*3);
squiffy.set("rnd",rnd);
{if rnd = 1:
@set name = Groo
@set desc = Warrior
@set str = 3
}
{if rnd = 2:
@set name = Blinky
@set desc = Wizzard
@set str = 1
}
{if rnd = 3:
@set name = Pointy
@set desc = elf
@set str = 2
}
[[next]]
[[next]]:
{rnd}<br>
{name}<br>
{desc}<br>
{str}<br>
Bluevoss wrote:
BTW, followup - when people say that you can write java script in the background, what are they referring to? I've looked up some JS tutorials and what I see isn't that close of a match to what I've seen in examples here.
@start Intro
[[]]:
squiffy.verbNoun = function(a, b) {
var JTxt = "";
/* Examine */
if (a == "examine") {
if (b == "book") { /* book */
JTxt = "You examine the book.";}
else if (b == "flagstone") {
JTxt = "You examine the flagstone.";}
else { JTxt = "You see nothing unusual about the "+b+"."; }
}
/* Take */
else if (a == "take") {
if (b == "flagstone") {
JTxt = "The stone is firmly set in the hard, dry earth.";}
else { JTxt = "That's not something you can carry with you."; }
}
/* for testing */
else {JTxt = a + b;}
return JTxt; }
[calc]:
squiffy.set(("verbNoun"), squiffy.verbNoun("take", "flagstone"));
Bluevoss wrote:
I figure this is going to be very much like my learning curve with Excel, where to really get anywhere, you needed VBA in the background.
@set low = 2
@set high = 4
{if low < high: low less then high}
{else: high less than low}
Done
Bluevoss wrote:I'll say it's simple. Even this doesn't work. I'm having to come up with a lot of tricks to get around these issues...@set low = 2
@set high = 4
{if low < high: low less then high}
{else: high less than low}
Done
(of course, now someone will show me where I'm wrong and I'll feel like and idiot. Though I will have working code )
@set var1 = 1
@set var2 = 2
if (squiffy.get("var2") == 2) {
squiffy.set("var2", 1);}
try
var1={var1}
var2={var2}
Bluevoss wrote:And here's how to do it. This is just an easy section of code, but you could string a bunch of these (including < and > to cover ranges) and get things done.
This is important since it means you don't have to go to different sections to set variables - you can do it right in one section.
@set var1 = 1
@set var2 = 2
if (squiffy.get("var2") == 2) {
squiffy.set("var2", 1);}
try
var1={var1}
var2={var2}
@start start
[[start]]:
var rnd=Math.ceil(Math.random()*3);
squiffy.set("rnd",rnd);
if (squiffy.get("rnd") == 1) {
squiffy.set("name", "Groo");}
if (squiffy.get("rnd") == 1) {
squiffy.set("desc", "Warrior");}
if (squiffy.get("rnd") == 1) {
squiffy.set("str", 3);}
if (squiffy.get("rnd") == 2) {
squiffy.set("name", "Blinky");}
if (squiffy.get("rnd") == 2) {
squiffy.set("desc", "Wizard");}
if (squiffy.get("rnd") == 2) {
squiffy.set("str", 1);}
if (squiffy.get("rnd") == 3) {
squiffy.set("name", "Pointy");}
if (squiffy.get("rnd") == 3) {
squiffy.set("desc", "Elf");}
if (squiffy.get("rnd") == 3) {
squiffy.set("str", 2);}
[[next]]
[[next]]:
{rnd}<br>
{name}<br>
{desc}<br>
{str}<br>
TyCamden wrote:I fixed OP's original post per the advice given in this thread.
Can anyone simplify it ?
@start start
[[start]]:
var rnd=Math.ceil(Math.random()*3);
squiffy.set("rnd",rnd);
if (rnd == 1) {
squiffy.set("name", "Groo");
squiffy.set("desc", "Warrior");
squiffy.set("str", 3);
}
if (rnd == 2) {
squiffy.set("name", "Blinky");
squiffy.set("desc", "Wizard");
squiffy.set("str", 1);
}
if (rnd == 3) {
squiffy.set("name", "Pointy");
squiffy.set("desc", "Elf");
squiffy.set("str", 2);
}
[[next]]
[[next]]:
{rnd}<br>
{name}<br>
{desc}<br>
{str}<br>