Author Topic: Need help with my code...  (Read 2402 times)

0 Members and 1 Guest are viewing this topic.

Offline joao9856

  • LV3 Member (Next: 100)
  • ***
  • Posts: 73
  • Rating: +3/-0
    • View Profile
Need help with my code...
« on: November 08, 2012, 04:16:24 pm »
I've recently started to program and i tried making a guess my number game...
the code is very deorganized but it worked with easy dificulty, when i upgraded the game so it could have normal and hard nothing succeded.
adn i'm getting a litle frustrated :banghead: so i'll post the code to see if anyone could help me find my error.
don't mind the text they are in portuguese my mother tongue.
Code: [Select]
Define LibPub gan()=
Prgm
:Lbl z
:e:=0
:If e=e Then
:RequestStr "Facil=F Normal=N Dificil=D",a,0
:If a="F" Then
:Goto v
:ElseIf a="f" Then
:Goto v
:elseIf a="D" Then
:Goto l
:ElseIf a="d" Then
:Goto l
:elseIf a="N" Then
:Goto q
:ElseIf a="n" Then
:Goto q
:Lbl q
:b:=randInt(0,100)
:Lbl u
:Request "Adivinha o numero de 0-100",c,0
:If c=b Then
:Disp "Bom jogo acabaste em ",e," tentativas!"
:Lbl t
:RequestStr "Novo jogo? S\N?",d,0
:If d="S" Then
:e:=0
:Goto z
:ElseIf d="s" Then
:e:=0
:Goto z
:ElseIf d="N" Then
:Goto y
:ElseIf d="n" Then
:Goto y
:Else
:Goto t
:EndIf
:ElseIf c>b and c<101 Then
:Text "Muito alto!",0
:e:=e+1
:Goto u
:ElseIf c<b and c>−1 Then
:Text "Muito baixo!",0
:e:=e+1
:Goto u
:Else
:Text "É só de 0 a 100!"
:Goto u
:Lbl l
:b:=randInt(0,1000)
:Lbl m
:Request "Adivinha o numero de 0-1000",c,0
:If c=b Then
:Disp "Bom jogo acabaste em ",e," tentativas!"
:Lbl n
:RequestStr "Novo jogo? S\N?",d,0
:If d="S" Then
:e:=0
:Goto z
:ElseIf d="s" Then
:e:=0
:Goto z
:ElseIf d="N" Then
:Goto y
:ElseIf d="n" Then
:Goto y
:Else
:Goto n
:EndIf
:ElseIf c>b and c<1001 Then
:Text "Muito alto!",0
:e:=e+1
:Goto m
:ElseIf c<b and c>−1 Then
:Text "Muito baixo!",0
:e:=e+1
:Goto m
:Else
:Text "É só de 0 a 1000!"
:Goto m
:Lbl v
:b:=randInt(0,10)
:Lbl w
:Request "Adivinha o numero de 0-10",c,0
:If c=b Then
:Disp "Bom jogo acabaste em ",e," tentativas!"
:Lbl x
:RequestStr "Novo jogo? S\N?",d,0
:If d="S" Then
:e:=0
:Goto z
:ElseIf d="s" Then
:e:=0
:Goto z
:ElseIf d="N" Then
:Goto y
:ElseIf d="n" Then
:Goto y
:Else
:Goto x
:EndIf
:ElseIf c>b and c<11 Then
:Text "Muito alto!",0
:e:=e+1
:Goto w
:ElseIf c<b and c>−1 Then
:Text "Muito baixo!",0
:e:=e+1
:Goto w
:Else
:Text "É só de 0 a 10!"
:Goto w
:endif
:endif
:endif
:endif
:endif
:Lbl y
:EndPrgm

Offline Rhombicuboctahedron

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 437
  • Rating: +41/-6
    • View Profile
Re: Need help with my code...
« Reply #1 on: November 08, 2012, 10:08:33 pm »
Hi, and welcome to omnimaga, and one question, are you Portuguese or Brazilian, or another?

I don’t know what you think went wrong.
It worked perfectly for me, so good job.
I’ll admit the code is pretty ugly, but it works, and my code is never pretty either.

One thing I’ll suggest though, is that you allow for N to work as one of your guesses to immediately exit the game, because it was annoying to have to keep playing because I couldn’t exit.

Offline joao9856

  • LV3 Member (Next: 100)
  • ***
  • Posts: 73
  • Rating: +3/-0
    • View Profile
Re: Need help with my code...
« Reply #2 on: November 09, 2012, 03:08:42 am »
I'm portuguese and i'll deal with that problem a litle later now i have to go to school.

EDIT: i came back already and for some reason the code was not running in my calc O.O, when i pasted it into my computer it worked in students software.
Added the option "exit" in the middle of the game like Rhombicuboctahedron suggested then i decided to try it in my calc with that little improvement to see if it worked since it didn't make any sense not to, and guess what it did work.

Now can anyone explain me why it was not working?
« Last Edit: November 09, 2012, 10:16:12 am by joao9856 »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Need help with my code...
« Reply #3 on: November 09, 2012, 09:09:06 pm »
What OS version do you have? (Welcome to the forums by the way :D)
« Last Edit: November 09, 2012, 09:09:16 pm by DJ_O »
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline joao9856

  • LV3 Member (Next: 100)
  • ***
  • Posts: 73
  • Rating: +3/-0
    • View Profile
Re: Need help with my code...
« Reply #4 on: November 10, 2012, 01:37:50 pm »
thanks.
I using os version 3.1.0.392 with Ndless installed latest version.

Offline Rhombicuboctahedron

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 437
  • Rating: +41/-6
    • View Profile
Re: Need help with my code...
« Reply #5 on: November 10, 2012, 02:14:26 pm »
What OS is your student software in, and were you trying to send it from your computer to your calc, or was it already on your calc. It should work on your calc, actually, no matter even if your software OS is newer, so I have no idea why it wouldn’t have worked.

Offline joao9856

  • LV3 Member (Next: 100)
  • ***
  • Posts: 73
  • Rating: +3/-0
    • View Profile
Re: Need help with my code...
« Reply #6 on: November 10, 2012, 07:17:27 pm »
Students software is the latest, and i always work on the calc.No matter what it got fixed and the problem is not there to annoy me. And i couldn't use a letter as you suggested because the request asks for an integer so a string won't work, so i used a number that does not bother the game.