Hi,
i'm having a small issue with this:
In global rep exec always I need the appropriate label to change when conditions are met but the label fails to change text.
//LABEL CHANGES
if (Game_finished==true && have_coating==true)
if(Lab2.Text=="Find way to land on KOI 703 with the green gas."){
Lab2.Text="Find way to land on KOI 703 with the green gas. Now have protection.";
}
else if(Lab3.Text=="Find way to land on KOI 703 with the green gas."){
Lab3.Text="Find way to land on KOI 703 with the green gas. Now have protection.";
}
else if(Lab4.Text=="Find way to land on KOI 703 with the green gas."){
Lab4.Text="Find way to land on KOI 703 with the green gas. Now have protection.";
Could you help please.
Edit
Think it is one place (""); and the other place ""; :-[
Hi there, barefoot.
This is not how you program. Do you even care? I mean you've been doing this for months now, right?
And that if structure, while it will work, is pretty much the worst of all possible ways to implement this, in terms of readability.
As for the code in general: not only are you using the same long sequence of characters SIX times in that short piece of code, I'd bet a significant sum that using three labels isn't necessary either.
// somewhere in your initializing routines
taskMessage[23] = "Find way to land on KOI 703 with the green gas.";
taskMessage[24] = taskMessage[23].Append(" Now have protection.");
// LABEL CHANGES
if (Game_finished == true && have_coating == true) gameState = 24;
...
lCurrentTask.Text == taskMessage[gameState];
Edit: thanks CW, I was renaming the variables while typing this
Khris, I believe this:
taskMessage[24] = Gamestate[23].Append(" Now have protection.");
should be
taskMessage[24] = taskMessage[23].Append(" Now have protection.");
Hi Khris,
the way I did this was an old way I used to do. And like you say it does works even if it is not a proper 'programmers' way: which I believe you do as a job? Whereas I, at 58, and barely passed the abacus, still have much to learn. But I will says thanks for your response and 'Who loves ya' baby' (laugh)
Khris / Crimson: Not heard of or seen 'taskMessage' can you explain a bit more please.
cheers.
Well, AGS isn't an abacus :-D
But yeah, I see what you mean. Whatever works for you, right? Problem is, it frequently doesn't work, and I'm pointing out simple ways to prevent error prone code. (Although using custom arrays is probably not that simple a technique if you've never used arrays.)
taskMessage[] isn't built-in, it's just a bunch of variables I declared. That way I don't have to edit multiple lines when I want to fix errors or change the text.
Given the size of your game projects, I'd say you'd hugely benefit from learning a few more advanced bits of AGSScript. It'll definitely pay off.
Hi Khris,
Thanks.
Well, I have 6 labels on a gui, any of which can change depending on what conditions are met.
QuoteGiven the size of your game projects, I'd say you'd hugely benefit from learning a few more advanced bits of AGSScript. It'll definitely pay off.
I should really go to the next level when doing this so thanks.
cheers