Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: Giacomo1982 on April 20, 2018, 03:22:04 PM
-
Hi coders! I want to put in my new theme a simple rectangular progress bar, with [ListEntry] as a variable of width, I try this but doesn't work
local progress = [ListEntry]*0.01;
local bar = fe.add_image("white.png", flx*0.10, fly*0.05, progress, flh*0.05);
Please help me
-
Magic Tokens can only be used by certain default functions provided my attract.
https://github.com/mickelson/attract/blob/master/Layouts.md#magic
I don’t think your formula is correct anyways. You can give your object a default width, divide it by the list size, and multiply it by the index. Reassign object width.
https://github.com/mickelson/attract/blob/master/Layouts.md#CurrentList
-
Thanks for the fast reply keilmillerjr, but I'm not a coder, could you correct this line? Thanks
local width = (1.00 / fe.list.size) * fe.list.index;
local bar = fe.add_image("white.png", flx*0.10, fly*0.05, flw*progress, flh*0.05);
-
It work only the first time when open new list, but when I change game it doesn't change... :(
It could be usefull if someone help me
-
It work only the first time when open new list, but when I change game it doesn't change... :(
It could be usefull if someone help me
Sorry, I have been super exhausted from work lately and cant provide lots of help, and generally only have time to point people in the right direction. I did like 85 hours in 5 days. Took weekend off for time with wife and kids.
You need to use a transition to update the width of your progress bar.
https://github.com/mickelson/attract/blob/master/Layouts.md#add_transition_callback
Something similar to this. You might have to play with it. I have to go to work.
fe.add_transition_callback(list_progress);
function transition(ttype, var, transition_time) {
switch(ttype) {
case Transition.ToNewSelection:
// insert code here
break;
}
return false;
}