|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
alphanote2 How do I cheat? Reputation: 0
Joined: 23 Sep 2014 Posts: 6
|
Posted: Wed Oct 01, 2014 5:42 pm Post subject: Progress bar into LUA script |
|
|
I have no clue of how to make a progress bar go up until it finishes then disappears.
like I click a button then after one something I call the function;
Code: | UpdateProgressBar(#,max) |
Where # is what part of the max is.
#max is how many #'s is possible. (max)
PLEASE. FOR. THE. LOVE. OF. GOD. HELP. ME.
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Wed Oct 01, 2014 6:01 pm Post subject: |
|
|
Progressbar.Max is the maximum possible
Progressbar.Position is the current position
I recommend setting the Max to 100, and set the Position to a percentage
Code: |
ProgressBar Class: (Inheritance: WinControl->Control->Component->Object)
createProgressBar(owner): Creates a ProgressBar class object which belongs to the given owner. Owner can be any object inherited from WinControl
properties
Min: integer - The minimum positionvalue the progressbar can have (default 0)
Max: integer - The maximum positionvalue the progressbar can have (default 100
Position: integer - The position of the progressbar
Step: integer- The stepsize to step by when stepIt() is called
methods
stepIt() - Increase position with "Step" size
stepBy(integer) - increase the position by the given integer value
|
_________________
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 |
|
|
alphanote2 How do I cheat? Reputation: 0
Joined: 23 Sep 2014 Posts: 6
|
Posted: Wed Oct 01, 2014 6:40 pm Post subject: |
|
|
but I need a Function
|
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 54
Joined: 01 Oct 2008 Posts: 941
|
Posted: Thu Oct 02, 2014 1:40 am Post subject: |
|
|
I do not understand how to synchronize the displaying of the bar and the setting of the bar position value.
I expected that the processMessages() will stop lua execution until ui updated their view, but it is not in this case.
So I use sleep(), but it need a high sleep value for the ui view to _catch up_ the value change.
-- updated: using stepIt() instead of only setting Position value, seems trigger the Bar display update.
Code: | local function tmerge(dst,src,inplace) -- short hand for control setting
local inplace = inplace or true
local t = inplace and dst or {}
if not inplace then for k,v in pairs(dst) do t[k] = v end end
for k,v in pairs(src) do t[k] = v end
if not inplace then return t end
end
local function UpdPB(pmax,pmin,title,hidedelay)
local title,hidedelay = title or 'Progressing...',hidedelay or 3000 -- in msec, 3sec
local pmin,pmax = pmin or 0, pmax or 100
local PF = createForm(false)
tmerge(PF,{Height=50,Width=120,Position='poOwnerFormCenter',Caption=title,BorderStyle='bsToolWindow',FormStyle='fsStayOnTop'})
local PB = createProgressBar(PF)
local b = 6 --border
tmerge(PB,{Top=b,Left=b,Height=PF.Height-2*b,Width=PF.Width-2*b,Min=pmin,Max=pmax,Position=pmax,Step=1})
PF.show()
-- print(PB.Min,PB.Max) -- debug print
return function (p,hide)
if p == nil then p = pmax*2 ; hide = true end
if p ~= PB.Position then
PB.Position = math.floor(p) - 1
PB.stepIt()--
-- processMessages() -- removed / PB) -- need for real time update?
sleep(1) -- seems sleep longer let later Position change show
end
if hide == true then coroutine.resume(coroutine.create(function() sleep(hidedelay) ; PF.hide() end)) end
if hide == false then PF.show() end
return p
end
end
-- for test
local a,upd = 1,UpdPB(100,0) -- each UpdPB call create new form and progress bar
for i=1,100 do
for j=1,300000 do a = a > 1000 and 1 or a + a end
upd(i)
end
--upd() -- hide
upd(200,false) -- show again
for i=100,1,-1 do
for j=1,300000 do a = a > 1000 and 1 or a + a end
upd(i)
end
upd() -- no parameter to hide form
|
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Thu Oct 02, 2014 4:44 am Post subject: |
|
|
Can you describe your exact issue? Because the script you posted does update the progressbar as expected (even without stepIt() )
If you mean it's 'flowing' to the current position instead of doing it instantly that's thanks to the windows theme. Disable themes for an exact progressbar.
Anyhow if for some reason your gui isn't updating anymore (since the gui can't handle messages while your lua loop is running) then force a gui update using the Control class's update() or repaint() method
e.g: instead of PB.stepIt() call PB.update() (or PF.update() to update the whole form)
_________________
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 |
|
|
panraven Grandmaster Cheater Reputation: 54
Joined: 01 Oct 2008 Posts: 941
|
Posted: Thu Oct 02, 2014 7:47 am Post subject: |
|
|
Dark Byte wrote: | Can you describe your exact issue? Because the script you posted does update the progressbar as expected (even without stepIt() )
If you mean it's 'flowing' to the current position instead of doing it instantly that's thanks to the windows theme. Disable themes for an exact progressbar.
Anyhow if for some reason your gui isn't updating anymore (since the gui can't handle messages while your lua loop is running) then force a gui update using the Control class's update() or repaint() method
e.g: instead of PB.stepIt() call PB.update() (or PF.update() to update the whole form) |
Thanks, I didn't find update() before.
But problem still exist.
I added an update()/repaint() after setting PB.Position.
By removing the last test loop, but calling the form to hide, it can be seen that the bar prematurely stop updating the view. Even I call repaint the form before hiding.
ie. PF.repaint() ; sleep(hidedelay) ; PF.hide()
However, if not calling the form to hide, it displayed as expected.
-- updated, just test in an XP, yes, it worked as expected with the hide function.
may be the op can consider to place the progress bar on the main form and let it always show. It will be much simple by just setting the bar's position. The Progress Bar default Min, Max is 0, 100, op can scale the position like this:
UpdateProgressBar(p,max) -- assume minimum p is zero
PB.Position = p / max * (PB.Max - PB.Min)
end
=== Updated ===
It turn out I'm misunderstood sleep and coroutine, this version should work fine:
Code: |
local function killTimer(t) if t and t.setEnabled then t.setEnabled(false); t.destroy() ; end t = nil end
local function setTimeout(s,f,...)
local t,p = createTimer(),table.pack(...)
t.setInterval(s)
t.setOnTimer(function()
killTimer(t)
f(unpack(p))
end)
t.setEnabled(true)
return t
end
local function tmerge(dst,src,inplace) -- short hand for control setting
local inplace = inplace or true
local t = inplace and dst or {}
if not inplace then for k,v in pairs(dst) do t[k] = v end end
for k,v in pairs(src) do t[k] = v end
return t
end
local function UpdPB(pmax,pmin,title,hidedelay)
local title,hidedelay = title or 'Progressing...',hidedelay or 3000 -- in msec, 3sec
local pmin,pmax = pmin or 0, pmax or 100
local PF,timer = createForm(false),nil
tmerge(PF,{Height=50,Width=120,Position='poOwnerFormCenter',Caption=title,BorderStyle='bsToolWindow',FormStyle='fsStayOnTop'})
local PB = createProgressBar(PF)
local b = 6 --border
tmerge(PB,{Top=b,Left=b,Height=PF.Height-2*b,Width=PF.Width-2*b,Min=pmin,Max=pmax,Position=pmax,Step=1,BarShowText=true})
PF.show()
return function (p,hide)
if p == nil then p = pmax*2 ; hide = true end
if p ~= PB.Position then PB.Position = p end
if hide == true then timer = setTimeout(hidedelay,PF.hide) end
if hide == false then if timer and timer.getEnabled and timer.getEnabled() then killTimer(timer); end PF.show() end
return p
end
end
-- for test
local a,upd = 1,UpdPB(100,0) -- each UpdPB call create new form and progress bar
for i=1,100 do
for j=1,1000 do a = a > 1000 and 1 or a + a end
upd(i)
end
upd() -- no parameter to hide form
setTimeout(5000,upd,59,false) -- show again |
|
|
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
|
|