GetCurrent
This function gets the current world. The current world is the world used when a new entity is created or loaded from a file.
Syntax
Returns
Returns the current world.
Example
--Create a window
window = Window:Create()
context = Context:Create(window)
myworld = {}
for i=0, 1 do
--Create a world
myworld[i] = World:Create()
--Create a camera
local camera = Camera:Create()
camera:Turn(35,0,0)
camera:Move(0,0,-3)
--Create a directional light
local light = DirectionalLight:Create()
light:SetRotation(35,35,0)
--Create a model
local model = nil
if (i==0) then
model = Model:Box()
else
model = Model:Cylinder()
end
model:SetColor(0.0,0.0,1.0)
end
while true do
if window:Closed() or window:KeyHit(Key.Escape) then return false end
--Press space key to switch between worlds
if (window:KeyHit(Key.Space)) then
if (World:GetCurrent()== myworld[0]) then
World:SetCurrent(myworld[1])
else
World:SetCurrent(myworld[0])
end
end
Time:Update()
World:GetCurrent():Update()
World:GetCurrent():Render()
context:Sync(false)
end