Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Array of Gui Buttons. (https://forums.graalonline.com/forums/showthread.php?t=134261541)

Toxen 01-04-2011 05:42 PM

Array of Gui Buttons.
 
Hi, I am currently trying to make a GUI based inventory system, and for some reason using a loop will not work.

i is the column count I could say, after 8 it should become 0 and j which is the row number should be added to 1.

Anyone have any ideas?

PHP Code:

     this.count 0;
     
this.0;
     
this.0;
      while (
this.count this.weplist.size) {//weplist.size does have a value
        
new GuiButtonCtrl("inv_obj_" this.count) {
          
profile GuiBlueButtonProfile;         
          
*((parent.width-20)/8); 
          
*((parent.height-20) / ( int(this.weplist.size) ) );  
          
width = ((parent.width-40)/8);
          
height = ((parent.width-40)/8);
          
text this.weplist[this.count];
        }
         
this.count++;
         
this.i++;
         if (
this.i>8) {//I put 8 Items on each row so after it adds to row#
          
this.j++;
         
this.i=0;
        }
        
       } 


fowlplay4 01-04-2011 05:58 PM

this.j isn't accessible to the child in the parent object, change your variables to temp ones and you'll be able to access them.

PHP Code:

new GuiControl("container") {
  
this.5;
  
temp.6;
  new 
GuiButtonCtrl("button") {
    echo(
this.name);  // echos "button"
    
echo(this.1); // echos 1
    
echo(parent.j);   // echos 5
    
echo(temp.k);     // echos 6
  
}



MrOmega 01-04-2011 07:43 PM

I believe thiso.j should work and/or container.j should work as well

Toxen 01-06-2011 11:27 PM

Thanks for the help on that question , but now kinda another problem and it seems so easy but I cant figure it out. :cry:

the name of my gui controls are "Ron_TD_EnemyImage_ 0-14" and I created them all at the same time using a loop, I also need to move them all at the same time using a loop but the problem is I've tried like


PHP Code:

 for (i=0i<15i++){
   (
Ron_TD_EnemyImage @"_"i).bleh();
 }

//Or i've tried

 
for (i=0i<15i++){
  (
Ron_TD_EnemyImage i).bleh();//Aswell as putting an @ before the Ron
 


But i cant get the control name to work !

Anyone got any ideas? Please and thank u!

fowlplay4 01-06-2011 11:51 PM

Take your pick:

PHP Code:

// Makevar
temp.obj makevar("Ron_TD_EnemyImage" i);
temp.obj.bleh();

// Directly
temp.obj = (@"Ron_TD_EnemyImage" i);
temp.obj.bleh();

// Without using a variable
(@"Ron_TD_EnemyImage" i).bleh(); 

When you use a variable you can then use with to change variables directly as well. I.e:

PHP Code:

temp.obj = (@"Ron_TD_EnemyImage" i);
with (temp.obj) {  // with ((@"Ron_TD_EnemyImage" @ i)) { // should work as well.
  
this.+= 10;
  
this.+= 10;



cbk1994 01-07-2011 12:10 AM

It's generally preferred not to use makevar.


All times are GMT +2. The time now is 09:07 AM.

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