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 


If and else with value

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
lothe23
Advanced Cheater
Reputation: 0

Joined: 28 May 2016
Posts: 51

PostPosted: Wed Jun 22, 2016 1:56 pm    Post subject: If and else with value Reply with quote

I want a function that would so something like this: check if value is 7, if value is 7 change it to 9. if it is 11 instead of 7 or 9 change it to 13, uncheck = set value to 7. I hope i made myself understood, however i dont understand how i could add this into a freezebox function.

This is the code i use for the checkbox right now.

Code:
function CETrainerCheckbox1Change(sender)
  if (CETrainer.CECheckbox1.State==cbChecked)then
writeFloat("[[[[[game.exe+0084E4BC]+38]+184]+480]+cc]+32c", 9)
  else
writeFloat("[[[[[game.exe+0084E4BC]+38]+184]+480]+cc]+32c", 7)
  end
end


all help apprechiated!
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 55

Joined: 01 Oct 2008
Posts: 942

PostPosted: Wed Jun 22, 2016 4:31 pm    Post subject: Reply with quote

Try~
Code:
function CETrainerCheckbox1Change(sender)
  local addr = "[[[[[game.exe+0084E4BC]+38]+184]+480]+cc]+32c"
  local function set(value)writeFloat(addr,value)end
  local function test(value)return value==readFloat(addr)end
  if sender.State==cbChecked then  -- checked action
    if test(7.0) then
      set(9.0)
    elseif test(11.0) then
      set(13.0)
    end
  else -- unchecked action
    set(7.0)
  end
end

_________________
- Retarded.
Back to top
View user's profile Send private message
lothe23
Advanced Cheater
Reputation: 0

Joined: 28 May 2016
Posts: 51

PostPosted: Sat Jun 25, 2016 7:17 am    Post subject: Reply with quote

panraven wrote:
Try~
Code:
function CETrainerCheckbox1Change(sender)
  local addr = "[[[[[game.exe+0084E4BC]+38]+184]+480]+cc]+32c"
  local function set(value)writeFloat(addr,value)end
  local function test(value)return value==readFloat(addr)end
  if sender.State==cbChecked then  -- checked action
    if test(7.0) then
      set(9.0)
    elseif test(11.0) then
      set(13.0)
    end
  else -- unchecked action
    set(7.0)
  end
end


thx
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