Welcome to Open Carnage

A resource for gamers and technology enthusiasts, with unique means of rewarding content creation and support. Have a wander to see why we're worth the time!

Weyland

Simple .lua timer

Hi,

 

I'm just looking for an example of a simple .lua timer script to repeat the spawn of a flare (it's a weap tag on @aLTis's Bigass Final map) that would otherwise burn for 30 seconds and then disappear. I currently have it running on event_alive so it respawns every second and it looks clunky as all buggery :D

 

Thank you please.

Share this post


Link to post
Share on other sites

Members of Open Carnage never see off-site ads.

Never scripted in lua before. But here is my take from a lot of googling and some corrections from 002:

 

api_version = "1.10.0.0"

minutes = 0
seconds = 0

function OnScriptLoad()
    timer(1000, "TimerFunction")
end

function TimerFunction()
    seconds = seconds + 1
    if seconds == 60 then
        seconds = 0
        minutes = minutes + 1
    end
    cprint(minutes .. ":" .. string.format("%02d",seconds))
end

You may still want a way to clear the screen so they don't pile up and a way to make the timer appear on the right side of the screen.

Kavawuvi, Weyland and Tucker933 like this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.