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 01-04-2011, 05:42 PM
Toxen Toxen is offline
A Toxic Fellow
Join Date: Jan 2008
Location: Georgia
Posts: 36
Toxen is on a distinguished road
Post 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;
        }
        
       } 
__________________
UN NAT.
Reply With Quote
  #2  
Old 01-04-2011, 05:58 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
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
  
}

__________________
Quote:
Reply With Quote
  #3  
Old 01-04-2011, 07:43 PM
MrOmega MrOmega is offline
One More Time
MrOmega's Avatar
Join Date: Aug 2010
Location: TN, USA
Posts: 631
MrOmega is an unknown quantity at this point
Send a message via AIM to MrOmega Send a message via MSN to MrOmega Send a message via Yahoo to MrOmega
I believe thiso.j should work and/or container.j should work as well
__________________
Time is the fire in which we burn...
Up, Up, Down, Down, Left, Right, Left, Right, B, A, Select, Start! Now I got 99 LIVES!!!
Reply With Quote
  #4  
Old 01-06-2011, 11:27 PM
Toxen Toxen is offline
A Toxic Fellow
Join Date: Jan 2008
Location: Georgia
Posts: 36
Toxen is on a distinguished road
Thanks for the help on that question , but now kinda another problem and it seems so easy but I cant figure it out.

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!
Reply With Quote
  #5  
Old 01-06-2011, 11:51 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
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;

__________________
Quote:
Reply With Quote
  #6  
Old 01-07-2011, 12:10 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
It's generally preferred not to use makevar.
__________________
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:22 PM.


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