SRL Archive - OSR Help

Picking information from an outputted array


GREEN GIANT

2013-07-28 15:06:07

Hi Guys,

When you do checks such as 'GetChooseOptions' and 'GetInven()' how would you go about selecting the outputted information. For example:

When i do 'GetChooseOption' on a Gamesnecklace and put it through WriteLn, i get the following printed array;

[('Remove Games necklace(2)', (546, 289, 730, 299), (543, 268, 730, 349)), ('Operate Games necklace(2)', (546, 304, 730, 317), (0, 0, 0, 0)), ('Examine Games necklace(2)', (546, 319, 730, 329), (0, 0, 0, 0)), ('Cancel', (546, 334, 730, 343), (0, 0, 0, 0))]

How would i go about selecting information from this if i wanted to say do a check and then writeLn 'Has 2 charges', or for instance if i did GetInven and then wanted to run a check for a certain integer within the array like for example;

If GetInven(1)Count = 138 then …. etc

Kasi

2013-07-28 15:10:19

@GREEN GIANT;

You could use Between. You would pass the Text to between.

Edit: Ill write you something give us a sec


function GetCharges(NeckOptions : Array Of TOptions) : Integer;
begin
Result := StrToInt(+Between('Games necklace(', ')', NeckOptions[0].Str));
end;

Should work, didnt compile. can be more efficient by simply just passing the string. but for learning purposes…
use like
Charges := GetCharges(GetChooseOptions(TextType));
where charges is an integer.

Nebula

2013-07-28 15:11:05

Use the function "Between()"

Edit: wtf I got ninjad

GREEN GIANT

2013-07-28 15:40:26

Thanks guys, but even with your worked example i can't understand how to use that function..

I'm rubbish with arrays and so haven't a clue how to call things from them, how do i even call your GetCharges function in my main loop?

GetCharges(what goes here?);

Kasi

2013-07-28 15:49:09

From: GREEN GIANT
Thanks guys, but even with your worked example i can't understand how to use that function..

I'm rubbish with arrays and so haven't a clue how to call things from them, how do i even call your GetCharges function in my main loop?

GetCharges(what goes here?);


GetChooseOptions, goes there.

Copy and paste that function in your script. all you have to do is replace the parameters with how you would use GetChooseOptions Regularly.
if you want pm me and ill help you over teamviewer.

GREEN GIANT

2013-07-28 16:12:01

From: Kasi
GetChooseOptions, goes there.

Copy and paste that function in your script. all you have to do is replace the parameters with how you would use GetChooseOptions Regularly.
if you want pm me and ill help you over teamviewer.


Hey Kasi,

If i use Getcharges(GetChooseOptions); in my main loop it simply writes all the options in my debug box the same as if i used WriteLn(GetChooseOptions);

Ignore the above, i actually had a WriteLn(GetChooseOptions); written in there lol

Have it working now, thankyou :)

Kasi

2013-07-28 16:28:17

From: GREEN GIANT
Hey Kasi,

If i use Getcharges(GetChooseOptions); in my main loop it simply writes all the options in my debug box the same as if i used WriteLn(GetChooseOptions);

Ignore the above, i actually had a WriteLn(GetChooseOptions); written in there lol

Have it working now, thankyou :)


okay :P PM if you need any help with anything else at all :P