Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 09-05-2017, 11:39 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
You should use this.level.name instead of this.level. While this.level will work, it's actually giving the level object and not a string name of the level. But because of how typecasting in Graal works it can still work in most situations but you can sometimes encounter oddities.

Also, why not just return null or false? Again, typecasting can be a bit weird here but unless "0" is a possible prefix null/boolean would be much more logical.

But some more tidbits of information:

You can use this.level.name.charat(temp.a) instead of substring if you just want a single character and not a substring. Also, you can use this.level.name.pos("_") to find the first instance of string within a string. -1 will be returned if the string is not found(since 0 can be returned if the character is the first character in the string). So you can do something like this, which is much more efficient:

PHP Code:
if (this.item in db_quests.items3) {
  
temp.prefix findPrefix(this.level.name);
  if (
temp.prefix == null) {
    echo(
"Level not found in quest database");
  } else {
    
// CODE
  
}


function 
findPrefix(temp.string) {
  
temp.pos temp.string.pos("_");
  if (
temp.pos 0) return null;
  return 
temp.string.substring(0,temp.pos);


Last edited by DustyPorViva; 09-06-2017 at 12:52 AM..
Reply With Quote
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 04:01 PM.


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