Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-09-2014, 05:00 PM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
Tiles Triggering Actions

I want to do a check to see if the player is in a certain tile.
How would I check?
For this example, I just want to use the top left tile (1x1)

PHP Code:
onTimeOut(){
 
setTimer(0.05);
 if 
/*Check if player is in certain tile (1x1)*/ {
  
player.chat "Found Tile!";
 }

Reply With Quote
  #2  
Old 06-09-2014, 05:07 PM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 354
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
PHP Code:
temp.playerTile tiles[player.1.5player.2]; 
theres also tiletype:

PHP Code:
temp.playerTiletype tiletype(player.1.5player.2); 
Quote:
0: non-blocking, foreground
1: non-blocking
2: hurting underground
3: chair
4: bed1 (upper part)
5: bed2
6: swamp
7: lava swamp
8: near water
9: near lava
10: desert
11: water
12: lava
20: throw-through
21: jump stone
22: blocking
23: blocking, foreground
__________________
This signature has been deleted by Darlene159.
Reply With Quote
  #3  
Old 06-09-2014, 05:17 PM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
Quote:
Originally Posted by Jakov_the_Jakovasaur View Post
PHP Code:
temp.playerTile tiles[player.1.5player.2]; 
theres also tiletype:

PHP Code:
temp.playerTiletype tiletype(player.1.5player.2); 


Do you think you could use it in an example for me, I'm having trouble understanding.. I was never good at tile stuff.

I'm using this for the check but I get errors. I guess I'm not using it in right context..

PHP Code:
 if ((temp.playerTiletype == 23(player.x+1.5player.y+2)){
  
player.chat "found";
 } 
Reply With Quote
  #4  
Old 06-09-2014, 05:26 PM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 354
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
temp.playerTiletype = tiles[player.x + 1.5, player.y + 2]; is just defining a temporary variable as whatever is returned by tiles[player.x + 1.5, player.y + 2], which will be unset once the current function process ends

all you need to do is:

PHP Code:
if (tiles[player.1.5player.2] == 1x1) {
 
player.chat "Found Tile!";

__________________
This signature has been deleted by Darlene159.
Reply With Quote
  #5  
Old 06-09-2014, 06:18 PM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
Quote:
Originally Posted by Jakov_the_Jakovasaur View Post
temp.playerTiletype = tiles[player.x + 1.5, player.y + 2]; is just defining a temporary variable as whatever is returned by tiles[player.x + 1.5, player.y + 2], which will be unset once the current function process ends

all you need to do is:

PHP Code:
if (tiles[player.1.5player.2] == 1x1) {
 
player.chat "Found Tile!";


error: unexpected symbol x1 at line 68: if (tiles[player.x + 1.5, player.y + 2] == 1x1) {

Don't think the check you gave me is correct..
Reply With Quote
  #6  
Old 06-09-2014, 06:50 PM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 354
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
i didnt realise graal doesnt like using 1x1 directly like that, i usually change the tile values to their actual hexadecimal value, in this case 17:

PHP Code:
if (tiles[player.1.5player.2] == 17) { 
 
player.chat "Found Tile!"

__________________
This signature has been deleted by Darlene159.
Reply With Quote
  #7  
Old 06-09-2014, 07:06 PM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
Quote:
Originally Posted by Jakov_the_Jakovasaur View Post
i didnt realise graal doesnt like using 1x1 directly like that, i usually change the tile values to their actual hexadecimal value, in this case 17:

PHP Code:
if (tiles[player.1.5player.2] == 17) { 
 
player.chat "Found Tile!"

A couple things...

1. Nothing is happening when I collide with the tile... Not sure if I'm missing something.

2. How did you come up with 17 for 1x1 tile?
Reply With Quote
  #8  
Old 06-09-2014, 07:24 PM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 354
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
i just realised that the first tile should be 0x0 rather than 1x1 as mentioned in your first post, 1x1 probably isnt even valid

should definitely work if you do:

PHP Code:
if (tiles[player.1.5player.2] == 0
taking a closer look at your snippet of code in the first post, its worth mentioning that it should be something like this if it isnt already:

PHP Code:
//#CLIENTSIDE
function onCreated()
  
this.onTimeout();

function 
onTimeout() {
  if (
tiles[player.1.5player.2] == 0) {
    
player.chat "Found Tile!";
  }
  
this.setTimer(0.05);

if something doesnt work as expected then you can also attempt to debug it like so:

PHP Code:
player.chat tiles[player.1.5player.2]; 
__________________
This signature has been deleted by Darlene159.
Reply With Quote
  #9  
Old 06-09-2014, 07:35 PM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
Quote:
Originally Posted by Jakov_the_Jakovasaur View Post
i just realised that the first tile should be 0x0 rather than 1x1 as mentioned in your first post, 1x1 probably isnt even valid

should definitely work if you do:

PHP Code:
if (tiles[player.1.5player.2] == 0
taking a closer look at your snippet of code in the first post, its worth mentioning that it should be something like this if it isnt already:

PHP Code:
//#CLIENTSIDE
function onCreated()
  
this.onTimeout();

function 
onTimeout() {
  if (
tiles[player.1.5player.2] == 0) {
    
player.chat "Found Tile!";
  }
  
this.setTimer(0.05);

if something doesnt work as expected then you can also attempt to debug it like so:

PHP Code:
player.chat tiles[player.1.5player.2]; 


Yay it works

But can you explain how you did get 17 though? How do I calculate what tiles are equal to what value?
Reply With Quote
  #10  
Old 06-09-2014, 07:54 PM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 354
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
there are plenty of online tools that can do it, for example:

http://www.binaryhexconverter.com/he...imal-converter

0x would unambiguously state that the following value is hexadecimal and the number before the x represents a count of 16s before it, so 1x1 is basically 16 + 1, 2x1 is 32 + 1 aka 33, 2xF is 32 + 15 aka 47 etc

whereas if you used the true hexadecimal value for 17 which is '11' that would appear more ambiguous
__________________
This signature has been deleted by Darlene159.
Reply With Quote
  #11  
Old 06-09-2014, 10:13 PM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
Quote:
Originally Posted by Jakov_the_Jakovasaur View Post
there are plenty of online tools that can do it, for example:

http://www.binaryhexconverter.com/he...imal-converter

0x would unambiguously state that the following value is hexadecimal and the number before the x represents a count of 16s before it, so 1x1 is basically 16 + 1, 2x1 is 32 + 1 aka 33, 2xF is 32 + 15 aka 47 etc

whereas if you used the true hexadecimal value for 17 which is '11' that would appear more ambiguous

I really appreciate the help

But I have one more question to add to this

What can I do so I don't have to do this..
PHP Code:
if ((tiles[player.x+1.5player.y+3] != 0) || (tiles[player.x+1.5player.y+3] != 32) || (tiles[player.x+1.5player.y+3] != 66) || /*etc*/){ 
just have all the tile values in one check
Reply With Quote
  #12  
Old 06-10-2014, 03:13 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
PHP Code:
temp.tile tiles[player.x+1.5player.y+3];
temp.badtiles = {0,1,2,3,4};
if (
temp.tile in temp.badtiles) {
  
player.chat "this is a bad tile";
} else {
  
player.chat "this is not a bad tile";

__________________
Quote:
Reply With Quote
  #13  
Old 06-10-2014, 02:00 PM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
Quote:
Originally Posted by fowlplay4 View Post
PHP Code:
temp.tile tiles[player.x+1.5player.y+3];
temp.badtiles = {0,1,2,3,4};
if (
temp.tile in temp.badtiles) {
  
player.chat "this is a bad tile";
} else {
  
player.chat "this is not a bad tile";

Could I do something like..

on created
PHP Code:
function onCreated(){
 
player.blocktiles = (1,2,3,4,5,etc);

on check
PHP Code:
if (tiles[player.x+1.5player.y+3] != player.blocktiles){ 
Obviously I don't think this will work as written. But I want to do it similar to that way.. How can I go about this?
Reply With Quote
  #14  
Old 06-10-2014, 03:51 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
PHP Code:
function onCreated() {
  if (!
isBlocking(tiles[player.x+1.5,player.y+3])) {
    
player.chat "this tile is not blocking";
  }
}

function 
isBlocking(tile) {
  
temp.blocktiles = {1,2,3,4,5};
  return (
tile in temp.blocktiles);

__________________
Quote:
Reply With Quote
  #15  
Old 06-11-2014, 11:28 AM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
Quote:
Originally Posted by Jakov_the_Jakovasaur View Post
there are plenty of online tools that can do it, for example:

http://www.binaryhexconverter.com/he...imal-converter

0x would unambiguously state that the following value is hexadecimal and the number before the x represents a count of 16s before it, so 1x1 is basically 16 + 1, 2x1 is 32 + 1 aka 33, 2xF is 32 + 15 aka 47 etc

whereas if you used the true hexadecimal value for 17 which is '11' that would appear more ambiguous

I'm having trouble figuring out the value for each tile. I used the calculator to figure out what this tile it:

Location: Farthest to the left. Second from the top
Possible Formulas: 2xa, ax2, 1xb, bx1

I put all these in calculator and none of the values are detecting
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:54 PM.


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