Hey all, I'm attempting to write a Rogue-like RPG in TI-BASIC. I've gotten basic movement and mapping done, as well as a semi-functioning menu. However I'm having some issues with the inventory system. The idea is that items will be randomly generated, so I need a way to dynamically retrieve the text data required for the name. I have code so far that reads the values from a list, looks for the index in a string, strips any unnecessary spaces, then concatenates the name in a for loop. My only issue is with speed. So my question is, is there a better way to go about doing something like this? Or can the code be optimized in any way?
Code:
Code:
ClrDraw:AxesOff
{3,2,5.1,2,3,5.2,4,5,1.2→L₁
"001BERSERKER 002KNIGHT 003ROGUE 004ARCHER 005MAGE 006AXE 007SWORD 008DAGGER 009BOW 010STAFF 011CHAINMAIL 012PLATEMAIL 013BRIGANDINE014GAMBESON 015ROBE 016BURN 017FREEZE 018PARALYSIS 019POISON 020CURSE "→Str0
"001NEUTRAL 002FIRE 003ICE 004LIGHTNING 005EARTH 006SHADOW "→Str1
"001COMMON 002RARE 003EPIC 004LEGENDARY "→Str2
DelVar L
For(I,1,dim(L₁),3
iPart(L₁(I+2)→J
10fPart(L₁(I+2)→K
sub(Str2,3+inString(Str2,sub("0123456789",iPart(L₁(I)/100)+1,1)+sub("0123456789",10fPart(iPart(L₁(I)/10)/10)+1,1)+sub("0123456789",10fPart(L₁(I)/10)+1,1)),10)
If " "=sub(Ans,length(Ans),1)
Then
While " "=sub(Ans,length(Ans),1
sub(Ans,1+(" "=sub(Ans,1,1)),length(Ans)-1→Str3
End
Else
Ans→Str3
End
sub(Str1,3+inString(Str1,sub("0123456789",iPart(L₁(I+1)/100)+1,1)+sub("0123456789",10fPart(iPart(L₁(I+1)/10)/10)+1,1)+sub("0123456789",10fPart(L₁(I+1)/10)+1,1)),10)
If " "=sub(Ans,length(Ans),1)
Then
While " "=sub(Ans,length(Ans),1
sub(Ans,1+(" "=sub(Ans,1,1)),length(Ans)-1→Str4
End
Str3+" "+Str4→Str3
DelVar Str4
Else
Str3+" "+Ans→Str3
End
sub(Str0,3+inString(Str0,sub("0123456789",iPart((J+5K)/100)+1,1)+sub("0123456789",10fPart(iPart((J+5K)/10)/10)+1,1)+sub("0123456789",10fPart((J+5K)/10)+1,1)),10)
If " "=sub(Ans,length(Ans),1)
Then
While " "=sub(Ans,length(Ans),1
sub(Ans,1+(" "=sub(Ans,1,1)),length(Ans)-1→Str4
End
Str3+" "+Str4→Str3
DelVar Str4
Else
Str3+" "+Ans→Str3
End
Text(L,0,Str3
L+6→L
End