SRL Archive - OSR Help

Storing data for multiple variables using one command


purerange86

2014-09-20 23:08:06

Was wondering if there's a way to do this. Right now I have an array of integer that I'm using to click some slots in the inventory using a modification of the itemcoords() function.


var
slot[1..28] of integer;

I want to reassign the slot numbers so that I can click the slots in a different order. I could just do


slot[1] := 5
slot[2] := 6
slot[3] := 19
slot[4] := some other random specified number

etc, but I was wondering if there was perhaps a better way to do this, perhaps with another array?

Thanks!

riwu

2014-09-20 23:56:34


var
slot[1..28] of integer;
Does that compile?
A way to declare an array of static length that i know of:
slot: array[0..27] of integer;

u can assign it by just slot := [5, 6, 19, ….];
If you do that, u wont have to specify the length of array at the declaration too (but specifying it can ensure u've correctly entered 28 integers)

Also, remember that an array starts with index 0.

purerange86

2014-09-21 09:56:36

Oh was my bad, was late at night and not paying attention. That for sure does not compile.

I'm also a noob, first time using arrays but hey–thanks for the reply, helped a lot

Incurable

2014-09-21 10:20:44

Here's how I did something similar, not sure if it'll help you or not:


// slotArray is a TBoxArray declared earlier
slotArray := [tabBackpack.getSlotBox(2), tabBackpack.getSlotBox(6), tabBackpack.getSlotBox(7)];
i := random(3);
slotBox := slotArray[i];

I use that to choose a random slot out of slot 3, 6, and 7 (other slots are dealt with elsewhere in the same procedure).