prgmZEN1:

:randInt(1,10)LMYS2(1)
:If LMYS2(1)2:Then
:"Beaver"Str0
:{4,1,2,1,15,5}LMONST
:prgmZEN2:End
:If LMYS2(1)3 and LMYS2(1)4:Then
:"Rabbit"Str0
:{3,1,1,1,10,3}LMONST
:prgmZEN2:End
:If LMYS2(1)5:Then
:" "Str2
:sub(Str1,1,T-1)+Str2+sub(Str1,T+1,length(Str1)-TStr1
:Return



prgmZEN2:


:ClrHome
:Menu(Str0,"SWORD",1,"MAGIC",2,"STATS",3,"ITEMS",4,"RUN",5
:Lbl 1
:randInt(0,LSTAT(3))LMYS2(2)
:ClrHome
:Output(1,1,"You deal"
:Output(1,10,LMYS2(2)
:Pause
:LMONST(1)-LMYS2(2)LMONST(1)
:If LMONST(1)0:Then
:prgmZEN3:End
:prgmZEN4
:Lbl 2
:Menu("MAGIC","CURE",6,"Lightning",7,"Fire",8,"BACK",8
:Lbl 6
:ClrHome
:If LSTAT(2)2:Then
:LSTAT(2)-2LSTAT(2)
:LSTAT(1)+10LSTAT(1)
:If LSTAT(1)>LSTAT(5):Then
:Output(1,1,"You heal to fullHP!"
:Pause
:LSTAT(5)LSTAT(1)
:prgmZEN4:End
:Output(1,1,"You heal 10 HP"
:Pause
:prgmZEN4:End
:Output(1,1,"Not enough MP"
:Pause
:prgmZEN1
:Lbl 7
:ClrHome
:If LSTAT(2)4:Then
:LSTAT(2)-4LSTAT(2)
:randInt(0,4)LMYS2(2)
:LMONST(1)-LMYS2(2)LMONST(1)
:Output(1,1,"You deal"
:Output(1,10,LMYS2(2)
:Pause
:If LMONST(1)0:Then
:prgmZEN3:End
:prgmZEN4:End
:Output(1,1,"Not enough MP"
:Pause
:prgmZEN1
:Lbl 8
:If LSTAT(2)8:Then
:LSTAT(2)-8LSTAT(2)
:randInt(0,8)LMYS2(2)
:LMONST(1)-LMYS2(2)LMONST(1)
:Output(1,1,"You deal"
:Output(1,10,LMYS2(2)
:Pause
:If LMONST(1)0:Then
:prgmZEN3:End
:prgmZEN4:End
:Output(1,1,"Not enough MP"
:Pause
:prgmZEN1
:Lbl 9
:prgmZEN1
:Lbl 3
:ClrHome
:Output(1,1,"HP-"
:Output(1,6,LSTAT(1)
:Output(1,9,"/"
:Output(1,12,LSTAT(5)
:Output(2,1,"MP-"
:Output(2,6,LSTAT(2)
:Output(2,9,"/"
:Output(2,12,LSTAT(6)
:Output(3,1,"STR-"
:Output(3,6,LSTAT(3)
:Output(4,1,"DEF-"
:Output(4,6,LSTAT(4)
:Output(5,1,"EXP-"
:Output(5,6,LMYS2(4)
:Output(5,9,"/"
:Output(5,12,LMYS2(5)
:Pause
:prgmZEN2
:Lbl 4
:Menu("Items","Bread",10,"Honey Bread",11,"Red Potion",12,"Blue Potion",13)
:Lbl 10
:If LMYS2(10)>0:Then
:LMYS2(10)-1LMYS2(10)
:LSTAT(1)+10LSTAT(1)
:If LSTAT(1)>LSTAT(5):Then
:Output(1,1,"You heal to fullHP!"
:Pause
:LSTAT(5)LSTAT(1)
:prgmZEN4:End
:Output(1,1,"You heal 10 HP"
:Pause
:prgmZEN4:End
:ClrHome
:Output(1,1,"None."
:Pause
:prgmZEN2:End
:Lbl 11
:If LMYS2(11)>0:Then
:LMYS2(11)-1LMYS2(11)
:LSTAT(1)+20LSTAT(1)
:If LSTAT(1)>LSTAT(5):Then
:Output(1,1,"You heal to fullHP!"
:Pause
:LSTAT(5)LSTAT(1)
:prgmZEN4:End
:Output(1,1,"You heal 20 HP"
:Pause
:prgmZEN4:End
:ClrHome
:Output(1,1,"None."
:Pause
:prgmZEN2:End
:Lbl 12
:If LMYS2(12)>0:Then
:LMYS2(12)-1LMYS2(12)
:LSTAT(2)+10LSTAT(2)
:If LSTAT(2)>LSTAT(6):Then
:Output(1,1,"You heal to fullMP!"
:Pause
:LSTAT(6)LSTAT(2)
:prgmZEN4:End
:Output(1,1,"You heal 10 MP"
:Pause
:prgmZEN4:End
:ClrHome
:Output(1,1,"None."
:Pause
:prgmZEN2:End
:Lbl 13
:If LMYS2(13)>0:Then
:LMYS2(13)-1LMYS2(13)
:LSTAT(2)+20LSTAT(2)
:If LSTAT(2)>LSTAT(6):Then
:Output(1,1,"You heal to fullMP!"
:Pause
:LSTAT(6)LSTAT(2)
:prgmZEN4:End
:Output(1,1,"You heal 20 MP"
:Pause
:prgmZEN4:End
:ClrHome
:Output(1,1,"None."
:Pause
:prgmZEN2:End
:Lbl 5
:randInt(1,4)LMYS2(3)
:If LMYS2(3)=1:Then
:ClrHome
:Output(1,1,"You ran away! (WIMP!)"
:Pause
:ClrHome
:prgmZTOWN1:prgmZGA:End
:If LMYS2(3)2:Then
:ClrHome
:Output(1,1,"You fail to run! (FAILURE!)"
:Pause
:ClrHome
:prgmZEN4


prgmZEN3:


:ClrHome
:Output(1,1,"You kill"
:Output(2,1,Str0
:Pause
:LMYS2(4)+LMONST(5)LMYS2(4)
:randInt(0,LMONST(6)LMYS2(Cool
:LMYS2(9)+LMYS2(8)LMYS2(9)
:prgmZLVL:prgmZTOWN1:prgmZGA


prgmZEN4:


:randInt(0,LMONST(3))LMYS2(7)
:ClrHome
:Output(1,1,Str0
:Output(2,1,"deals"
:Output(2,7,LMYS2(7)
:Pause
:LSTAT(1)-LMYS2(7)LSTAT(1)
:If LSTAT(1)0:Then
:ClrHome
:Output(1,1,"You die..."
:Pause
:Stop:End
:prgmZEN2





I'm thinking of switching from list to variables in here too, but wouldn't really want to, considering I took a long time changing it to lists...
Well, here is another tip, if you use lists, try to use user defined lists as saved data, and the on-calc lists (L1-L6) as the lists being used in the game.

There is a difference in 3 bytes of Memory between using L1 and LSTAT. Dunno if it would be faster, but it is more optimized.
If I change back to variables, think that'd fix it?
What is it doing wrong?
A) The memory issue. Though, I was at 4000, now i'm at 8000 (deleted some stuff).
B) After combat, I still get slower and slower. Just not as slow as before.
C) Here's my idea:
In the prgm that runs everything, you define each list element as a variable. In the rest of the programs, you use the variables (makes it quicker). Then, when you Quit or Rest, all variables get stored back into the lists so you can load the game later on. Smile
Let me look through it again really quick, see what I can figure out...
Alright. Try to make it reasonably quick, I'm past my bedtime! Wink
What is up with:

Quote:
f LMONST(1)0:Then
:prgmZEN3:End
:prgmZEN4:End
:Output(1,1,"Not enough MP"
:Pause
:prgmZEN1
:Lbl 9
:prgmZEN1
:Lbl 3


That will cause a memory leak...

As will
Quote:
Output(4,6,LSTAT(4)
:Output(5,1,"EXP-"
:Output(5,6,LMYS2(4)
:Output(5,9,"/"
:Output(5,12,LMYS2(5)
:Pause
:prgmZEN2
:Lbl 4


As I look through this code, I am horrified to learn that you start in prgmZEN1, which calls ZEN2, which is ok. BUT in ZEN2, you keep calling ZEN1, Which doesn't allow the program to return back to the calling, or parent, program. The calc allots memory to keep track of that as well. You need to use more Return commands. In ZEN3, it looks like you are calling up the level and main engine progs, this is bad. Trust me, you REALLY need to go through and start adding Return commands.

Try that and see if things don't go better...
:prgmZEN3:End
:prgmZEN4:End
:Output(1,1,"Not enough MP"
:Pause
:prgmZEN1
:Lbl 9
:prgmZEN1
:Lbl 3


Should be ZEN2, not 1. Is it OK to call the same prgm? ZEN2 calling ZEN2?


In here as well:

:Output(4,6,LSTAT(4)
:Output(5,1,"EXP-"
:Output(5,6,LMYS2(4)
:Output(5,9,"/"
:Output(5,12,LMYS2(5)
:Pause
:prgmZEN2
:Lbl 4
No. At the very top of the program, put Lbl AA. At every instance in ZEN2, replace with Goto AA, as long as it is not within an If:Then:End loop. Try that on the calc, see if that doesn't improve the game...

Basically, everytime you see prgmZEN2 within prgmZEN2, then replace it with Goto AA.
Shall take a bit, but OK.
Well, let us know the results, I have to sign off, as it is 10:45, and I need to work tommorrow, so I can get some cars finished up. (I am a mechanic and tow truck driver, to cut off any questions. Wink)

Besides, if I am going to get Pokemon ready for its next release tommorrow, I will need all the energy I can get... Smile
Sweet, I'll be there to download it. Wink


I'll have results after school, I hope...
KermMartian wrote:
Yes. As long as a Goto isn't inside a For, IfThen, Whiile, or Repeat loop, it's ok. Although in general, avoid Lbl and Goto if possible.


Wait... This may make me sound stupid, but what's wrong with using goto in an ifthen? I'm trying to make a third person shooter and in the few lines of code I have, I'm already doing it.

ex.

:if condition
:then
:change variable
:change another variable
:goto whereever
:end
Because the calc allocates memory to determine how many End statements it has to hit, and if it never does and hits that spot again and again, it uses up RAM, causing the infamous ERR:MEMORY error...
Yup. If you Goto out of the Then/End, the calculator will be reminding itself to look for an End that will never come. The more times it happens, the slower your program will get, and when it has too many Ends to remember, it will just ERR:MEMORY.
Did you read my reply, Kerm? Razz I said the same thing... Laughing

@dopeheaddude: When using Source coder, under each prog, there are 3 (?) links which says something along the lines of:

HTML
PHPbb
BBCode

Just copy and paste the code from the phpbb code box that drops down. It will look less confusing that way...

(Just put Final Fantasy Magic's End through, and I can save a whopping 19 bytes... Laughing)
Nice! Very Happy
prgmZEN1

BASIC Code wrote:
:randInt(1,10)LMYS2(1)
:If LMYS2(1)2:Then
:"Beaver"Str0
:{4,1,2,1,15,5}LMONST
:prgmZEN2:End
:If LMYS2(1)3 and LMYS2(1)4:Then
:"Rabbit"Str0
:{3,1,1,1,10,3}LMONST
:prgmZEN2:End
:If LMYS2(1)5:Then
:" "Str2
:sub(Str1,1,T-1)+Str2+sub(Str1,T+1,length(Str1)-TStr1
:Return
Generated by SourceCoder, © 2005 Cemetech



prgmZEN2:


BASIC Code wrote:
:Lbl AA
:ClrHome
:Menu(Str0,"SWORD",1,"MAGIC",2,"STATS",3,"ITEMS",4,"RUN",5
:Lbl 1
:randInt(0,C)LMYS2(2)
:ClrHome
:Output(1,1,"You deal"
:Output(1,10,LMYS2(2)
:Pause
:LMONST(1)-LMYS2(2)LMONST(1)
:If LMONST(1)0:Then
:prgmZEN3:End
:prgmZEN4
:Lbl 2
:Menu("MAGIC","CURE",6,"Lightning",7,"Fire",8,"BACK",8
:Lbl 6
:ClrHome
:If B2:Then
:B-2B
:A+10A
:If A>E:Then
:Output(1,1,"You heal to fullHP!"
:Pause
:EA
:prgmZEN4:End
:Output(1,1,"You heal 10 HP"
:Pause
:prgmZEN4:End
:Output(1,1,"Not enough MP"
:Pause
:Goto AA
:Lbl 7
:ClrHome
:If B4:Then
:B-4B
:randInt(0,4)LMYS2(2)
:LMONST(1)-LMYS2(2)LMONST(1)
:Output(1,1,"You deal"
:Output(1,10,LMYS2(2)
:Pause
:If LMONST(1)0:Then
:prgmZEN3:End
:prgmZEN4:End
:Output(1,1,"Not enough MP"
:Pause
:Goto AA
:Lbl 8
:If B8:Then
:B-8B
:randInt(0,8)LMYS2(2)
:LMONST(1)-LMYS2(2)LMONST(1)
:Output(1,1,"You deal"
:Output(1,10,LMYS2(2)
:Pause
:If LMONST(1)0:Then
:prgmZEN3:End
:prgmZEN4:End
:Output(1,1,"Not enough MP"
:Pause
:Goto AA
:Lbl 9
:Goto AA
:Lbl 3
:ClrHome
:Output(1,1,"HP(-)"
:Output(1,6,A
:Output(1,9,"/"
:Output(1,12,E
:Output(2,1,"MP(-)"
:Output(2,6,B
:Output(2,9,"/"
:Output(2,12,F
:Output(3,1,"STR(-)"
:Output(3,6,C
:Output(4,1,"DEF(-)"
:Output(4,6,D
:Output(5,1,"EXP(-)"
:Output(5,6,N
:Output(5,9,"/"
:Output(5,12,Z
:Output(6,1,"Money(-)"
:Output(6,12,
:Pause
:Goto AA
:Lbl 4
:Menu("Items","Bread",10,"Honey Bread",11,"Red Potion",12,"Blue Potion",13)
:Lbl 10
:If LMYS2(10)>0:Then
:LMYS2(10)-1LMYS2(10)
:A+10A
:If A>E:Then
:Output(1,1,"You heal to fullHP!"
:Pause
:EA
:prgmZEN4:End
:Output(1,1,"You heal 10 HP"
:Pause
:prgmZEN4:End
:ClrHome
:Output(1,1,"None."
:Pause
:Goto AA
:Lbl 11
:If LMYS2(11)>0:Then
:LMYS2(11)-1LMYS2(11)
:A+20A
:If A>E:Then
:Output(1,1,"You heal to fullHP!"
:Pause
:EA
:prgmZEN4:End
:Output(1,1,"You heal 20 HP"
:Pause
:prgmZEN4:End
:ClrHome
:Output(1,1,"None."
:Pause
:Goto AA
:Lbl 12
:If LMYS2(12)>0:Then
:LMYS2(12)-1LMYS2(12)
:B+10B
:If B>F:Then
:Output(1,1,"You heal to fullMP!"
:Pause
:FB
:prgmZEN4:End
:Output(1,1,"You heal 10 MP"
:Pause
:prgmZEN4:End
:ClrHome
:Output(1,1,"None."
:Pause
:Goto AA
:Lbl 13
:If LMYS2(13)>0:Then
:LMYS2(13)-1LMYS2(13)
:B+20B
:If B>F:Then
:Output(1,1,"You heal to fullMP!"
:Pause
:FB
:prgmZEN4:End
:Output(1,1,"You heal 20 MP"
:Pause
:prgmZEN4:End
:ClrHome
:Output(1,1,"None."
:Pause
:Goto AA
:Lbl 5
:randInt(1,4)LMYS2(3)
:If LMYS2(3)=1:Then
:ClrHome
:Output(1,1,"You ran away! (WIMP!)"
:Pause
:ClrHome
:prgmZTOWN1:prgmZGA:End
:If LMYS2(3)2:Then
:ClrHome
:Output(1,1,"You fail to run! (FAILURE!)"
:Pause
:ClrHome
:prgmZEN4
Generated by SourceCoder, © 2005 Cemetech



prgmZEN3:


BASIC Code wrote:
:ClrHome
:Output(1,1,"You kill"
:Output(2,1,Str0
:Pause
:N+LMONST(5)N
:randInt(0,LMONST(6))LMYS2(8)
:+LMYS2(8)
:prgmZLVL:prgmZTOWN1:prgmZGA
Generated by SourceCoder, © 2005 Cemetech



prgmZEN4:


BASIC Code wrote:
:randInt(0,LMONST(3))LMYS2(7)
:ClrHome
:Output(1,1,Str0
:Output(2,1,"deals"
:Output(2,7,LMYS2(7)
:Pause
:A-LMYS2(7)A
:If A0:Then
:ClrHome
:Output(1,1,"You die..."
:Pause
:Stop:End
:prgmZEN2
Generated by SourceCoder, © 2005 Cemetech




As I understand, the more it runs, the more memory is taken. The more memory is taken, the more it lags.

A) Why does it take more and more memory? I don't understand the concept...
B) How can I stop it from happening? Currently, I can go about 10-20 minutes without a memory error...
Me wrote:
Because the calc allocates memory to determine how many End statements it has to hit, and if it never does and hits that spot again and again, it uses up RAM, causing the infamous ERR:MEMORY error...


The above also seems to apply when calling programs over and over (i.e. prgmZEN2 calling ZEN4, and then ZEN4 calls prgmZEN2 and repeats) will also do the same thing, because the calc also allocates memory to "remember" where to return to once it comes across the Return command, or runs out of programming. Smile

Also, ZEN4 needs to lose the call to prgmZEN2, if you already didn't get the hint... Smile
  
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 Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next
» View previous topic :: View next topic  
Page 4 of 10
» 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