I was porting some code to my new HP Prime, but I ran into a problem. I cannot find an alternative to the code "B》dim(LZ)", as it produces the error "Invalid input". What is a good alternative to setting the size of a list (or matrix) from a variable?
Entire TI-BASIC code (For context, nobody port this for me):
[spoiler]C-1》C
Prompt B
B》dim (LZ)
B》dim (LPOKE)
Prompt B
If B=1
Then
Prompt B
Fill (B, LPOKE
Fill (1, LZ)
0》C
End
dim (LPOKE》B
While 1
Lbl 0
[[1,0,3,1][4,3,10,4] [15,10,5,0][12,11,15,10][20,11,10,8][17,16,17,4][20,15,20,19]]》[B]
C+1》C
If C=B+1
1》C
If LZ(C)=2
Then
iPart (rand×4》D
If D≠0
Then
1》LZ(C)
Disp "GET UP"
Disp C
End
Goto 0
End
Pause
ClrHome
0》H
If LPOKE(C)≤0
Goto 0
While H<B and B≤14
H+1》H
Disp LPOKE(H)
If B<7 and LZ(H)=2
Output(H,12,"F
End
0》H
While H<B-7 and B≤14 and B>7
H+1》H
Output(H,1,LPOKE(H)
If LZ(H)=2
Output(H,5,"F
End
Output(5,8,C
If B>7 and B≤14
B-7》H
While H<B
H+1》H
If LZ(H)=2
Output(H-B+7,12,"F
End
C》D
While D=C or LPOKE(D)≤0
Prompt D
End
ClrHome
If LZ(D)=1
Disp "STANDING"
If LZ(D)=2
Disp "FALLEN"
Pause
ClrHome
Disp "1:POKE"
Disp "2:JAB POKE
Disp "3:FOOT POKE"
Disp "4:POWER POKE"
Disp "5:SOLE POKE"
Disp "6:SHANK POKE"
Disp "7:FALCON POKE:
0》A
While A<7
0》H
A+1》A
While H<2
H+1》H
Output(A,11+2H,[B](A,H+2(LZ(D)-1))
End
End
Prompt E
iPart(rand*20+1》F
Disp F
0》G
If [B](E,2LZ(D))≥F
-1》G
If [B](E,2LZ(D)-1)≤F
1》G
If G=-1
Then
Disp "FALLEN"
2》LZ(C)
End
If G≤0
Goto 0
[[6,0][6,3][6,5][8,10][10,8][60,0][30,40]]》[B]
Disp "SUCCESS"
Disp "DAMAGE:"
iPart(rand*[B](E,1))+[B](E,2)+1》H
LPOKE(D)-H》LPOKE(D)
Disp H
Pause
Goto 0
[/spoiler]
Heya gogoluke and welcome to the forums. I don't remember what is the exact syntax to set a list dimension, but one trick I found that worked was to set a value to the highest list element you wanted.
For example, in Tunnel, I wanted my list to be 512 elements, so I just stored 0 in element 512 and it set the list dimension for me (or maybe it set it to 513? I forgot if lists start at 0 or 1 in HP PPL). That trick doesn't work if you want to set the list to a lower dimension afterwards, though (it only works upwards).
0►LZ(B);
(I actually wish that there was a TI-BASIC interpreter written in HP PPL, so that no porting would have been necessary, but since that doesn't exist yet)
Perhaps
@alexgt might know if there is an actual dim command on the HP Prime?
Thanks, and I wish that there was an interpreter too, would be a lot faster than manually porting all of my programs. There is a dim function, but it appears to only report list/matrix dimensions, not set them. Lists are started at 1 in Non-CAS mode, but in CAS it starts at 0. On another note, what is the alternate for FILL(1,LZ)? (The game keeps track of HP via lists)
Hm interesting that HP would let us view dimensions, but not set them. That seems rather limiting when it's like one of the most fundamental features of lists and matrices in maths. I don't exactly remember if there is a FILL command, but since HP PPL runs so fast, you can probably fill the elements one by one via a FOR loop and it will almost be instant.
I was hoping that wasn't the case, but at least it will be fast. I'm not filling insane amounts of list items anyways, so it shouldn't be a problem even if it were TI-BASIC.
Use the MAKELIST(Expr,Var,Start,End) command :P
Or I can make a program for UtilPack ;)
Ideally it would be best for him to use standalone solutions for now, since UltiPack dev is stalled for now. But thanks for the command. Does that set his list dimension alex?
yep Expr is the equation that you want evaluated (or just put zero in there if you want it to be a fresh list). Var is the variable you want to be a list and then just put 1 for the start and the DIM you want for End ;)
Thank you. Do you happen to know of an alternative to output()? It appears to not exist for HP Prime.
No, but there is an alternative to Text(), which is TEXTOUT_P() . Also Instead of ClrHome or ClrDraw you can use RECT_P(#FFFFFF).
You can use some maths and take advantage of TEXTOUT_P(), like what DJ said. all of the characters except some special chars take up the same amount of pixels if that helps ;)
Wait, HP PPL text is monospace? O.O I thought it wasn't. That's good to know, because on the 83+ text on the graph screen wasn't.
Well, at least for the built in program editor it is, but I am pretty sure it is also monospaced in regular TEXTOUT_P() functions but I haven't needed it to be so I haven't tested it.
Last I tried doing something with text on the HP Prime, the text was definitely not monospaced. Unless something has changed since then.
really?! it must be only in CAS, Homeview, NOtes, and the Editor because I know they are in there.
I'll check later to see if it's monospaced in my old screenshots. If it isn't except in the editor, then that might explain why the program editor had speed problems. :P
EXPORT Street_Poker()
BEGIN
PRINT();
remove(1=1,L2);
remove(1=1,L1);
0▶C;
INPUT(B,"Playercount");
0▶L1(B);
0▶L2(B);
INPUT(H,"Health");
1▶X;
WHILE X≤B DO //Was a bit lazy when setting up lists, but this works.
H▶L2(X); //setuphealth
" "▶L1(X); //fallen
X+1▶X;
END;
[[1,0,3,1],[4,3,10,4],[15,10,5,0],[12,11,15,10],[20,11,10,8],[17,16,17,4],[20,15,20,19]]▶M0; //Move statistics
[[6,0],[6,3],[6,5],[8,10],[10,8],[60,0],[30,40]]▶M1; //Move HP Withdrawl
WHILE 1=1 DO //Begin Gameplay
WHILE 1=1 DO //Like goto on ti, except with BREAK
PRINT();
C+1▶C; //Go to the next player
IF C==B+1 THEN //Set player to one if current player does not exist
1▶C
END;
IF L1(C)=="F" THEN //Check if player is fallen
IF RANDINT(4)==0 THEN
" "▶L1(C); //Denotes that no, player is not fallen
PRINT(C + " got up");
END;
BREAK; //basically goto line 21
END;
WAIT();
0▶H;
IF L2(C)≤0 THEN //if player has no health, move to next player
BREAK;
END;
WHILE H<B AND B≤14 DO //Display players, HP counts, and Fallen status
H+1▶H;
PRINT(L1(H) + L2(H));
END;
WAIT();
C▶D; //starts while loop
WHILE D==C OR L2(D)≤0 DO
INPUT(D,C);
IF D==0 THEN
RANDINT(1,B)▶D;
END;
END;
PRINT();
IF L1(D)==" " THEN
PRINT("Standing");
1▶Q;
ELSE
PRINT("Fallen");
3▶Q;
END;
PRINT();
PRINT("1:Poke " + M0(1,Q) + " " + M0(1,Q+1)); //inefficient way of showing all moves and their stats. yay.
PRINT("2:Jab Poke " + M0(2,Q) + " " + M0(2,Q+1));
PRINT("3:Foot Poke " + M0(3,Q) + " " + M0(3,Q+1));
PRINT("4:Power Poke " + M0(4,Q) + " " + M0(4,Q+1));
PRINT("5:Sole Poke " + M0(5,Q) + " " + M0(5,Q+1));
PRINT("6:Shank Poke " + M0(6,Q) + " " + M0(6,Q+1));
PRINT("7:Falcon Poke " + M0(7,Q) + " " + M0(7,Q+1));
WAIT();
PRINT();
8▶P;
WHILE P<1 OR P>7 DO
INPUT(P);
IF P==0 THEN
RANDINT(1,7)▶P;
END;
END;
RANDINT(1,20)▶F;
PRINT(F);
0▶G;
IF M0(E,Q+1)≥F THEN
0-1▶G;
PRINT("Fallen");
"F"▶L1(C);
END;
IF M0(E,Q) THEN
1▶G;
END;
IF G≤0 THEN
BREAK;
END;
PRINT("Success");
RANDINT(1,M1(E,1))+M1(E,2)▶H;
L2(D)-H▶L2(D);
PRINT(H + "damage");
WAIT();
BREAK;
END;
END;
END;
I am having issues with the line " IF M0(E,Q+1)≥F THEN", as it says "Invalid Input"
The info button shows this: (http://173.74.22.194/error1.PNG)
Does anyone know why this may be happening?
@alexgt Dj told me to add your username to the post.
Hm interesting. The error and line of code suggests that you might be trying to access a matrix element outside the matrix boundaries, but I sometimes got invalid input errors when there were no error too. Have you tried restarting your HP Prime (by pressing ON+SYMB) to see if that might fix it?
You should use some TEXTOUT_P commands to display the values of E and Q+1 to see if you are going outside the boundaries. I haven't used HP PPL in a while so at first glance I can't help much, but maybe alexgt might be able to.
The error occurs both in my physical calculator and in my simulated one. Once I get home from school I will take a look at those variables.
EDIT: Looked over code, I used E instead of P with the matrix. Yippee. Now to figure out why failed moves are still attacking.
EDIT 2: also solved that.
Glad to hear :D, I didn't notice those actually >.<
Also backup very often. Especially the simulator, which can wipe out your data if it crashes too often. As for sprites, since you are making a Poker game, you could use the RECT_P command instead to save space then use text to draw the card icons (I think they exist in the character map). That would save space. Let me know if you need help displaying sprites, though.
EDIT: Also you scared me the other night, because I first misread Street Poker as Strip Poker <_<
Awesome! glad to hear you fixed those bugs ;)\
As for sprites you can do what DJ said and use RECT_P or you can use and App but it is up to you ;)
Quote from: DJ Omnimaga on January 14, 2016, 05:45:25 PM
Glad to hear :D, I didn't notice those actually >.<
Also backup very often. Especially the simulator, which can wipe out your data if it crashes too often. As for sprites, since you are making a Poker game, you could use the RECT_P command instead to save space then use text to draw the card icons (I think they exist in the character map). That would save space. Let me know if you need help displaying sprites, though.
EDIT: Also you scared me the other night, because I first misread Street Poker as Strip Poker <_<
While strip poker on a calculator would be pretty funny, it's not even Poker. The description of the TI-83 version reads "Street Poker is a game created by Luis on his calculator. Programmed to be a mixture of Pokemon, D&D, and Street Fighter, the game has people playing in a turn based fighter game where dice rolls determine your fate."
Basically, you and your friends poke each other digitally.
Oh rofl, I see now. By the way, will you post screenshots eventually?
(http://imgur.com/0VjF98i.png)
A new game with four players.
(http://imgur.com/obTzr6i.png)
The attacks screen. The left number is what the dice must roll at or above to make a move successful. The right number is what the dice must roll at or below in order to make you fall
(http://imgur.com/yiOA7fI.png)
The top number is what the dice rolled. (No, it's not that one xkcd joke, it just happened to be four this time.)
(http://imgur.com/Ta9wWDL.png)
The results of the last move. Give calculator to player two. If you have no friends, just push zero on each selection screen to have an AI pick for you.
(http://i.imgur.com/xbhVtkq.png)
Different game with fallen players.
Nice to see multiplayer mode. I wonder if it would work on hardware A calcs or only the newer C hardware? I got the A one that isn't compatible with the wifi add-on and I don't think it lets me connect two calcs together via USB either.
I am curious about how the game will look like with actual graphics :) (and color)
Sounds cool but I have to wait to get home to see the pictures because our school blocked imgur <_<