Lua:Tutorial GettingStarted

From Spring
Revision as of 18:03, 14 April 2015 by 8611 (talk | contribs) (edited with better beginner widget)
Jump to navigationJump to search

Development < Lua Scripting < Lua:Tutorial GettingStarted


function widget:GetInfo()
   return {
      name         = "Name as shown in widget list",
      desc         = "",
      author         = "john doe",
      date         = "date",
      license          = "PD",
      layer          = 0,
      experimental   = false,
      enabled          = true
   }
end

local stringOfWords = "BLAH BLAH BLAH"
local toggle

function widget:Initialize()
   Spring.Echo(stringOfWords .. " I STARTED LOOK AT ME JIM!")
end


function widget:Update(frame)
   if(toggle == true) then
      Spring.Echo("TOCK")
      toggle = false
   else
      Spring.Echo("TICK")
      toggle = true
   end
end