Map Database  •  FAQ  •  RSS  •  Login

How do multidimensional arrays work in KaMRemake?

<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 08 Sep 2015, 07:30

How do multidimensional arrays work in KaMRemake?

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;
<<

Esthlos

User avatar

Knight

Posts: 676

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 08 Sep 2015, 08:03

Re: How do multidimensional arrays work in KaMRemake?

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;
Just when you think you know something, you have to look at it in another way, even though it may seem silly or wrong. You must try! - John Keating, "Dead Poets Society"
<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 08 Sep 2015, 08:05

Re: How do multidimensional arrays work in KaMRemake?

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.
<<

Esthlos

User avatar

Knight

Posts: 676

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 08 Sep 2015, 09:21

Re: How do multidimensional arrays work in KaMRemake?

Tried that. Didn't work either. When i do that, i get a Type Mismatch error.
That's because aHouse is not an integer :P
  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;
Just when you think you know something, you have to look at it in another way, even though it may seem silly or wrong. You must try! - John Keating, "Dead Poets Society"
<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 08 Sep 2015, 09:47

Re: How do multidimensional arrays work in KaMRemake?

Tried that. Didn't work either. When i do that, i get a Type Mismatch error.
That's because aHouse is not an integer :P
  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 ;)
<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 08 Sep 2015, 12:47

Re: How do multidimensional arrays work in KaMRemake?

EDIT: NVM, got it!

Sorry about the double post.
<<

Lewin

User avatar

KaM Remake Developer

Posts: 3822

Joined: 16 Sep 2007, 22:00

KaM Skill Level: Skilled

ICQ: 269127056

Website: http://lewin.hodgman.id.au

Yahoo Messenger: lewinlewinhodgman

Location: Australia

Post 08 Sep 2015, 22:49

Re: How do multidimensional arrays work in KaMRemake?

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]);
<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 09 Sep 2015, 07:50

Re: How do multidimensional arrays work in KaMRemake?

It sure would be neater with a record. Next time i'll use that way! For now, however it works with the multidimensional arrays.

Return to “Dynamic Scripting”

Who is online

Users browsing this forum: No registered users and 8 guests