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 


convert trackbar position value to hex [help]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Lynxz Gaming
Expert Cheater
Reputation: 4

Joined: 01 Jul 2017
Posts: 208
Location: help

PostPosted: Sun Jun 17, 2018 9:01 am    Post subject: convert trackbar position value to hex [help] Reply with quote

How to convert trackbar position value to hex?

trackbar min is 0 max is 255
white color is FF in hex
black color is 00 in hex

i want to convert trackbar position value into hex
(sorry for my bad english)

_________________
my english is bad
discord : rynx#9828
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Sun Jun 17, 2018 9:28 am    Post subject: Reply with quote

255 and 0xff are the same integer. It doesn't matter what base it's in.
Code:
assert(255 == 0xff)

If you want to convert it to a string, use a format specifier.
Code:
print(('%06X'):format(color))

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sun Jun 17, 2018 7:00 pm    Post subject: Reply with quote

Or...

Code:
f = createForm()

tb = createTrackBar(f)
tb.top = 100
tb.left = 5
tb.width = f.width - 10
tb.frequency = 1
tb.Max = 255
tb.Min = 0
tb.position = 0
tb.SelStart = 0
tb.SelEnd = 0

lb = createLabel(f)
lb.Caption = 'Trakbar Pos : '
lb.Top = tb.Top + tb.Height + 8
lb.Left = 5

function num2hex(num)
    local hexstr = '0123456789abcdef'
    local s = ''
    while num > 0 do
        local mod = math.fmod(num, 16)
        s = string.sub(hexstr, mod+1, mod+1) .. s
        num = math.floor(num / 16)
    end
    if s == '' then s = '0' end
    return s
end

function getTBpos()
 local input = tb.Position
 -- local output = string.format("%02x", input * 256)
 local output = num2hex(input)
 lb.Caption = 'Trakbar Pos : '..tostring(input)..'  = Hex : '..output
end

f.show()

tb.onChange = getTBpos

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Lynxz Gaming
Expert Cheater
Reputation: 4

Joined: 01 Jul 2017
Posts: 208
Location: help

PostPosted: Mon Jun 18, 2018 8:09 am    Post subject: Reply with quote

Thank you Corroder & ParkourPenguin
_________________
my english is bad
discord : rynx#9828
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting 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