View Single Post
  #1  
Old 09-05-2017, 04:56 AM
maximus_asinus maximus_asinus is offline
RIP DarkCloud_PK
Join Date: Oct 2001
Location: Canada
Posts: 3,729
maximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond repute
Script ignoring if statement conditions?

This is a small sample of a larger script I wrote.

Graal Script Code:
if (this.item in db_quests.items3) {
  
temp.prefix FindPrefix();
  if (
temp.prefix == -1) {
    echo(
"Level not found in quest database");
  }
  else {
    
// CODE
  
}
}

// find NPC level prefix then check if it is in the quest database
function FindPrefix() {
  for (
temp.a=0;temp.a<=this.level.length();temp.a++) {
    
temp.search this.level.substring(temp.a,1);
    if (
temp.search == "_") {
      
temp.checkprefix this.level.substring(0,temp.a);
      if (
temp.checkprefix in db_quests.quests) {
        return 
temp.checkprefix;
      }
      else return -
1;
    }
  }

The problem is the if statement temp.prefix == -1 in the first block of code. Despite findPrefix returning a value not equal to -1 (verified by echo) it will activate regardless and the else statement will be ignored. Any ideas as to why?
__________________
Save Classic!
Reply With Quote