as said I would like to turn on and off objects
function hComputerbutton_AnyClick()
{
if (Verbs.UsedAction(eGA_WalkTo)) {
} else if (Verbs.UsedAction(eGA_Push)) {
}
if (MyCounter == 0) {
player.Say("Okay.");
player.Walk(214, 159, eBlock);
object[0].Visible = true;
MyCounter +=1;
}
if (MyCounter == 1) {
player.Say("Okay.");
player.Walk(214, 159, eBlock);
object[0].Visible = false;
MyCounter -=1;
}
but instead of having separate instances, It does it all in the same loop. essentially i'm hoping using the minus counter will reset back to 0 enabling the character to keep turning off and on continuously
Shouldn't you have
MyCounter = 1;
instead of MyCounter +=1, and vice versa (= 0;) with the second one. The same could be done with a boolean variable, but I guess it all comes down to personal preference.
You don't need a counter. Simply do:
player.Say("Okay.");
player.Walk(214, 159, eBlock);
object[0].Visible = !object[0].Visible;
If the object is visible (true), this will set it to false. If it's false, it'll turn it to true.
Laura shows a better solution, but the reason your original code doesn't work is that between the two MyCounter conditions you need an else if to ensure only one of them runs. Otherwise the first block runs, changes the value of MyCounter to 1, then checks the second condition (which is now true), and runs that block as well.
Perfect. that's so much eaiser! thanks everyone
Btw, you should really look into the features of the Thumbleweed template, specifically the Verbs.* functions.
That interface is well-known for the ability to interrupt any action as long as the character hasn't reached the hotspot yet, and you're using blocking walks right now, which can be pretty jarring for the player.
Check out the PDF in the game folder to learn about the available commands, the arguably most important one being Verbs.MovePlayer().
thanks Khris wil do!