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 09-08-2007, 06:16 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
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. :<
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #2  
Old 09-08-2007, 06:26 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
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.
__________________
Reply With Quote
  #3  
Old 09-08-2007, 06:29 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
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
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #4  
Old 09-08-2007, 07:11 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by coreys View Post
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?
__________________
Do it with a DON!
Reply With Quote
  #5  
Old 09-08-2007, 05:01 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by zokemon View Post
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.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #6  
Old 09-08-2007, 05:49 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
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..
__________________
Reply With Quote
  #7  
Old 09-08-2007, 06:01 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
The loop is determining the coordinates though o.0
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #8  
Old 09-08-2007, 08:01 PM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Quote:
Originally Posted by Chompy View Post
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.
__________________
Reply With Quote
  #9  
Old 09-08-2007, 10:18 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
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 )
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 **** =/
Reply With Quote
  #10  
Old 09-08-2007, 10:39 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
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:
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #11  
Old 09-08-2007, 11:04 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by coreys View Post
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 =/
__________________
Reply With Quote
  #12  
Old 09-09-2007, 01:53 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by coreys View Post
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.
__________________
Do it with a DON!

Last edited by zokemon; 09-09-2007 at 02:04 AM..
Reply With Quote
  #13  
Old 09-09-2007, 02:32 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by zokemon View Post
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:
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #14  
Old 09-09-2007, 05:31 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Quote:
Originally Posted by coreys View Post
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...
__________________
Reply With Quote
  #15  
Old 09-09-2007, 03:14 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by coreys View Post
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
__________________
Reply With Quote
  #16  
Old 09-09-2007, 04:03 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by Googi View Post
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:
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #17  
Old 09-09-2007, 11:26 PM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Quote:
Originally Posted by coreys View Post
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.
__________________
Reply With Quote
  #18  
Old 09-10-2007, 02:50 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by Googi View Post
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
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #19  
Old 09-27-2007, 02:13 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by Chompy View Post
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 )
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.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
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 09:52 AM.


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