SRL Archive - Help and Support

Syntax help


WT-Fakawi

2011-03-18 04:36:23

This is the Record I use for my new Ratz script, to identify objects in my inventory.

type
InvItem = record
w, h, z, s : Integer;
n : string;
C : Array of Integer;
Checksum: Integer;
end;
InvBase, LibBase: Array of InvItem;

I wish to print these Records in the debug and use it as reference, by placing it back into my script. This would greatly help enlarge it's efficiency. But I can't seem to get it right in terms of syntax:

this wont work…syntax error:
LibBase[0]:=[26, 25, 76, 0, 'Tinderbox',[(4013632), (5395285), (537146), (470581), (5395285), (4474439), (5198163), (604482), (5790300), (2105392), (4803148), (2960943), (2105392)], 43854188];
LibBase[1]:=[28, 25, 177, 0, 'Small fishing net',[(1581355), (2174522), (1317667), (1779248), (1251873), (592911), (2105392), (1317925), (1910835), (1515561)], 15547289);
LibBase[2]:=[27, 28, 73, 0, 'Water rune',[(10296087), (10296087), (10296087), (5658202), (11316660), (9079697), (8092544), (7434871), (6710891), (11447990), (9342612), (9342612)], 109314340);
LibBase[3]:=[25, 13, 62, 0, 'Coins',[(1606564), (1606564), (2141400), (1606564), (2276073), (2105392), (1606564), (1472662)], 14421783);
LibBase[4]:=[29, 22, 141, 0, 'Shrimps',[(1333640), (1262210), (1328264), (2105392), (1534624), (1195385), (2105392)], 10864907);
LibBase[5]:=[28, 30, 85, 0, 'Raw rat meat',[(11645369), (1318280), (10592937), (10329508), (10724266), (1318280), (1318280), (9539992), (7434871), (9671577), (9342612), (6974063), (2105392)], 92315427);
LibBase[6]:=[21, 26, 76, 0, '1ron hatchet',[(1202555), (2105392), (4144962), (3487032), (2105392)], 13045333);
LibBase[7]:=[18, 29, 72, 0, 'Iron full helm',[(3684410), (3289909), (3158066), (3803167), (4196642)], 18132194);
LibBase[8]:=[17, 28, 108, 0, 'Amulet of power',[(10066592), (11711419), (9211026), (2105392)], 33094429);
LibBase[9]:=[30, 22, 133, 0, 'Iron platebody',[(2368550), (3487032), (4013376), (4013376), (4013376), (526345), (1908255), (1710619), (3815997), (3289909), (2763308)], 31910143);
LibBase[10]:=[11, 28, 73, 0, 'Iron platelegs',[(3487032), (3289909), (3289909), (4144962), (4013376), (2105392), (2105392), (2105392), (2105392), (2105392)], 28752148);
LibBase[11]:=[26, 29, 78, 0, '1ron scimitar',[(6184546), (2105392), (2105392), (6052960), (2960687), (9868957), (3158066)], 32436000);
LibBase[12]:=[29, 28, 76, 0, 'Iron kiteshield',[(535098), (534584), (4144962), (4473927), (4473927), (4473927), (4473927), (601664), (601664), (601664)], 24915344);
LibBase[13]:=[28, 30, 85, 0, 'Cooked meat',[(3886980), (998503), (3557497), (3425909), (3623291), (998503), (998503), (3228013), (2503509), (3293807), (3162219), (2305870), (2105392)], 34087996);


anyone knows how to properly format this?

Floor66

2011-03-18 04:59:49

Maybe you can make a func which returns an invitem? Like _InvItem(w, h, z, s : Integer; etcetc): InvItem; ?
So u put LibBase := _InvItem(stuff);

Also, idk if its on purpose, but u put "1ron hatchet" (One-ron) a few times.

i luffs yeww

2011-03-18 05:56:50

I'm not really sure what you're asking? :x

If I'm right, you just need to loop through each item. for i := 0 to High(array) do writeln(array); or whatever.

Sorry if that's not what you mean. :(

rogeruk

2011-03-18 06:16:24

Just a heads up you got 1ron scimitar, 1ron hatchet

WT-Fakawi

2011-03-18 06:24:37

Each time when I startup my script, I parse all Items in the inventory, by grabbing their TPA, Width, Height, some unique colors and the object's name. This means floating with the mouse over each and every object in the inventory every time I startup the script. I want to avoid that by having an in-script reference Database with the properties of all objects.

So I need a way to printout this Record so that I can use it inscript. That way I can skip the mouse movements at startup.

I want that before I release my script. It makes it much more undetectable.


Rogeruk: 1ron. Yeah, sometimes the simba OCR does that :)

Dan Cardin

2011-03-18 06:59:48

If i understand correctly, you need to do each variable seperately, you cant just initialize something in an array like you're doing. You could make an array of each variable, fill those vars up like you're doing, then loop through and do like

for i := 0 to high(arr) do
begin
arr.w := warr
arr.n := sarr

etc.

i luffs yeww

2011-03-18 07:07:37

Dan is right. If you think about how the variable Players works in SRL, you'll know why this isn't working. You can't do Players[0] := ['i luffs yeww', 'mypassword', '1234', etc.];. You have to do Players[0].Name := 'i luffs yeww'; etc.

:)

rogeruk

2011-03-18 07:18:27

Yea it works if you array them.


InvBase: Array of InvItem;
wa, ha, za : Array of Integer;

Procedure Populate;
Var
I : Integer;
Begin
For I := 0 to High(wa) Do
Begin
With InvBase[I] Do
Begin
w := wa[I];
h := ha[I];
z := za[I];
writeln(InvBase[I]);
End;
End;
End;

(26, 25, 76, 0, '', [], 0)
(28, 25, 177, 0, '', [], 0)
(27, 28, 73, 0, '', [], 0)
(25, 13, 62, 0, '', [], 0)
(29, 22, 141, 0, '', [], 0)
(28, 30, 85, 0, '', [], 0)
(21, 26, 76, 0, '', [], 0)
(18, 29, 72, 0, '', [], 0)
(17, 28, 108, 0, '', [], 0)
(30, 22, 133, 0, '', [], 0)
(11, 28, 73, 0, '', [], 0)
(26, 29, 78, 0, '', [], 0)
(29, 28, 76, 0, '', [], 0)
(28, 30, 85, 0, '', [], 0)

Only added the first 3

WT-Fakawi

2011-03-18 07:20:15

I know that. I only wished for Pascal to be a little more adaptive. So what you are saying is:

you cannot format a Record into one line?

nielsie95

2011-03-18 07:24:53

You can use Floor66's method and just use a function to create a record from its arguments :)

rogeruk

2011-03-18 07:28:58

From: WT-Fakawi
I know that. I only wished for Pascal to be a little more adaptive. So what you are saying is:

you cannot format a Record into one line?


Doesn't look like it

i luffs yeww

2011-03-18 07:42:07


function ReturnLibBase(arr: TVariantArray): InvItem;
begin
with Result do
begin
w := arr[0];
h := arr[1];
z := arr[2];
s := arr[3];
n := arr[4];
c := arr[5];
CheckSum := arr[6];
end;
end;

As long as you stay in the order you have.. that will work.

Floor66

2011-03-18 10:29:49

From: i luffs yeww

function ReturnLibBase(arr: TVariantArray): InvItem;
begin
with Result do
begin
w := arr[0];
h := arr[1];
z := arr[2];
s := arr[3];
n := arr[4];
c := arr[5];
CheckSum := arr[6];
end;
end;

As long as you stay in the order you have.. that will work.


^This
That's what I meant.

lordsaturn

2011-03-18 21:52:28

From: nielsie95
You can use Floor66's method and just use a function to create a record from its arguments :)


This. Create a constructor for your type. Other examples of constructors for types that are built into Simba include Point() and IntToBox(). You will just have to make your own.

Nava2

2011-03-18 23:46:56

LibBase[0]:= _libBase(26, 25, 76, 0, 'Tinderbox', TIntegerArray([4013632, 5395285, 537146, 470581, 5395285, 4474439, 5198163, 604482, 5790300, 2105392, 4803148, 2960943, 2105392]), 438541880);

lordsaturn

2011-03-19 00:26:11

From: Nava2
LibBase[0]:= _libBase(26, 25, 76, 0, 'Tinderbox', TIntegerArray([4013632, 5395285, 537146, 470581, 5395285, 4474439, 5198163, 604482, 5790300, 2105392, 4803148, 2960943, 2105392]), 438541880);


function CreateInvItem(w, h, z, s: Integer; n: string; C: array of Integer; CheckSum: Integer): InvItem;
begin
Result.w := w;
Result.h := h;
Result.z := z;
Result.s := s;
Result.n := n;
Result.C := C;
Result.CheckSum := CheckSum;
end;

procedure WriteInvItem(item: InvItem);
var
str: string;
begin
str := 'CreateInvItem'+ ToStr(item) + ';';
Writeln(str);
end;

WT-Fakawi

2011-03-19 04:25:13

Thank you lordsaturn, nielsie and floor66!… and all others giving input :)

So I use a string as Database and use CreateInvItem to reconstruct the InvItems, right?

YoHoJo

2011-03-19 04:27:30

I LOVE SRL so much! This is great! Good job everyone!

WT-Fakawi

2011-03-19 07:27:33

Yes! It works. Thats good news :). Never have I assembled such a strangely formatted string in Pascal.

Yoho: Shiny day today?