Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Auto Menu Class (https://forums.graalonline.com/forums/showthread.php?t=39851)

Era_Admin1 10-31-2002 02:48 PM

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;
}


sage_chaozu 11-01-2002 12:48 AM

Hey I used that
 
I used that on Era for the *secret project name*.. lol

Maybe a part for text not selectable would be good to add.

Psycho_Goldfish42 11-01-2002 02:18 AM

testing it
 
If only I "could be bothered" to see what it does...

Com013 11-01-2002 11:38 PM

Re: Auto Menu Class
 
Quote:

Originally posted by Era_Admin1
NPC Code:

/* Strings
*
* - #s this.style
* - #sA this.menuOptionsthis.maxIndex-i,1,1,1,1;


I think there are no this. strings clientside. I guess local. strings would be the best in this situation.

R0bin 11-02-2002 06:46 AM

Re: Re: Auto Menu Class
 
Quote:

Originally posted by Com013

I think there are no this. strings clientside. I guess local. strings would be the best in this situation.


God i hope you are j/king.

Com013 11-02-2002 10:19 PM

Re: Re: Re: Auto Menu Class
 
Quote:

Originally posted by R0bin



God i hope you are j/king.

No, I'm not joking. I just don't know whether what I wrote is correct. As far as I know this. strings are clientside apearing in the normal flag list, so every NPC can access them.

Falcor 11-02-2002 10:33 PM

There are, on servers w/ npcs server.


All times are GMT +2. The time now is 09:20 PM.

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