Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Starfall v
« Previous 1 … 12 13 14 15 16 … 18 Next »
Release Screensaver for starfall screens[level easy]
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode
Release Screensaver for starfall screens[level easy]
22-07-2015, 10:18 PM, (This post was last modified: 22-07-2015, 10:48 PM by LocInt.)
#1
LocInt Offline
Long gone
****
Posts: 489
Threads: 91
Joined: Aug 2014
Screensaver for starfall screens[level easy]
Hello,

Im releasing my screensaver code for starfall screens.

Level of this tutorial is quite advanced.

It's purpose is to turn on screensaver if your quota is about to hit its limit.

Like if your quota percent suddenly pop from 1% to 95% it turns on the screensaver. Usually if you create something player related then more players->more quota which is why your screens hits the limit. It has also idle screensaver in case its not used for 60 seconds.

In case your screen is using use(ply) function for touchscreen you might want to write these lines inside that function therefore it does not turn on the idle screensaver if you're using the screen. It still will turn it on if your quota is about to hits it limit.
Code:
timer.remove("ScreenSaver") ScreenSaver=false timer.create( "ScreenSaver", 60, 1, function() ScreenSaver=true Keyboard=false end)

Next thing is to place these lines to the section you render your screen. We calculate if your quota is about to hits its limit.

Code:
if(math.round(cpuAverage()/cpuMax()*100, 2)>98 or cpuAverage()>5500) then hook.remove("net", "yournethook") hook.remove("render", "yourrenderhook") Hooks=false ScreenSaver=true end

Also if you want to make something else than a black screen when you turn on screensaver you might want to add these lines after that last statement. Im not deciding what text or background does your screensaver has therefore i let it up to you.

I would propably add buttons for all your tabs in case you want to see your tabs. You can disable the screensaver just by using the screen again as we stated before.
Code:
if(ScreenSaver) then end

We need a timer therefore we can return the hooks and you can begin rendering again.

Code:
timer.create( "ScreenSaverCheck", 1, 0, function() if(not ScreenSaver) then if(not Hooks) then hook( "net", "yournethook", receiveMessage) hook( "render", "yourrenderhook", renderScreen) Hooks=true end end end )

You might also wanna initialize the variables we used on this tutorial.

Code:
local Hooks=false local ScreenSaver=true

Thanks for reading!

Regards,

LocInt

тѕсм.Person8880 hovers the nerf bat over Tetryon damage
Website Find
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
Forum Jump:


Users browsing this thread: 1 Guest(s)
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.