Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Detecting Tiles on a Board (https://forums.graalonline.com/forums/showthread.php?t=50760)

vahn32 02-01-2004 06:51 AM

Detecting Tiles on a Board
 
I know there's things for board[] and stuff, but I don't know how to use them. So to put it simply: Could someone explain to me how to use board[] or any other function to detect if a certain x,y is on a certain tile?

Thanks for your help!

-Spike Spiegal

-Ramirez- 02-01-2004 07:04 AM

board[] is outdated. Use tiles[]. Tiles[x,y] returns the value of the tile on that coordinate. If you want to find out the value of a tile, select it on the level in the editor and click "Export Tiles Array". (It's the button to the immediate right of the sign button.) That will give you the hex value of the tile, which you can use directly in scripts. (You don't have to convert it to decimal.)

WanDaMan 02-01-2004 11:48 AM

I use it for weapons where you have to be on specific tile(s).
It goes like:
Quote:

if(tiles[playerx,playery] == tileshere||tileshere2){
//stuff
}
Or put all the tile values in a variable to make it easier to add and read.

VeX_RaT_Boy 02-01-2004 02:25 PM

Quote:

Originally posted by WanDaMan
I use it for weapons where you have to be on specific tile(s).
It goes like:

Or put all the tile values in a variable to make it easier to add and read.

What I usually do with checking if the player is on specific tiles is that i make an array:

NPC Code:
beontiles={0x0,0x1,0x10,0x1FF};



and this in the checking:
NPC Code:

if (tiles[playerx,playery] in beontiles) {
//Do stuff
}


adam 02-01-2004 03:26 PM

That be a good method. Yes indeed.

WanDaMan 02-01-2004 05:24 PM

Argh sorry, not a variable an array.. I need to catch up :o!

-Ramirez- 02-01-2004 06:06 PM

Quote:

Originally posted by VeX_RaT_Boy

What I usually do with checking if the player is on specific tiles is that i make an array

You probably already know this, but just in case you dont... setting a variable as an array to use in the condition isn't necessary. You can just put {num,num2,num3,etc} directly in the if ().

Neoreno 02-01-2004 06:24 PM

Aye, but it's good practice to set them beforehand, isn't it?

-Ramirez- 02-01-2004 07:40 PM

I don't see how. It's just adding extra space to the script, and adding a variable that isn't necessary.

adam 02-01-2004 07:40 PM

Yes yes it is.

ZeLpH_MyStiK 02-01-2004 07:59 PM

Quote:

Originally posted by -Ramirez-
I don't see how. It's just adding extra space to the script, and adding a variable that isn't necessary.
What if you need to use it more than once? o.O

-Ramirez- 02-01-2004 08:24 PM

Quote:

Originally posted by adam
Yes yes it is.
How?

Quote:

Originally posted by ZeLpH_MyStiK
What if you need to use it more than once? o.O
That wasn't the case here, was it?

WanDaMan 02-01-2004 09:34 PM

Quote:

Originally posted by -Ramirez-


That wasn't the case here, was it?

He was asking, it could help him and the forum starter to learn it?

-Ramirez- 02-01-2004 09:42 PM

Quote:

Originally posted by WanDaMan
He was asking, it could help him and the forum starter to learn it?
It's a thread, not a forum.

Sure, it could, and it could also teach him to use variables every time he does something, which isn't always efficient.

ZeLpH_MyStiK 02-01-2004 10:18 PM

Quote:

Originally posted by -Ramirez-

It's a thread, not a forum.

Sure, it could, and it could also teach him to use variables every time he does something, which isn't always efficient.

What's wrong with using variables? Even if it's used only once, it isn't being inefficient -.- Who agrees with me?

WanDaMan 02-01-2004 10:23 PM

Quote:

Originally posted by -Ramirez-

It's a thread, not a forum.

Sure, it could, and it could also teach him to use variables every time he does something, which isn't always efficient.

Yes but it could save them in the future from starting another thread asking a question which is related to this thread..

-Ramirez- 02-01-2004 10:25 PM

Quote:

Originally posted by ZeLpH_MyStiK
What's wrong with using variables? Even if it's used only once, it isn't being inefficient -.- Who agrees with me?
When did I ever say there was anything wrong with EVER using variables? There's no reason to use them if they're simply going to be used once. That's like making a function just to do "say2 Hi;" and calling the function rather than using the actual command. Wasted space in the script. More to sift through.

Quote:

Originally posted by WanDaMan
Yes but it could save them in the future from starting another thread asking a question which is related to this thread..
As if it's not going to happen anyway. Besides, a different thread relating DIRECTLY to that topic would be more useful for people who don't know about it.

WanDaMan 02-01-2004 10:37 PM

Quote:

Originally posted by -Ramirez-

As if it's not going to happen anyway. Besides, a different thread relating DIRECTLY to that topic would be more useful for people who don't know about it.

Ah okay, either way it's okay to do since people will read it where ever it is placed:megaeek:

ZeLpH_MyStiK 02-02-2004 12:37 AM

Quote:

Originally posted by -Ramirez-

When did I ever say there was anything wrong with EVER using variables? There's no reason to use them if they're simply going to be used once. That's like making a function just to do "say2 Hi;" and calling the function rather than using the actual command. Wasted space in the script. More to sift through.


As if it's not going to happen anyway. Besides, a different thread relating DIRECTLY to that topic would be more useful for people who don't know about it.

So is VeX_RaT_Boy just using it once or are you assuming that? O.o

vahn32 02-02-2004 12:42 AM

Well thanks for all your help everybody, lol.

-Ramirez- 02-02-2004 03:35 AM

Quote:

Originally posted by ZeLpH_MyStiK
So is VeX_RaT_Boy just using it once or are you assuming that? O.o
Obviously an assumption, unless you thought I had talked to him elsewhere, which hasn't happened.

VeX_RaT_Boy 02-02-2004 05:11 PM

Quote:

You probably already know this, but just in case you dont... setting a variable as an array to use in the condition isn't necessary. You can just put {num,num2,num3,etc} directly in the if ().
I know that.
Quote:

So is VeX_RaT_Boy just using it once or are you assuming that? O.o
My name is Kjetil.

I got 2 reasons for using a variable;

1. It looks nice if your going to have the array long: if (blah in {1,2,3})

That is ok, but what if it was up to 50?


2. When I script with variables I normally use it in more than one place.


Even though it wasn't more than 1 in this case, I did not post the whole script. It could've been longer.

-Ramirez- 02-02-2004 05:16 PM

Quote:

Originally posted by VeX_RaT_Boy
That is ok, but what if it was up to 50?
...your point being? It's still going to be the same length as it would if it were assigned to a variable instead. ;)

VeX_RaT_Boy 02-02-2004 05:32 PM

Quote:

Originally posted by -Ramirez-

...your point being? It's still going to be the same length as it would if it were assigned to a variable instead. ;)

NPC Code:

if (blah in {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15})



NPC Code:

test={
1,2,3,
4,5,6,
7,8,9,
10,11,12,
13,14,15};
if (blah in test)


See a diffrence? The first is a lot longer, and LOOK more messy. I don't really want this to turn into a flame-war. :\

-Ramirez- 02-02-2004 06:26 PM

Quote:

Originally posted by VeX_RaT_Boy
See a diffrence?
Stupid question. Obviously there's a difference, however, it's a matter of personal opinion on what looks better.

Quote:

The first is a lot longer, and LOOK more messy.
Look above.

VeX_RaT_Boy 02-02-2004 07:28 PM

Quote:

Originally posted by -Ramirez-

Stupid question.

Supid questions are made by stupid people.

Blue_Dragn 02-02-2004 08:34 PM

Another thing with board[] and tiles[]...

Is it possibile to use tiles[] to change the tile under the npc? because ive been working with trying to change tiles under and arround an npc and it goes like

NPC Code:

...
board[x+y*64] = 2079;
updateboard 0, 0, 10, 10;
...



So even when i used board[] or tiles[] with an array or value, it never changed the tile under the npc to anything else.

Notes:
In Theory "2079" is a tile value, i cant remember if it actually is or not, i just substituted that number.

I cant get either style to work, board[] or tiles[] to update the tiles under the npc

WanDaMan 02-02-2004 08:37 PM

Yeah* go-boom did with a face moving, using tiles. He posted on the forums, It rocked :D

http://forums.graal2001.com/forums/s...ghlight=goboom

That's the link :]

VeX_RaT_Boy 02-02-2004 10:26 PM

Quote:

Originally posted by Blue_Dragn
Another thing with board[] and tiles[]...

Is it possibile to use tiles[] to change the tile under the npc? because ive been working with trying to change tiles under and arround an npc and it goes like

NPC Code:

...
board[x+y*64] = 2079;
updateboard 0, 0, 10, 10;
...



So even when i used board[] or tiles[] with an array or value, it never changed the tile under the npc to anything else.

Notes:
In Theory "2079" is a tile value, i cant remember if it actually is or not, i just substituted that number.

I cant get either style to work, board[] or tiles[] to update the tiles under the npc

NPC Code:

tiles[30,30]=0x4A3;
updateboard 0,0,64,64;


Admins 02-03-2004 04:22 AM

tiles[30,30]=0x4A3;
updateboard 30,30,1,1;

would be better :)
Works even on serverside, then all people see it. When you do updateboard2 x,y,width,height; then the tile change is even saved to the level after a few minutes, the serveroption savelevels=true must be set.
(saving not enabled on gmaps yet)

adam 02-03-2004 04:35 AM

Stefan, don't ever stop coming here, reading and giving us gems of information everyday!

Duwul 02-03-2004 09:34 PM

Lol.
I was just wondering if it could be used serverside too. =P

ZeLpH_MyStiK 02-03-2004 11:35 PM

o wow updateboard2, didnt know that. Now you can make a online level editor o.O that's cool =)

Duwul 02-04-2004 12:31 AM

Quote:

Originally posted by ZeLpH_MyStiK
o wow updateboard2, didnt know that. Now you can make a online level editor o.O that's cool =)
Actually I was going to make a pretty simple tile layer. You would click, and it would lay that tile at the mousex/y. You would be able to change the tile type, the width(in tiles) that it would lay, and the height it would lay. Erm, if the width was 2, it would lay 2 of those tiles starting from the mousex, and continue right one tile. =)

Blue_Dragn 02-05-2004 07:37 PM

Quote:

Originally posted by Duwul


Actually I was going to make a pretty simple tile layer. You would click, and it would lay that tile at the mousex/y. You would be able to change the tile type, the width(in tiles) that it would lay, and the height it would lay. Erm, if the width was 2, it would lay 2 of those tiles starting from the mousex, and continue right one tile. =)

Easy, Ive already done it, i think Riot may have? I can remember someone else boasting their completion of one

WanDaMan 02-05-2004 08:10 PM

That's easy, and cool a new command I didn't know!

Riot 02-05-2004 10:41 PM

Quote:

Originally posted by Blue_Dragn
Easy, Ive already done it, i think Riot may have? I can remember someone else boasting their completion of one
I never posted one. Though I do know if you search the forums you will find atleast an old one.

R0bin 02-05-2004 11:54 PM

Quote:

Originally posted by WanDaMan
That's easy, and cool a new command I didn't know!
like "message" maybe? :)


All times are GMT +2. The time now is 07:50 AM.

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