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 


about active=true and active=false

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
staticfluids
How do I cheat?
Reputation: 0

Joined: 11 Jan 2018
Posts: 4

PostPosted: Thu Jan 11, 2018 9:02 pm    Post subject: about active=true and active=false Reply with quote

Code:
function CEButton1Click(sender)

getAddressList().getMemoryRecordByDescription("ActivateItFirst").Active=true
end

function CEButton2Click(sender)
getAddressList().getMemoryRecordByDescription("Player Training").Active=true
getAddressList().getMemoryRecordByDescription("Remove countdown").Active=true
getAddressList().getMemoryRecordByDescription("More efficient training").Active=true
getAddressList().getMemoryRecordByDescription("Unlimited Training Sessions").Active=true
getAddressList().getMemoryRecordByDescription("Training Everyday").Active=true
getAddressList().getMemoryRecordByDescription("Training sim - A").Active=true

end


the button works only for activating the cheat but i cant disable it, what code should i put in there? i mean how to put active=true and active=false each time i click the button?

sorry guys im new into this. i got interested on how things work in CE trainer.

thanks, have a great day.


Last edited by staticfluids on Thu Jan 11, 2018 9:28 pm; edited 1 time in total
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Thu Jan 11, 2018 9:23 pm    Post subject: Reply with quote

Big Text!
_________________
Back to top
View user's profile Send private message Visit poster's website
staticfluids
How do I cheat?
Reputation: 0

Joined: 11 Jan 2018
Posts: 4

PostPosted: Thu Jan 11, 2018 9:28 pm    Post subject: Reply with quote

TheyCallMeTim13 wrote:
Big Text!


hehehe
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu Jan 11, 2018 11:38 pm    Post subject: Reply with quote

use mr.Active = not mr.Active to toggle it eg

getAddressList().getMemoryRecordByDescription("Training sim - A").Active= not getAddressList().getMemoryRecordByDescription("Training sim - A").Active

though it's better in several ways to do something like

local mr = getAddressList().getMemoryRecordByDescription("Training sim - A")
mr.Active = not mr.Active

And in this case I'd use a table and a loop

Code:
local getmr = getAddressList().getMemoryRecordByDescription -- you can store functions too
local first = getmr("ActivateItFirst")
function CEButton1Click(sender)
  first.Active = not first.Active
end

local button2Mrs = {
  getmr("Player Training"),
  getmr("Remove countdown"),
  getmr("More efficient training"),
  getmr("Unlimited Training Sessions"),
  getmr("Training Everyday"),
  getmr("Training sim - A")
}

function CEButton2Click(sender)
  for index, mr in ipairs(button2Mrs) do
    mr.Active = not mr.Active
  end
end


with a CheckBox or ToggleBox you'd use mr.Active = sender.Checked that way the script state gets synced to the gui state if anything strange happens, so that if one gets changed and the other doesn't then the next click would fix things rather than leaving it such that off is on and on is off Smile
Back to top
View user's profile Send private message
staticfluids
How do I cheat?
Reputation: 0

Joined: 11 Jan 2018
Posts: 4

PostPosted: Fri Jan 12, 2018 12:16 am    Post subject: Reply with quote

FreeER wrote:
use mr.Active = not mr.Active to toggle it eg

getAddressList().getMemoryRecordByDescription("Training sim - A").Active= not getAddressList().getMemoryRecordByDescription("Training sim - A").Active

though it's better in several ways to do something like

local mr = getAddressList().getMemoryRecordByDescription("Training sim - A")
mr.Active = not mr.Active

And in this case I'd use a table and a loop

Code:
local getmr = getAddressList().getMemoryRecordByDescription -- you can store functions too
local first = getmr("ActivateItFirst")
function CEButton1Click(sender)
  first.Active = not first.Active
end

local button2Mrs = {
  getmr("Player Training"),
  getmr("Remove countdown"),
  getmr("More efficient training"),
  getmr("Unlimited Training Sessions"),
  getmr("Training Everyday"),
  getmr("Training sim - A")
}

function CEButton2Click(sender)
  for index, mr in ipairs(button2Mrs) do
    mr.Active = not mr.Active
  end
end


with a CheckBox or ToggleBox you'd use mr.Active = sender.Checked that way the script state gets synced to the gui state if anything strange happens, so that if one gets changed and the other doesn't then the next click would fix things rather than leaving it such that off is on and on is off Smile


sir i just found out the code for the 2nd button has a problem, it doesnt work with the children because when i activate the code, only the "Player Training" is on but the children are off. i forgot to mention that, sorry
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Fri Jan 12, 2018 7:56 am    Post subject: Reply with quote

what exactly is the problem? It should toggle all of them individually, if they are on then they are turned off and vice versa.

If you want them all to have the same state after clicking the button then you'd use a state variable and set them all based on that instead of their own active state, eg.


Code:
local button2MrsActive = false -- start assuming they are disabled
function CEButton2Click(sender)
  button2MrsActive = not button2MrsActive -- toggle logical state
  -- update actual mr states
  for index, mr in ipairs(button2Mrs) do
    mr.Active = button2MrsActive
  end
end
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Fri Jan 12, 2018 8:15 am    Post subject: Reply with quote

One thing to ask is "Will these scripts activate alone?", to insure that they will activate at all.
_________________
Back to top
View user's profile Send private message Visit poster's website
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Fri Jan 12, 2018 8:22 am    Post subject: Reply with quote

TheyCallMeTim13 wrote:
One thing to ask is "Will these scripts activate alone?", to insure that they will activate at all.
Yeah, that's one thing I kind of assumed Smile

If one does depend on another then that may cause issues, making sure it's lower in the list/table than what it depends on should let it enable, disabling may depend on how it actually works (ipairs goes in the same order each time starting at 1, pairs won't but works with non-number indexes, something to remember if you get into using lua more).

And of course if there's one that doesn't enable/disable at all due to a bug in the script then the lua code won't force it to (though there is disableWithoutExecute to force disable a script)
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Fri Jan 12, 2018 8:39 am    Post subject: Reply with quote

I only say that because, I have spent a lot of time debugging Lua code to find it was a misspelled label or some thing simple like that.
_________________
Back to top
View user's profile Send private message Visit poster's website
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Fri Jan 12, 2018 8:41 am    Post subject: Reply with quote

yeah, I imagine we've all had that experience lol
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Fri Jan 12, 2018 8:44 am    Post subject: Reply with quote

You could also use the "autoAssebleCheck" function to check the syntax of AA script from your Lua code.

EDIT:
Note that the "autoAssebleCheck" function is a newly added one, so it's not perfect yet. If you supply even a nil "targetSelf", "enable" is ignored.

_________________
Back to top
View user's profile Send private message Visit poster's website
staticfluids
How do I cheat?
Reputation: 0

Joined: 11 Jan 2018
Posts: 4

PostPosted: Sat Jan 13, 2018 2:18 am    Post subject: Reply with quote

sorry im new into this... i want to make a trainer from that table but not with a hotkey. instead i put the codes into a button, what function or what code should i use... sorry guys.


1515831330434.jpg
 Description:
 Filesize:  109.29 KB
 Viewed:  10493 Time(s)

1515831330434.jpg


Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Sat Jan 13, 2018 8:34 am    Post subject: Reply with quote

To put the code in a button you just need a button and then set the OnClick.
Code:

local format = string.format
local strE = string.empty or STRING_EMPTY or ''
local t = translate

local fW = 400
local row = 0
local lPush = 90
local sX = fW - (lPush + 10)
local sY = 23
local pX = 3
local pY = 3
local bW = 75
local bH = 24
local padF = 5
local pad1 = 3
local pad2 = 1

local frmHookSetup = createForm(false)
frmHookSetup.centerScreen()
frmHookSetup.setSize(fW, fH)
frmHookSetup.Name = 'frmHookSetup'
frmHookSetup.Caption = t('Hook Setup')

local lblHookName = createLabel(frmHookSetup)
lblHookName.Name = 'lblHookName'
lblHookName.setPosition(pX, pY + sY * row + pad1)
lblHookName.Caption = t('Hook Name') .. ':'
local edHookName = createEdit(frmHookSetup)
edHookName.Name = 'edHookName'
edHookName.setSize(sX, sY)
edHookName.setPosition(pX + lPush, pY + sY * row + pad2)
edHookName.Text = ''

row = row + 1
local lblHookAddress = createLabel(frmHookSetup)
lblHookAddress.Name = 'lblHookAddress'
lblHookAddress.setPosition(pX, pY + sY * row + pad1)
lblHookAddress.Caption = t('Address') .. ':'
local edHookAddress = createEdit(frmHookSetup)
edHookAddress.Name ='edHookAddress'
edHookAddress.setSize(sX, sY)
edHookAddress.setPosition(pX + lPush, pY + sY * row + pad2)
edHookAddress.Text = ''

row = row + 1
local btnOk = createButton(frmHookSetup)
btnOk.Name = 'btnOk'
btnOk.Caption = t('OK')
btnOk.setSize(bW, bH)
btnOk.setPosition((fW / 3) - (bW / 2), pY + sY * row + pad2)
btnOk.Default = true
local btnCancel = createButton(frmHookSetup)
btnCancel.Name = 'btnCancel'
btnCancel.Caption = t('Cancel')
btnCancel.setSize(bW, bH)
btnCancel.setPosition(((fW / 3) * 2) - (bW / 2), pY + sY * row + pad2)
btnCancel.Cancel = true

row = row + 1
frmHookSetup.setSize(fW, pY + sY * row + padF)

btnOk.OnClick = function() print('I have the power!') end ---- Setting to OnClick for the OK Button.
function CancelOnClick()
  frmHookSetup.close()
end
btnCancel.OnClick = CancelOnClick ---- Setting the OnClick for the Cancel Button.
frmHookSetup.show()


To use AA scripts just look in to the "autoAssemble" function.

_________________
Back to top
View user's profile Send private message Visit poster's website
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