 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Sun Feb 04, 2018 7:38 pm Post subject: Color Tool [Lua Plug-in] |
|
|
============================
File name : ColorTool.lua
Author : Corroder
Date : 22-08-2017
============================
Purpose :
1. Add CE Menu : Color
2. Sub Menu : Check RGB / HEX Color Code [with function RGBToHex(red value, green value, blue value)
3. Give user easy to check RGB / HEX color code and use result on user form property
Example :
---------------------------------------------------------------------------------------------------------------------------
1. Form background color (use same way to coloring Label, Panel, etc)
Code: | [Form Name].color = RGBToHex(83, 129, 63) --> 'Solid Green Color'
or
[Form Name].color = '0x53813F' --> 'Solid Green Color' |
2. To set Form / Panel to transparent (Change RGB value as you want)
Code: | [Form Name].color = RGBToHex(50, 142, 25)
[Form Name].setLayeredAttributes(RGBToHex(50, 142, 25), 200, 2) |
Source :
--------------------------------------------------------------------------------------------------------------------------
Code: | --===========================================================--
-- Author : Corroder --
-- Project : Add Menu RGB COlor To Hex on CE Main Menu --
-- Date : 30 Jan 2018 --
-- Goal : Give user a function to check RGB color --
-- code and able to use on CE form GUI etc --
--===========================================================--
--======================================================--
-- Define function to change RGB code Color to Hex Code --
--======================================================--
function RGBToHex(red, green, blue)
if(red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) then
return nil
end
return string.format("0x%.2X%.2X%.2X", red,green,blue)
end
--======================================================--
--Define function to popup menu when Color menu clicked --
--======================================================--
function colorMenuClick()
fc = createForm()
fc.Width = 300
fc.Height = 400
fc.Position = 'poScreenCenter'
fc.Caption = 'RGB/HEX COLOR TOOL'
fc.Color = '0x00DFF7FF'
p = createPanel(fc)
p.top = 20
p.height = 150
p.width = 250
p.left = math.floor((fc.width - p.width) / 2)
p.color = '0x00000000'
t1 = createTrackBar(fc)
t1.left = 15
t1.top = p.height + p.top + 20
t1.width = fc.width - t1.left - 80
t1.height = 30
t1.Max = 255
t1.Min = 0
t1.position = 0
t1.SelStart = 0
t1.SelEnd = 0
t2 = createTrackBar(fc)
t2.left = 15
t2.top = t1.height + t1.top + 10
t2.width = fc.width - t2.left - 80
t2.height = 30
t2.Max = 255
t2.Min = 0
t2.position = 0
t2.SelStart = 0
t2.SelEnd = 0
t3 = createTrackBar(fc)
t3.left = 15
t3.top = t2.height + t2.top + 10
t3.width = fc.width - t3.left - 80
t3.height = 30
t3.Max = 255
t3.Min = 0
t3.position = 0
t3.SelStart = 0
t3.SelEnd = 0
RLabel = createLabel(fc)
RLabel.top = t1.top
RLabel.left = t1.left + t1.width + 12
RLabel.caption = 'R : 0'
RLabel.font.color = '0x001717FF'
RLabel.font.style = 'fsBold'
GLabel = createLabel(fc)
GLabel.top = t2.top
GLabel.left = t2.left + t2.width + 12
GLabel.caption = 'G : 0'
GLabel.font.color = '0x00009300'
GLabel.font.style = 'fsBold'
BLabel = createLabel(fc)
BLabel.top = t3.top
BLabel.left = t3.left + t3.width + 12
BLabel.caption = 'B : 0'
BLabel.font.color = '0x00FF2020'
BLabel.font.style = 'fsBold'
HxLabel = createLabel(fc)
HxLabel.top = t3.top + t3.height + 15
HxLabel.left = t3.left
HxLabel.caption = 'Current Hex Color Code : '
Hx1Label = createLabel(fc)
Hx1Label.top = t3.top + t3.height + 7
Hx1Label.left = HxLabel.left + HxLabel.width
Hx1Label.font.size = 14
Hx1Label.font.style = 'fsBold'
Hx1Label.caption = ' '
ExamLabel = createLabel(fc)
ExamLabel.top = HxLabel.top + HxLabel.height + 5
ExamLabel.left = HxLabel.left
ExamLabel.font.size = 8
ExamLabel.caption = 'Usage to get current color :'
rgbLabel = createLabel(fc)
rgbLabel.top = ExamLabel.top + ExamLabel.height + 3
rgbLabel.left = ExamLabel.left
rgbLabel.font.size = 8
smpLabel = createLabel(fc)
smpLabel.top = rgbLabel.top + rgbLabel.height + 13
smpLabel.left = rgbLabel.left
smpLabel.font.size = 8
smp1Label = createLabel(fc)
smp1Label.top = smpLabel.top + smpLabel.height + 13
smp1Label.left = smpLabel.left
smp1Label.font.size = 8
fc.show()
R = 0
G = 0
B = 0
col = nil
function rtbChange(sender)
R = t1.position
G = t2.position
B = t3.position
RLabel.Caption = 'R : '..tostring(t1.position)
rgbLabel.Caption = "[Object Name].Color = RGBToHex("..tostring(t1.position)..","..tostring(t2.position)..","..tostring(t3.position)..")"
smpLabel.Caption = "eq. UDF1.Color = RGBToHex("..tostring(t1.position)..","..tostring(t2.position)..","..tostring(t3.position)..")"
col = RGBToHex(R,G,B)
p.color = col
Hx1Label.caption = tostring(col)
smp1Label.caption = 'or '..' UDF1.Color = '..'"'..tostring(col)..'"'
end
function gtbChange(sender)
R = t1.position
G = t2.position
B = t3.position
GLabel.Caption = 'G : '..tostring(t2.position)
rgbLabel.Caption = "[Object Name].Color = RGBToHex("..tostring(t1.position)..","..tostring(t2.position)..","..tostring(t3.position)..")"
smpLabel.Caption = "eq. UDF1.Color = RGBToHex("..tostring(t1.position)..","..tostring(t2.position)..","..tostring(t3.position)..")"
col = RGBToHex(R,G,B)
p.color = col
Hx1Label.caption = tostring(col)
smp1Label.caption = 'or '..' UDF1.Color = '..'"'..tostring(col)..'"'
end
function btbChange(sender)
R = t1.position
G = t2.position
B = t3.position
BLabel.Caption = 'B : '..tostring(t3.position)
rgbLabel.Caption = "[Object Name].Color = RGBToHex("..tostring(t1.position)..","..tostring(t2.position)..","..tostring(t3.position)..")"
smpLabel.Caption = "eq. UDF1.Color = RGBToHex("..tostring(t1.position)..","..tostring(t2.position)..","..tostring(t3.position)..")"
col = RGBToHex(R,G,B)
p.color = col
Hx1Label.caption = tostring(col)
smp1Label.caption = 'or '..' UDF1.Color = '..'"'..tostring(col)..'"'
end
t1.onChange = rtbChange
t2.onChange = gtbChange
t3.onChange = btbChange
end
--======================================--
-- Add/Insert new menu to CE Main Menu
--======================================--
local mainForm = getMainForm()
local colorMenu = createMenuItem(mainForm)
colorMenu.Caption = [[RGB/HEX Color Code]]
colorMenu.onClick = colorMenuClick
mainForm.PopupMenu2.Items.insert(15,colorMenu)
local mainMenu = mainForm.Menu.Items
local miColor
--Find "Color" item in main menu. Create one if not found.
for i=0,mainMenu.Count-1 do
if mainMenu[i].Name == 'miColor' then miExtra = mainMenu[i] end
end
if miColor == nil then
miColor = createMenuItem(mainForm)
miColor.Name = 'miColor'
miColor.Caption = 'Color'
mainMenu.insert(mainMenu.Count-2,miColor)
end
--==============================================--
--Add "Check RGB Color" item to "Color" submenu
--==============================================--
local miCheckRGBcolor = createMenuItem(miColor)
miCheckRGBcolor.Caption = 'Check RGB Color Code'
miCheckRGBcolor.onClick = colorMenuClick
miColor.add(miCheckRGBcolor)
|
copy codes above, save as lua file (I'm save it as ColorTool.lua) and place in CE > autorun folder
Future :
- Add custom functions to get RGBA color opacity, luminance color, etc
Note :
- Actually I want place Color Menu as sub menu under Help Menu. If you want do that, then you are free to modify provided codes above
- Free to add you custom function, etc
- This is just a small contribute
Description: |
|
Filesize: |
90.51 KB |
Viewed: |
35862 Time(s) |

|
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 35
Joined: 16 Feb 2017 Posts: 1478
|
Posted: Mon Feb 19, 2018 12:19 pm Post subject: |
|
|
How I missed it.
Nice work. Sometimes I am looking for online sites to find the color code.
Now all the color codes under the elimination. Thank you, Corroder.
_________________
|
|
Back to top |
|
 |
TheyCallMeTim13 Wiki Contributor
Reputation: 51
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Mon Feb 19, 2018 1:19 pm Post subject: Re: Color Tool [Lua Plug-in] |
|
|
@Corroder
You might want to post this in the Lua Extensions forum section, to make it easier for users find when looking for Lua extensions.
_________________
|
|
Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Mon Feb 19, 2018 6:53 pm Post subject: Re: Color Tool [Lua Plug-in] |
|
|
TheyCallMeTim13 wrote: | @Corroder
You might want to post this in the Lua Extensions forum section, to make it easier for users find when looking for Lua extensions. |
Yes, you are right Tim. I hope someone from admins forum move it to Lua extensions section.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
 |
ksmiz How do I cheat?
Reputation: 0
Joined: 07 Oct 2018 Posts: 2
|
Posted: Sun Oct 14, 2018 7:34 pm Post subject: |
|
|
Why is this backwards? I tried to figure it out but can't seem to find out what is going on
This color square should be blue right?
Is this a Big/Little endian type thing going on?
Description: |
|
Filesize: |
8.37 KB |
Viewed: |
29850 Time(s) |

|
|
|
Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Mon Oct 15, 2018 5:32 am Post subject: |
|
|
n RBG value might look like this: rgb(255, 0, 0).
At first this may not look like much, but if we take a closer look, the first number represents red, second number represents green, and the third number represents blue. The values in those spots can range anywhere from 0, all the way up to 255
A hex color will look something like this, #ff0000 or 0xff0000.
We know that 0xFF is 255 in hexadecimal, and 255 is the maximum value for RGB. If we see what #ff0000 is, we can see that it is a bright red color
But when try it in CE :
Code: | f = createForm()
f.color = '0x0000fff' (might be blue) or rgb(0,0,255)
f.show()
|
code above will show a CE form with RED background instead blue.
So, I wonder this problem can be found in CE source itself. Maybe inside script main.pas..
Should be this is a CE bug ?
Description: |
|
Filesize: |
76.42 KB |
Viewed: |
29819 Time(s) |

|
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 150
Joined: 06 Jul 2014 Posts: 4652
|
Posted: Mon Oct 15, 2018 8:57 am Post subject: |
|
|
Corroder wrote: | A hex color will look something like this, #ff0000 or 0xff0000. |
An RGB color encoded as a 4-byte value is typically in this format: 0x??BBGGRR. Red is 0xff, green is 0xff00, and blue is 0xff0000. The most significant byte could represent different ideas in different contexts.
I've never seen an API that encodes it as you describe. If anything, storing it as 0xRRGGBB?? would be strange since the bytes are stored in little endian format.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Mon Oct 15, 2018 9:41 am Post subject: |
|
|
Yes, it's about endianess.
Lua use BBGGRR stored bytes in little endian format, almost x86 machines store bytes in little endiran format.
Then, when converting from #rrggbb hex color format, need to use #bbggrr and convert the hex (bbggrr) to int.
It is nothing to do with Lua. In C, it will be the same.
RGB is red/green/blue;
So, red is the lower-order byte (it comes first).
Green is next, and is multiplied by 256.
Blue is last, and is multiplied by 65536.
Languages like Lua, Java, C, Fortran, etc. etc. will all represent (as hex codes) the colours in that order, that is:
0xBBGGRR
However in HTML they rearranged things to be in "human" order, and write it as:
#RRGGBB.
@Gnysek code (from game maker community)
Code: | ///convert_color_endianness(val)
//Converts a color from RGB to the little endian BGR and vice versa
var rgb = argument[0],
bgr = 0, //Output
bsh = $10; //Number of bits to shift
bgr = (rgb & $FF) << bsh; //Blue
bgr += (rgb & $FF00); //Green
bgr += (rgb & $FF0000) >> bsh; //Red
return bgr; |
one line :
Code: | /// @desc rgb_to_bgr - converts RGB int/hex to BGR real
/// @param rgb_color {real} example: $00BBFF or 48127
return (argument0 & $FF) << 16 | (argument0 & $FF00) | (argument0 & $FF0000) >> 16; |
Can you write that code in lua ?. Thanks
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Last edited by Corroder on Mon Oct 15, 2018 9:49 am; edited 2 times in total |
|
Back to top |
|
 |
ksmiz How do I cheat?
Reputation: 0
Joined: 07 Oct 2018 Posts: 2
|
Posted: Mon Oct 15, 2018 9:43 am Post subject: |
|
|
ParkourPenguin wrote: | I've never seen an API that encodes it as you describe. If anything, storing it as 0xRRGGBB?? would be strange since the bytes are stored in little endian format. |
So if they are stored in little endian format I think Corroder's extension is displaying or interpreting them as big endian format
The green color bar works perfect because it will be the same either way.
The red and blue are flipped because of this
edit: Corroder replied right before I posted this
Description: |
|
Filesize: |
90.97 KB |
Viewed: |
29798 Time(s) |

|
Description: |
|
Filesize: |
91.05 KB |
Viewed: |
29798 Time(s) |

|
|
|
Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Mon Oct 15, 2018 8:01 pm Post subject: |
|
|
To get right displaying color in CE is better use MsAccess color code to coloring some CE GUI.
Reference for MsAcces code e.q : http://www.endprod.com/colors/
Description: |
|
Filesize: |
60.21 KB |
Viewed: |
29768 Time(s) |

|
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Wed Oct 17, 2018 5:59 pm Post subject: |
|
|
EDIT - 18/10/2018
Change format to BBGGRR <> HEX
Just save as a lua file and place it at CE -> Autorun folder
Source Code :
Code: | --========================================================--
-- Author : Corroder --
-- Project : Add Menu BGR Color To Hex on CE Main Menu --
-- Date : Edit #1 18 Oct 2018 --
-- Goal : Give user a function to check BGR color --
-- code and able to use on CE form GUI etc --
--========================================================--
--======================================================--
-- Define function to change BGR code Color to Hex Code --
--======================================================--
function BGRToHex(blue, green, red)
if(red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) then
return nil
end
return string.format("0x%.2X%.2X%.2X", blue,green,red)
end
--======================================================--
--Define function to popup menu when Color menu clicked --
--======================================================--
function colorMenuClick()
fc = createForm()
fc.Width = 300
fc.Height = 400
fc.Position = 'poScreenCenter'
fc.Caption = 'BGR/HEX COLOR TOOL'
fc.Color = '0x00DFF7FF'
p = createPanel(fc)
p.top = 20
p.height = 150
p.width = 250
p.left = math.floor((fc.width - p.width) / 2)
p.color = '0x00000000'
t1 = createTrackBar(fc)
t1.left = 15
t1.top = p.height + p.top + 20
t1.width = fc.width - t1.left - 80
t1.height = 30
t1.Max = 255
t1.Min = 0
t1.position = 0
t1.SelStart = 0
t1.SelEnd = 0
t2 = createTrackBar(fc)
t2.left = 15
t2.top = t1.height + t1.top + 10
t2.width = fc.width - t2.left - 80
t2.height = 30
t2.Max = 255
t2.Min = 0
t2.position = 0
t2.SelStart = 0
t2.SelEnd = 0
t3 = createTrackBar(fc)
t3.left = 15
t3.top = t2.height + t2.top + 10
t3.width = fc.width - t3.left - 80
t3.height = 30
t3.Max = 255
t3.Min = 0
t3.position = 0
t3.SelStart = 0
t3.SelEnd = 0
BLabel = createLabel(fc)
BLabel.top = t1.top
BLabel.left = t1.left + t1.width + 12
BLabel.caption = 'B : 0'
BLabel.font.color = '0x00FF2020'
BLabel.font.style = 'fsBold'
GLabel = createLabel(fc)
GLabel.top = t2.top
GLabel.left = t2.left + t2.width + 12
GLabel.caption = 'G : 0'
GLabel.font.color = '0x00009300'
GLabel.font.style = 'fsBold'
RLabel = createLabel(fc)
RLabel.top = t3.top
RLabel.left = t3.left + t3.width + 12
RLabel.caption = 'R : 0'
RLabel.font.color = '0x001717FF'
RLabel.font.style = 'fsBold'
HxLabel = createLabel(fc)
HxLabel.top = t3.top + t3.height + 15
HxLabel.left = t3.left
HxLabel.caption = 'Current Hex Color Code : '
Hx1Label = createLabel(fc)
Hx1Label.top = t3.top + t3.height + 7
Hx1Label.left = HxLabel.left + HxLabel.width
Hx1Label.font.size = 14
Hx1Label.font.style = 'fsBold'
Hx1Label.caption = ' '
ExamLabel = createLabel(fc)
ExamLabel.top = HxLabel.top + HxLabel.height + 5
ExamLabel.left = HxLabel.left
ExamLabel.font.size = 8
ExamLabel.caption = 'Usage to get current color :'
bgrLabel = createLabel(fc)
bgrLabel.top = ExamLabel.top + ExamLabel.height + 3
bgrLabel.left = ExamLabel.left
bgrLabel.font.size = 8
smpLabel = createLabel(fc)
smpLabel.top = bgrLabel.top + bgrLabel.height + 13
smpLabel.left = bgrLabel.left
smpLabel.font.size = 8
smp1Label = createLabel(fc)
smp1Label.top = smpLabel.top + smpLabel.height + 13
smp1Label.left = smpLabel.left
smp1Label.font.size = 8
fc.show()
B = 0
G = 0
R = 0
col = nil
function btbChange(sender)
B = t1.position
G = t2.position
R = t3.position
BLabel.Caption = 'B : '..tostring(t1.position)
bgrLabel.Caption = "[Object Name].Color = BGRToHex("..tostring(t1.position)..","..tostring(t2.position)..","..tostring(t3.position)..")"
smpLabel.Caption = "eq. UDF1.Color = BGRToHex("..tostring(t1.position)..","..tostring(t2.position)..","..tostring(t3.position)..")"
col = BGRToHex(B,G,R)
p.color = col
Hx1Label.caption = tostring(col)
smp1Label.caption = 'or '..' UDF1.Color = '..'"'..tostring(col)..'"'
end
function gtbChange(sender)
B = t1.position
G = t2.position
R = t3.position
GLabel.Caption = 'G : '..tostring(t2.position)
bgrLabel.Caption = "[Object Name].Color = BGRToHex("..tostring(t1.position)..","..tostring(t2.position)..","..tostring(t3.position)..")"
smpLabel.Caption = "eq. UDF1.Color = BGRToHex("..tostring(t1.position)..","..tostring(t2.position)..","..tostring(t3.position)..")"
col = BGRToHex(B,G,R)
p.color = col
Hx1Label.caption = tostring(col)
smp1Label.caption = 'or '..' UDF1.Color = '..'"'..tostring(col)..'"'
end
function rtbChange(sender)
B = t1.position
G = t2.position
R = t3.position
RLabel.Caption = 'R : '..tostring(t3.position)
bgrLabel.Caption = "[Object Name].Color = BGRToHex("..tostring(t1.position)..","..tostring(t2.position)..","..tostring(t3.position)..")"
smpLabel.Caption = "eq. UDF1.Color = BGRToHex("..tostring(t1.position)..","..tostring(t2.position)..","..tostring(t3.position)..")"
col = BGRToHex(B,G,R)
p.color = col
Hx1Label.caption = tostring(col)
smp1Label.caption = 'or '..' UDF1.Color = '..'"'..tostring(col)..'"'
end
t1.onChange = btbChange
t2.onChange = gtbChange
t3.onChange = rtbChange
end
--======================================--
-- Add/Insert new menu to CE Main Menu
--======================================--
local mainForm = getMainForm()
local colorMenu = createMenuItem(mainForm)
colorMenu.Caption = [[BGR/HEX Color Code]]
colorMenu.onClick = colorMenuClick
mainForm.PopupMenu2.Items.insert(15,colorMenu)
local mainMenu = mainForm.Menu.Items
local miColor
--Find "Color" item in main menu. Create one if not found.
for i=0,mainMenu.Count-1 do
if mainMenu[i].Name == 'miColor' then miExtra = mainMenu[i] end
end
if miColor == nil then
miColor = createMenuItem(mainForm)
miColor.Name = 'miColor'
miColor.Caption = 'Color'
mainMenu.insert(mainMenu.Count-2,miColor)
end
--==============================================--
--Add "Check BGR Color" item to "Color" submenu
--==============================================--
local miCheckBGRcolor = createMenuItem(miColor)
miCheckBGRcolor.Caption = 'Check BGR Color Code'
miCheckBGRcolor.onClick = colorMenuClick
miColor.add(miCheckBGRcolor) |
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
 |
|
|
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
|
|