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 08-26-2011, 11: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
Showpoly Explain

I really want to lean towards using images and shapes in my scripts. I thought a good place to start was showpoly. I searched the graal wiki and I didn't find anything that can help me. Maybe you guys can?
__________________
Reply With Quote
  #2  
Old 08-26-2011, 11:54 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
There's not a lot to it:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
setTimer(0.05);
}

function 
onTimeout() {
  
showPolygon();
  
setTimer(0.05);
}

// Draw square on mousex and mousey position.
function showPolygon() {
  
// using showpoly
  
showpoly(200, {
     
mousexmousey,
     
mousex 2mousey,
     
mousex 2mousey 2,
     
mousexmousey 2
  
});

  
// Same as doing
  
with (findimg(200)) {
    
polygon = {
     
mousexmousey,
     
mousex 2mousey,
     
mousex 2mousey 2,
     
mousexmousey 2
    
});
  }

The polygon array is just a collection of x, y points listed in order. I.e: {x1, y1, x2, y2, x3, y3, x4, y4};

You can use as many points as you want. I think you need at least 3 sets of x,y points though. Used to be able to draw lines with just two but i believe that changed with V5.

Other Reading:
http://gscript.graal.net/showpoly
__________________
Quote:
Reply With Quote
  #3  
Old 08-27-2011, 12:03 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 fowlplay4 View Post
I think you need at least 3 sets of x,y points though. Used to be able to draw lines with just two but i believe that changed with V5.
Quite sure I only got two somewhere..
__________________
Reply With Quote
  #4  
Old 08-27-2011, 12:05 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
Takes some fiddling to get the shape you want.
__________________
Reply With Quote
  #5  
Old 08-27-2011, 12:17 AM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is a jewel in the roughTricxta is a jewel in the rough
Not really,what you do is you plot the outline of the points you want:
Square example:
PHP Code:
temp.square={20,20,40,20,40,40,20,40};
showpoly (300temp.square); 
And this is how I drew it in order of verticies


Another example would be drawing a circle:
PHP Code:
temp.radius=4;
for (
temp.i=0;temp.i<(pi*2);temp.i++)temp.circle.add((cos(temp.i)*temp.radius+30),(sin(temp.i)*temp.radius+30));
showpoly (300temp.circle); 
So basically summing up, you draw the outline and the showpoly will fill in the middle. And basically what I've done here in both examples is define an array outside the showpoly statement rather then within it. Hope this helped.
Reply With Quote
  #6  
Old 08-27-2011, 01:52 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
So it is
PHP Code:
showpoly(point1x,point1y,point2x,point2y,point3x,point3y,point4x,point4y); 
Right?
__________________
Reply With Quote
  #7  
Old 08-27-2011, 02:08 AM
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 Emera View Post
So it is
PHP Code:
showpoly(point1x,point1y,point2x,point2y,point3x,point3y,point4x,point4y); 
Right?
No. See the wiki page linked in Jer's post above.
__________________
Reply With Quote
  #8  
Old 08-27-2011, 03:22 AM
oo_jazz_oo oo_jazz_oo is offline
Jazz teh Awesome
oo_jazz_oo's Avatar
Join Date: Jul 2006
Location: California
Posts: 596
oo_jazz_oo is a jewel in the roughoo_jazz_oo is a jewel in the rough
Send a message via MSN to oo_jazz_oo
Quote:
Originally Posted by Crow View Post
Quite sure I only got two somewhere..
You can use only two. :P
v5 and v6 works just fine using 2 x/y coords.
__________________

Reply With Quote
  #9  
Old 08-27-2011, 05:13 AM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of light
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
You need {}. It's an array.

showpoly(index, {x1,y1,x2,y2,...,xn,yn});

That's why Tricxta used temp.square to list the points first.

You forgot the index, too.
__________________
Reply With Quote
  #10  
Old 08-27-2011, 07:28 AM
gaben gaben is offline
uhh no
gaben's Avatar
Join Date: Aug 2011
Posts: 47
gaben is an unknown quantity at this point
Polygons also support RGBA coloring, which is nice I guess.

PHP Code:
green 1;
blue 0;
red 0;
alpha 1
Would output a 'green' polygon. Not sure if you can define/initialize color vars outside of the polygon index though.

Last edited by gaben; 08-27-2011 at 08:40 AM..
Reply With Quote
  #11  
Old 08-27-2011, 07:52 AM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is a jewel in the roughTricxta is a jewel in the rough
You should be able too.... just use findimg(index).
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 01:46 AM.


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