the following is the code for the sell in my game i am making. but i am having problems. i want it to go all the way through and display a name for the type of items you have. but when i run the program it only displays the first thing it detects how could i fix that.


Code:
If L2(1)>0 or L2(2)>0 or L2(3)>0 or L2(4)>0 or L2(5)>0 or L2(6)>0 or L2(7)>0
:Then
:Goto A
:Else
:Return
:End
:Lbl A
:Text(9,28,"GOLD:
:Text(9,47,L1(7
:While L2(1)≥1
:Text(15,45,"1.HELMET
:End
:While L2(2)≥1
:Text(21,49,"2.BODY
:While L2(3)≥1
:Text(27,41,"3.LEGGINGS
:While L2(4)≥1
:Text(33,43,"4.ARMLETS
:While L2(5)≥1
:Text(39,43,"5.WEAPONS
:While L2(6)≥1
:Text(45,47,"6.BOOTS
:While L2(7)≥1
:Text(51,45,"7.GLOVES
:End
:End
:End
:End
:End
:End
could you post L2?
Have you learned nothing? Gotos == bad code. Gotos inside loops or inside If...then == super bad code. Additonally, how the hell are you supposed to exit the while loop? It never adjusts the value for the list element to check the conditional. I'm preety sure that is your problem right there.
While's should only be used when a loop is needed. Labels are things to try and avoid.


Code:
:If L2(1)<0 and L2(2)<0 and L2(3)<0 and L2(4)<0 and L2(5)<0 and L2(6)<0 and L2(7)<0
:Return
:Text(9,28,"GOLD:
:Text(9,47,L1(7
:If L2(1)≥1
:Text(15,45,"1.HELMET
:End
:If L2(2)≥1
:Text(21,49,"2.BODY
:If L2(3)≥1
:Text(27,41,"3.LEGGINGS
:If L2(4)≥1
:Text(33,43,"4.ARMLETS
:If L2(5)≥1
:Text(39,43,"5.WEAPONS
:If L2(6)≥1
:Text(45,47,"6.BOOTS
:If L2(7)≥1
:Text(51,45,"7.GLOVES
See lafferjm, it was that easy.
The code could be further optimized by reordering the conditional tests in the If statements. I.e., L2(1)>=1 becomes 1=<L2(1 , saving a little more memory. Smile
true, but that will do the trick.
i have already tried the if part. and well i am trying to make it simple so that i do not have to enter every possible combination. like what i am trying to say is if you buy a weapon i store a number into L2 and what i want it to do is if you own a boot and helmet to display boot and helmet instead of just helmet do you get what i am saying now.
So what's wrong with the modified code?
true, that is exactly what mine does
i will try it and see what it do
k, keep us posted.
thanks the code worked.
Awesome. Topic closed. On second thought, I'll leave it for the next time you have a question.
alrighty
if you read other posts in this topic this has nothing to do with them. i just stuck it here to keep down the number of topics in this here forum. anyways i am making a sprite and it draws and erases and i was wondering if there was any way possible to speed it up. and i know someone will probably say lines if they type the code in but i dont want to use lines because i am just trying to get used to the plotting and all that. here is code:


Code:

:ClrDraw
:AxesOff
:CoordOff
:0→Xmin
:94→Xmax
:‾62→Ymin
:0→YMax
:"24,25,26,27,28,
:""+Ans+Ans+Ans+Ans+Ans+"0→L1
:"10,10,10,10,10,11,11,11,11,11,12,12,12,12,12,13,13,13,13,13,14,14,14,14,14,
:""+Ans+"0→L2
:1→W
:While W
:For(A,1,25
:Pxl-On(L2(A),L1(A
:End
:getKey→K
:If max(K=24,25,26,34
:For(A,1,25
:Pxl-Off(L2(A),L1(A
:End
:L2-5(K=25)(L2>5)+5(K=34)(L2<57→L2
:L1-5(K=24)(L1>5)+5(K=26)(L1<89→L1
:End
I figured out what the problem is.
You should put:

Code:

:expr("{"+Ans+Ans+Ans+Ans+Ans+"0->L1

because otherwise L1 keeps evaluating it each time you mention it

and do something similar with L2
is there also a way to speed up the drawing and erasing because it looks slopy when it moves.
Statsprites:

:Plot1(Scatter,L1,L2,[tiny dot]
This is in points,not pixels.

I think that's the syntax...
is there anyway i can stop it from blinking so much
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 3
» All times are UTC - 5 Hours
 
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

 

Advertisement