View Single Post
  #6  
Old 03-18-2001, 07:40 AM
kyle0654 kyle0654 is offline
-. .`
kyle0654's Avatar
Join Date: Mar 2001
Posts: 1,000
kyle0654 will become famous soon enough
1) Since it's a 64x64 array but there can be really 4 tiles per section of that board, what determines the value? is it an "anded" value of the 4 tiles? And if so, what order is it in?

2) How exactly does changing tiles work? I kinda understand updateboard, but don't fully get it. I'd also like to know if maybe putting this type of code in the NPC server would make it global to all users. I've heard that it's only really local, but the documentation does say it's temporaray.

3) What actually determines the values? Like what makes grass 2096 (or whatever it was)? Is it the position they're in the pics1.png?

First, you need to understand how it works:

board[x + y * 64] = tilex + tiley * 16;

The y will always get bigger, while the x goes from 0 to 15 then loops back to 0. If you run your mouse over the tileset on the right side, you'll see the values in the bottom right change. It tells you the tilex and tiley of the tile you are hovering over. If you go from left to right in a straight line, you'll notice that the tilex will go to 15 then to 0, and the tiley will jump up a lot. Well, this is because the tileset isn't arranged from left to right, it's arranged in strips that are 16 tiles wide and however many tiles tall.

Okay, too many words eh? Anyways, back to what I was gonna say. If you want to change a board tile, you must know what tile you are replacing with in terms of its tilex and tiley on the tileset. once you know that, you can use the equation above to set it. Then update the board using this:

updateboard x, y, 1, 1;

That will load the current tile at that position. Of course, this is all client-side, and only certain tiles will work well online. Bushes to stumps, Rocks to holes, and signs to holes I think will work.

Anyway, if you want to know the tilex and tiley of what tile you're standing on:

boardvalue = board[playerx + playery * 64];
setplayerprop #c,tilex: #v(boardvalue%16), tiley: #v(int(boardvalue/16));

And of course use that in a timeout script.

Btw, doing %16 or %# just find the remainder of the number when you divide it by 16, if you didn't know that already.


Now, as for global tile changes using an npc server...I know how you would do it, but you better ask Stefan, cuz I don't think the command is really open to public as of yet, and it's server-side too, meaning it won't work offline.


Well, did I thoroughly confuse you? As Tyhm said, a great example to look at is the shovel or hammer script if you want to see it in action.
Reply With Quote