Logic error

Hi, I want to do next page switch. With input E it works and when I want to go backwards and press Q in list and I'm going from index 1 to 0 it will give an error that says I have wrong index but I'm on 0 index in list.
14 Replies
♡Mr. L0stík♡
And I have forgotten to mention that I changed the if (currentPage <= 0) to currentPage == 0
Angius
Angius2mo ago
Well, that would be the issue You're at index 0 Then you decrement it It's now -1 -1 is not equal to 0
jcotton42
jcotton422mo ago
What on earth is skok?
♡Mr. L0stík♡
it is boolean. When code detect that next index will be more or less it will be true so nextpage will be the opposite index I'm maybe dumb but how to fix it?
Angius
Angius2mo ago
Go back to using <=
♡Mr. L0stík♡
Yeah but it still gives me the error
Angius
Angius2mo ago
The same one?
♡Mr. L0stík♡
Yes
Angius
Angius2mo ago
Could be because you never change currentPage You roll nextPage over, but currentPage stays as that -1 So next time you use it... it's -1
♡Mr. L0stík♡
I don't think so. I added currentPage = 4; when skok is true. There is some other problem, because when I'm going from index 1 to 0 it still kick me off Do you want video to show you the problem?
Angius
Angius2mo ago
No need, I know what the problem is I guess you should just debug it
♡Mr. L0stík♡
It works but for some reason it won't change to page 4 I somehow fixed it but this is smaller problem Thanks
Angius
Angius2mo ago
$debug
MODiX
MODiX2mo ago
Tutorial: Debug C# code and inspect data - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
Want results from more Discord servers?
Add your server
More Posts