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 08-18-2009, 09:18 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Anchoring Knockoff.

Trying to emulate the anchoring support I asked for.

It appears to be hitting the proper case in switch statement, yet does not set x and y accordingly.

Adding debug checks such as "player.chat = this.ANCHOR_TOP[0] - (GControl.width / 2);" give me the position I want, but the x/y always ends up being 0.

edit: also not complete, once I get this issue out of the way I'll add x-y offsets as well.

PHP Code:
function onCreated()
{
findplayer("mark sir link").addweapon(this.name);
}

//#CLIENTSIDE
function onCreated()
{
  
this.ANCHOR_TOP = {screenwidth/20}; //12 O'Clock
  
this.ANCHOR_TOPRIGHT = {screenwidth0}; //between 1-2 O'Clock
  
this.ANCHOR_RIGHT = {screenwidthscreenheight/2}; //3 O'Clock
  
this.ANCHOR_BOTTOMRIGHT = {screenwidthscreenheight}; //between 4-5 O'Clock
  
this.ANCHOR_BOTTOM = {screenwidth/2screenheight}; //6 O'Clock
  
this.ANCHOR_BOTTOMLEFT = {0screenheight}; //between 7-8 O'Clock
  
this.ANCHOR_LEFT = {0screenheight/2}; //9 O'Clock
  
this.ANCHOR_TOPLEFT = {00}; //between 10-11 O'Clock
  
  
this.ANCHORS = {ANCHOR_TOPANCHOR_TOPRIGHTANCHOR_RIGHTANCHOR_BOTTOMRIGHTANCHOR_BOTTOMANCHOR_BOTTOMLEFTANCHOR_LEFTANCHOR_TOPLEFT};  

  new 
GuiWindowCtrl("Test_Window") {
  
profile "GuiBlueWindowProfile";
  
this.anchor "TOP";
  
width 160;
  
height 80;
  
text "Window";
  
canmove true;
  
editing true;
  
canclose true;
  
destroyonhide true;
}
  
anchorPosition(Test_Window);

}


function 
anchorPosition(GControl)
{
  
with(GControl)
  {
    switch (
this.anchor)
    {
    case 
"TOP":
      
text thiso.test;
      
thiso.ANCHOR_TOP[0] - (width 2);
      
thiso.ANCHOR_TOP[1];
      break;
    case 
"TOPRIGHT":
      
thiso.ANCHOR_TOPRIGHT[0] - width;
      
thiso.ANCHOR_TOPRIGHT[1];
      break;
    case 
"RIGHT":
      
thiso.ANCHOR_RIGHT[0] - width;
      
thiso.ANCHOR_RIGHT[1] - (height 2);
      break;
    case 
"BOTTOMRIGHT":
      
thiso.ANCHOR_BOTTOMRIGHT[0] - width;
      
thiso.ANCHOR_BOTTOMRIGHT[1] - height;
      break;
    case 
"BOTTOM":
      
thiso.ANCHOR_BOTTOM[0] - (width 2);
      
thiso.ANCHOR_BOTTOM[1] - height;
      break;
    case 
"BOTTOMLEFT":
      
thiso.ANCHOR_BOTTOMLEFT[0];
      
thiso.ANCHOR_BOTTOMLEFT[1]; - height;
      break;
    case 
"LEFT":
      
thiso.ANCHOR_LEFT[0];
      
thiso.ANCHOR_LEFT[1] - (height 2);
      break;
    case 
"TOPLEFT":
      
thiso.ANCHOR_TOPLEFT[0];
      
thiso.ANCHOR_TOPLEFT[1];
      break;
    default:
      
0;
      
0;
    }
  }

Reply With Quote
  #2  
Old 08-18-2009, 09:21 AM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
picture?
image?
screenshot!?
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #3  
Old 08-18-2009, 09:23 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
I fell through every case like a *****. Not scripting in awhile has taken it's toll.

I edited the code with the fixed version.
Reply With Quote
  #4  
Old 08-18-2009, 06:31 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Just a comment on the code, you should either use const/enum, or not use the all-caps convention associated with constants when they aren't.

Although, const/enum can be problematic since they just replace the variables at compile-time, so if you do anything dynamic with them it'll fail.

An alternative route would be to use a TStaticVar:
PHP Code:
this.anchors = new TStaticVar();
this.anchors.top = {screenwidth/20};
this.anchors.topRight = {screenwidth0}; 
Glad you got it working though.
Reply With Quote
  #5  
Old 08-20-2009, 06:11 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
Your anchors will need to update if the player re-sizes the window, so why bother with those this.anchor.var's at all.

The default needs a break too.
__________________
Quote:
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 08:55 PM.


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