Page 1 of 1
How do multidimensional arrays work in KaMRemake?
PostPosted: 08 Sep 2015, 07:30
by Strangelove
When i tried doing it like this, i get the error that it is expecting a closed braket after the H. According to various pascal-tutorial-sites however, it should work like this. Is it possible that the remake does not support multidimensional arrays, and if it does, what am i doing wrong?
- Code:
var aHouse: array of Integer;
var aHouseData: array of array[0..3] of Integer;
//2nd Dimension:
//0: Type
//1: Damage
//2: X
//3: Y
procedure OnPlayerVictory(aIndex: Integer);
var H: Integer;
begin
aHouse := States.PlayerGetAllHouses(1);
SetLength(aHouseData, Length(aHouse)); //Set length of aHouseData-array
for H := 0 to Length(aHouse) do
begin
aHouseData[H,0] := States.HouseType(aHouse);
aHouseData[H,1] := States.HouseDamage(aHouse);
aHouseData[H,2] := States.HousePositionX(aHouse);
aHouseData[H,3] := States.HousePositionY(aHouse);
end;
end;
procedure OnTick();
begin
if States.GameTime() = 200 then
Actions.PlayerWin([0], true);
end;
Re: How do multidimensional arrays work in KaMRemake?
PostPosted: 08 Sep 2015, 08:03
by Esthlos
Does this work?
- Code:
for H := 0 to Length(aHouse)-1 do
begin
aHouseData[H][0] := States.HouseType(aHouse);
aHouseData[H][1] := States.HouseDamage(aHouse);
aHouseData[H][2] := States.HousePositionX(aHouse);
aHouseData[H][3] := States.HousePositionY(aHouse);
end;
Re: How do multidimensional arrays work in KaMRemake?
PostPosted: 08 Sep 2015, 08:05
by Strangelove
Does this work?
- Code:
for H := 0 to Length(aHouse)-1 do
begin
aHouseData[H][0] := States.HouseType(aHouse);
aHouseData[H][1] := States.HouseDamage(aHouse);
aHouseData[H][2] := States.HousePositionX(aHouse);
aHouseData[H][3] := States.HousePositionY(aHouse);
end;
Tried that. Didn't work either. When i do that, i get a Type Mismatch error.
Re: How do multidimensional arrays work in KaMRemake?
PostPosted: 08 Sep 2015, 09:21
by Esthlos
Tried that. Didn't work either. When i do that, i get a Type Mismatch error.
That's because aHouse is not an integer
- Code:
for H := 0 to Length(aHouse)-1 do
begin
aHouseData[H][0] := States.HouseType(aHouse[H]);
aHouseData[H][1] := States.HouseDamage(aHouse[H]);
aHouseData[H][2] := States.HousePositionX(aHouse[H]);
aHouseData[H][3] := States.HousePositionY(aHouse[H]);
end;
Re: How do multidimensional arrays work in KaMRemake?
PostPosted: 08 Sep 2015, 09:47
by Strangelove
Tried that. Didn't work either. When i do that, i get a Type Mismatch error.
That's because aHouse is not an integer
- Code:
for H := 0 to Length(aHouse)-1 do
begin
aHouseData[H][0] := States.HouseType(aHouse[H]);
aHouseData[H][1] := States.HouseDamage(aHouse[H]);
aHouseData[H][2] := States.HousePositionX(aHouse[H]);
aHouseData[H][3] := States.HousePositionY(aHouse[H]);
end;
Thanks! Good to know that i am just stupid haha
Re: How do multidimensional arrays work in KaMRemake?
PostPosted: 08 Sep 2015, 12:47
by Strangelove
EDIT: NVM, got it!
Sorry about the double post.
Re: How do multidimensional arrays work in KaMRemake?
PostPosted: 08 Sep 2015, 22:49
by Lewin
A record might be neater than a multidimensional array:
- Code:
var aHouseData: array of record
HouseType: Integer;
Damage: Integer;
PosX: Integer;
PosY: Integer;
end;
- Code:
aHouseData[H].HouseType := States.HouseType(aHouse[H]);
aHouseData[H].Damage := States.HouseDamage(aHouse[H]);
aHouseData[H].PosX := States.HousePositionX(aHouse[H]);
aHouseData[H].PosY := States.HousePositionY(aHouse[H]);
Re: How do multidimensional arrays work in KaMRemake?
PostPosted: 09 Sep 2015, 07:50
by Strangelove
It sure would be neater with a record. Next time i'll use that way! For now, however it works with the multidimensional arrays.