CEMETECH
Leading The Way To The Future
Login [Register]
Username:
Password:
Autologin:

Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 140 users online: 1 member, 107 guests and 32 bots.
Members: None.
Bots: VoilaBot (3), Spinn3r (1), Magpie Crawler (3), VoilaBot (8), Googlebot (17).
RSS & Social Media
SAX
You must log in to view the SAX chat widget
    » Goto page 1, 2, 3  Next
» View previous topic :: View next topic  
Author Message
lafferjm


Calculator Deity


Joined: 14 Mar 2006
Posts: 1529
Location: at my house

Posted: 13 Apr 2006 03:42:26 pm    Post subject: problem with code

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
Back to top
rivereye


Future Admin


Joined: 16 Mar 2005
Posts: 5450
Location: Out Fishing

Posted: 13 Apr 2006 03:49:36 pm    Post subject:

could you post L2?
_________________
I am the eye of the river
>(<')


Back to top
something1990


Supreme Commander of the Asgard Fleet


Joined: 12 Jan 2006
Posts: 1144
Location: Orilla

Posted: 13 Apr 2006 03:49:49 pm    Post subject:

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.
_________________
Check the links:



Please help save Stargate SG-1.
Back to top
rivereye


Future Admin


Joined: 16 Mar 2005
Posts: 5450
Location: Out Fishing

Posted: 13 Apr 2006 03:53:38 pm    Post subject:

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

_________________
I am the eye of the river
>(<')


Back to top
something1990


Supreme Commander of the Asgard Fleet


Joined: 12 Jan 2006
Posts: 1144
Location: Orilla

Posted: 13 Apr 2006 04:11:55 pm    Post subject:

See lafferjm, it was that easy.
_________________
Check the links:



Please help save Stargate SG-1.
Back to top
Kuro


Numerophile


Joined: 09 Jun 2005
Posts: 1207
Location: [insert position vector]

Posted: 13 Apr 2006 04:16:21 pm    Post subject:

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
_________________
Allergic to morons? Don't click here. >(v')

Back to top
rivereye


Future Admin


Joined: 16 Mar 2005
Posts: 5450
Location: Out Fishing

Posted: 13 Apr 2006 04:28:46 pm    Post subject:

true, but that will do the trick.
_________________
I am the eye of the river
>(<')


Back to top
lafferjm


Calculator Deity


Joined: 14 Mar 2006
Posts: 1529
Location: at my house

Posted: 13 Apr 2006 04:37:15 pm    Post subject:

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.
Back to top
something1990


Supreme Commander of the Asgard Fleet


Joined: 12 Jan 2006
Posts: 1144
Location: Orilla

Posted: 13 Apr 2006 04:41:08 pm    Post subject:

So what's wrong with the modified code?
_________________
Check the links:



Please help save Stargate SG-1.
Back to top
rivereye


Future Admin


Joined: 16 Mar 2005
Posts: 5450
Location: Out Fishing

Posted: 13 Apr 2006 04:45:37 pm    Post subject:

true, that is exactly what mine does
_________________
I am the eye of the river
>(<')


Back to top
lafferjm


Calculator Deity


Joined: 14 Mar 2006
Posts: 1529
Location: at my house

Posted: 13 Apr 2006 05:43:44 pm    Post subject:

i will try it and see what it do
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55878
Location: Earth, Sol, Milky Way

Posted: 13 Apr 2006 07:13:51 pm    Post subject:

k, keep us posted.
_________________


Back to top
lafferjm


Calculator Deity


Joined: 14 Mar 2006
Posts: 1529
Location: at my house

Posted: 14 Apr 2006 02:11:37 pm    Post subject:

thanks the code worked.
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55878
Location: Earth, Sol, Milky Way

Posted: 14 Apr 2006 02:14:10 pm    Post subject:

Awesome. Topic closed. On second thought, I'll leave it for the next time you have a question.
_________________


Back to top
lafferjm


Calculator Deity


Joined: 14 Mar 2006
Posts: 1529
Location: at my house

Posted: 14 Apr 2006 05:44:11 pm    Post subject:

alrighty
Back to top
lafferjm


Calculator Deity


Joined: 14 Mar 2006
Posts: 1529
Location: at my house

Posted: 03 Aug 2006 08:49:38 am    Post subject:

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
Back to top
calc84maniac


Epic z80 roflpwner


Joined: 01 Aug 2006
Posts: 1503
Location: The ex-planet Pluto

Posted: 03 Aug 2006 09:27:32 am    Post subject:

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
_________________
~calc84maniac has spoken.

Projects:
TI-Boy SE
F-Zero
Super Mario (aka Project M)


Last edited by calc84maniac on 24 Aug 2006 03:29:48 pm; edited 2 times in total
Back to top
lafferjm


Calculator Deity


Joined: 14 Mar 2006
Posts: 1529
Location: at my house

Posted: 03 Aug 2006 09:33:07 am    Post subject:

is there also a way to speed up the drawing and erasing because it looks slopy when it moves.
Back to top
calc84maniac


Epic z80 roflpwner


Joined: 01 Aug 2006
Posts: 1503
Location: The ex-planet Pluto

Posted: 03 Aug 2006 09:39:01 am    Post subject:

Statsprites:

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

I think that's the syntax...
_________________
~calc84maniac has spoken.

Projects:
TI-Boy SE
F-Zero
Super Mario (aka Project M)


Last edited by calc84maniac on 24 Aug 2006 03:29:59 pm; edited 1 time in total
Back to top
lafferjm


Calculator Deity


Joined: 14 Mar 2006
Posts: 1529
Location: at my house

Posted: 03 Aug 2006 09:42:42 am    Post subject:

is there anyway i can stop it from blinking so much
Back to top
Display posts from previous:   
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
    » Goto page 1, 2, 3  Next
» View previous topic :: View next topic  
Page 1 of 3 » All times are GMT - 5 Hours

 
Jump to:  
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

© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.035074 seconds.