Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: dark1973 on November 12, 2018, 02:05:27 AM
-
Hi. i need help regarding this code:
local charlist = [ "a", "b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0"];
//return the first letter of the game
function firstletter()
{
local pstrip = fe.game_info(Info.Title).slice(0,1);
return pstrip;
}
//return the index position of letter game
function findchar()
{
local pstrip = fe.game_info(Info.Title).slice(0,1);
foreach (index, item in charlist) {
if (item == pstrip) {
return index;
}
}
}
local lettera = fe.add_text( "[!firstletter] ", 25+[!findchar], 25, 70, 35 );
i have an error "null 0x000"returnig the value index.
...if (item == "d").... in this case index value is "3" correct
My goal is to create an alphabet bar with char select. Please Help
-
function firstletter()
{
local pstrip = fe.game_info(Info.Title).slice(0,1);
return pstrip;
}
function findchar()
{
foreach (index, item in charlist)
{
if (item.tostring() == fe.game_info(Info.Title).slice(0,1)) {
posizione = (index+1)*10;
return (index+1)*10;
}
else {}
}
posizione = 130
return 130;
}
posizione = findchar();
local lettera = fe.add_text( "[!firstletter] [!findchar]", posizione ,10 , 100, 35 );
now position of char work correctly.
integer posizione not refresh. Help please
-
Could you just use find(value) to return the array index?
-
now problem is posizione refresh :'(
Layout with text refresh only when load first time.
-
Could you just use find(value) to return the array index?
charlist.find(fe.game_info(Info.Title).slice(0,1))+1)*20 this way?
Unfortunately, when I change games, position is not updated
-
function transition( ttype, var, transition_time )
{
if ( ttype == Transition.?????????) {
...
...
....
}
return false
}
fe.add_transition_callback(this, "on_transition")
this way?
-
Could you just use find(value) to return the array index?
charlist.find(fe.game_info(Info.Title).slice(0,1))+1)*20 this way?
Unfortunately, when I change games, position is not updated
Do it inside your magic function instead of your foreach loop and compare line. Both do the same thing. Just trying to clean up code. :)