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 


Hotkey register error

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

Joined: 04 Dec 2011
Posts: 27

PostPosted: Sat Mar 05, 2016 10:30 pm    Post subject: Hotkey register error Reply with quote

Code:

createHotkey(bossHP,VK_NUMPAD1)
function bossHP()
  ms=createMemScan()
  memscan_firstScan(ms, soExactValue, vtQword, rtRounded, 2660989938529320, "", 0x0000000000200000, 0x7fffffffffffffff, "", fsmAligned, 4, false, false, false, true) --change the last true to false if you do not wish case sensitivity
  memscan_waitTillDone(ms)
  --get the result of the scans
  fl=createFoundList(ms)
  foundlist_initialize(fl)
  local count=foundlist_getCount(fl)

  if (count>0) then
    --local saddress=foundlist_getAddress(fl, 0) --get the first address
    --writeQword(saddress, 1)
    for i = 0, count -1 do
        local saddress=foundlist_getAddress(fl, i)
        writeQword(saddress, 1)
    end
  else
  end
  object_destroy(fl)
  object_destroy(ms)
end


debug is "Error:attempt to call a nil value"

if not register hotkey = no error

why print error message?
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Mar 05, 2016 11:11 pm    Post subject: Reply with quote

Follow the directions in your other post?
Back to top
View user's profile Send private message
gamjadory
Cheater
Reputation: 0

Joined: 04 Dec 2011
Posts: 27

PostPosted: Sun Mar 06, 2016 5:58 am    Post subject: Reply with quote

Zanzer wrote:
Follow the directions in your other post?


Kinky do not want as answers.

If I did not bother to reply to my post.

Be just do not like, Pass. OK?
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 Mar 06, 2016 6:32 am    Post subject: Reply with quote

Code:
function bossHP()
  ms=createMemScan()
  memscan_firstScan(ms, soExactValue, vtQword, rtRounded, 2660989938529320, "", 0x0000000000200000, 0x7fffffffffffffff, "", fsmAligned, 4, false, false, false, true) --change the last true to false if you do not wish case sensitivity
  memscan_waitTillDone(ms)
  --get the result of the scans
  fl=createFoundList(ms)
  foundlist_initialize(fl)
  local count=foundlist_getCount(fl)

  if (count>0) then
    --local saddress=foundlist_getAddress(fl, 0) --get the first address
    --writeQword(saddress, 1)
    for i = 0, count -1 do
        local saddress=foundlist_getAddress(fl, i)
        writeQword(saddress, 1)
    end
  else
  end
  object_destroy(fl)
  object_destroy(ms)
end

createHotkey(bossHP,VK_NUMPAD1)



or
Code:
createHotkey("bossHP" , VK_NUMPAD1)

function bossHP()
  ms=createMemScan()
  memscan_firstScan(ms, soExactValue, vtQword, rtRounded, 2660989938529320, "", 0x0000000000200000, 0x7fffffffffffffff, "", fsmAligned, 4, false, false, false, true) --change the last true to false if you do not wish case sensitivity
  memscan_waitTillDone(ms)
  --get the result of the scans
  fl=createFoundList(ms)
  foundlist_initialize(fl)
  local count=foundlist_getCount(fl)

  if (count>0) then
    --local saddress=foundlist_getAddress(fl, 0) --get the first address
    --writeQword(saddress, 1)
    for i = 0, count -1 do
        local saddress=foundlist_getAddress(fl, i)
        writeQword(saddress, 1)
    end
  else
  end
  object_destroy(fl)
  object_destroy(ms)
end


or
Code:
createHotkey(function ()
  ms=createMemScan()
  memscan_firstScan(ms, soExactValue, vtQword, rtRounded, 2660989938529320, "", 0x0000000000200000, 0x7fffffffffffffff, "", fsmAligned, 4, false, false, false, true) --change the last true to false if you do not wish case sensitivity
  memscan_waitTillDone(ms)
  --get the result of the scans
  fl=createFoundList(ms)
  foundlist_initialize(fl)
  local count=foundlist_getCount(fl)

  if (count>0) then
    --local saddress=foundlist_getAddress(fl, 0) --get the first address
    --writeQword(saddress, 1)
    for i = 0, count -1 do
        local saddress=foundlist_getAddress(fl, i)
        writeQword(saddress, 1)
    end
  else
  end
  object_destroy(fl)
  object_destroy(ms)
end ,VK_NUMPAD1)





Note:
Executing your script few times will create few objects with the same key combination - you press NUMPAD1 once and function is executed few times.

It is better to keep those objects in Lua variables. That is:
Code:
variable = createHotkey(func, VK_NUMPAD1)


And check if it already exist, so:
Code:
if variable==nil then variable = createHotkey(func, VK_NUMPAD1) end




Summary:
Code:
function bossHP()
  ms=createMemScan()
  memscan_firstScan(ms, soExactValue, vtQword, rtRounded, 2660989938529320, "", 0x0000000000200000, 0x7fffffffffffffff, "", fsmAligned, 4, false, false, false, true) --change the last true to false if you do not wish case sensitivity
  memscan_waitTillDone(ms)
  --get the result of the scans
  fl=createFoundList(ms)
  foundlist_initialize(fl)
  local count=foundlist_getCount(fl)

  if (count>0) then
    --local saddress=foundlist_getAddress(fl, 0) --get the first address
    --writeQword(saddress, 1)
    for i = 0, count -1 do
        local saddress=foundlist_getAddress(fl, i)
        writeQword(saddress, 1)
    end
  else
  end
  object_destroy(fl)
  object_destroy(ms)
end

if bossHPhotkey==nil then bossHPhotkey = createHotkey(bossHP,VK_NUMPAD1) end

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