I'm having a problem with the 'if' an 'else if' operators.Ã, Here's the code:
if (cIronf.Transparency == 0) {
Ã, Ã, score ++;
Ã, Ã, cIronf.Transparency = 33;
Ã, }
Ã, else if (cIronf.Transparency == 33) {
Ã, Ã, score ++;
Ã, Ã, cIronf.Transparency = 66;
Ã, }
Ã, else if (cIronf.Transparency == 66) {
Ã, Ã, score ++;
Ã, Ã, cIronf.ChangeRoom(-1);
Ã, }
The problem is that the first time the script is run, cIronf's transparency is set to 33, but after that when the interaction is run, nothing happens.Ã, Why is this?Ã, How do I fix it?
The code you posted is correct. It should set the transparency to 66 the second time you run it (etc). The problem has to be somewhere else. Are you sure you are calling this script correctly?
I'm pretty positive that I'm calling it correctly. It is called by a function, and this script is also in that function:
if (cCoppera.Transparency == 0) {
score ++;
cCoppera.Transparency = 50;
}
else if (cCoppera.Transparency == 50) {
score ++;
cCoppera.ChangeRoom(-1);
}
This script works perfectly. The first run makes cCoppera half-invisible, and the second run makes it disappear. This script (the one above) is in the same function, but errors like I described:
if (cIronf.Transparency == 0) {
score ++;
cIronf.Transparency = 33;
}
else if (cIronf.Transparency == 33) {
score ++;
cIronf.Transparency = 66;
}
else if (cIronf.Transparency == 66) {
score ++;
cIronf.ChangeRoom(-1);
}
Thank you for any help you can offer.
This bit from the manual might explain it:
QuoteSome rounding is done internally when the transparency is stored -- therefore, if you get the transparency after setting it, the value you get back might be one out.
So, what if you try rounding it (e.g. to 35 and 65) yourself, or use a variable to store
cIronf's state, and check that rather than the transparency?
Ahh, that seems to have been the problem. It seems the engine counts in 10's for transparency. Thank you very much Ashen!