var HowManyPikeMen=prompt("How many?")
squiffy.set("Cost", HowManyPikeMen*3);
if (Cost>Money) {
alert("You don't have enough money for that!") }
else {
squiffy.set("Pikemen", HowManyPikeMen) }
[[start]]:
var Money=10;
var HowManyPikeMen=prompt("How many?");
set("Cost", HowManyPikeMen*3);
if (get("Cost")>Money) // <-- get("Cost")
alert("You don't have enough money for that!");
else set("Pikemen", HowManyPikeMen);
Wow, thanks for spotting all those things for me. But sadly it still doesn't seem to work :/
It doesn't come up with an alert if it costs too much and it doesn't set the "Pikemen" variable to "HowManyPikeMen" if i have enough. I was wondering if I would be able to do this in the normal squiffy code instead (not JavaScript), would that be possible?
I fixed the previous javascript oriented codes above. (Try it again).
And I rewrited the codes with the minimum use of javascript as the following.
[[start]]:
@set money=10
How many? {rotate HowMany:1:2:3:4:5}
+++Done
set("moneyLeft",get("money")-3*get("HowMany"));
{if moneyLeft<0: You don't have enough money for that!}
{else:[[You hired {HowMany} pikemen.]](hirePikemen)}
[[hirePikemen]]:
set("Pikemen",get("HowMany"));
set("money",get("moneyLeft"));
Pikemen: {Pikemen}, Money: {money}