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 


Color Tool [Lua Plug-in]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting -> Lua Extensions
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater
Reputation: 17

Joined: 10 Apr 2015
Posts: 619

PostPosted: Sun Feb 04, 2018 7:38 pm    Post subject: Color Tool [Lua Plug-in] This post has 1 review(s) Reply with quote

============================
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



Capture.JPG
 Description:
Color Tool Menu
 Filesize:  90.51 KB
 Viewed:  3917 Time(s)

Capture.JPG



_________________
Singapore Sling + Johnnie Walker + Some Peanuts....
Back to top
View user's profile Send private message
Aylin
Expert Cheater
Reputation: 2

Joined: 16 Feb 2017
Posts: 154

PostPosted: Mon Feb 19, 2018 12:19 pm    Post subject: Reply with quote

How I missed it. Sad
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. Smile

_________________
See Hitler ! This Trainer is for you!
http://forum.cheatengine.org/viewtopic.php?t=606786
Enthusiastic people: Always one step ahead!
Do not underestimate me Master: You were a beginner in the past!
Back to top
View user's profile Send private message MSN Messenger
TheyCallMeTim13
Wiki Contributor
Reputation: 14

Joined: 24 Feb 2017
Posts: 441
Location: 'Merica

PostPosted: Mon Feb 19, 2018 1:19 pm    Post subject: Re: Color Tool [Lua Plug-in] Reply with quote

@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
View user's profile Send private message
Corroder
Grandmaster Cheater
Reputation: 17

Joined: 10 Apr 2015
Posts: 619

PostPosted: Mon Feb 19, 2018 6:53 pm    Post subject: Re: Color Tool [Lua Plug-in] Reply with quote

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.

_________________
Singapore Sling + Johnnie Walker + Some Peanuts....
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting -> Lua Extensions 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