Sounds perfect!
Wolfschadowe.
It's a bit more complex than you might think at first glance, varPlus("variable", -1) and varMinus("variable", 1) may seem to achieve the same thing but there's a slight difference:Mortze wrote:1) What is the formula to substract a value from a variable? Is it VarPlus('variable', -1), or VarMinus('variable', 1), or something else?
// varMinus("variable", 1) will clamp the result to the [0, +MAX_INT] range.
// varPlus("variable", -1) won't.
// What does this mean in practice?
// Let's say that "variable" is currently 0. [readVar("variable") === 0 is true]
setVar("variable", 0); // just to be sure :)
varPlus("variable", -1); // "variable" will be -1 at this point
// Now for the other case, let's reset "variable" to 0.
setVar("variable", 0);
varMinus("variable", 1); // "variable" will be 0 at this point
// Excercise: What will be the result of varMinus("variable", 5) if the starting value is -10?
// Answer: 0, of course.
Mortze wrote:2) Can someone tell me what to write in the fuction when I need to check several variables and not only one.
// This is what tlaero would tell you:
function checkVolt()
{
var voltmeter = readVar("voltmeter");
var gas = readVar("gas");
if (voltmeter > 0 && gas < 3)
{
GotoPage("heli11.htm");
}
else
{
GotoPage("heli11b.htm");
}
}
// This is what I would tell you:
function checkVolt() {
"use strict";
var voltmeter = readVar("voltmeter"),
gas = readVar("gas");
if (voltmeter > 0 && gas < 3) {
GotoPage("heli11.htm");
} else {
GotoPage("heli11b.htm");
}
}
// And just to confuse you:
var checkVolt = function() { GotoPage(readVar("voltmeter") > 0 && readVar("gas") < 3 ? "heli11.htm" : "heli11b.htm"); }
Mortze wrote:Dear Masters of the Code,
May you enlight me on two misteries?
1/ What is the formula to substract a value from a variable? Is it VarPlus('variable', -1), or VarMinus('variable', 1), or something else?
2/ Can someone tell me what to write in the fuction when I need to check several variables and not only one.
Example:
function checkVolt()
{
var voltmeter = readVar("voltmeter");
if (voltmeter > 0)
{
window.location = "heli11.htm";
}
else
{
window.location = "heli11b.htm";
}
return false;
}
What if I wanted to check also a variable like "gas" and wanted it NOT above, let's say, 3.
So to proceed to heli11.htm the voltmeter has to be superior to 1 and the gas has to be below 3.
How do I write it?
A cookie for the wise one!
Mortze wrote:I use VarPlus1('variable'). What should I use for a substraction by 1 point?.
First of all it's varPlus1() and varMinus1() - capitalization is important!Super wrote:VarMinus1('variable')Mortze wrote:I use VarPlus1('variable'). What should I use for a substraction by 1 point?
Say you want to achieve the following:Mortze wrote:Please, code is Chinese to me, so could you explain to me as if I was a toddler monkey?
function checkVolt() {
// Declare local variables to hold the values of the "voltmeter" and "gas" game-variables.
var voltmeter = readVar("voltmeter");
var gas = readVar("gas");
// If the voltmeter shows a value greater than 0 and there's less than 3 units of gas then
if (voltmeter > 0 && gas < 3) {
// Go to page "heli11.htm"
GotoPage("heli11.htm");
} else {
// Else go to page "heli11b.htm"
GotoPage("heli11b.htm");
}
}
Bug with the page comments.tlaero wrote:Changes in 6.3
Added a page comment box that can be shown or not.
Wolfschadowe wrote:When creating an Area target, after filling the title section, if you go to page comments and start typing, the comment appears over the image in the area target, and then it replaces the active area target title text.
Return to The workshop of creators
Users browsing this forum: No registered users and 4 guests