Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Question

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
daspamer
Grandmaster Cheater Supreme
Reputation: 54

Joined: 13 Sep 2011
Posts: 1588

PostPosted: Sat May 04, 2013 7:22 am    Post subject: Question Reply with quote

Is it possible to change string for specific item in ListBox?
Let's say I got 5 items in my ListBox,
I want the first one to be Red, the second one to be Blue, the third one to be Green, the forth one to be Yellow and the fifth one to be Orange.

How can i do it?



hmmm.png
 Description:
 Filesize:  17 KB
 Viewed:  2579 Time(s)

hmmm.png



_________________
I'm rusty and getting older, help me re-learn lua.
Back to top
View user's profile Send private message Visit poster's website
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25796
Location: The netherlands

PostPosted: Sat May 04, 2013 7:39 am    Post subject: Reply with quote

Get the Items object of the listbox
Items is an inherited object of Strings, so you can then use strings_setString(list, index, text)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
daspamer
Grandmaster Cheater Supreme
Reputation: 54

Joined: 13 Sep 2011
Posts: 1588

PostPosted: Sat May 04, 2013 7:44 am    Post subject: Reply with quote

Oh crap,
I forgot to write one important word at the question.
Heres the real question.
Flash hacker wrote:
Is it possible to change string color for specific item in ListBox?
Let's say I got 5 items in my ListBox,
I want the first one to be Red, the second one to be Blue, the third one to be Green, the forth one to be Yellow and the fifth one to be Orange.

How can i do it?

_________________
I'm rusty and getting older, help me re-learn lua.
Back to top
View user's profile Send private message Visit poster's website
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat May 04, 2013 7:49 am    Post subject: Reply with quote

You can edit them like this:
Code:
function replaceString( l, f, r )
    local s = listbox_getItems( l );
    for x = 0, strings_getCount( s ) - 1 do
        local str = strings_getString( s, x );
        if (str == f) then
           strings_setString( s, x, r );
           return true;
        end
    end
    return false;
end


Full example:
Code:

local f = createForm( true );
local l = createListBox( f );

-- Add items to listbox..
local s = listbox_getItems( l );
strings_add( s, 'Entry 1' );
strings_add( s, 'Entry 2' );
strings_add( s, 'Entry 3' );
strings_add( s, 'Entry 4' );

-- Replacement function..
function replaceString( l, f, r )
    local s = listbox_getItems( l );
    for x = 0, strings_getCount( s ) - 1 do
        local str = strings_getString( s, x );
        if (str == f) then
           strings_setString( s, x, r );
           return true;
        end
    end
    return false;
end

-- Replace entry 3 with derp..
replaceString( l, 'Entry 3', 'derp' );

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
daspamer
Grandmaster Cheater Supreme
Reputation: 54

Joined: 13 Sep 2011
Posts: 1588

PostPosted: Mon May 06, 2013 1:11 pm    Post subject: Reply with quote

Flash hacker wrote:
Oh crap,
I forgot to write one important word at the question.
Heres the real question.
Flash hacker wrote:
Is it possible to change string color for specific item in ListBox?
Let's say I got 5 items in my ListBox,
I want the first one to be Red, the second one to be Blue, the third one to be Green, the forth one to be Yellow and the fifth one to be Orange.

How can i do it?

_________________
I'm rusty and getting older, help me re-learn lua.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites