Welcome to the Builder Academy

Question Faking a 2D array and % symbols on output

More
13 Feb 2020 14:36 #8568 by krell
Hey all,

I've managed to cobble together a script that fakes a 2-dimensional array. Unformatted and raw from my text editor: (the []'s aren't required, but just a convention I sort of like)
Code:
set i 0 set j 0 set m 0 set n 0 if count == %cmd% while %i% <= 5 set array[%i%][j] %m% while %j% <= 5 set array[i][%j%] %n% eval n %n% + 1 eval j %j% + 1 done eval m %m% + 1 eval i %i% + 1 set j 0 done set i 0 set j 0 while %i% <= 5 while %j% <= 5 %echo% %%%array[%%i%%][%%j%%]%%% eval j %j% + 1 done eval i %i% + 1 set j 0 done else return 0 end

Which seems to work except I get %'s in the output which I really don't want.

#LOG: LOGGING OUTPUT TO 'fake2dlist.log' FILESIZE: 0

Jess the test MOB. has arrived.
set krell level 20
Krell's level set to 20.
count

%00%
%01%
%02%
%03%
%04%
%05%
%10%
%11%
%12%
%13%
%14%
%15%
%20%
%21%
%22%
%23%
%24%
%25%
%30%
%31%
%32%
%33%
%34%
%35%
%40%

%41%
%42%
%43%
%44%
%45%
%50%
%51%
%52%
%53%
%54%
%55%

Edgar the test MOB leaves north.
#log off


Is there any way to get rid of them and still get the output I want? I've tried varying the level of %'s on the variable, but it either puts the name of the list or just the names i and j.

Please Log in or Create an account to join the conversation.

More
15 Feb 2020 04:17 #8569 by Parnassus
Thomas has written up a wonderful explanation of %s .

I'm not sure if this is the problem because, you know, I have some problems understanding the complex stuff but I hope you'll find it helpful anyway. And if not, hey, it gives people a chance to see it after 6 years because it's important.
The following user(s) said Thank You: krell

Please Log in or Create an account to join the conversation.

More
15 Feb 2020 05:22 #8570 by krell
I'll have to mull this over, just trying to apply it without thinking about the implication thoroughly is only tripping me up. But yeah, I do seem to recall this.

Hope to see you around more, Parna. Miss you.

Please Log in or Create an account to join the conversation.

More
15 Feb 2020 12:49 - 18 Feb 2020 20:42 #8571 by krell

Parnassus wrote: Thomas has written up a wonderful explanation of %s


Yep, that fixed it. Almost exactly as Thomas explained it. I had to track how many levels the percent symbol was at, and I had to use more eval statements then I originally wanted. Last night I wasn't able to wrap my head around it, but now it works. Thanks again, Parna. You're the best.
Code:
set i 0 set j 0 set m 0 set n 0 if count == %cmd% while %i% <= 5 set array[%i%][j] %m% while %j% <= 5 set array[i][%j%] %n% eval n %n% + 1 eval j %j% + 1 done eval m %m% + 1 eval i %i% + 1 set j 0 done set i 0 set j 0 while %i% <= 5 while %j% <= 5 eval temp %%array[%%%i%%][%%j%%]%% eval temp2 %temp% %echo% %temp2% eval j %j% + 1 done eval i %i% + 1 set j 0 done else return 0 end

Output

00
01
02
03
04
05
10
11
12
13
14
15
20
21
22
23
24
25
30
31
32
33
34
35
40
41
42
43
44
45
50
51
52
53
54
55

Last edit: 18 Feb 2020 20:42 by krell. Reason: Because it's "levels" not "level's"

Please Log in or Create an account to join the conversation.

More
22 Apr 2020 14:38 #8647 by Parnassus
Always nice to hear from you :) Glad you got it to work.

Please Log in or Create an account to join the conversation.

Time to create page: 0.191 seconds