Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   GuiTextCtrl passed text not showing (https://forums.graalonline.com/forums/showthread.php?t=134267660)

sssssssssss 12-27-2012 04:56 PM

GuiTextCtrl passed text not showing
 
This is just showing up "0"...

The echo right above the gui shows the correct value as well. I've also done it without destroy(), destroyonhide, and without the tween. None of that is effecting it.

PHP Code:

// Function to move in name on the screen
function showName()
{
  echo(
this.speaker);
  
Dialog_Name.destroy();
  new 
GuiTextCtrl("Dialog_Name"
  { 
    
30;
    
profile Armageddon_Text;
    
destroyonhide true;
      
    
text this.speaker;
    
    
width 128;
    
height 320;
      
    
//layer = 7;
    
zoom 0.7;
    
alpha 1;
    
    
fonttype "Palatino Linotype";
    
fontstyle "bu";
    
textshadow true;
    
shadowcolor = {606045};
    
shadowoffset = {43};
    
    
this.join("tween");
  }
  
Dialog_Control.addcontrol(Dialog_Name);
  
  
// tween the image
  
(@"Dialog_Name").tween("x"0.250110);
  
waitfor((@"Dialog_Name"), "TweenFinished"0.05);



xXziroXx 12-27-2012 06:13 PM

Change...

PHP Code:

text this.speaker

to...

PHP Code:

text thiso.speaker

this.speaker is not defined in the GUI object.

sssssssssss 12-27-2012 06:51 PM

Ok cool that was it. Can you give me a brief explanation of making variables objects and why?

Also, am I doing the addcontrol correctly? It tends to mess things up but I obviously wanted it all to be part of a control. Specifically in this weapon another brings up bitmap buttons and it seems they lose on catchevent if I hit any button or click anything, even one of the 3 buttons itself. Even the hover highlight never works at all unless I remove the addcontrol.

PHP Code:

// Function to move in message on the screen
function showOptions(temp.idC)
{
  echo(
this.options[temp.idC]);
  (
"Dialog_Choice" @temp.idC).destroy();
  new 
GuiBitmapButtonCtrl("Dialog_Choice" @temp.idC)
  {
    
150;
    
destroyonhide true;
      
      
    
text thiso.options[temp.idC];
    
//normalbitmap = "";
    //mouseoverbitmap = "";
      
    //layer = 7;
    
zoom 0.6;
    
alpha 1;
      
    
this.join("tween");
    
this.catchId temp.idC;
    
    
thiso.catchevent(this"onMouseUp""selectedOpt");
  }
  
Dialog_Control.addcontrol(@ "Dialog_Choice" @temp.idC);
  
  
// tween the image x 
  
(@"Dialog_Choice" @temp.idC).tween("x"0.5050);
  
waitfor((@"Dialog_Choice" @temp.idC), "TweenFinished"0.05);
  
  
// tween the image y
  
(@"Dialog_Choice" @temp.idC).tween("y"0.5, (@"Dialog_Choice" @temp.idC).y, (@"Dialog_Choice" @temp.idC).+ (temp.idC 300));
  
waitfor((@"Dialog_Choice" @temp.idC), "TweenFinished"0.05);



cbk1994 12-27-2012 08:28 PM

Quote:

Originally Posted by sssssssssss (Post 1710754)
Ok cool that was it. Can you give me a brief explanation of making variables objects and why?

The this. prefix always refers to the current object scope. When you're in a GUI "new" block (or similar, such as "with"), you're outside of the script scope. The thiso. prefix can always be used to get back to the script scope.

PHP Code:

// script of NPC Test
function onCreated() {
  
this.foo "bar";
  echo(
this.foo); // echoes "bar"
  
echo(Test.foo); // echoes "bar"
  
  
with (findPlayer("cbk1994")) {
    echo(
this.foo); // probably echoes 0 since this won't exist
    
echo(thiso.foo); // echoes "bar"
  
}


Looks like the addControl is being used correctly to me but depending on what you're trying to do it may or may not be correct. In general I would move the addControl line up to inside the control definition and just do Dialog_Control.addControl(this);

sssssssssss 12-27-2012 09:11 PM

Ok I think I get it.

And with addcontrol I was just making sure I guess its controller.addcontrol(controlled);


All times are GMT +2. The time now is 07:46 AM.

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