SRL Archive - Lape

Exception in Script: Operator "cmp_Equal" not compatible with types


rj

2013-12-11 22:56:20

How come I can't do

function rsps_inventory.invCount:Integer;
var
i:Integer;
begin
for i := 0 to high(inventory.slots) do
begin
if rsps_inventory.slotFull(i) then
result := result + 1;
end;
end;

function rsps_inventory.invFull:Boolean;
begin
exit(rsps_inventory.invCount = 28);
end;

Specifically

exit(rsps_inventory.invCount = 28);




But in pascal script I can do
result := invCount = 28

bonsai

2013-12-12 08:14:12

If you use parenthesis on your function calls (which imo you always should) then it works fine.

Gu3st...

2013-12-12 08:41:29

To elaborate on @bonsai's post: When you're referring to a function without adding in parenthesis then Lape will check if the function itself equals 28 and not the result from the function.

Try doing this:
writeLn(functionName);
writeLn(functionName());

To see the difference

rj

2013-12-12 15:10:23

From: Zyt3x
To elaborate on @bonsai's post: When you're referring to a function without adding in parenthesis then Lape will check if the function itself equals 28 and not the result from the function.

Try doing this:
writeLn(functionName);
writeLn(functionName());

To see the difference


Thanks for the replies, but I still seem to get the same error whether I use


exit(rsps_inventory.invCount() = 28);

or
exit(self.invCount() = 28);

or

c := rsps_inventory.invCount();
exit(c = 28);

Gu3st...

2013-12-12 16:05:30

Just do Result := blah() = 28; then. No real need for exit(result); in a one liner

rj

2013-12-12 16:11:40

From: Zyt3x
Just do Result := blah() = 28; then. No real need for exit(result); in a one liner


result := (rsps_inventory.invCount() = 28);

Still the same results :/

Abu

2013-12-12 16:26:28

Is this error thrown when trying to compile or while the script is running?

Coz it compiles fine for me (osr + lape).

rj

2013-12-12 16:34:08

From: abu_jwka
Is this error thrown when trying to compile or while the script is running?

Coz it compiles fine for me (osr + lape).


on compile or run

Gu3st...

2013-12-12 16:44:53

Try
function rsps_inventory.invFull:Boolean;
begin
exit(rsps_inventory.invCount = 28); // self. instead of rsps_inventory.
end;

Abu

2013-12-12 16:46:43

From: Officer Barbrady
on compile or run


Hmm, I don't understand why I can't reproduce this (error) :L

rj

2013-12-12 16:48:38

From: abu_jwka
Hmm, I don't understand why I can't reproduce this :/


I guess the include would help :)

Install https://github.com/officerBarbrady/srlRSPS

and run this test:

{$I RSPS/srlRSPS.Simba}

var
myServer:_rsps_server;

begin
myServer := _rsps_server.init(720, 'CloudIn');
end.

Abu

2013-12-12 17:04:36

From: Officer Barbrady
I guess the include would help :)

Install https://github.com/officerBarbrady/srlRSPS


Yes it would :p

Anyway managed to create a similar issue with srl 6:

var
oreDTM : Array [0..1] of Integer;

procedure freeDTMz();
begin

if oreDTM = 0 then
FreeDTMs(oreDTM);
end;

The above throws this:

Exception in Script: Operator "cmp_Equal" not compatible with types "array [0..1] of Int32" and "Int32" at line 12, column 13

In order to make it compile I must do this:
var
oreDTM : Array [0..1] of Integer;

procedure freeDTMz();
begin

if (length(oreDTM) = 0) then
FreeDTMs(oreDTM);
end;


Will that solution in any way help with the error your getting?

rj

2013-12-12 17:13:13

From: abu_jwka
Yes it would :p

Anyway managed to create a similar issue with srl 6:

var
oreDTM : Array [0..1] of Integer;

procedure freeDTMz();
begin

if oreDTM = 0 then
FreeDTMs(oreDTM);
end;

The above throws this:

Exception in Script: Operator "cmp_Equal" not compatible with types "array [0..1] of Int32" and "Int32" at line 12, column 13

In order to make it compile I must do this:
var
oreDTM : Array [0..1] of Integer;

procedure freeDTMz();
begin

if (length(oreDTM) = 0) then
FreeDTMs(oreDTM);
end;


Will that solution in any way help with the error your getting?


I don't think so since invCount is a integer :s

Olly

2013-12-12 17:15:31

Everyone works fine for me, not sure what the problem is.
type
rsps_inventory = record b: byte; end;

function rsps_inventory.invCount:Integer;
begin
end;

function rsps_inventory.invFull:Boolean;
begin
result := (self.invCount() = 28);
end;

Gu3st...

2013-12-12 20:43:35

Those guys just ignored my post, @Olly; :(

rj

2013-12-12 21:26:15

From: Zyt3x
Those guys just ignored my post, @Olly; :(


using self results in the same error :s

Gu3st...

2013-12-12 22:09:06

From: Officer Barbrady
using self results in the same error :s

Post the code. I don't believe you :p

rj

2013-12-12 22:15:55

From: Zyt3x
Post the code. I don't believe you :p


https://github.com/officerBarbrady/srlRSPS

Gu3st...

2013-12-13 17:13:46

You don't seem to have fully understood the concept of type functions, unfortunately; you should always use self. instead of i.e _rsps_server. in every type function; this also makes it easier for you to rename types.

There's also not really any reason for you to also return that type as a result in addition to editing the type's self-variables. type functions should mostly return things like boolean, integer, string or extended; but you can of course return something else if it's absolutely necessary.

Example:
function typeFunction.loadFromFiles(const filePaths : TStringArray): Boolean;
begin
result := True;
for self.loaded := 0 to length(filePaths) do
result := self.files.loadFromFile(filePaths[I]) and result;
end;

bonsai

2013-12-13 18:30:43

From: Officer Barbrady

{$I RSPS/srlRSPS.Simba}

var
myServer:_rsps_server;

begin
myServer := _rsps_server.init(720, 'CloudIn');
end.


You don't call init that way with the type on it. You call it against the variable you made like this:

{$I RSPS/srlRSPS.Simba}

var
myServer:_rsps_server;

begin
myServer.init(720, 'CloudIn');
end.


And the code snippet Olly posted is the same thing I tried the other day. Worked fine for me. You are using lape?

rj

2013-12-18 11:54:13

From: bonsai
You don't call init that way with the type on it. You call it against the variable you made like this:

{$I RSPS/srlRSPS.Simba}

var
myServer:_rsps_server;

begin
myServer.init(720, 'CloudIn');
end.


And the code snippet Olly posted is the same thing I tried the other day. Worked fine for me. You are using lape?


got it thanks


Getting a access violation here:

procedure rsps_inventory.init(rev:Integer);
begin
case rev of
317..507:
with self do
begin
outline := 65536;
setUp(IntToBox(563, 214, 720, 460));
bounds := intToBox(0, 0, 0, 0);
name := '317 inventory';
end;
507..719:
with self do
begin
outline := 65536;
setUp(IntToBox(563, 214, 720, 460));
bounds := intToBox(0, 0, 0, 0);
name := '508 inventory';
end;
720..800:
with self do
begin
outline := 131072;
setUp(IntToBox(568, 213, 717, 458));
bounds := intToBox(0, 0, 0, 0);
name := '724 inventory';
end;
end;
end;

at any line were it has self.outline (which is a integer)

type
rsps_inventory = record(rsps_interface)
slots:TboxArray;
outline:Integer;
end;

Brandon

2013-12-18 20:47:52

From: Officer Barbrady
got it thanks



type rsps_interface = record
none: char;
end;

type
rsps_inventory = record(rsps_interface)
slots:TboxArray;
outline:Integer;
end;

procedure rsps_inventory.init(rev:Integer);
begin
case rev of
317..507:
with self do
begin
outline := 65536;
end;
507..719:
with self do
begin
outline := 65536;
end;
720..800:
with self do
begin
outline := 131072;
end;
end;
end;

var
T: rsps_inventory;
begin
T.init(318);
end.


Works just fine.. Maybe it's your Setup function.

rj

2013-12-18 21:19:23

From: Brandon

type rsps_interface = record
none: char;
end;

type
rsps_inventory = record(rsps_interface)
slots:TboxArray;
outline:Integer;
end;

procedure rsps_inventory.init(rev:Integer);
begin
case rev of
317..507:
with self do
begin
outline := 65536;
end;
507..719:
with self do
begin
outline := 65536;
end;
720..800:
with self do
begin
outline := 131072;
end;
end;
end;

var
T: rsps_inventory;
begin
T.init(318);
end.


Works just fine.. Maybe it's your Setup function.


err I think that was it forgot what I did but it's fixed

Dgby714

2013-12-20 05:50:33

Just going to note there is no need to even use self, any child of self is part of the local varaibles/methods when inside of a type method.

type
TRSInv = Pointer;

function TRSInv.InvCount(): UInt32;
begin
Result := 20;
end;

function TRSInv.InvFull(): Boolean;
begin
Result := InvCount() = 28; //No need for Self., unless InvCount is ambiguous..
end;

Gu3st...

2013-12-20 14:21:14

If you take away the "self." in front of any type-function or variable then it will always be ambiguous in my opinion.