![]() |
Horay I finally get to post on here! I think... Anyway...
Ok, from what I understand, board[] contains information about the tiles that are on that level. Now I decided to make a stupid little npc that does: setplayerprop #c,#v(board[playerx+playery*64]); With this, I could actually look at what types of values are in the array. I'd expect things like 10, or 20, or maybe 200... but here I get like 2096 (or something close to that) for grass. Anyway my 3 questions are as follows: 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? Happily making his first post (since the damn thing didn't send me a verification code right away!) -- JoMomma |
. . .
|
NPC Code: |
Open hammer.txt or shovel.txt
It explains it rather better than I can. One number in the value of the array is the first coordinate when you mousover the tiling pallette, the other is (naturally) the other coordinate. And of course, one value in the array's index calculator is the x, the other is the y. I always get them confused though, and what numbers one is supposed to multiply by... |
I suppose I will eventually have to figure out what that means. *Heads spins*
|
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. |
Quote:
But I do wonder how tiles that are on the 1/2 mark of a coordinate (ie: x of 25.5) are gonna be read. Does the array somehow accept floating point numbers as an index? |
oops, sorry. Like an array, you must first do int(x) on the boardx you are checking to make sure that you are checking the tile on that array position. It stores whole number values for tile positions, not decimals, so you need to truncate it (what int does...cuts off decimals)
A weather system that does that would be pretty cool, and I think I know how you could achieve it pretty simply....although to actually implement it and have it work online would be another story... Use two arrays, one called weather.grasstiles, and the other called weather.snowtiles. Store corresponding tiles in the same position in the array (you're gonna need ta know arrays pretty well), and just check for both positions every timeout and replace based on the season. Here, I'll give you a little example. Say that 2000 is normal grass, 3000 is normal snow, 2001 is a grass corner, and 3001 is the same type of corner, but with snow: NPC Code: That uh....should work.....not entirely sure it will. If it doesn't, tell me and I'll go find my old random tile replacing script I did one day when I was bored. Just whatever you do, do a timeout at about 5 or more if you're doing updateboard, I'd even suggest 10 or 20 maybe... If that break in the function doesn't work, replace it with something like this.ap = this.arraypos and make sure you replace the things up above. This script is longer than necessary, but better for showing how things are done. |
Quote:
plain grass, red flower grass blade left, grass blade right That's 4 "tiles" which is one unit in the board array. So which one would come up? And how do I get the other ones? Or is the array even bigger than I thought? |
If it has a
green tile,flower tile, leftgrass tile, rightgrass tile then it would be a 2x2 square, so if you were just using that you would have this.x+64*this.y for your top left one, this.x+1+64*this.y for the top right, and this.x+1+64*(this.y+1) for the bottom right, and so on... But to have the tiles cover the whole screen in a 2x2 square pattern I am not sure how to do it... could there be a way to skip every other number, or use even numbers only/odd numbers only? |
Quote:
|
Oh wait I see what my problem was: I didn't realize that something like x of 2.5 was in the MIDDLE of a tile... doy! I thought a 2 tile by 2 tile "object" took up one unit... duh for me!
|
| All times are GMT +2. The time now is 01:42 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.