Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Dumb array question (https://forums.graalonline.com/forums/showthread.php?t=30686)

zallus-k 06-03-2002 01:34 AM

Dumb array question
 
I'm trying to script a system to create, display, and destroy "message box" type widows on the screen. The only thing is, I need to address each box as an individual object containing an x,y position. Now, how do I do this without using a multi-dimensional array?

Spanko 06-03-2002 05:42 PM

You could sort of recreate a multi-dimensional array in one array, you just need to make the array twice as big as usual, and use some extra calculation while accesing it to seperate the x and y values.

a+b*c is the key.

Bhala 06-04-2002 12:05 AM

what i do when i use 1 array for things like x & y you can ether put them side by side or at equal lenghts apart.... {x, y, x, y } {x, x, y, y,}

with the first one to acess the x & y its index = x & index +1=y

the second is index=x index+(lenght of first part of array)=y

BBflat 06-04-2002 03:32 AM

I just do what Graal does offline in the tile selection window thing. Take this matrix, for example...
NPC Code:

0 1 2 3 4

0 0 1 2 3 4
1 5 6 7 8 9
2 10 11 12 13 14
3 15 16 17 18 19


Those can be all the indexes, and you can treat them exactly like x,y coordinates. Just do row * 5 + column to get a specific index (start counting at 0).

adam 06-04-2002 09:11 PM

NPC Code:

setarray XY,lenght; // define array
for ( i = 0 ; i < lenght * 2 ; i += 2){ // for loop with step of 2
XY[i + 0] = Whatever; // x value
XY[i + 1] = Whatever; // y value
}

// You could easily add as many variables as you like to an array this way.




This is basically how I do it.

I been using arrays for a long time. This works.


All times are GMT +2. The time now is 12:00 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.