Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-24-2007, 02:31 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
GUI Issue

I'm new to the GUI functions in Graal and I'm certain I'm overlooking something simple with this error, but here goes.

I am writing a Class NPC to implement the flier script Ziplock had requested be made awhile back, if anyone remembers that.

Right now, I have the window being created in Clientside in the CLASS.


However, when if I hit the red X, the GUI window disappears and walking into the flier image again will not open the GUI window back up.

Do I need to implement onCloseQuery to get this to work desirably?

PHP Code:
//#CLIENTSIDE
function onPlayerTouchsMe()
{
FlierWindow = new GuiWindowCtrl("Flier_" this.number);
  
with (FlierWindow)
  {
    
profile "GuiBlueWindowProfile";
    
position "30 30";
    
extent "300 300";
    
canMove true;
    
canResize false;
    
canClose true;
    
tile true;
    
text "Flier by " this.owner.account;
  }
  
GraalControl.addControl(FlierWindow);

Reply With Quote
  #2  
Old 09-24-2007, 02:36 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Resolved:

for future reference, enabling destroyonhide will fix this.
Reply With Quote
  #3  
Old 09-24-2007, 03:07 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Mark Sir Link View Post
Resolved:

for future reference, enabling destroyonhide will fix this.
that or use

if (guiwindowname != NULL) guiwindowname.destroy();

When redrawing guis.
Reply With Quote
  #4  
Old 09-26-2007, 01:29 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
rather than make anew thread, I'll insert this issue here.

Again, I am sure this the noobness instead of a legitimate issue here, but...

in Scroll Control, inside a Window Control, I am attempting to add text using a MLTextObject.

PHP Code:
new GuiMLTextCtrl("Test_MultiLineText") {
  
profile "GuiBlueMLTextProfile";
  
position "5 5";
  
extent "250 250";
  
text format("<font size = 16> %s </font>"this.text); 
the issue as I'm sure you'll notice is with the text.

I have tried appending the text and then anotehr </font> tag, I have tried using the format functionality - Tests have shown this.text is a valid string so I am certain the issue isn't with actually getting data.

Could use help with this.


UPDATE:

Upon further review, I am finding that the this.text actually doesn't exist clientside but it does serverside.

I tried using a triggerclient in the class but found that doesn't work for getting the string to clientside.

Any suggestions?

Last edited by Mark Sir Link; 09-26-2007 at 01:41 PM..
Reply With Quote
  #5  
Old 09-26-2007, 02:58 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Since you're accessing a GUI control, you'll need to use thiso.text rather then this.text.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #6  
Old 09-26-2007, 04:45 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Quote:
Originally Posted by xXziroXx View Post
Since you're accessing a GUI control, you'll need to use thiso.text rather then this.text.

Uh, regardless, this.text isn't transitioning properly from serverside to clientside. Once I get that fixed, the other errors should be fixed.

So, any ideas on how to synchronize across serverside and clientside?
Reply With Quote
  #7  
Old 09-26-2007, 08:07 PM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Quote:
Originally Posted by Mark Sir Link View Post
So, any ideas on how to synchronize across serverside and clientside?
Use attr[] or (depreciated?) save[], use a clientr.var instead...

I don't see why you wouldn't be able to pass it by triggering the client though.
__________________
Reply With Quote
  #8  
Old 09-26-2007, 08:19 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Quote:
Originally Posted by Googi View Post
Use attr[] or (depreciated?) save[], use a clientr.var instead...
clientr would be worthless since the text is intended to be readable by many people in a GUI, and is being passed to a class.

Server is impractible because there is a potential for over 9000 () NPCs to join the class and use it.




Alright, further research has shown that a Class NPC cannot do what I am looking for it to do (triggerclient doesn't work for non weapon/GUI scripts).


So I guess my next question would be, can I triggeraction to the client if I use an on function?

Ok, verified I can't.

am I to assume I am out of luck and it is impossible to pass information the clientside of a Class NPC?
Reply With Quote
  #9  
Old 09-27-2007, 01:55 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by Mark Sir Link View Post
Uh, regardless, this.text isn't transitioning properly from serverside to clientside. Once I get that fixed, the other errors should be fixed.

So, any ideas on how to synchronize across serverside and clientside?
That's what I get for not reading properly.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #10  
Old 09-27-2007, 02:35 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Mark Sir Link View Post
am I to assume I am out of luck and it is impossible to pass information the clientside of a Class NPC?
Like Googi said, try using this.attr[] (and when you access from within the new Gui Control, use thiso.attr[]).
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #11  
Old 09-28-2007, 01:15 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Alright. Still not working as intended unfortunately, but I'm willing to guess I messed up somewhere since I've never tried using attributes like this.
PHP Code:
//Serverside, function onCreated()...
this.attr[0] = this.text;

//#CLIENTSIDE
text format("<font size = 16> %s lolol</font>"thiso.attr[0]); 
Before we tear apart the format part, let it be known that when setting player.chat to this.attr[0], it is still coming up null.
Reply With Quote
  #12  
Old 09-28-2007, 02:30 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Mind posting the entire code?
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #13  
Old 09-28-2007, 02:34 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Class script:
PHP Code:
function onCreated()
{
setimg("classic_warpicon_gcstudios.png");
this.attr[0] = this.text;
}

function 
onActionRemoveFlier()
  {
  
destroy();
}

//#CLIENTSIDE
function onPlayerTouchsMe()
{
player.chat this.attr[0];
FlierWindow = new GuiWindowCtrl("Flier_" this.number);
  
with (FlierWindow)
  {
    
profile "GuiBlueWindowProfile";
    
this.posx screenwidth/-150 ;
    
this.posy screenheight/150;
    
position = {this.posxthis.posy};
    
extent "300 300";
    
canMove true;
    
canResize false;
    
canClose true;
    
tile true;
    
canmaximize false;
    
text "Flier by " thiso.owner.account;
    
destroyonhide true;
    
    new 
GuiScrollCtrl("Test_ScrollField") {
  
profile GuiBlueScrollProfile;
  
position "5 23";
  
extent "290 270";
  
hScrollBar "dynamic";
  
vScrollBar "alwaysOn";
  
  new 
GuiMLTextCtrl("Test_MultiLineText") {
  
profile "GuiBlueMLTextProfile";
  
position "5 0";
  
extent "250 250";
  
text format("<font size = 16> %s lolol</font>"thiso.attr[0]);
}

}
  }
  
GraalControl.addControl(FlierWindow);

NPC Script (Kinda Messy because of checks I was doing, etc)
PHP Code:
//Coded by Kevin Azite
//Under Progress

function onActionServerside()
  {
  if(
params[0] == "place")
    {
    
temp.npc putnpc2(params[1], params[2], "join fliers;");
    
temp.npc.text params[3];
    
temp.npc.owner player;
  }
}
//#CLIENTSIDE
function onPlayerChats()
  {
  if(
player.chat.starts("/flier"))
  {
  
this.text player.chat.substring(6);
  
player.chat this.text;
  
  if(
player.dir == 0)
  {
  if(
onwall(player.x+.5player.1.5))
  {
  
triggeraction(00"serverside""Fliers""place"player.x+.5player.y-1this.text);
}
}
}
}
function 
onMouseDown(button)
  {
  if(
button "right")
    {
    
triggeraction(mousexmousey"RemoveFlier"null);
  }
  } 
Reply With Quote
  #14  
Old 09-28-2007, 03:42 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
I dont see this.text being declared in either of the scripts serversided, that's why it returns NULL.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #15  
Old 09-28-2007, 04:39 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Quote:
Originally Posted by xXziroXx View Post
I dont see this.text being declared in either of the scripts serversided, that's why it returns NULL.
temp.npc.text = params[3]


that means in the NPC, this.text will become whatever the params were.
Reply With Quote
  #16  
Old 09-28-2007, 04:52 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Doh, there I go not reading properly again, sorry.

Try debugging it by doing:

PHP Code:
function onCreated()
{
setimg("classic_warpicon_gcstudios.png");
this.text "test";
this.attr[0] = this.text;
echo(
this.text SPC "|" SPC this.attr[0]);

__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #17  
Old 09-28-2007, 04:59 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
this.text displays "test", this.attr[0] is coming null.

So it seems that using an attr will be impossible, which leaves me in quite a predicament if I can't triggerclient in a class.

Reply With Quote
  #18  
Old 09-28-2007, 05:17 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Try using this.attr[1]. I don't think attr[0] works.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #19  
Old 09-28-2007, 05:22 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Yea, isnt attr[0] non-existant?
Reply With Quote
  #20  
Old 09-28-2007, 05:30 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
this.attr[1] resolves the issue.

Thanks guys
Reply With Quote
  #21  
Old 09-28-2007, 05:36 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by napo_p2p View Post
Try using this.attr[1]. I don't think attr[0] works.
Thanks for teaching an old dog something new!
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #22  
Old 10-23-2007, 05:48 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Hmm...

gonna bump this thread rather than creating a new one.

I'm trying to create a custom GUI profile, and I'm sticking this in a class so I can easily use each profile in multiple NPCs. However, when I call createGUIs, the new profiles aren't working properly.

NPC Code
PHP Code:
function onCreated()
{
this.join("customgui");
createGUIs();

in class "customgui".
PHP Code:
//vampiro_button.png
//vampiro_scroll.png
//vampiro_window.png
//#CLIENTSIDE
function createGUIs()
{
new 
GuiWindowCtrlProfile("VampiroWindowProfile")
{

bitmap "vampiro_window.png";

opaque false;
transparency 0.5;
}

new 
GuiScrollCtrlProfile("VampiroScrollProfile")
{

bitmap "vampiro_scroll.png";

opaque false;
transparency 0.5;
}

new 
GuiButtonCtrlProfile("VampiroButtonProfile")
{

bitmap "vampiro_button.png";

opaque false;
transparency 0.5;
}

Attached Images
   
Reply With Quote
  #23  
Old 10-23-2007, 05:54 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Not sure if it helps but I generally make functions public inside classes if they are going to be called outside the class.

Then again whats the actual problem? Does nothing happen or does the profile look all weird?
Reply With Quote
  #24  
Old 10-23-2007, 05:56 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
The function itself is clientside, though you are calling it serverside
Reply With Quote
  #25  
Old 10-23-2007, 10:33 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
He's not calling the function outside of the original NPC so he doesn't need it to be public. Also, you only need to create profiles one time (do it from like a system WNPC) not for every npc. Profiles are global variables just like GUIs so once you create them, every npc can use them.
__________________
Do it with a DON!
Reply With Quote
Reply


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 11:47 PM.


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