Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Loses temp value (https://forums.graalonline.com/forums/showthread.php?t=134267549)

sssssssssss 12-12-2012 02:48 AM

Loses temp value
 
I can't for the life of me figure out, or know, why this temp.message var loses its array value.... the first player.chat shows up perfectly fine, but the player.chat marked under // HERE is empty. The script does make it to that spot just fine.

PHP Code:

  // clear all images
  
player.chat message[0][0];
  
clearImages();
  
  
// set vars
  
this.conReturn conReturn;

  
// make player still
  
setani("idle"null);
  
disabledefmovement();
  
  
// move in stuff
  
tweenInHead(head);
  
tweenInName(speaker);
  
  if (
conReturn)
  {
    
// HERE
    
player.chat message[0][0];

    
tweenInMessage(message[0][0]);
    for (
temp.0message[0].size() - 1t++)
    {
      
tweenInChoices(message[0][i]);
    }
    
this.messageWaiting true;
  }else
  {
    
tweenInMessage(message);
  }
  
tweenInBG();
  
  
// set to show it's shown up and wait for interaction
  
this.shown true


fowlplay4 12-12-2012 03:04 AM

Use the temp. prefix (temp.message) throughout your code (not just message) and see if you still have the same issues. message is also a function so I would probably replace it with msg just so it's not potentially conflicting.

DustyPorViva 12-12-2012 03:25 AM

Not sure if it's exactly related, but I've reported similar problems:

http://forums.graalonline.com/forums...05#post1514105

sssssssssss 12-12-2012 03:48 AM

fowlplay: From my experience proper syntax is temp.var, and I typically initialize the temp.var as so, but nothing so far has stopped it from working as long as its a local var. Although, I went and changed all of them, and changes message to msg and it still isn't working at all....

Dusty: Pretty much the same thing probably. It's just odd because at first I had this, not sending an array through but just single var to the public funciton

PHP Code:

tweenInMessage(temp.msg); 

and it worked fine and sent. Now it's an array, and sub array inside, and it's not working with the if's and such.

Really, really annoying.... anyone else have any other ideas. To explain a little deeper a level npc is just sending the information to this (might as well put updated anyways):

PHP Code:

public function loadDialog(temp.conReturntemp.speakertemp.headtemp.msg)
{
  
// clear all images
  
clearImages();
  
// THIS PLAYER CHAT HAS THE CORRECT VALUE FROM THE ARRAY
player.chat temp.msg[0][0];

  
// set vars
  
this.conReturn temp.conReturn;
  
  
// make player still
  
setani("idle"null);
  
disabledefmovement();
  
  
// move in stuff
  
tweenInHead(temp.head);
  
tweenInName(temp.speaker);
  
  if (
this.conReturn)
  {
    
// THIS PLAYER CHAT RESULTS IN A 0
    
player.chat temp.msg[0][0];
    
tweenInMessage(temp.msg[0][0]);
    for (
temp.0temp.msg[0].size() - 1t++)
    {
      
tweenInChoices(temp.msg[0][i]);
    }
    
this.messageWaiting true;
  }else
  {
    
tweenInMessage(temp.msg);
  }
  
tweenInBG();
  
  
// set to show it's shown up and wait for interaction
  
this.shown true;


This section seems to be the issue:
PHP Code:

if (this.conReturn)
  {
    
player.chat temp.msg[0][0];
    
tweenInMessage(temp.msg[0][0]);
    for (
temp.0temp.msg[0].size() - 1t++)
    {
      
tweenInChoices(temp.msg[0][i]);
    }
    
this.messageWaiting true;
  }else
  {
    
tweenInMessage(temp.msg);
  } 

Just doing
PHP Code:

tweenInMessage(temp.msg

with a single var sent works fine, sending an array gets lost in the if statement.

cbk1994 12-12-2012 03:55 AM

Have you been able to isolate it beyond that? (e.g. if you comment out the tweens, does it work?) My guess would be a sleep in the tweens is doing something odd.

Also, I would always avoid using "message" as a variable name. I've had problems with that forever.

sssssssssss 12-12-2012 04:04 AM

Compare the top to the one I'm trying to make work. This works when NOT sending an array to it.

PHP Code:

public function loadDialog(temp.conReturntemp.speakertemp.headtemp.msg)
{
  
// clear all images
  
clearImages();

  
// set vars
  
this.conReturn temp.conReturn;
  
  
// make player still
  
setani("idle"null);
  
disabledefmovement();
  
  
// move in stuff
  
tweenInHead(temp.head);
  
tweenInName(temp.speaker);
  
tweenInMessage(temp.msg);
  
tweenInBG();
  
...... 

This is the script using to send as single (the true/false is just my way of saying if its an array or not, doesn't seem to be effecting the code whatsoever):

PHP Code:

  temp.speaker "Billy";
  
temp.head this.head;
  
temp.message "I'm really bored and have no idea what to do...";

  
// send false for single message or true for multiple
  
temp.response findweapon("-System/NPCDialog").loadDialog(falsespeakerheadmessage); 

Sending as array and not working:

PHP Code:

  temp.speaker "Billy";
  
temp.head this.head;
  
temp.msg.add({"I'm really bored and have no idea what to do...","So?""Go swimming!""I hate you"});
  
temp.msg.add({"Whatever dude...""I can't swim""We share that feeling now"});

  
// send false for single message or true for multiple
  
temp.response findweapon("-System/NPCDialog").loadDialog(truespeakerheadmsg); 


So it's not the tween. I don't think it's the way I'm sending an array or the fact that I am sending an array or not because it worked where I marked in the previous post in comments which chat showed it, then 10 lines down it's lost.

I just don't get this. Tried everything I can think of.

sssssssssss 12-12-2012 04:27 AM

This worked. Had to just assign it separate and correctly into this.vars

PHP Code:

public function loadDialog(temp.conReturntemp.speakertemp.headtemp.msg)
{
  
// clear all images
  
clearImages();
  
  
// set vars
  
this.conReturn conReturn;
  
this.msgFull temp.msg[0].size();
  
this.msg temp.msg[0][0];
  
  for (
temp.1temp.temp.msg[0].size(); i++)
  {
    
this.options.add(temp.msg[0][i]);
  }
  
//player.chat = this.options;
  
  // make player still
  
setani("idle"null);
  
disabledefmovement();
  
  
// move in stuff
  
tweenInHead(temp.head);
  
tweenInName(temp.speaker);
  
  if (
this.conReturn)
  {
    
//player.chat = this.options;
    
tweenInMessage(this.msg);
    for (
temp.0temp.this.msgFull 1temp.j++)
    {
      
tweenInChoices(this.options[j]);
    }
    
this.messageWaiting true;
  }else
  {
    
tweenInMessage(temp.msg);
  }
  
tweenInBG();
  
  
// set to show it's shown up and wait for interaction
  
this.shown true;



That's still bs imo. Local vars should be able to work as far as I can see. All well. If someone notices something to teach me or something I did wrong please note so I can switch it back to local vars.

fowlplay4 12-12-2012 07:47 AM

What you're referring to as 'temp vars' are the function parameters, and if your system uses waitfor/sleep that can make those disappear for some reason (as you found out) so you need to store them.


All times are GMT +2. The time now is 01:59 AM.

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