All pastes #516507 Raw Edit

Someone

public lua v1 · immutable
#516507 ·published 2007-05-28 18:56 UTC
rendered paste body
raiseTable = { "advshading 1", "shadows 1 1024", "water 1", "shadows 1 2048", "water 3", "shadows 4096",   "water 2" }lowerTable = { "advshading 0", "shadows 0",      "water 0", "shadows 1 1024", "water 1", "shadows 1 2048", "water 3" }maxFps = 40minFps = 30function widget:GetInfo()  return {    name      = "FPSManager",    desc      = "fill",    author    = "quantum",    date      = "May 28, 2007",    license   = "GNU GPL, v2 or later",    layer     = 0,    enabled   = false  --  loaded by default?  }endcounter       = 0detailLevel   = 1fpsTable      = {}raisePoints   = 0lowerPoints   = 0  function RaiseDetail()  raisePoints = raisePoints + 1  if detailLevel < 8 and raisePoints > 3 then	--Spring.SendCommands({"echo detail is "..detailLevel..", raising"})    Spring.SendCommands({raiseTable[detailLevel]})    detailLevel = detailLevel + 1	raisePoints = 0  endendfunction LowerDetail()  lowerPoints = lowerPoints + 1  if detailLevel > 1 and lowerPoints > 3 then 	--Spring.SendCommands({"echo detail is "..detailLevel..", lowering"})    Spring.SendCommands({lowerTable[detailLevel - 1]})	detailLevel = detailLevel - 1	lowerPoints = 0  endendfunction widget:Initialize()  Spring.SendCommands({"water 0", "shadows 0", "advshading 0"})endfunction widget:Update(t)  counter  = counter + 1  table.insert(fpsTable, Spring.GetFPS())  if #fpsTable > 30 then    table.remove(fpsTable, 1)  end  if counter % 30 == 0 then    counter = 0	sum = 0	for _, v in ipairs(fpsTable) do	  sum = sum + v	end	average = sum / #fpsTable 	--Spring.SendCommands({"echo average FPS is "..average})	if average > maxFps then RaiseDetail() else raisePoints = 0 end	if average < minFps then LowerDetail() else lowerPoints = 0 end  endend