PenUltima Online

It is currently Fri Sep 05, 2008 4:12 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Entry option.
PostPosted: Sat Mar 29, 2008 3:26 pm 
Offline
User avatar

Joined: Fri Dec 28, 2007 11:19 pm
Posts: 91
Location: Montreal, Canada
I would be able to attribute a value to my entries. And I can't find the solution yet.

Code:
foreach entry in ( options )

      GFCheckBox(s_gump, 180, y_pos, 2360, 2361, 0, _entry_iter);
                GFCheckBox(s_gump, 200, y_pos, 2360, 2361, 0, _entry_iter);
                GFCheckBox(s_gump, 220, y_pos, 2360, 2361, 0, _entry_iter);


Each checkbox represent different options that I would be able to add to another option.

using _entry_iter above is simply duping the checkbox function as if I click one it's always the same answer. I need to know how to give my _entry_iter values as 1 2 or 3.

_________________
Image
FantasiaShard.com


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 29, 2008 6:12 pm 
Offline

Joined: Sat Feb 04, 2006 5:49 pm
Posts: 747
Location: Chicago, IL USA
the _entry_iter only increases every time the foreach loops because its saying which iteration the foreach is on with the variable "entry". To get it to count up correctly in the way you want to use it, you'd have to do...

Code:
var x_pos := 180;
foreach entry in (options)
  GFCheckBox(s_gump, x_pos, y_pos, 2360, 2361, 0, _entry_iter);
  x_pos := x_pos + 20; // (if on POL097) x_pos += 20
endforeach


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 29, 2008 7:50 pm 
Offline
User avatar

Joined: Fri Dec 28, 2007 11:19 pm
Posts: 91
Location: Montreal, Canada
I will try that right now, thank you for your answer.

_________________
Image
FantasiaShard.com


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 30, 2008 1:39 pm 
Offline
User avatar

Joined: Fri Dec 28, 2007 11:19 pm
Posts: 91
Location: Montreal, Canada
Just to be sure, does the _entry_iter will return a different value with the foreach loops?

Code:
GFPage(s_gump, 1);
   var num_options := options.Size();
   var y_pos := 110;
        var i;
   foreach entry in ( options )

                var x_pos := 200;
                for( i:=1; i<=7; i+=1 )
                          GFCheckBox(s_gump, x_pos, y_pos, 2360, 2361, 0, _entry_iter);
                          x_pos += 50;
                          SleepMS(2);
                endfor

      GFTextLine(s_gump, 20, y_pos, 1153, entry);
      y_pos := y_pos+20;

      if ( _entry_iter % 15 == 0 && _entry_iter < num_options )
         GFAddButton(s_gump, 590, 385, 0xA92, 0xA93, GF_PAGE_BTN, s_gump.cur_page+1);
         GFPage(s_gump, s_gump.cur_page+1);
         GFAddButton(s_gump, 590, 110, 0xA90, 0xA91, GF_PAGE_BTN, s_gump.cur_page-1);
         y_pos := 110;
      endif

      SleepMS(2);
   endforeach


If you understand, the CheckBox Button are different x value repeatly for y

_________________
Image
FantasiaShard.com


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 30, 2008 1:59 pm 
Offline
User avatar

Joined: Fri Feb 10, 2006 12:15 am
Posts: 209
Maybe this clears it.

Code:
var list := array{ "a", "b", "c" };

foreach value in list
    print(_value_iter + ": " + value);
    // 1: a
    // 2: b
    // 3: c
endforeach

list := dictionary{ "a" -> 1, "b" -> 2, "c" -> 3 };

foreach value in list
    print(_value_iter + ": " + value);
    // a: 1
    // b: 2
    // c: 3
endforeach


In foreach, _variable_iter is the index of the array (dictionary) that identifies the element it is just looping.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 30, 2008 8:50 pm 
Offline
User avatar

Joined: Fri Dec 28, 2007 11:19 pm
Posts: 91
Location: Montreal, Canada
Thanks a lot. It makes it clear now.

_________________
Image
FantasiaShard.com


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 04, 2008 9:23 am 
Offline
User avatar

Joined: Fri Dec 28, 2007 11:19 pm
Posts: 91
Location: Montreal, Canada
I understand now the iteration applied in the foreach loop. But I still have some headache with my question:

Code:
GFPage(s_gump, 1);
   var num_options := options.Size();
   var y_pos := 110;
        var i;
   foreach entry in ( options )

                var x_pos := 210;
                for( i:=1; i<=7; i+=1 )
                          GFCheckBox(s_gump, x_pos, y_pos, 2360, 2361, 0, _entry_iter);
                          x_pos += 50;
                          SleepMS(2);
                endfor

      GFTextLine(s_gump, 30, y_pos, 1153, entry);
      y_pos := y_pos+20;

      if ( _entry_iter % 14 == 0 && _entry_iter <num_options>= 1 && key <= num_options )
         values.Append(options[key]);
      endif
      SleepMS(2);
   endforeach

Options defined are a list of proprieties in an array. The checkboxes needs to send a special event to only the good option.

With the above code _entry_iter will simply loop to the next entry wich is normal but not exactly what I need. I tried to use numbers as if the value of the check box will return if checked. But it stills loop into the options given.

ex.:
entry1 checkbox1 checkbox2 checkbox3 checkbox4 checkbox5
entry2 checkbox1 checkbox2 checkbox3 checkbox4 checkbox5
entry3 checkbox1 checkbox2 checkbox3 checkbox4 checkbox5
[...]

If checkbox1 is checked, it will return a rename..
If checkbox2 is checked, it will return a new color..
If checkbox3 is checked, it will return a new graphic..

(that's an exemple)

_________________
Image
FantasiaShard.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: Yahoo [Bot] and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl