Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   gui windows x_X (https://forums.graalonline.com/forums/showthread.php?t=64794)

excaliber7388 03-17-2006 11:20 PM

gui windows x_X
 
I'm having a hell of a time trying to learn about these things. I now consider the wikis useless, as a simple listing of commands has gotten me nowhere. :whatever: Anyone know a better site, or willing to pass on some knowledge? I've been working/searching for a while, and all I got is a window with some useless tabs that won't reaopen after it's closed >_< . I'm trying to create a tool for players and staff for various commands and options. I'm NOT asking for a script, small examples, or a good site to learn would be nice though.

Skyld 03-17-2006 11:37 PM

PHP Code:

new GuiWindowCtrl("objectname")
{
  
extent = {14062};
  
position = {5050};

  
text "Window Title";

  new 
GuiButtonCtrl("buttonname")
  {
    
position = {624};
    
extent = {12832};

    
text "Button!";
  }


... will create a window, and a button inside of it. Child objects usually go inside the parent objects.

The following code will show you how to handle the event of a button being clicked:
PHP Code:

function buttonname.onAction()
{
  
// code


If you would rather some custom actions, you could do:
PHP Code:

thiso.catchEvent(this"onAction""newActionName"); 

... inside one of the new blocks, and then newActionName() would be called when the button is clicked, in the case of a button.

The first parameter passed to newActionName() would be the object of the button.
PHP Code:

function newActionName(obj)
{
  
// obj is the button that was clicked


You can also change parameters about an object later:
PHP Code:

with (controlname)
{
  
member value;


PHP Code:

controlname.member value


excaliber7388 03-17-2006 11:39 PM

<3 ^^ thanks, I'll get to work =D

excaliber7388 03-17-2006 11:46 PM

How do i get it to come back after it's closed? I've been using onWeaponfired() to bring it up, but it only works once

Skyld 03-17-2006 11:49 PM

Quote:

Originally Posted by excaliber7388
How do i get it to come back after it's closed? I've been using onWeaponfired() to bring it up, but it only works once

I can't remember if the window just hides when you close it, or whether it's actually destroyed. If it's destroyed, then you will need to redefine the window in order to return it. Alternatively, you could use something to toggle the window's visibility:
PHP Code:

windowcontrolname.visibile = !(windowcontrolname.visible); 


excaliber7388 03-18-2006 12:03 AM

I'm not sure, recalling it won't bring it back unless it's minimized.

Also, how do I clear buttons for creating a new window?

Admins 03-18-2006 01:48 AM

When someone clicks on the X then it is by default just hidden, you can show it again by calling windowname.show() or windowname.showtop() (to make it show on top of all other windows and giving it the key focus).
What do you mean with clearing buttons?

Prozac 03-18-2006 02:11 AM

when you say
thiso.variablename

does the o after the word this
stand for object?
or what?

excaliber7388 03-18-2006 03:26 AM

Forgive me, I'm new with these and gs2, but can you do text input with these? For example, a jailing system that would allow text input? (I just need it to ask for some text, and send the parameters serverside, so really all i need is text input that the npc can read)

Rick 03-18-2006 12:37 PM

Quote:

Originally Posted by Prozac
when you say
thiso.variablename

does the o after the word this
stand for object?
or what?

thiso = 'this outside' (basically - don't know if that's the technical term).

Think of it this way:

PHP Code:

function someSillyFunctar()
{
  
this.myvar "foo";
  
with (someObject)
  {
    
this.myvar "bar";
    echo(
thiso.myvar); //echos 'foo';
    
echo(this.myvar); // echos 'bar'
  
}


'thiso' accesses 'this' variables in the previous enviornment. There is also a 'tempo' I think, or I might be thinking of 'playero', I can't remember.

Admins 03-18-2006 05:32 PM

There is a list of variable prefixes for the old scripting engine at http://wiki.graal.net/index.php/Crea...iable_Prefixes,
someone should do that for the new scripting engine may be. There is now also a playero prefix. The 'o' means 'original', thiso and playero always refer to the original this and player variables when the script execution started.

excaliber7388 03-18-2006 07:23 PM

I've been thinking about using text display on the gui, and a loop that stores your keyboard input, then increments an array to store it, giving the text output, then when you push the buton for jail, disconnect, etc (staff npc) it would use that array, along with a serverside action, and getplayer, to do that action to them. However, I want to know it there is an easier way, through gui text input

Skyld 03-18-2006 07:31 PM

Quote:

Originally Posted by excaliber7388
I've been thinking about using text display on the gui, and a loop that stores your keyboard input, then increments an array to store it, giving the text output, then when you push the buton for jail, disconnect, etc (staff npc) it would use that array, along with a serverside action, and getplayer, to do that action to them. However, I want to know it there is an easier way, through gui text input

Using the GUI controls, you do not even need to capture keyboard input. Using a GuiTextEditCtrl will create an editable text box, and you can read the entered text using objectName.text.

excaliber7388 03-18-2006 09:06 PM

thanks, this is what I currently have for a staff weapon, it's not calling the action, or the parameters are wrong. (I'm trying gs2, finally)
PHP Code:

function onActionserverside()
{
  if(
params[0]==jail)
  {
    
with(getplayer(params[1]))
    {
      
setlevel2 jail_darkrival2.nw,30,30;
      
#c="Jailed For params[2]";
      
savelog2 StaffToollog.txt,Staff="player.account" Jailed Player="params[1]" Reason="params[2]";
    }
    
with(getplayer(player.account))
    {
      
#c="Jailed params[1] for params[2]";
    
}
  }
  if(
params[0]==disconnect)
  {
//same stuff as jail, but with serevrwarp Login thrown in ;)
  
}
}
//#CLIENTSIDE
function onWeaponfired()

  
staffwindow.showtop();
  new 
GuiWindowCtrl("staffwindow"
  { 
    
extent = {21090}; 
    
position = {0screenheight-100}; 
    
text "Staff Control"
    new 
GuiTextEditCtrl("Player")
    {
      
position = {5,25};
      
extent = {100,20};
      
text "Account";
    }
    new 
GuiTextEditCtrl("Reason")
    {
      
position = {5,45};
      
extent = {100,20};
      
text "Reason";
    }
    new 
GuiButtonCtrl("Jail"
    { 
      
position = {10525}; 
      
extent = {10030}; 
      
text "Jail"
    }
    new 
GuiButtonCtrl("Disconnect"
    { 
      
position = {10555}; 
      
extent = {10030}; 
      
text "Disconnect"
    }
  } 
}
function 
Jail.onAction() 

    
triggeraction 0,0,serverside,Staff Control,jail,Player.text,Reason.text;
}
function 
Disconnect.onAction()
{
  
//stuff



excaliber7388 03-18-2006 11:01 PM

It is calling the action, but im having trouble getting it to send the text of Player.text and to read it.

Skyld 03-18-2006 11:13 PM

It's not an excellent idea using the object "player", since that is already reserved for the current player.
PHP Code:

if(params[0]==jail
  { 

... also won't work because jail should be "jail" with it being a string value.
PHP Code:

#c= 

... isn't really good practice, you should be using player.chat =.
PHP Code:

setlevel2 jail_darkrival2.nw,30,30

... should be:
PHP Code:

setlevel2("jail_darkrival2.nw"3030); 

to be new engine scripting. The same applies for savelog2() and such.

Most of what's there is a mix of old gscript and new gscript, so you should iron those kinks out and work purely in new gscript.

excaliber7388 03-18-2006 11:27 PM

Made those fixes, but when the action is called, params[1] is just pl_acct.text (new name of that object)

Rick 03-19-2006 01:35 AM

triggeraction(0, 0, "serverside", "Staff Control", "jail", pl_acct.text, Reason.text);

excaliber7388 03-19-2006 05:46 PM

I also added in a numerical value, the time for jailings (DR has an auto unjail system) however, it's not sending the time right it's params[3]*3600 and it shows up at literally params[3]*3600 (which may as well be 0) since gs2 doesn't have a #v() what do I do?
Also, I had hoped to display text like this:
player.chat="Jailed for " params[2] " for " params[3] " hours";
bu obviously, that doesn't work
(params[2] is the reason, 3 is the time).

Skyld 03-19-2006 05:48 PM

Quote:

Originally Posted by excaliber7388
I also added in a numerical value, the time for jailings (DR has an auto unjail system) however, it's not sending the time right it's params[3]*3600 and it shows up at literally params[3]*3600 (which may as well be 0) since gs2 doesn't have a #v() what do I do?

Sounds like you need to stop putting "quotemarks" around variable names.
Quote:

Originally Posted by excaliber7388
Also, I had hoped to display text like this:
player.chat="Jailed for " params[2] " for " params[3] " hours";
bu obviously, that doesn't work
(params[2] is the reason, 3 is the time).

PHP Code:

player.chat "Jailed for " params[2] @ " for " params[3] @ " hours";
// Or even better:
player.chat format("Jailed for %s for %i hours"params[2], params[3]); 


excaliber7388 03-19-2006 06:15 PM

there are no quotes around the parameter, it's just params[3]*3600 :(
And thanks, the text stuff make me miss the old format a bit :(

Skyld 03-19-2006 06:47 PM

Read what Rick said.
PHP Code:

triggeraction(00"action" ...); 

Using the old gscript triggeraction will not treat variables properly, you need to use the new format.

excaliber7388 03-19-2006 07:27 PM

nevermind, i was setting the string in GS1 x_X

excaliber7388 03-19-2006 09:42 PM

PHP Code:

    savelog2("StaffToollog.txt","Staff= player.account Jailed Player=params[1] Reason=params[2]"); 

^ ^ All that does is save the EXACT text into the file :frown:

Skyld 03-19-2006 10:22 PM

Quote:

Originally Posted by excaliber7388
PHP Code:

    savelog2("StaffToollog.txt","Staff= player.account Jailed Player=params[1] Reason=params[2]"); 

^ ^ All that does is save the EXACT text into the file :frown:

That's because you need to concatenate the strings properly. You have to be explicitly clear when you want something to be treated as a variable or whatever.
PHP Code:

"Staff= " player.account " jailed player= " params[1]... etc 


excaliber7388 03-19-2006 10:26 PM

PHP Code:

    savelog2("StaffToollog.txt","Staff= " player.account " Jailed Player= " params[1] @ " Reason= " params[2] @); 

^ returns an error to rc ^
Quote:

error: unexpected token: ) at line 5: savelog2("StaffToollog.txt","Staff= " @ player.account @ " Jailed Player= " @ params[1] @ " Reason= " @ params[2] @);

Skyld 03-19-2006 10:38 PM

Quote:

Originally Posted by excaliber7388
PHP Code:

    savelog2("StaffToollog.txt","Staff= " player.account " Jailed Player= " params[1] @ " Reason= " params[2] @); 

^ returns an error to rc ^

You don't need the @ at the end. You only put it between two values.

excaliber7388 03-19-2006 10:53 PM

<3 thanks!!


All times are GMT +2. The time now is 07:29 PM.

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