Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-11-2011, 04: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
Very awesome staff "panel"

So, Emera's thread reminded me I wanted to release my little staff tool to you guys. Here you go!


The idea and design is a blatant rip off of the tool Era (used to?) use, sorry guys It looks a little cooler, though, and is full of awesome. You can add new items to the tool easily without even really touching the main portion of the code. First off, here's the code:

PHP Code:
//#CLIENTSIDE
function onCreated() {  
  
// staff tool stuff
  
this.toolOn false;
  
this.toolIdx 0;
  
  
// add new items here
  
this.toolEntries = {
    { 
"Exit""block.png" },
    { 
"Update Level""block.png" }
  };
}

// draw the staff tool
function DrawTool(create) {
  
// create image objects
  
if (create) {
    
// background
    
temp.GraalControl.width this.toolEntries.size() * 20;
    
temp.GetPolyRect(temp.xGraalControl.height 104this.toolEntries.size() * 4064);
    
with (findImg(200)) {
      
polygon temp.p;
      
red green blue 0;
      
alpha 0.75mode 1;
      
layer 5;
    }
    
    
// text
    
with (findImg(201)) {
      
temp.8;
      
GraalControl.height 58;
      
text thiso.toolEntries[thiso.toolIdx][0];
      
font "Arial"zoom 0.5;
      
red green blue 1;
      
layer 6;
    }
    
    
// icons
    
for (temp.0this.toolEntries.size(); i++) {
      
with (findImg(202 i)) {
        
temp.40;
        
GraalControl.height 96;
        
image thiso.toolEntries[i][1];
        
partx party 0;
        
partw parth 32;
        
alpha 0.5mode 1;
        
layer 6;
      }
    }
  }
  
  
// update text & alpha
  
findImg(201).text this.toolEntries[this.toolIdx][0];
  
  
temp.ci this.toolIdx// current tool
  
temp.li = (ci ci this.toolEntries.size() - 1); // last tool
  
findImg(202 ci).alpha 1;
  
findImg(202 li).alpha 0.5;
}

// reposition the staff tool when resizing Graal
function GraalControl.onResize(nwnh) {
  if (!
this.toolOn)
    return;
  
  
DrawTool(true);
}

// keyboard stuff
function GraalControl.onKeyDown(code) {
  if (
code == 69) { // E
    
if (!this.toolOn) {
      
this.toolOn  true;
      
this.toolIdx 0;
      
      
DrawTool(true);
    } else {
      
this.toolIdx++;
      
this.toolIdx %= this.toolEntries.size() - 1;

      
DrawTool(false);
    }
  } elseif (
code == 87) { // W
    
if (!this.toolOn)
      return;
    
    
temp.ReplaceText(this.toolEntries[this.toolIdx][0].upper(), " ""_");
    (
"StaffTool" temp.f)();
  }
}


// close staff tool
function StaffToolEXIT() {
  
this.toolOn false;
  
hideImgs(200201 this.toolEntries.size());
}

// update level
function StaffToolUPDATE_LEVEL() {
  
shared.chat("");
  
sleep(0.05);
  
shared.chat("update level");
}


// Dusty's, restyled
function ReplaceText(txtab) {
  if (
txt.pos(a) < 0)
    return 
txt;
  
  
temp.len a.length();
  
temp.txtpos txt.positions(a);
  
temp.newtxt txt.substring(0txtpos[0]);
  
  for (
temp.itemp.txtpos) {
    
temp.txt.substring(temp.len).pos(a);
    
temp.newtxt @= b
    
temp.newtxt @= txt.substring(temp.lentemp.p); 
  }
  
  return 
temp.newtxt
}

// Crow's :3
function GetPolyRect(xywh)
  return { 
xywywhx}; 

To use it, press E to open the menu and scroll through the items, then W to "use" the highlighted item.

To add more items, just edit the this.toolEntries array in the onCreated() event and also add a function for your new item. Functions are prefixed with "StaffTool" and then the name of the item is added, with all upper case and spaces replaced with underscores. So if your item's name is "Do some crazy StUfF", the function that's being called is StaffToolDO_SOME_CRAZY_STUFF.

Second entry in the item arrays is the icon; change if you want to.


This should run just fine, but it was "dry-stripped" (didn't test it) from an existing system that is way bigger than just this stuff. Report any problems, pretty please.

End product can look like this:
Click image for larger version

Name:	stafftool.jpg
Views:	1164
Size:	18.0 KB
ID:	52689


Enjoy! <3

Last edited by Crow; 04-11-2011 at 05:24 PM..
Reply With Quote
  #2  
Old 04-11-2011, 05:35 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Ah good ol crow
__________________
Reply With Quote
  #3  
Old 04-11-2011, 09:43 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
yes big rip o_o gj skyld / [crow?]
__________________
Reply With Quote
  #4  
Old 04-11-2011, 09:47 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
Quote:
Originally Posted by xAndrewx View Post
yes big rip o_o gj skyld / [crow?]
Just the idea was taken Was the one on Era actually as easily expandable? I can't remember.
Reply With Quote
  #5  
Old 04-11-2011, 09:57 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Yeah
HTML Code:
  this.tools = {
    {"Exit", "exit", "era_tool-exit.png", "Close tool"},
    {"Staff Stick", "staffstick", "era_icon-staffstick.png", "Destroys NPCs and unsticks players"},
    {"Staff Boomerang", "staffboomerang", "era_icon-staffrang.png", "Destroys NPCs and unsticks players"},
//    {"Staff Block", "staffblock", "era_staffblock.png", "Places staff blocks"},
    {"Staff Boots", "staffboots", "wboots.png", "Say 'Setspeed #'. Walk speed: 'setwalkspeed #'."},
    {"Unstick Me", "unstick", "era_icon-globe-hallow.png", "Go to Unstick me"},
    {"Stealth", "stealth", "block.png", "Turns you invisible"},
    {"Drag", "drag", "block.png", "Drags players"},
    {"Staff Tag", "stafftag", "era_icon-cashmoneys.png", "Adds your staff tag"},
    //{"Staff Chat", "staffchat", "block.png", "Shows staff chat"}
  };
lol it looks nicer though [yours]
__________________
Reply With Quote
  #6  
Old 04-11-2011, 10:00 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
I can't stand your function name capitalization...why??? Nice release though.

Also, you should probably just use VK_E instead of checking the key code directly.
__________________
Reply With Quote
  #7  
Old 04-11-2011, 10:29 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
Quote:
Originally Posted by cbk1994 View Post
I can't stand your function name capitalization...why??? Nice release though.
What exactly don't you like? Thanks!


Quote:
Originally Posted by cbk1994 View Post
Also, you should probably just use VK_E instead of checking the key code directly.
That exists?! Is there a list of all constants like those somewhere? I thought Graal didn't have these.
Reply With Quote
  #8  
Old 04-11-2011, 10:36 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Crow View Post
What exactly don't you like?
I'm used to using upper case first letter for object/class names and a lowercase first letter for methods like in Java.

Quote:
That exists?! Is there a list of all constants like those somewhere? I thought Graal didn't have these.
It exists, but I don't know of any documentation. We just found out about it recently. Gotta love GScript.

Quote:
Originally Posted by Stefan View Post
It has been added more than 3 years ago x-x
Additionally to the normal VK_ defines it also provides VK_A, .. VK_Z (value is the same as 'a' ... 'z')
__________________
Reply With Quote
  #9  
Old 04-11-2011, 10:55 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
Quote:
Originally Posted by cbk1994 View Post
I'm used to using upper case first letter for object/class names and a lowercase first letter for methods like in Java.
Well, it's all about preference I guess. I got used to upper case for my own functions and lower case for Graal's. Not sure why, but it works nicely.

Also, GScript really needs some solid documentation.
Reply With Quote
  #10  
Old 04-11-2011, 11:10 PM
PowerProNL PowerProNL is offline
Retired Zone Manager
PowerProNL's Avatar
Join Date: Feb 2008
Location: Holland
Posts: 266
PowerProNL can only hope to improve
Send a message via AIM to PowerProNL
You must spread some Reputation around before giving it to Crow again.
__________________
Graal Mail: [email protected]
McPowerProNL, I'm loving it
Reply With Quote
  #11  
Old 04-12-2011, 07:14 AM
Demisis_P2P Demisis_P2P is offline
Kanto League Champion
Demisis_P2P's Avatar
Join Date: Jan 2005
Posts: 2,357
Demisis_P2P has much to be proud ofDemisis_P2P has much to be proud ofDemisis_P2P has much to be proud ofDemisis_P2P has much to be proud ofDemisis_P2P has much to be proud ofDemisis_P2P has much to be proud ofDemisis_P2P has much to be proud of
Quote:
Originally Posted by Crow View Post
Also, GScript really needs some solid documentation.
Maybe when GS3 comes out. Stefan's added way too much stuff to GS2 that nobody knows about to start documenting it now.
__________________
Reply With Quote
  #12  
Old 04-12-2011, 09:57 AM
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
Quote:
Originally Posted by Demisis_P2P View Post
Maybe when GS3 comes out. Stefan's added way too much stuff to GS2 that nobody knows about to start documenting it now.
The sole purpose of GS3 would probably be the documentation.
Reply With Quote
  #13  
Old 04-12-2011, 05:29 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Gs3???!!!??
__________________
Reply With Quote
  #14  
Old 04-12-2011, 10:13 PM
Devil_Lord2 Devil_Lord2 is offline
David K?
Devil_Lord2's Avatar
Join Date: Apr 2011
Location: PA, MD.
Posts: 643
Devil_Lord2 can only hope to improve
Quote:
Originally Posted by Crow View Post
The sole purpose of GS3 would probably be the documentation.
I hopes so >.>,
And I hope it explains better than commands.txt and bible..
That would be awesome :]
__________________

Digital Media Artist - David K? </3 (UnLoved)
www.davidkrout.com
www.twitch.com/DavidKkz



Reply With Quote
  #15  
Old 07-19-2011, 06:36 PM
fatcat123 fatcat123 is offline
Levels Artist
fatcat123's Avatar
Join Date: Aug 2010
Location: Wisconsin
Posts: 70
fatcat123 is an unknown quantity at this point
I love this.

Although, when I die, I cannot figure out why the black GUI disappears and all I see is the wording of the staff tool name in white font.
Reply With Quote
  #16  
Old 07-19-2011, 07:23 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
Quote:
Originally Posted by fatcat123 View Post
I love this.

Although, when I die, I cannot figure out why the black GUI disappears and all I see is the wording of the staff tool name in white font.
Graal destroys all GUI layer images upon (default) death. Since I don't care much in this case, I didn't add anything to "fix" this. Try adding these lines of code though:
PHP Code:
function onPlayerDies() {
  if (
this.toolOn)
    
DrawTool(true);

Just add it at the very bottom of the code. Should work.
Reply With Quote
  #17  
Old 07-21-2011, 05:11 PM
fatcat123 fatcat123 is offline
Levels Artist
fatcat123's Avatar
Join Date: Aug 2010
Location: Wisconsin
Posts: 70
fatcat123 is an unknown quantity at this point
Works like a charm. Thanks for posting this =), I've been growing my scripting experience off of it.
Reply With Quote
  #18  
Old 07-23-2011, 10:48 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
I tried to import this onto a server earlier today, and I have checked through the script many times but when I hit w or e or whatever it is, nothing happens.
__________________
Reply With Quote
  #19  
Old 07-23-2011, 10:59 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Emera View Post
I tried to import this onto a server earlier today, and I have checked through the script many times but when I hit w or e or whatever it is, nothing happens.
Make sure it's added to you and that GraalControl has focus, you'll be able to move if it does.
__________________
Quote:
Reply With Quote
  #20  
Old 07-23-2011, 11:40 PM
fatcat123 fatcat123 is offline
Levels Artist
fatcat123's Avatar
Join Date: Aug 2010
Location: Wisconsin
Posts: 70
fatcat123 is an unknown quantity at this point
Quote:
Originally Posted by fowlplay4 View Post
Make sure it's added to you and that GraalControl has focus, you'll be able to move if it does.
It didn't work for me either when I first put it on :[
I had a scripter help me out, and after a while we got it to work.
Reply With Quote
  #21  
Old 07-23-2011, 11:43 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
Quote:
Originally Posted by fatcat123 View Post
It didn't work for me either when I first put it on :[
I had a scripter help me out, and after a while we got it to work.
That's strange. It should work right away. Mind posting any code differences?
Reply With Quote
  #22  
Old 07-24-2011, 12:04 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Make sure the //#CLIENTSIDE at the top doesn't have a space after it
__________________
Reply With Quote
  #23  
Old 07-24-2011, 12:16 AM
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
Quote:
Originally Posted by xAndrewx View Post
Make sure the //#CLIENTSIDE at the top doesn't have a space after it
Right, listen to this man. Damn vBulletin code boxes
Reply With Quote
  #24  
Old 07-24-2011, 02:16 AM
fatcat123 fatcat123 is offline
Levels Artist
fatcat123's Avatar
Join Date: Aug 2010
Location: Wisconsin
Posts: 70
fatcat123 is an unknown quantity at this point
Quote:
Originally Posted by xAndrewx View Post
Make sure the //#CLIENTSIDE at the top doesn't have a space after it
Oh.. I feel stupid now because I had to have an actual scripter look at the script :[..
Reply With Quote
  #25  
Old 07-24-2011, 05:45 PM
fatcat123 fatcat123 is offline
Levels Artist
fatcat123's Avatar
Join Date: Aug 2010
Location: Wisconsin
Posts: 70
fatcat123 is an unknown quantity at this point
After fixing the //#CLIENTSIDE it won't scroll when press e. o_O?
" I had it working before, but I decided to replace my work and start over again.. "
Reply With Quote
  #26  
Old 07-24-2011, 05:53 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by fatcat123 View Post
After fixing the //#CLIENTSIDE it won't scroll when press e. o_O?
" I had it working before, but I decided to replace my work and start over again.. "
Because you press W...
__________________
Reply With Quote
  #27  
Old 07-24-2011, 07:12 PM
fatcat123 fatcat123 is offline
Levels Artist
fatcat123's Avatar
Join Date: Aug 2010
Location: Wisconsin
Posts: 70
fatcat123 is an unknown quantity at this point
Quote:
Originally Posted by Emera View Post
Because you press W...
No. E scrolls/turns it on, "W" activates the weapon.
Reply With Quote
  #28  
Old 07-24-2011, 07:26 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
No. E scrolls/turns it on, "W" activates the weapon.
Oh pardon me, I should have looked closer, sorry mate.
__________________
Reply With Quote
  #29  
Old 07-24-2011, 08:29 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
It should work perfectly fine. Is there anything else mapped to E on the playerworld you're trying this on? Also, does GraalControl have focus?
Reply With Quote
  #30  
Old 07-25-2011, 02:51 AM
fatcat123 fatcat123 is offline
Levels Artist
fatcat123's Avatar
Join Date: Aug 2010
Location: Wisconsin
Posts: 70
fatcat123 is an unknown quantity at this point
Quote:
Originally Posted by Crow View Post
It should work perfectly fine. Is there anything else mapped to E on the playerworld you're trying this on? Also, does GraalControl have focus?
How do I give GraalControl focus?
Reply With Quote
  #31  
Old 07-25-2011, 11:15 AM
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
Quote:
Originally Posted by fatcat123 View Post
How do I give GraalControl focus?
It has focus by default. You know that it has focus when you can walk around using your arrow keys (or whatever you use to move).
Reply With Quote
  #32  
Old 08-03-2011, 05:01 PM
fatcat123 fatcat123 is offline
Levels Artist
fatcat123's Avatar
Join Date: Aug 2010
Location: Wisconsin
Posts: 70
fatcat123 is an unknown quantity at this point
Quote:
Originally Posted by Crow View Post
It has focus by default. You know that it has focus when you can walk around using your arrow keys (or whatever you use to move).
The tool runs just fine, but when you activate it, you cannot scroll. It'll only stay on exit. When you create another staff tool, it'll scroll to the first and second one, but not the third. Also, the second one will keep on lighting up as if it's chosen.
Reply With Quote
  #33  
Old 08-03-2011, 05:08 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
Quote:
Originally Posted by fatcat123 View Post
The tool runs just fine, but when you activate it, you cannot scroll. It'll only stay on exit. When you create another staff tool, it'll scroll to the first and second one, but not the third. Also, the second one will keep on lighting up as if it's chosen.


Edit: Only thing I can think of is a broken toolEntries array. What does yours look like?

Last edited by Crow; 08-03-2011 at 06:52 PM..
Reply With Quote
  #34  
Old 08-03-2011, 06:35 PM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to all
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
So it works, but it doesn't work?
__________________
Reply With Quote
  #35  
Old 08-04-2011, 03:44 AM
fatcat123 fatcat123 is offline
Levels Artist
fatcat123's Avatar
Join Date: Aug 2010
Location: Wisconsin
Posts: 70
fatcat123 is an unknown quantity at this point
Log onto the server "Dev iKiDD". I added you it so you can see it for yourself.
Reply With Quote
  #36  
Old 08-04-2011, 11:35 AM
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
Quote:
Originally Posted by fatcat123 View Post
Log onto the server "Dev iKiDD". I added you it so you can see it for yourself.
Again, I suspect a broken array:

Quote:
Originally Posted by Crow View Post
Edit: Only thing I can think of is a broken toolEntries array. What does yours look like?
Show me yours, please.

Edit: Nevermind. I ****ed up one of the lines, not even sure how I managed to do that. Line 79:
PHP Code:
this.toolIdx %= this.toolEntries.size() - 1
Needs to be replaced with this instead:
PHP Code:
this.toolIdx %= this.toolEntries.size(); 


Edit²: Full code, fixed:
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
// staff tool stuff
  
this.toolOn false;
  
this.toolIdx 0;
  
  
// add new items here
  
this.toolEntries = {
    { 
"Exit""block.png" },
    { 
"Update Level""block.png" }
  };
}

// draw the staff tool
function DrawTool(create) {
  
// create image objects
  
if (create) {
    
// background
    
temp.GraalControl.width this.toolEntries.size() * 20;
    
temp.GetPolyRect(temp.xGraalControl.height 104this.toolEntries.size() * 4064);
    
with (findImg(200)) {
      
polygon temp.p;
      
red green blue 0;
      
alpha 0.75mode 1;
      
layer 5;
    }
    
    
// text
    
with (findImg(201)) {
      
temp.8;
      
GraalControl.height 58;
      
text thiso.toolEntries[thiso.toolIdx][0];
      
font "Arial"zoom 0.5;
      
red green blue 1;
      
layer 6;
    }
    
    
// icons
    
for (temp.0this.toolEntries.size(); i++) {
      
with (findImg(202 i)) {
        
temp.40;
        
GraalControl.height 96;
        
image thiso.toolEntries[i][1];
        
partx party 0;
        
partw parth 32;
        
alpha 0.5mode 1;
        
layer 6;
      }
    }
  }
  
  
// update text & alpha
  
findImg(201).text this.toolEntries[this.toolIdx][0];
  
  
temp.ci this.toolIdx// current tool
  
temp.li = (ci ci this.toolEntries.size() - 1); // last tool
  
findImg(202 ci).alpha 1;
  
findImg(202 li).alpha 0.5;
}

// reposition the staff tool when resizing Graal
function GraalControl.onResize(nwnh) {
  if (!
this.toolOn)
    return;
  
  
DrawTool(true);
}

// keyboard stuff
function GraalControl.onKeyDown(code) {
  if (
code == 69) { // E
    
if (!this.toolOn) {
      
this.toolOn  true;
      
this.toolIdx 0;
      
      
DrawTool(true);
    } else {
      
this.toolIdx++;
      
this.toolIdx %= this.toolEntries.size();

      
DrawTool(false);
    }
  } elseif (
code == 87) { // W
    
if (!this.toolOn)
      return;
    
    
temp.ReplaceText(this.toolEntries[this.toolIdx][0].upper(), " ""_");
    (
"StaffTool" temp.f)();
  }
}


// close staff tool
function StaffToolEXIT() {
  
this.toolOn false;
  
hideImgs(200201 this.toolEntries.size());
}

// update level
function StaffToolUPDATE_LEVEL() {
  
shared.chat("");
  
sleep(0.05);
  
shared.chat("update level");
}


// Dusty's, restyled
function ReplaceText(txtab) {
  if (
txt.pos(a) < 0)
    return 
txt;
  
  
temp.len a.length();
  
temp.txtpos txt.positions(a);
  
temp.newtxt txt.substring(0txtpos[0]);
  
  for (
temp.itemp.txtpos) {
    
temp.txt.substring(temp.len).pos(a);
    
temp.newtxt @= b;
    
temp.newtxt @= txt.substring(temp.lentemp.p);
  }
  
  return 
temp.newtxt;
}

// Crow's :3
function GetPolyRect(xywh)
  return { 
xywywhx}; 
If a mod would be so kind and edit the first post with this.

Last edited by Crow; 08-04-2011 at 11:46 AM..
Reply With Quote
  #37  
Old 08-04-2011, 05:05 PM
fatcat123 fatcat123 is offline
Levels Artist
fatcat123's Avatar
Join Date: Aug 2010
Location: Wisconsin
Posts: 70
fatcat123 is an unknown quantity at this point
Quote:
Originally Posted by Crow View Post
Again, I suspect a broken array:



Show me yours, please.

Edit: Nevermind. I ****ed up one of the lines, not even sure how I managed to do that. Line 79:
PHP Code:
this.toolIdx %= this.toolEntries.size() - 1
Needs to be replaced with this instead:
PHP Code:
this.toolIdx %= this.toolEntries.size(); 


Edit²: Full code, fixed:
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
// staff tool stuff
  
this.toolOn false;
  
this.toolIdx 0;
  
  
// add new items here
  
this.toolEntries = {
    { 
"Exit""block.png" },
    { 
"Update Level""block.png" }
  };
}

// draw the staff tool
function DrawTool(create) {
  
// create image objects
  
if (create) {
    
// background
    
temp.GraalControl.width this.toolEntries.size() * 20;
    
temp.GetPolyRect(temp.xGraalControl.height 104this.toolEntries.size() * 4064);
    
with (findImg(200)) {
      
polygon temp.p;
      
red green blue 0;
      
alpha 0.75mode 1;
      
layer 5;
    }
    
    
// text
    
with (findImg(201)) {
      
temp.8;
      
GraalControl.height 58;
      
text thiso.toolEntries[thiso.toolIdx][0];
      
font "Arial"zoom 0.5;
      
red green blue 1;
      
layer 6;
    }
    
    
// icons
    
for (temp.0this.toolEntries.size(); i++) {
      
with (findImg(202 i)) {
        
temp.40;
        
GraalControl.height 96;
        
image thiso.toolEntries[i][1];
        
partx party 0;
        
partw parth 32;
        
alpha 0.5mode 1;
        
layer 6;
      }
    }
  }
  
  
// update text & alpha
  
findImg(201).text this.toolEntries[this.toolIdx][0];
  
  
temp.ci this.toolIdx// current tool
  
temp.li = (ci ci this.toolEntries.size() - 1); // last tool
  
findImg(202 ci).alpha 1;
  
findImg(202 li).alpha 0.5;
}

// reposition the staff tool when resizing Graal
function GraalControl.onResize(nwnh) {
  if (!
this.toolOn)
    return;
  
  
DrawTool(true);
}

// keyboard stuff
function GraalControl.onKeyDown(code) {
  if (
code == 69) { // E
    
if (!this.toolOn) {
      
this.toolOn  true;
      
this.toolIdx 0;
      
      
DrawTool(true);
    } else {
      
this.toolIdx++;
      
this.toolIdx %= this.toolEntries.size();

      
DrawTool(false);
    }
  } elseif (
code == 87) { // W
    
if (!this.toolOn)
      return;
    
    
temp.ReplaceText(this.toolEntries[this.toolIdx][0].upper(), " ""_");
    (
"StaffTool" temp.f)();
  }
}


// close staff tool
function StaffToolEXIT() {
  
this.toolOn false;
  
hideImgs(200201 this.toolEntries.size());
}

// update level
function StaffToolUPDATE_LEVEL() {
  
shared.chat("");
  
sleep(0.05);
  
shared.chat("update level");
}


// Dusty's, restyled
function ReplaceText(txtab) {
  if (
txt.pos(a) < 0)
    return 
txt;
  
  
temp.len a.length();
  
temp.txtpos txt.positions(a);
  
temp.newtxt txt.substring(0txtpos[0]);
  
  for (
temp.itemp.txtpos) {
    
temp.txt.substring(temp.len).pos(a);
    
temp.newtxt @= b;
    
temp.newtxt @= txt.substring(temp.lentemp.p);
  }
  
  return 
temp.newtxt;
}

// Crow's :3
function GetPolyRect(xywh)
  return { 
xywywhx}; 
If a mod would be so kind and edit the first post with this.
The tool won't even work now =S
Never mind. You forgot to remove the space by //@CLIENTSIDE

Last edited by fatcat123; 08-04-2011 at 05:06 PM.. Reason: Ohhh CLIENTSIDE
Reply With Quote
  #38  
Old 08-04-2011, 05:29 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by fatcat123 View Post
The tool won't even work now =S
Never mind. You forgot to remove the space by //@CLIENTSIDE
No he didn't. The forums add spaces after every line in scripts.
__________________
Reply With Quote
  #39  
Old 08-04-2011, 05:39 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
Quote:
Originally Posted by cbk1994 View Post
No he didn't. The forums add spaces after every line in scripts.
Aye.
Reply With Quote
  #40  
Old 08-10-2011, 11:56 AM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
I fixed that problem where is misses out the last staff tool and also added a functional description system in there too. I thought it was a nice touch. Here is is.
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
// staff tool stuff 
  
this.toolOn false;
  
this.toolIdx 0;
  
// add new items here 
  
this.toolEntries = {
    {
"Update Level""bush.png""Updates the current level."},
  };
}
// draw the staff tool 

function DrawTool(create) {
  
// create image objects 
  
if (create) {
    
// background 
    
temp.GraalControl.width this.toolEntries.size() * 20;
    
temp.GetPolyRect(temp.xGraalControl.height 119this.toolEntries.size() * 4089);
    
with(findImg(200)) {
      
polygon temp.p;
      
red green blue 1;
      
alpha 0.75;
      
mode 1;
      
border true;
      
layer 5;
    }
    
// text 
    
with(findImg(201)) {
      
temp.8;
      
GraalControl.height 58;
      
text thiso.toolEntries[thiso.toolIdx][2];
      
font "Arial";
      
zoom 0.5;
      
red green blue 0;
      
layer 6;
      
style "b";
    }
    
//desc
    
with(findImg(212)) {
      
temp.8;
      
GraalControl.height 48;
      
text thiso.toolEntries[thiso.toolIdx][3];
      
font "Arial";
      
zoom 0.5;
      
red green blue 0;
      
layer 6;
      
style "b";
    }
    
//title
    
with(findImg(213)) {
      
temp.70;
      
GraalControl.height 115;
      
text "Staff Panel - " servername;
      
font "Arial";
      
zoom 0.5;
      
red green blue 0;
      
layer 6;
      
style "b";
      if (
mouseover) {
        
say2 lol;
      }
    }
    
// icons 
    
for (temp.0this.toolEntries.size(); i++) {
      
with(findImg(202 i)) {
        
temp.40;
        
GraalControl.height 96;
        
image thiso.toolEntries[i][1];
        
partx party 0;
        
partw parth 32;
        
alpha 0.5;
        
mode 1;
        
layer 6;
      }
    }
  }
  
// update text & alpha 
  
findImg(201).text this.toolEntries[this.toolIdx][0];
  
findimg(212).text this.toolEntries[this.toolIdx][2];
  
temp.ci this.toolIdx// current tool 
  
temp.li = (ci ci this.toolEntries.size() - 1); // last tool 
  
findImg(202 ci).alpha 1;
  
findImg(202 li).alpha 0.5;
}
// reposition the staff tool when resizing Graal 

function GraalControl.onResize(nwnh) {
  if (!
this.toolOn) return;
  
DrawTool(true);
}
// keyboard stuff 

function GraalControl.onKeyDown(code) {
  if (
code == 219) { // [
    
if (!this.toolOn) {
      
this.toolOn true;
      
this.toolIdx 0;
      
DrawTool(true);
    } else {
      
this.toolIdx++;
      
this.toolIdx %= this.toolEntries.size();
      
DrawTool(false);
    }
  }
  elseif(
code == 221) { // ]
    
if (!this.toolOn) return;
    
temp.ReplaceText(this.toolEntries[this.toolIdx][0].upper(), " ""_");
    (
"StaffTool" temp.f)();
  }
}
// update level 

function StaffToolUPDATE_LEVEL() {
  
shared.chat("");
  
sleep(0.05);
  
shared.chat("update level");
}
// Dusty's, restyled 

function ReplaceText(txtab) {
  if (
txt.pos(a) < 0) return txt;
  
temp.len a.length();
  
temp.txtpos txt.positions(a);
  
temp.newtxt txt.substring(0txtpos[0]);
  for (
temp.itemp.txtpos) {
    
temp.txt.substring(temp.len).pos(a);
    
temp.newtxt @= b;
    
temp.newtxt @= txt.substring(temp.lentemp.p);
  }
  return 
temp.newtxt;
}
// Crow's :3 

function GetPolyRect(xywh)
return {
  
xywywhxh
};
  function 
onPlayerDies() { 
  if (
this.toolOn
    
DrawTool(true); 

__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 12:35 AM.


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