Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-31-2002, 02:48 PM
Era_Admin1 Era_Admin1 is offline
Registered User
Join Date: Oct 2002
Location: Melbourne, Victoria, Australia
Posts: 23
Era_Admin1 is on a distinguished road
Send a message via ICQ to Era_Admin1 Send a message via AIM to Era_Admin1
Auto Menu Class

Here's a little menu class I made a long time ago...it's useful in those cases where you just "can't be bothered". The instructions are commented inside the code.
NPC Code:

/* Strings, Variables and Arrays needed to be set: *
* - #v this.maxIndex: The lowest index so the images in this class don't overtake *
* the images from the calling npc. *
* - #s this.style: The style of the text. e.g. b - bold, c - centre etc... *
* - #sA this.menuOptions: String array of what you want the player to select from *
* - #v this.menux: x pos of menu items *
* - #v this.menuy: y pos of menu items *
* - *boolean* this.menuOpen: So this class knows when to show the menu items. *
* *
* To detect if a player has clicked on a menu item add this to the calling npc: *
* if (strequals(#s(this.select),ITEMNAME)) { <dostuff> } *
* Be sure to tell this class that afterwards no item is selected: *
* setstring this.select,; *
* Add that after the last command in the menu click detection. */
//#CLIENTSIDE
if (created) timeout = 0.05;
if (timeout) {
if (this.menuOpen == true) {
for (i=0;i<sarraylen(this.menuOptions);i++) {
showimg this.maxIndex-i,@verdana@/*delph*/#s(this.style)@#I(this.menuOptions,i),this.menux,t his.menuy + (i*15);
changeimgzoom this.maxIndex-i,0.7;
changeimgvis this.maxIndex-i,4;
if (this.maxLen < strlen(#I(this.menuOptions,i))) this.maxLen = strlen(#I(this.menuOptions,i));
if (mousescreenx in |this.menux,this.menux + this.maxLen*7| &&
mousescreeny in |this.menuy + (i*15),this.menuy + (i*15) + 15|) {
if (mousebuttons == 1 && this.mouseDown == false) {
setstring this.select,#I(this.menuOptions,i);
}
changeimgcolors this.maxIndex-i,1,1,0,1;
} else changeimgcolors this.maxIndex-i,1,1,1,1;
}
if (mousebuttons == 1) this.mouseDown = true;
else this.mouseDown = false;
} else for (i=0;i<sarraylen(this.menuOptions);i++) hideimg this.maxIndex-i;
timeout = 0.05;
}

__________________
Reply With Quote
 


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 09:14 AM.


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