Author Topic: Quick question on local variables and scripts  (Read 753 times)

Legacy_Alassirana

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #15 on: August 18, 2011, 07:41:11 pm »


               Yes, it's a different script, but a similar question, which is why I put it back in here...I'm just trying to figure out how to retrieve local variables (originally so I could destroy items with the variables, now so that I can retrieve the variables for a conversation node check...for a teleporter with several possible locations, depending on where you've been before)
               
               

               
            

Legacy_Alassirana

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #16 on: August 18, 2011, 07:42:04 pm »


               The variables, in both cases are on objects carried by pc's.  I'd do Lilac soul stuff with it, but she doesn't have the option for retrieving local variables on objects.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #17 on: August 18, 2011, 08:03:29 pm »


               Ahh I think I gotcha. So you just want to check out a variable on a specific item that the player has? Maybe something like so:

object oPButton = GetItemPossessedBy(oPC, "PanicButton");
int iFokual = GetLocalInt(oPButton, "Fokual");

if (iFokual == TRUE)
{
    //do something
}


If I'm understanding correctly. haha. Hope it helps.

P.S. It is also good practice to specify "items" as apposed to "objects" when talking about items in player inventory. "Objects" are usually going to be placeables. While they are all objects, it just gets confusing when talking about these things sometimes.
               
               

               


                     Modifié par GhostOfGod, 18 août 2011 - 07:06 .
                     
                  


            

Legacy_Alassirana

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #18 on: August 18, 2011, 08:22:00 pm »


               Ok, thanks, that should work nicely...I'll save that so that I can use it in other scripts as needed too.
               
               

               
            

Legacy_Alassirana

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #19 on: August 27, 2011, 09:14:44 pm »


               Hrm, I thought it was working right, but when I brought in a brand new character (who did not have the local variables set on her panic button), I'm still getting the options for those cities she has not visited...Here's one of the scripts, set as a starting conditional to bringing up that option from the Nexus.  Please tell me what I'm doing wrong (and yes, I've checked to make sure that the variable names and object names are correct).

int StartingConditional()
{
    // Get the PC who is involved in this conversation
    object oPC = GetPCSpeaker();
    object oPButton = GetItemPossessedBy(oPC, "panicbutton");
    int iFokual = GetLocalInt(oPButton, "Fokual");
    if (iFokual == TRUE)
        return FALSE;

    // If we make it this far, we have passed all tests.
    return TRUE;
}

I've tried making iFokual != TRUE, and that makes it disappear for my character with the variables...so I'm doing something wrong here..

Alassirana
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #20 on: August 27, 2011, 09:39:38 pm »


                int StartingConditional()
{
    // Get the PC who is involved in this conversation
    object oPC = GetPCSpeaker();
    object oPButton = GetItemPossessedBy(oPC, "panicbutton");
    int iFokual = GetLocalInt(oPButton, "Fokual");
    if (iFokual == TRUE || oPButton == OBJECT_INVALID)
        return FALSE;

    // If we make it this far, we have passed all tests.
    return TRUE;
}

 
 
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #21 on: August 27, 2011, 09:59:46 pm »


               <counts on his fingers...>

Lightfoot8 wrote...
...
    object oPButton = GetItemPossessedBy(oPC, "panicbutton");
    int iFokual = GetLocalInt(oPButton, "Fokual");
    if (iFokual == TRUE || oPButton == OBJECT_INVALID)
        return FALSE;
...
 

So... if PC *has* oPButton and iFokual is *not* set, it will return true...

But, if I read Alassirana correctly, her problem is that it is still returning TRUE, i.e. iFokual is SET, regardless of  "who did not have the local variables set"...

Try having the PC speak the value of iFokual to see if it has somehow been set somewhere along the line?

<...sighs and takes off his boots>
               
               

               
            

Legacy_Alassirana

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #22 on: August 27, 2011, 10:49:11 pm »


               I've gone into Leto, looked at the item in question, and it did not have the variables.  I've also gone into the toolset, verified that the variables were not set in the toolset...and still it comes up in the game as ringing true to having the variables, though she does not have them.  I'm really very, very confused by all of this, and don't know how to fix it...it's almost enough to make me go back to using tokens that the player will complain about filling up their inventory, just to make it necessary to walk to a town before being able to port to it.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #23 on: August 27, 2011, 10:55:30 pm »


               

Alassirana wrote...

I've gone into Leto, looked at the item in question, and it did not have the variables.  I've also gone into the toolset, verified that the variables were not set in the toolset...and still it comes up in the game as ringing true to having the variables, though she does not have them.  I'm really very, very confused by all of this, and don't know how to fix it...it's almost enough to make me go back to using tokens that the player will complain about filling up their inventory, just to make it necessary to walk to a town before being able to port to it.


Are there any other items by the same tag?
               
               

               
            

Legacy_Alassirana

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #24 on: August 27, 2011, 11:00:45 pm »


               No, there aren't...and I made sure that the version of the panic button that is in the toolset is updated across the entire module, so it shouldn't have any old/wrongly set up versions floating around...
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #25 on: August 27, 2011, 11:07:31 pm »


               <looks alarmed...>

Don't give up!

(because I'm working with the Travel Builder system, and it sounds like your problem - or, more importantly, your solution - will be pertinent to me ;-)

First, verify (in game) that the variable is/is not set. I am suspecting it is somehow set.  Perhaps it is set on another object (or supposed to be) but got set on this one... Like WhiZard said.

At any rate, put in traps (like LoWs is doing with *his* problem :-) in different places to try and catch when it is being set (if that's the case).

<...and trapped>
               
               

               


                     Modifié par Rolo Kipp, 27 août 2011 - 10:08 .
                     
                  


            

Legacy_Alassirana

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #26 on: August 27, 2011, 11:22:52 pm »


               I'm still fairly new to a lot of this...how do I put in traps to find these things?
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #27 on: August 27, 2011, 11:33:26 pm »


               

Alassirana wrote...

I'm still fairly new to a lot of this...how do I put in traps to find these things?



If you are testing this singleplayer, you can use GetFirstPC() in signalling commands to make sure your character is reported the details.

Example
if(iInteger == TRUE)
  {
 SendMessageToPC(GetFirstPC(), "iInteger is returning TRUE");
  }
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #28 on: August 27, 2011, 11:39:02 pm »


               <looks contrite...>

Alassirana wrote...

I'm still fairly new to a lot of this...how do I put in traps to find these things?

Sorry, didn't mean to be obscure.

What I meant is to put in some debugging printouts in places likely to affect the PButton item.

In those places put a couple lines of code in there like:

    if (iFokua != TRUE) ActionSpeakString("Fokua is NOT DEFINED", TALKVOLUME_SHOUT);
    if (iFokua == TRUE) ActionSpeakString("Fokua is SET! Drat!!!!!!! I'm in so-and-so function/script", TALKVOLUME_SHOUT);

Then test the mod and see where it gets set.

<...but it's probably a sham>
               
               

               
            

Legacy_Alassirana

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #29 on: August 27, 2011, 11:42:55 pm »


               I had an idea while looking through things...since I'm dealing with a single item with several local variables on it, could that be the problem there?  Should I be using an array, rather than a local int on the item?