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 


Call function from other function: Access violation [Solved]

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

Joined: 20 Jul 2017
Posts: 209

PostPosted: Fri Jan 09, 2026 1:19 pm    Post subject: Call function from other function: Access violation [Solved] Reply with quote

get an idea here: [ https://ibb.co/mFcS5g8z ]

I think this is standard stuff (or so i thought):
1. the main funtion builds a list of items, which get shown in a Listbox
2. that same form offers an option/button to change a particular value in these items; iow 'setLevel()' is called upon clicking this button
3. setLevel: parkours the Listbox, and updates each item's value (this part works fine and dandy)
4. when finished: i'd obviously like to update the listbox visually... which basically means re-run the main script 'CollectInventory()' again
=> since this is a particular list, the choice needs to be passed on as well.

I've also tried: local vs global, and placing subfunction inside main function

Fyi: i do have a workaround; basically getting each line, edit as string and then update the listbox accordingly...
(but above approach should work somehow as well ?!)

Strange thing is: i (vaguely) recall having done this for another game; but just can't remember which one

ps: i'm using CE v7.3 here, but also tried with 7.6 (kinda hoping it would give me a more specific error_definition)


Last edited by paul44 on Sat Jan 10, 2026 2:37 am; edited 1 time in total
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Warning
Reputation: 37

Joined: 16 Feb 2017
Posts: 1538

PostPosted: Fri Jan 09, 2026 5:59 pm    Post subject: Reply with quote

I think the problem seems to be confusing the order in which you use what isn't there.

It's healthier to assign it above and use it in the lines below.

That's the difference between Lua and CE Lua, I guess.

Test these:

Code:
local f = nil
local nChoice = 0
local sListItems
local CollectInventory

function setLevel()



  CollectInventory(2)
end

-- *** main function ***
CollectInventory=function(nFormChoice)
 -- nChoice = nFormChoice or nChoice
--  local addrInventory = getAddress("[pInventory2]")
  if nFormChoice==1 then
    print("I'm here.")
  elseif nFormChoice==2 then
    print("Where am I?")
  else
    print("I'm gone!")


-- (builds a list of items, which get shown in Listbox)

end
--sListItems.endUpdate()
end

nChoice = 1

if (nChoice > 0 and nChoice < 5) then CollectInventory(nChoice) end

setLevel()


If the CollectInventory() function doesn't contain setLevel(), you can use it like this:

Code:
function CollectInventory(nFormChoice) -- Introduce first.
-- ...
end

function setLevel()
-- ...
  CollectInventory(2) -- Then use it.
end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website 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