Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-16-2006, 05:35 AM
Warcaptain Warcaptain is offline
Banned
Warcaptain's Avatar
Join Date: Jun 2001
Location: Virginia, USA
Posts: 2,086
Warcaptain is on a distinguished road
Send a message via ICQ to Warcaptain Send a message via AIM to Warcaptain Send a message via Yahoo to Warcaptain
ShowSignWindow

I made a little script to show the same type of window used in signs and Q-Menu.

It uses stretchx/stretchy for the sides and uses showpoly for the center so it uses a minimal ammount of images. (9 total) This is good because before we had to have hundreds of images.

It also allows you to draw as many sign windows as you want (so long as theres not a limit to image indexes.. which I do not think there is)

Notes:
  • temp.letters (the last parameter that sets what letters file to use) does not have to be set, if its blank it will set it to the default player.letters that has been set in-game.
  • temp.vis does not have to be set either, by default it will draw the box on layer 4
  • included is the function HideSignBox(index) to hide the signbox with said index. DrawSignBox() returns the index of the sign it makes.. so you would do var = DrawSignBox(0,0,100,100); and var would be equal to the value of the drawn box.

Questions? Comments? Opinions?

NPC Code:

function DrawSignBox(temp.x,temp.y,temp.w,temp.h,temp.lette rs,temp.vis){
this.signboxes++;
if (temp.letters=="") temp.letters=player.letters;
if (temp.x<0) temp.x=0;
if (temp.y<0) temp.y=0;
if (temp.w<32) temp.w=32;
if (temp.h<64) temp.h=64;
if (temp.x+temp.w>screenwidth) temp.w=screenwidth;
if (temp.y+temp.h>screenheight) temp.w=screenheight;
if (temp.vis<4) temp.vis=4;
temp.id=(this.signboxes*9);
showimg(1000+temp.id,temp.letters,temp.x,temp.y);
changeimgpart(1000+temp.id,0,192,16,32);
changeimgvis(1000+temp.id,temp.vis);
temp.id++;
showimg(1000+temp.id,temp.letters,temp.x-8+(temp.w/2),temp.y);
changeimgvis(1000+temp.id,temp.vis);
changeimgpart(1000+temp.id,64,192,16,32);
findImg(1000+temp.id).stretchx=(temp.w-32)/16;
temp.id++;
showimg(1000+temp.id,temp.letters,temp.x+temp.w-16,temp.y);
changeimgpart(1000+temp.id,16,192,16,32);
changeimgvis(1000+temp.id,temp.vis);
temp.id++;
showimg(1000+temp.id,temp.letters,temp.x,temp.y+te mp.h-32);
changeimgpart(1000+temp.id,32,192,16,32);
changeimgvis(1000+temp.id,temp.vis);
temp.id++;
showimg(1000+temp.id,temp.letters,temp.x-8+(temp.w/2),temp.y+temp.h-32);
changeimgvis(1000+temp.id,temp.vis);
changeimgpart(1000+temp.id,80,192,16,32);
findImg(1000+temp.id).stretchx=(temp.w-32)/16;
temp.id++;
showimg(1000+temp.id,temp.letters,temp.x+temp.w-16,temp.y+temp.h-32);
changeimgpart(1000+temp.id,48,192,16,32);
changeimgvis(1000+temp.id,temp.vis);
temp.id++;
showimg(1000+temp.id,temp.letters,temp.x,temp.y-16+(temp.h/2));
changeimgpart(1000+temp.id,96,192,16,32);
changeimgvis(1000+temp.id,temp.vis);
findImg(1000+temp.id).stretchy=(temp.h-32)/32;
temp.id++;
showimg(1000+temp.id,temp.letters,temp.x+temp.w-16,temp.y-16+(temp.h/2));
changeimgpart(1000+temp.id,112,192,16,32);
changeimgvis(1000+temp.id,temp.vis);
findImg(1000+temp.id).stretchy=(temp.h-32)/32;
temp.id++;
showpoly(1000+temp.id,{temp.x+16,temp.y+32,temp.x+ 16+(temp.w-32),temp.y+32,temp.x+16+(temp.w-32),temp.y+32+(temp.h-64),temp.x+16,temp.y+32+(temp.h-64)});
changeimgvis(1000+temp.id,temp.vis);
temp.colors=getimgpixel(temp.letters,72,222);
changeimgcolors(1000+temp.id,temp.colors[0],temp.colors[1],temp.colors[2],1);
return this.signboxes;
}

function HideSignBox(temp.i)
hideimgs(1000+(temp.i*9),1009+(temp.i*9));


Last edited by Warcaptain; 05-16-2006 at 06:20 AM..
Reply With Quote
  #2  
Old 05-16-2006, 08:40 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
Don't put temp. in the function argument declaration.
Reply With Quote
  #3  
Old 05-16-2006, 09:02 AM
Warcaptain Warcaptain is offline
Banned
Warcaptain's Avatar
Join Date: Jun 2001
Location: Virginia, USA
Posts: 2,086
Warcaptain is on a distinguished road
Send a message via ICQ to Warcaptain Send a message via AIM to Warcaptain Send a message via Yahoo to Warcaptain
Why? I thought it would be better, so that they were only used in that function and wouldnt affect other things.
Reply With Quote
  #4  
Old 05-16-2006, 09:25 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Warcaptain
Why? I thought it would be better, so that they were only used in that function and wouldnt affect other things.
No don't do that.

As Rick said, you don't need temp. in the function argument declaration. The temp. prefix is automatically added.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
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 07:05 AM.


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