Jump to content

Lua Syntax Highlighting


Josh
 Share

Recommended Posts

Use the "lua" forum tag for Lua syntax highlighting:

 

--[[------------------------------------------------------------

 

This is a block of comments

You can have multiple lines of comments

Pretty neat, huh?

 

------------------------------------------------------------]]--

 

--This function will be called once when the program starts

function App:Start()

 

--Set the application title

self.title="Darkness Awaits"

 

--Create settings table and add defaults

self.settings={}

self.settings.vsync=true

 

--Load the user's settings

self:LoadSettings()

 

--Create a window

self.window=Window:Create(self.title,0,0,1024,768,Window.Titlebar)

 

--Create the graphics context

self.context=Context:Create(self.window,0)

if self.context==nil then return false end

 

--Create a world

self.world=World:Create()

 

--Create a camera

self.camera = Camera:Create()

self.camera:SetPosition(0,5,-10)

 

--Load a test scene

Scene:Load("Scenes\\trash.scene")

 

return true

end

 

--This is our main program loop and will be called continuously until the program ends

function App:Continue()

 

--If window has been closed, end the program

if self.window:Closed() then

return false

end

 

--If escape key has been pressed, end the program

if self.window:KeyHit(KeyCode.Escape) then

return false

end

 

--Update the world

self.world:Update()

 

--Render the world

self.world:Render()

 

--Refresh the screen

self.context:Swap(self.settings.vsync)

 

--Returning true tells the main program to keep looping

return true

end

 

function App:Pause()

--Pause time updating

Time:Pause()

end

 

function App:Resume()

--Resume time updating

Time:Resume()

end

 

function App:Finish()

--Save user settings to a file

self:SaveSettings()

end

 

--Load user settings from a file (not yet implemented)

function App:LoadSettings()

return true

end

 

--Save user settings to a file (not yet implemented)

function App:SaveSettings()

return true

end

  • Upvote 2

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • 2 weeks later...

This is what the code block does:

--This function will be called once when the program starts
function App:Start()

       --Set the application title
       self.title="Darkness Awaits"

       --Create settings table and add defaults
       self.settings={}
       self.settings.vsync=true

       --Load the user's settings
       self:LoadSettings()

       --Create a window
       self.window=Window:Create(self.title,0,0,1024,768,Window.Titlebar)

       --Create the graphics context
       self.context=Context:Create(self.window,0)
       if self.context==nil then return false end

       --Create a world
       self.world=World:Create()

       --Create a camera
       self.camera = Camera:Create()
       self.camera:SetPosition(0,5,-10)

       --Load a test scene
       Scene:Load("Scenes\\trash.scene")

       return true
end

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...