Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Text Contains... (https://forums.graalonline.com/forums/showthread.php?t=134264708)

Emera 10-04-2011 08:33 PM

Text Contains...
 
I was wondering if there was a way to detect if my chat bar contained a certain word. For instance.
NPC Code:
I like to sniff socks.


Is there a way I can check if my chat bar contains the work sniff?

Maybe there is a function like...
PHP Code:

if (ChatBar.containstext("sniff")) { 


Tolnaftate2004 10-04-2011 08:52 PM

PHP Code:

ChatBar.text.pos("fartzz") >= 


fowlplay4 10-04-2011 09:10 PM

Additional Information:

haystack.pos(needle) will return the position of needle in the haystack (string/variable).

Also since arrays are treated like strings, it can be used as a quick method to search an array as well, for arrays there's also haystack.index(needle).

Examples:

PHP Code:

function onCreated() {
  
// Position Example
  
temp.str "hello world";
  echo(
temp.str.pos("world")); // will echo 
  // Index Example
  
temp.fruits = {
    
"apple""orange""grapes"
  
};
  echo(
temp.fruits.index("orange"));



Emera 10-04-2011 09:29 PM

Thank you!


All times are GMT +2. The time now is 12:25 AM.

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