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 


writeBytes line
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
mgr.inz.Player
I post too much
Reputation: 222

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

PostPosted: Sun Apr 07, 2013 5:08 pm    Post subject: Reply with quote

First thing first. We have to find out what doesn't work.

My code above is not a solution. Just try if this work:
1. launch CE
2. paste LUA code, nothing more
(I forgot to remove "form_show(UDF2)" thing, don't paste that)

3. attach CE
4. execute script

If it work, we can go step further.


Note: above code was quick copy&paste&edit, I didn't even changed onTimer function name.

_________________
Back to top
View user's profile Send private message MSN Messenger
iroku
Advanced Cheater
Reputation: 0

Joined: 18 Oct 2012
Posts: 54

PostPosted: Sun Apr 07, 2013 5:44 pm    Post subject: Reply with quote

no, no. What I was trying to say was that I dont really understand your code. So it would take me time to even try to write it. I wanted to understand what it actually said first. And that meant i would have to go do some searching for new words and such. It would take time until i could verify if it worked or not.

When i kindda understood what the code was saying and finally wrote it to CE(with a few changes) the code worked!

it did work! in a way lol :p ! so ty !
check last page msg
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

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

PostPosted: Sun Apr 07, 2013 6:07 pm    Post subject: Reply with quote

well, if this code works for you...

Just upload what you have got here as post attachment. So I could change/edit this to more readable Lua code.
And I'll add few comments.

Little question, this "timer value", is this regular 4 bytes integer value? Or 2bytes integer value. Or maybe 1 byte integer value?


Edit:
your last script is weird too, this is proper one (I assume this "timer value" is 4byte integer):

Code:
function CECheckbox3Click(sender)

  local enabledOrDisabled = ( checkbox_getState(sender)==1 )
  -- checkbox_getState(sender)    will be 0 if unticked, 1 if ticked
  -- checkbox_getState(sender)==1 will give us false if unticked, true if ticked
  -- enabledOrDisabled will be true or false

  timer_setEnabled(t, enabledOrDisabled)  -- enable or disable timer


  -- or you can use only this line (uncomment it)
  -- timer_setEnabled(t, checkbox_getState(sender)==1)
end

function myOntimerFunction()
  local timer_value = readInteger("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128")

  if timer_value==nil then return end -- needed if pointer not always points to
                                      -- readable address memory


  if timer_value <= 99 then
    writeInteger("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128",99)
  end
end

if t~=nil then object_destroy(t);t=nil;end -- better always destroy previously created object
                                           -- (of course if such object exist)

t = createTimer(nil,false)
timer_onTimer(t, myOntimerFunction)
timer_setInterval(t,300)




Paste above code to cheatengine lua script editor, because we don't have syntax highlighting here (on forum)


Edit2:
there is doc file named main.lua inside CheatEngine directory. (C:\Program Files\Cheat Engine 6)

_________________
Back to top
View user's profile Send private message MSN Messenger
iroku
Advanced Cheater
Reputation: 0

Joined: 18 Oct 2012
Posts: 54

PostPosted: Mon Apr 08, 2013 2:10 pm    Post subject: Reply with quote

mgr.inz.Player wrote:
well, if this code works for you...

Just upload what you have got here as post attachment. So I could change/edit this to more readable Lua code.
And I'll add few comments.

Little question, this "timer value", is this regular 4 bytes integer value? Or 2bytes integer value. Or maybe 1 byte integer value?


Edit:
your last script is weird too, this is proper one (I assume this "timer value" is 4byte integer):



i attached the curret script. works and looks clean.

1 thing tho.
i now have:

Code:
local timer_value = readBytes


and before i just had:

Code:
timer_value = readBytes


before i coudnt use the local pref (error access bla bla)
but now, i HAD to add local pref. i was getting access error as well.. weird. im not understanding the local too well i guess.

Readinteger is still a no, no.

i think the adress has floating values but its set at 4 byte type.
thing is
the pointer shows me this 4 byte integer number,
and if i search the adress mannually if gives me 99 decimal value...

so i dont know how to answer your quention but that might help..



ongoing1.CT
 Description:

Download
 Filename:  ongoing1.CT
 Filesize:  3.32 KB
 Downloaded:  586 Time(s)

Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

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

PostPosted: Mon Apr 08, 2013 4:38 pm    Post subject: Reply with quote

Code:
form_show(UDF2)

function CECheckbox3Click(sender)
  local enabledOrDisabled = (checkbox_getState(sender)==1)
  timer_setEnabled(t, enabledOrDisabled)
end

function myONtimerFunc()

  -- readBytes(address,bytecount, ReturnAsTable ) : returns the bytes at the given address.
  -- If ReturnAsTable is true it will return a table instead of multiple bytes

 local timer_value = readBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128",1,false)

  if timer_value <= 99 then
    writeBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 99)
  end

end


if t~=nil then object_destroy(t);t=nil;end
t = createTimer(nil,false)
timer_onTimer(t, myONtimerFunc)
timer_setInterval(t,300)




Note:
about local: http://www.lua.org/pil/4.2.html


Btw. official CE6.2 has bugged writeBytes(address,table). If you want to use writeBytes(address,table) then look for more recent CheatEngine build - CE6.2+

_________________


Last edited by mgr.inz.Player on Mon Apr 08, 2013 4:51 pm; edited 2 times in total
Back to top
View user's profile Send private message MSN Messenger
iroku
Advanced Cheater
Reputation: 0

Joined: 18 Oct 2012
Posts: 54

PostPosted: Mon Apr 08, 2013 4:48 pm    Post subject: Reply with quote

where is the bug ? did you mean readinteger?
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 Previous  1, 2
Page 2 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