Log In  

Hi

I'm wondering about arrays, I cant seem to find any way to delete specific IDs/keys. I don't know if the functionality is lacking or I'm missing it.

eg to do;
del(step[count(step)-1]) to remove the last entry to an array

And in extent, how do I access a specific ID/key in an array?

I'm trying to do eg;
h = step[count(step)-1].h;
v = step[count(step)-1].v;

to get key from array looking like;
step = {h=INT,v=INT}
step = {h=INT,v=INT}
step = {h=INT,v=INT}

Say I'd want the last, or second to last entry, how would this be done?

P#93966 2021-06-24 14:22

1

So, the first thing you need to know is that arrays in PICO-8 are 1 indexed, not 0 indexed. So the first entry would be step[1] and not step[0], and you don't have to do the -1 to get the last element. In PICO-8, step[#step] will get you the last element in the array (#step returns the length of the step array).

To remove an element at a specific index, you can use the deli function: deli(step,2) will remove the second element. If you omit the index, like deli(step), then the last element is removed.

P#93973 2021-06-24 15:16

2bitchuck, absolutely lovely. Thank you kindly !

P#93975 2021-06-24 15:28

[Please log in to post a comment]