'Self' returns a Nil value - basic lua question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi guys,
I'm trying to learn a bit more about lua and using the API reference to create some functions in lua. My lua is very basic.
I managed to write a function that will spawn a unit on a keyboard input using this code and script call global in flow:
function SphereSpawn()
unit_sphere = World.spawn_unit(SimpleProject.world, "content/models/BUILDING B1/Sphere")
end
now i want to be able to turn the visibility of this object off. So using the API reference i found "set_unit_visibility".
I then wrote this function:
function SphereVisibility(self)
unit_sphere = self.unit
stingray.unit.set_unit_visiblity(unit_sphere, false)
end
but i keep getting an error saying that 'self' is a nil value. I think i can see why, but just can't get my head around it yet.
Can someone give me some more information about the 'self' side of things and how that is declared?
Thanks!