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 


Memory address value to GUI for flightsim gauge

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Trisolaris
Newbie cheater
Reputation: 0

Joined: 10 Mar 2019
Posts: 20

PostPosted: Sun Mar 10, 2019 10:08 am    Post subject: Memory address value to GUI for flightsim gauge Reply with quote

Hello everyone,
I'm a flight simmer and new to the CE world. I'm blown away by this awesome app. I'd like to use CE to read in-game values that are not displayed to the user, without changing them.

I'd like to build a gui as gauge on top of my flight simulator of choice (let's call it MySim.exe). Think head-up display. My tool of choice would be autohotkey, because that's the only scripting language I use regularly, and because it can do borderless, transparent GUIs that stay on top of my windowed game.

As proof of concept I'd do a turn indicator:

The source value
- I've hunted down the value of interest using CE
- The value is stored as "double value" in the first two "??" of following array of byte (AoB): ?? ?? ?? ?? ?? ?? ?? ?? ?? 31 BD 41 3A 3A C1 3F 28 F3 7B 62 4A 22 D5 BF
- I don't have a pointer, just the AoB shown above
- The value is <0 when turning left and >0 when turning right

What my script should do:
- Grab the value 10-30 times per second
- Convert the value to decimal format
- Round the value to 2 decimals
- Feed the value into one or two gui(s) that display(s) a bar. If the value is 0.00 +/- a tolerance interval of 0.1 no bar should be visible. If the value is positive, the bar should "grow" to the right depending on the value (cutoff at +10.00). If the value is negative, a bar should grow to the left (cutoff value at -10.00)

What's the best way of pulling this off?

Any help with this would be greatly appreciated.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Sun Mar 10, 2019 1:02 pm    Post subject: Reply with quote

creating a transparent form is easiest done by setting AlphaBlend on a form lower than 255, or use form.setLayeredAttributes

first do an aobscan to find the address
then create a timer with interval 33 (30 times a second)
in the OnTimer event of that timer call readDouble(address)
then convert it to a string. easiest is string.format("%.2f",doublevalue)

as for the bar try a progressbar, or else a paintbox or image

_________________
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
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Sun Mar 10, 2019 9:11 pm    Post subject: Reply with quote

Just a basic sample using a progress bar as mouse movement indicator.

Code:
f = createForm()
f.height = 30
f.width = 200
f.position = 'poScreenCenter'
f.caption = 'PB Test'

pb = createProgressBar(f)
pb.left = 0
pb.width = 200
pb.height = 30
pb.Min = 0
pb.Max = 200
pb.Position = 0


z=createTimer(nil)
z.Interval=100
z.OnTimer=function(z)
local x, y = getMousePos()
 if x > 500 then
  pb.Position = pb.Position + 10
  if pb.Position > 200 then pb.Position = 200 end
 else
  pb.Position = pb.Position - 10
  if pb.Position < 0 then pb.Position = 0 end
 end
z.enabled = true
end

function stopResponse()
 z.enabled = false
 z.destroy()
end

f.onClose = stopResponse


If using an image or progressbar itslef as indicator, then better use image width / progressbar width as an indicator instead progressbar position.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Trisolaris
Newbie cheater
Reputation: 0

Joined: 10 Mar 2019
Posts: 20

PostPosted: Mon Mar 11, 2019 1:12 pm    Post subject: Reply with quote

Thanks guys, I've just tested Corroder's bar and it looks promising.

How can I feed in the AoB data instead of a mouse axis?

Can the window be made borderless and always on top?
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Mon Mar 11, 2019 10:24 pm    Post subject: Reply with quote

just an illustration :

- using an image as progress bar (gauge bar)
- the form set to transparent
- the form set always on top

Code:
--- ==================================================== FUNCTIONS & VARIABLES
function exit()
 closeCE()
 return caFree
end

---1. First do an aobscan to find the address
--aob2scan = '?? ?? ?? ?? ?? ?? ?? ?? ?? 31 BD 41 3A 3A C1 3F 28 F3 7B 62 4A 22 D5 BF'
--local memscan = createMemScan(nil)
--memscan.OnlyOneResult = true
--memscan.firstScan(soExactValue, vtByteArray, rtRounded, aob2scan, '', 0, 0x7fffffffffffffff, '+X', fsmNotAligned, '', true, true, false, false)
--memscan.waitTillDone()
--local addr = memscan.Result
--memscan.destroy()
--assert(addr, 'no results found')

---2. then create a timer with interval 33 (30 times a second)
---3. in the OnTimer event of that timer call readDouble(address)
---4. then convert it to a string. easiest is string.format("%.2f",doublevalue)

--function rddbl()
-- dblvalue = readDouble(addr)
-- dblval = string.format("%.2f",dblvalue)
--end

--t1 = createTimer(nil, false)
--t1.Interval = 33
--t1.Enabled = true
--t1.OnTimer = rddbl

--- ==================================================== GUI
f = createForm()
f.BorderStyle = 'bsNone'
f.FormStyle = 'fsSystemStayOnTop'
f.width = 500
f.height = 30
f.Color = '0xFFFFFF'
f.OnMouseDown = function() f.DragNow() end
local LWA_COLORKEY = 1
local LWA_ALPHA = 2
f.setLayeredAttributes(0xFFFFFF, 255, LWA_COLORKEY|LWA_ALPHA)
f.onDoubleClick = exit

ggImg = createImage(f)
ggImg.Width = 10
ggImg.Height = 30
ggImg.Left = 0
ggImg.Top = 0
ggImg.Picture.loadFromStream(findTableFile('pb2.png').Stream)
ggImg.onDoubleClick = exit

--- ==================================================== TESTED P.BAR IMAGE
z=createTimer(nil)
z.Interval=100
z.OnTimer=function(z)
local x, y = getMousePos()
 if x > 500 then
  ggImg.Width = ggImg.Width + 10
  if ggImg.Width > 500 then ggImg.Width = 500 end
 else
  ggImg.Width = ggImg.Width - 10
  if ggImg.Width < 10 then ggImg.Width = 10 end
 end
z.enabled = true
end

function stopResponse()
 z.enabled = false
 z.destroy()
end

f.onClose = stopResponse


NOTE :
replace 'pb2.png' file and filename with your own 'progress bar' image

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
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
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