Posted: Wed Nov 14, 2018 4:39 pm Post subject: Variables are being ignored.
Im working on a new script and I've encountered a problem I haven't seen before. Im using the word Travelling and assigning values ranging from 1 to 30 Eg
if isKeyPressed (0x77) then
Travelling = 1
end
if (Travelling == 1) and (BlaBla == DoDo) then
DoStuff
Travelling = 2
elseif (Travelling == 2) and (BlaBla == DoDo) then
DoStuff
Travelling = 3
elseif and so on
So yeah. Im encountering the problem where even if Travelling equals 3 at the time then the part of the code that requires it to equal 2 or 1 is still running. Im not sure why this is happening. Could someone enlighten me. I'd really appreciate it.
Thanks for the input guys. Sadly I was making a really simple mistake with OR statements. That's how some lines were being run repeatedly. I hadn't worked with OR statements before. Pretty much the part of the code with the Travelling variable that also had OR statements were being run repeatedly and ignoring the Travelling part.
if (Travelling == 2) and (Xcoords > 100) or (Zcoords > 600) or (Xcoords < 200) or (Zcoords < 800) then
Travelling = 3
by changing it to
if (Travelling == 2) then
if (Xcoords > 100) or (Zcoords > 600) or (Xcoords < 200) or (Zcoords < 800) then
Travelling = 3
end
elseif and so on
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum