Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-17-2006, 11:20 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Unhappy 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. 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.
Reply With Quote
  #2  
Old 03-17-2006, 11:37 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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
__________________
Skyld
Reply With Quote
  #3  
Old 03-17-2006, 11:39 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
<3 thanks, I'll get to work =D
Reply With Quote
  #4  
Old 03-17-2006, 11:46 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to 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
Reply With Quote
  #5  
Old 03-17-2006, 11:49 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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); 
__________________
Skyld
Reply With Quote
  #6  
Old 03-18-2006, 12:03 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
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?

Last edited by excaliber7388; 03-18-2006 at 12:47 AM..
Reply With Quote
  #7  
Old 03-18-2006, 01:48 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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?
Reply With Quote
  #8  
Old 03-18-2006, 02:11 AM
Prozac Prozac is offline
one of the good guys
Prozac's Avatar
Join Date: Jan 2006
Posts: 245
Prozac is on a distinguished road
Send a message via AIM to Prozac
when you say
thiso.variablename

does the o after the word this
stand for object?
or what?
Reply With Quote
  #9  
Old 03-18-2006, 03:26 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
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)
Reply With Quote
  #10  
Old 03-18-2006, 12:37 PM
Rick Rick is offline
PipBoy Extraordinaire!
Rick's Avatar
Join Date: Jul 2004
Location: Long Beach, California.
Posts: 831
Rick is on a distinguished road
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.
Reply With Quote
  #11  
Old 03-18-2006, 05:32 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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.
Reply With Quote
  #12  
Old 03-18-2006, 07:23 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to 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
Reply With Quote
  #13  
Old 03-18-2006, 07:31 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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.
__________________
Skyld
Reply With Quote
  #14  
Old 03-18-2006, 09:06 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
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

Reply With Quote
  #15  
Old 03-18-2006, 11:01 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
It is calling the action, but im having trouble getting it to send the text of Player.text and to read it.
Reply With Quote
  #16  
Old 03-18-2006, 11:13 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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.
__________________
Skyld
Reply With Quote
  #17  
Old 03-18-2006, 11:27 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Made those fixes, but when the action is called, params[1] is just pl_acct.text (new name of that object)
Reply With Quote
  #18  
Old 03-19-2006, 01:35 AM
Rick Rick is offline
PipBoy Extraordinaire!
Rick's Avatar
Join Date: Jul 2004
Location: Long Beach, California.
Posts: 831
Rick is on a distinguished road
triggeraction(0, 0, "serverside", "Staff Control", "jail", pl_acct.text, Reason.text);
Reply With Quote
  #19  
Old 03-19-2006, 05:46 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to 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?
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).
Reply With Quote
  #20  
Old 03-19-2006, 05:48 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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]); 
__________________
Skyld
Reply With Quote
  #21  
Old 03-19-2006, 06:15 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
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
Reply With Quote
  #22  
Old 03-19-2006, 06:47 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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.
__________________
Skyld
Reply With Quote
  #23  
Old 03-19-2006, 07:27 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
nevermind, i was setting the string in GS1 x_X

Last edited by excaliber7388; 03-19-2006 at 08:01 PM..
Reply With Quote
  #24  
Old 03-19-2006, 09:42 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to 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
Reply With Quote
  #25  
Old 03-19-2006, 10:22 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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
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 
__________________
Skyld
Reply With Quote
  #26  
Old 03-19-2006, 10:26 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
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] @);
Reply With Quote
  #27  
Old 03-19-2006, 10:38 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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.
__________________
Skyld
Reply With Quote
  #28  
Old 03-19-2006, 10:53 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
<3 thanks!!
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 06:14 PM.


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