I have an object defined as global in my main.lua, in my library.lua I have defined a global function called doSomthing(). In the main.lua I’m trying to change the property of that object but for some reason I always get the following error:-
Attempt to set the value of ‘myobject’ a nil value.
I don’t think you’ve explained that right. You’ve said your object is in main.lua and you’re trying to change it in main.lua
Anyway it’s only global if you use the global _G
ie _G.something = “whatever”
Otherwise you’ll probably need to pass a reference to main into library eg library.root = self (in main, if this doesn’t work use a setter function eg setRoot), then root.myMainObject = “whatever” in your library function [import]uid: 6645 topic_id: 3866 reply_id: 12049[/import]
Im sorry, but what i meant is the variable i want to access is inside my library.lua.
I didnt understand what u’ve explained with regard to a setter function. Would u give me a brief example so i can understand properly
also you need to define your problem more clearly. where is your object defined. where are you trying to access it and what are you trying to do to it?