What
A variable holding a LuaSurface does not point to that unique created surface, but instead seems to point to whichever surface has that specific index. For example if a the variable's surface is destroyed, and a new different surface created later, it might have the same index. And in that case the original variable will point to the newer surface.This can easily be seen using the following commands (on a fresh vanilla save). Create initial surface
Code: Select all
/c foo = game.create_surface("foo")
/c game.print("Foo: "..(foo.valid and foo.name.." "..foo.index or "invalid"))
Now delete the surface
Code: Select all
/c game.delete_surface(foo)
/c game.print("Foo: "..(foo.valid and foo.name.." "..foo.index or "invalid"))
Now for the unintuitive part, create what the modder might believe is a different surface
Code: Select all
/c bar = game.create_surface("bar")
/c game.print("Foo: "..(foo.valid and foo.name.." "..foo.index or "invalid"))