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 


different text colors in one memo or caption
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
exohaxor
Expert Cheater
Reputation: 1

Joined: 02 Sep 2018
Posts: 101

PostPosted: Wed Jan 15, 2020 7:05 am    Post subject: different text colors in one memo or caption Reply with quote

i want to make rainbow text but like every letter different color can i do that?
_________________
hi
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Wed Jan 15, 2020 8:42 am    Post subject: Reply with quote

here's an example you can look at (CE 7.0)

Code:

function buildrandomcolorstringRGB(s)
  local i=1
  local r=''
  for p,cnr in utf8.codes(s) do

    local c=utf8.char(cnr)

    local red=math.random(0,255)
    local green=math.random(0,255)
    local blue=math.random(0,255)

    c=string.char(27)..'[38;2;'..red..';'..green..';'..blue..'m'..c
    r=r..c
  end

  return r
end

function buildrandomcolorstring16(s)
  local i
  local r=''
  for p,cnr in utf8.codes(s) do
    local c=utf8.char(cnr)

    if math.random(1,2)==1 then
      c=string.char(27)..'['..math.random(90,97)..'m'..c
    else
      c=string.char(27)..'['..math.random(30,37)..'m'..c
    end
    r=r..c
  end

  return r
end


f=createForm()
pb=createPaintBox(f)
pb.Canvas.Font.Size=20

pb.Align='alClient'
t=createTimer(f)
t.Interval=250
t.Enabled=true
t.OnTimer=function(t)
  local rect={}
  rect.Left=0
  rect.Top=0
  rect.Right=pb.Width
  rect.Bottom=pb.Height

--  local s=buildrandomcolorstring16('Hello')
  local s=buildrandomcolorstringRGB('Hello')
  pb.Canvas.clear()
  pb.Canvas.textRect(rect,0,0,s)
end

_________________
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


Last edited by Dark Byte on Fri Jan 17, 2020 2:45 pm; edited 2 times in total
Back to top
View user's profile Send private message MSN Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1533

PostPosted: Wed Jan 15, 2020 9:40 am    Post subject: Reply with quote

https://forum.cheatengine.org/viewtopic.php?p=5734347

https://forum.cheatengine.org/viewtopic.php?p=5456691#5456691

and Final:

https://forum.cheatengine.org/viewtopic.php?t=562691

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
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 Visit poster's website MSN Messenger
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Wed Jan 15, 2020 3:49 pm    Post subject: Reply with quote

Interesting. I see my STARS do not render properly in recent CE Shocked
Laughing

_________________
Back to top
View user's profile Send private message MSN Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1533

PostPosted: Thu Jan 16, 2020 1:00 am    Post subject: Reply with quote

mgr.inz.Player wrote:
Interesting. I see my STARS do not render properly in recent CE Shocked
Laughing


Nice work. I tried it first, and when I saw it working, I shared the link.
Please consider processing this work in the "Lua Extensions" section.
It's sad and embarrassing to open the code without permission. Smile

Code:
math.randomseed( tonumber(tostring(os.time()):reverse():sub(1,6)))
form_onClose(UDF1,function ()
                    if animateTimer~=nil then
                       object_destroy(animateTimer)
                       animateTimer = nil
                    end
                    form_hide(UDF1)
                    closeCE()
                    return caFree
                  end)

function ClickedExitButton(x,y)
 if (x>188 and x<267) and (y>233 and y<253)
 then return true
 else return false
 end
end
...
...


Thank you for your coding that makes a difference.

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
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 Visit poster's website MSN Messenger
.lua
Expert Cheater
Reputation: 1

Joined: 13 Sep 2018
Posts: 203

PostPosted: Fri Jan 17, 2020 12:03 am    Post subject: Reply with quote

Dark Byte wrote:
here's an example you can look at (CE 7.0
I want to use wide characters, but it's ignored,
Code:
local s=buildrandomcolorstringRGB('【Hello】-【Word】')
Wide characters are also ignored in d3dhook
Code:
d3dhook_initializeHook()
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Fri Jan 17, 2020 12:37 am    Post subject: Reply with quote

textRect should support mulibyte characters, so the problem is in buildrandomcolorstringRGB

perhaps the lua utf8 table can be used here

_________________
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
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Fri Jan 17, 2020 2:45 pm    Post subject: Reply with quote

I've updated the lua code above so it now supports UTF8
_________________
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
.lua
Expert Cheater
Reputation: 1

Joined: 13 Sep 2018
Posts: 203

PostPosted: Fri Jan 17, 2020 11:07 pm    Post subject: Reply with quote

Dark Byte wrote:
I've updated the lua code above so it now supports UTF8
I've tested it. I can show wide characters.

How to use wide characters in the game screen?
Code:
d3dhook_initializeHook()
if font and fontmap and TextObject then
  font.destroy()
  fontmap.destroy()
  TextObject.destroy()
end
font = createFont()
font.size = 30
font.color=0xff00
fontmap=d3dhook_createFontmap(font)
txt = '【Test】'
TextObject=d3dhook_createTextContainer(fontmap,200,300,txt)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Sat Jan 18, 2020 2:47 am    Post subject: Reply with quote

draw it to a bitmap or png and then show it as a Sprite

fontmaps won't work as they only generate characters for chars 32 to 255

_________________
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
.lua
Expert Cheater
Reputation: 1

Joined: 13 Sep 2018
Posts: 203

PostPosted: Sat Jan 18, 2020 4:01 am    Post subject: Reply with quote

Dark Byte wrote:
draw it to a bitmap or png and then show it as a Sprite

fontmaps won't work as they only generate characters for chars 32 to 255
I've tried to create it as a sprite, but the bitmap or PNG is not a transparent background
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Sat Jan 18, 2020 4:31 am    Post subject: Reply with quote

use createTexture(picture, coloroftransparentbackground)

then set coloroftransparentbackground to a specific color you want as see through

_________________
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
.lua
Expert Cheater
Reputation: 1

Joined: 13 Sep 2018
Posts: 203

PostPosted: Sat Jan 18, 2020 4:35 am    Post subject: Reply with quote

Dark Byte wrote:

then set coloroftransparentbackground to a specific color you want as see through
I want it to look colorless, like an internal image
I set to display wide characters and transparent codes as follows
Code:
createTexture(picture,nil)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Sat Jan 18, 2020 6:01 am    Post subject: Reply with quote

if the background is white with colored text then do createTexture(picture,0xffffff) so only the text remains
_________________
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
.lua
Expert Cheater
Reputation: 1

Joined: 13 Sep 2018
Posts: 203

PostPosted: Sat Jan 18, 2020 7:24 am    Post subject: Reply with quote

Dark Byte wrote:
Without a timer, when the form is minimized and restored, the color text will disappear. What should I do
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 All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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