Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Wed 05/04/2006 14:33:51

Title: Can a label display a slider.value? Sorry, slider.Value
Post by: on Wed 05/04/2006 14:33:51
Hello - I'm having a few little problems with AGS, my main one right now being a listbox problem. I've set up a listbox which values are

max - 30,000

and the current value is

current 10,000

By clicking a button here or there, I can reset the value to 10 or 376, for example, but I want - at times, the script to be able to change the value.

My listbox is called "pureprofit", and what I wanted to do was at a certain point in time (I have the timer working) for the listbox to add "profit", and the code I thought would work was;

pureprofit.value = pureprofit.value + 250

But that gives me a "struct" error or something, saying it's not possible. So instead I tried to assign a globalint with the value "250" and get pureprofit to reset it's value to that global int, but then I'm getting messages saying "value" isn't a public member of slider.

Well, this has totally confused me! Is there any alternatives? Could I structure a profit bar in any other way that would allow me to more easily modify when it changes? I haven't been able to find any other compenents that have a value that work on a GUI - as the pureprofit bar sits on a GUI.

Any ideas or help appareciated :) Thanks for listening!
Title: Re: Listbox.values - valid or not?
Post by: SSH on Wed 05/04/2006 14:44:35
2 words, m0ds: Case sensitivity

Value with a capital V
Title: Re: Listbox.values - valid or not?
Post by: RickJ on Wed 05/04/2006 14:57:30
I am not clear as to what you are trying to do.  A listbox doesnt have a "value"; it has a list of items.  If you are trying to add a new item then you would do something like this:

pureprofit.AddItem("The item string");

It almost sounds like you want a bar graph of some sort.  This can be done using a slider or a button.  To use the slider you would do something like the following:

pureprofit.Max = 30000;
pureprofit.Min = 0;
pureprofit.Value = pureprofit.Value+250;


To use a button for this you need to import a big sprite In this case one that is 100 pixels wide into the button's normal graphic and then do somethng like this.

int profit=10000;

pureprofit.Enabled = false;
pureprofit.ClipImage = true;

profit = Profit +250;

// For a horizontal bar that is a maximum of 100 pixels wide.
// For a bar of different max a little more math is required
pureprofit.Width = (profit*100)/30000;

Hope this helps.
Title: Re: Listbox.values - valid or not?
Post by: on Wed 05/04/2006 14:59:15
Thanks, SHH.

Thanks RickJ! Sorry, I got it wrong, I was talking about a slider, and yes, I had forgotten the capital letters. I will have more questions regarding LISTBOXES later today though, I can sense it! :P
Title: Re: Timer events not working correctly
Post by: SSH on Wed 05/04/2006 15:14:57
Are you sure these questions shouldn't be in beginners tech, m0ds ;) :P
Title: Re: Can a label display a slider.value?
Post by: on Wed 05/04/2006 15:17:01
Feel free to move if you want :P Just be glad I'm actually using AGS :P It's all advanced sheet to me!!!!

My new main problem is that I want a label to be able to express the value of my slider. It's currently set to 30,000 so I want a label on the same GUI to express "30,000" - but I can't get it to work. I presume this uses INTS and stuff....I remember trying to get this kind of thing to work in Delphi & that took me two weeks...

Any suggestions?
Title: Re: Can a label display a slider.value? Sorry, slider.Value
Post by: SSH on Wed 05/04/2006 15:32:00
myguilabel.Text=String.Format("%d", variable_containing_my_number);


Don't forget #agstech, too, if you want interactive help,  Mark
Title: Re: Can a label display a slider.value? Sorry, slider.Value
Post by: on Wed 05/04/2006 15:45:50
Thanks SHH. I put it in my repeatedly execute but the following code produces an error - Text is not a public member of label.

Quote
profdisplay.Text = String.Format("%d", pureprofit.Value);
Title: Re: Can a label display a slider.value? Sorry, slider.Value
Post by: SSH on Wed 05/04/2006 15:56:33
Which version are you using? If 2.7 rather than 2.71, you might need:


string temp;
StrFormat(temp, "%d",  pureprofit.Value);
profdisplay.SetText(temp);


I think...

Title: Re: Can a label display a slider.value? Sorry, slider.Value
Post by: on Wed 05/04/2006 17:31:28
Works a treat! Thanks SSH :)