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 


return values are not printed in lua engine

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

Joined: 27 Dec 2013
Posts: 15

PostPosted: Mon Oct 14, 2024 6:35 pm    Post subject: return values are not printed in lua engine Reply with quote

My testing code:
Code:

function test12(a, b)
a12 = a == b
    return a12
end
print(a12)
print(test12(1,2))
print(test12(2,2))
test12(1,2)
test12(2,2)

this doesnt print anything

And this is the bigger code:
Code:

[ENABLE]
{$lua}
local startTime = os.clock()
local gameWindowTitle = "Core Keeper" -- Replace with the actual game window title

-- Get the handle of the game window using the window title
function getGameWindowHandle()
    return findWindow(nil, gameWindowTitle)
end

function isGameWindowFocused()
     gameWindow = getGameWindowHandle()
     focusedWindow = getForegroundWindow()
    boolw= gameWindow == focusedWindow
    print(gameWindow ,focusedWindow)
    a1 = gameWindow == focusedWindow
    if a1==nil then
print("a1 is nil :"..a1)
end
    return gameWindow == focusedWindow
end
function test12(a, b)
a12 = a == b
    return a12
end
print(a12)
print(test12(1,2))
print(test12(2,2))
test12(1,2)
test12(2,2)
function fishing ()

  if gameWindow == nil then
        print("Game Window Handle is nil")
    else
        print("Game Window Handle:", gameWindow)
    end

    if focusedWindow == nil then
        print("Focused Window Handle is nil")
    else
        print("Focused Window Handle:", focusedWindow)
    end
   printf("fishing")
   local bite = readShortInteger("[bitestart]")

print("Is Game Window Focused?", isFocused)
print("b=",bite,"isfocused:",isGameWindowFocused())
   if bite ~= nil and bite==0 and isGameWindowFocused()
   printf(bite)
     writeShortInteger("bitestart",1)
      -- Send the right mouse button down message (WM_RBUTTONDOWN) to the window
  sendMessage(hwnd, 0x0204, 0x0002, 0) -- 0x0204 = WM_RBUTTONDOWN
  printf("RB down")
  -- Optionally, add a small delay
  sleep(500) -- 100 milliseconds delay

  -- Send the right mouse button up message (WM_RBUTTONUP) to the window
  sendMessage(hwnd, 0x0205, 0x0002, 0) -- 0x0205 = WM_RBUTTONUP
  printf("RB up")
  writeShortInteger("bitestart",1)
   end
   local elapsedTime = os.clock() - startTime
print("Fishing operation took", elapsedTime, "seconds")
end

-- your existing fishing logic

tf=createTimer(nil)
timer_setInterval(tf, 500)
timer_onTimer(tf, fishing)
timer_setEnabled(tf, true)
{$asm}
[DISABLE]
{$lua}
timer_setEnabled(tf, false)
which prints nothing, "b=" and"isfocused:" print nothing after b and is focused , it does print the window handles I can even see that they match. also,bite/bitestart is 1 or 0.
Basically the sendMessage section is not executed ever.
Excuse my noobiness.
Back to top
View user's profile Send private message Send e-mail
ParkourPenguin
I post too much
Reputation: 150

Joined: 06 Jul 2014
Posts: 4656

PostPosted: Mon Oct 14, 2024 11:54 pm    Post subject: Reply with quote

`print` won't call `tostring` automatically for some things- i.e. booleans
Code:
print(false) -- blank line
print(tostring(false)) -- prints "false"

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
theo1996
Newbie cheater
Reputation: 0

Joined: 27 Dec 2013
Posts: 15

PostPosted: Tue Oct 15, 2024 4:56 pm    Post subject: Reply with quote

Thanks, it prints now.
The next issue is that I use sendmessage for a RB mouse click and it doesnt do anything even though the game is in foreground. I have read about postMessage but I think it doesnt exists in CELua. I saw I need to import it somehow from a wind.ows dll. I t would be even better if it could send a RB click to a background window/game.
Back to top
View user's profile Send private message Send e-mail
theo1996
Newbie cheater
Reputation: 0

Joined: 27 Dec 2013
Posts: 15

PostPosted: Thu Oct 17, 2024 12:11 pm    Post subject: Reply with quote

APPARENTLY THE DIARRHEA DOGSHIT THAT IS UNITY DOESN'T USE WINDOWS APIs for input but its own hardware input functions.
Back to top
View user's profile Send private message Send e-mail
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