Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Some Gui problems (https://forums.graalonline.com/forums/showthread.php?t=76687)

coreys 09-08-2007 06:16 AM

Some Gui problems
 
Well, I'm setting up an Inventory on Maloria, and there's obviously an area there with the slots for the item icons. It's a 4x6 grid, basically, and there' up/down page buttons. So I have this function to show the items for the page:
PHP Code:

function loadPage() {
  
this.itemssize clientr.items.size()-((this.page-1)*24);
  
temp.base = {21853};
  
temp.1;
  
with (Inv) {
    for (
h=0h<6h++) {
      for (
w=0w<4w++) {
        
with (new GuiShowImgCtrl("ItemIcon_" temp.i)) {
          
resize(temp.base[0]+(32*w),temp.base[1]+(32*h),32,32);
          
image "block.png";
          
Inv.addControl(this);
        }
        
player.chat h;
        if (
temp.<= this.itemssize)
          
temp.i++;
        else
          break;
      }
    }
  }


But, for whatever reason, when it gets the point where it's setting player.chat to h, h equals 5...that means it seems to be waiting until the end of the first for loop before going on the the next for loop. o.0

Help. :<

Inverness 09-08-2007 06:26 AM

h and w should both be temp variables.

And use the F2 window (echo) rather than player.chat. Because most likely all the loops are being completed so fast player.chat only shows the last result.

coreys 09-08-2007 06:29 AM

Okay, I did change them to that, but I also figured out why that's happening. It has to do with the chat system on Maloria, so there's nothing wrong with the for loops. However, the icons are showing in...odd places.
Here's what I have now:
PHP Code:

function loadPage() {
  for (
a=1a<25a++) {
    
makevar("ItemIcon_" a).destroy();
  }
  
this.itemssize clientr.items.size()-((this.page-1)*24);
  
temp.base = {21853};
  
temp.1;
  
temp.height temp.width 0;
  for (
temp.height=0temp.height<6temp.height++) {
    for (
temp.width=0temp.width<4temp.width++) {
      
with (new GuiShowImgCtrl("ItemIcon_" temp.i)) {
        
resize(temp.base[0]+(32*temp.width),temp.base[1]+(32*temp.height),32,32);
        
image "block.png";
        
Inv.addControl(this);
      }
      if (
temp.this.itemssize)
        
temp.i++;
      else
        break;
    }
  }


There's an icon in the top left corner and the the bottom left corner. o.0

zokemon 09-08-2007 07:11 AM

Quote:

Originally Posted by coreys (Post 1346455)
Okay, I did change them to that, but I also figured out why that's happening. It has to do with the chat system on Maloria, so there's nothing wrong with the for loops. However, the icons are showing in...odd places.
Here's what I have now:
PHP Code:

function loadPage() {
  for (
a=1a<25a++) {
    
makevar("ItemIcon_" a).destroy();
  }
  
this.itemssize clientr.items.size()-((this.page-1)*24);
  
temp.base = {21853};
  
temp.1;
  
temp.height temp.width 0;
  for (
temp.height=0temp.height<6temp.height++) {
    for (
temp.width=0temp.width<4temp.width++) {
      
with (new GuiShowImgCtrl("ItemIcon_" temp.i)) {
        
resize(temp.base[0]+(32*temp.width),temp.base[1]+(32*temp.height),32,32);
        
image "block.png";
        
Inv.addControl(this);
      }
      if (
temp.this.itemssize)
        
temp.i++;
      else
        break;
    }
  }


There's an icon in the top left corner and the the bottom left corner. o.0

Huh? How would the chat system be doing it?

coreys 09-08-2007 05:01 PM

Quote:

Originally Posted by zokemon (Post 1346461)
Huh? How would the chat system be doing it?

Oh, no it's just that the chat is setting so fast that your chat system doesn't actually show until the number 5.

Chompy 09-08-2007 05:49 PM

The icon coords, are you taking them into consideration from the inventory itself?
Like before the loop get the x and y of the inventory object etc..

coreys 09-08-2007 06:01 PM

The loop is determining the coordinates though o.0

Googi 09-08-2007 08:01 PM

Quote:

Originally Posted by Chompy (Post 1346536)
The icon coords, are you taking them into consideration from the inventory itself?
Like before the loop get the x and y of the inventory object etc..

I think that's what temp.base is for.

Chompy 09-08-2007 10:18 PM

Hmm, then my guess is, you're not giving them a coordinate in the Inventory control? I'm not used to use the inventory itself as an gui control.. I just use an image and then a for() loop and place them on the image itself..

and I use another method for placing them (Thanks Contiga for that one :p)
PHP Code:

+ (offsetx*index§iconshorizontal);
+ (offsety*int(index/iconsvertical)); 

for example for 6x6 icons I do:
PHP Code:

this.ix inventory.x;
this.iy inventory.y;
for(
temp.036++) {
  new 
GuiBitmapButtonCtrl("button_" i) {
    
thiso.ix 13.5 + (33*(i§6));
    
thiso.iy 165 + (33*int(i/6));
          
    
this.image "bomb.png";
          
    
normalbitmap this.image;
    
mouseoverbitmap this.image;
    
pressedbitmap this.image;

    
width 32;
    
height 32;
          
    
thiso.catchevent(this"onMouseDown""onItemPressed");
  }


PS: In the scripts I had to write § instead of o/o (percent symbol), stupid bad request **** =/

coreys 09-08-2007 10:39 PM

Thanks Chompy...well now I'm having problems with dragging the icon around. Here's what I have:
PHP Code:

function loadPage() {
  for (
a=1a<25a++) {
    
makevar("ItemIcon_" a).destroy();
  }
  
this.itemssize clientr.items.size()-((this.page-1)*24);
  
temp.base = {218+Inv.x53+Inv.y};
  for (
temp.i=0temp.i<this.itemssizetemp.i++) {
    new 
GuiShowImgCtrl("ItemIcon_" temp.i) {
      
temp.base[0] + (32*(temp.i%4));
      
temp.base[1] + (32*int(temp.i/6));
      
image "bcalarmclock.png";
      
this.origin = {this.xthis.y};
      
thiso.catchevent(this.name"onMouseDown""linkItem");
      
thiso.catchevent(this.name"onRightMouseDown""onItemRightClicked");
      
thiso.catchevent(this.name"onMouseUp""unlinkItem");
      
thiso.catchevent(this.name"onMouseDragged""moveItem");
      
InventoryGUI.addControl(this);
    }
  }
}
function 
linkItem(iname) {
  
makevar(iname).zoom 1.2;
  
makevar(iname).width makevar(iname).width*1.2;
  
makevar(iname).height makevar(iname).height*1.2;
  
this.linkeditem makevar(iname);
}
function 
unlinkItem() {
  if (
this.linkeditem != NULL) {
    for (
i=0i<this.slots.size(); i++) {
      if (
this.linkeditem.x in |this.slots[i][0]+Inv.xthis.slots[i][2]+Inv.x| && this.linkeditem.y in |this.slots[i][1]+Inv.ythis.slots[i][3]+Inv.y|) {
        if (
this.slots[i][5] == NULLequipItem(this.slots[i][4], this.linkeditem.name);
        else {
          
unequipItem(this.slots[i][4], this.slots[i][5]);
          
equipItem(this.slots[i][4], this.linkeditem.name);
        }
        
this.slots[i][5] = this.linkeditem.name;
      }
    }
    
with (this.linkeditem) {
      
zoom 1;
      
extent = {32,32};
      
position this.origin;
    }
    
this.linkeditem NULL;
  }
}
function 
moveItem() {
  if (
this.linkeditem != NULL)
    
this.linkeditem.position = {params[2], params[3]};


Which works, except...for some reason I can't drag the icon to the left. o.0 Which is kind of a problem, because the main reason I'm doing this is to drag it to the equip slots, which is to the left of the icons.

By the way, Chompy, where the hell have you been? You haven't been on Maloria in forever. D:

Chompy 09-08-2007 11:04 PM

Quote:

Originally Posted by coreys (Post 1346641)
By the way, Chompy, where the hell have you been? You haven't been on Maloria in forever. D:

Internet problems...
I'm switching to a faster modem tomorrow, because our current one just plainly sucks.. I think my current modem is run by teletubies =/

zokemon 09-09-2007 01:53 AM

Quote:

Originally Posted by coreys (Post 1346519)
Oh, no it's just that the chat is setting so fast that your chat system doesn't actually show until the number 5.

That's not the chat system, normal chat is just like that o_o. Everything in Graal only updates every 0.05 seconds you know.

coreys 09-09-2007 02:32 AM

Quote:

Originally Posted by zokemon (Post 1346682)
That's not the chat system, normal chat is just like that o_o. Everything in Graal only updates every 0.05 seconds you know.

That's what I meant, jerk ;(

And Zeo, you said you fixed it when you were on RC, but you didn't D:

Googi 09-09-2007 05:31 AM

Quote:

Originally Posted by coreys (Post 1346641)
PHP Code:

this.linkeditem.position = {params[2], params[3]}; 


I'm not sure where the values for the params[] array are supposed to be coming from here...

Chompy 09-09-2007 03:14 PM

Quote:

Originally Posted by coreys (Post 1346693)
And Zeo, you said you fixed it when you were on RC, but you didn't D:

I fixed the dragging..
It worked for me atleast xD

coreys 09-09-2007 04:03 PM

Quote:

Originally Posted by Googi (Post 1346730)
I'm not sure where the values for the params[] array are supposed to be coming from here...

From the event the catchevent() is catching. It worked.

And Chompy wtf, it works the same as before for me...I already tried exactly what you did, which was use mousescreenx and mousescreeny and it didn't change anything...D:

Googi 09-09-2007 11:26 PM

Quote:

Originally Posted by coreys (Post 1346789)
From the event the catchevent() is catching. It worked.

But I thought the params[] array for onMouseDragged should only have three values - the modifier key, mousex and mousey.

coreys 09-10-2007 02:50 PM

Quote:

Originally Posted by Googi (Post 1346874)
But I thought the params[] array for onMouseDragged should only have three values - the modifier key, mousex and mousey.

But, because I used catchevent(), the first param is the control name
Anyways, I signed back on and it suddenly works, so wtf o.o

coreys 09-27-2007 02:13 AM

Quote:

Originally Posted by Chompy (Post 1346635)
Hmm, then my guess is, you're not giving them a coordinate in the Inventory control? I'm not used to use the inventory itself as an gui control.. I just use an image and then a for() loop and place them on the image itself..

and I use another method for placing them (Thanks Contiga for that one :p)
PHP Code:

+ (offsetx*index§iconshorizontal);
+ (offsety*int(index/iconsvertical)); 

for example for 6x6 icons I do:
PHP Code:

this.ix inventory.x;
this.iy inventory.y;
for(
temp.036++) {
  new 
GuiBitmapButtonCtrl("button_" i) {
    
thiso.ix 13.5 + (33*(i§6));
    
thiso.iy 165 + (33*int(i/6));
          
    
this.image "bomb.png";
          
    
normalbitmap this.image;
    
mouseoverbitmap this.image;
    
pressedbitmap this.image;

    
width 32;
    
height 32;
          
    
thiso.catchevent(this"onMouseDown""onItemPressed");
  }


PS: In the scripts I had to write § instead of o/o (percent symbol), stupid bad request **** =/

Sorry to revive this thread, but...that actually doesn't work, Chompy. =/
It works only for an even grid (like your 6x6 example)
So i changed the y to:
PHP Code:

temp.base[1] + (32*int(roundTo((temp.id/6),1.1))); 

roundTo() being Zero's roundTo() function.
PHP Code:

public function roundTo(valplace) {
  return 
int(val/place 0.5)*place;


But, that only works for TWO lines...(on a 4x6 grid)...so now I can't figure out how to do it.


All times are GMT +2. The time now is 10:08 PM.

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