Difference between revisions of "Playtime Counter (h2)"
From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "{| class="ts" style="width:100%" |- ! style="text-align:left" | Name !! style="text-align:left;width:10%" | By {{lee_PP}} |- | Playtime Counter (action part, value & lua) || A...") |
|||
Line 67: | Line 67: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | 2. Next you are going to want to create a value somewhere. Name it '''playtime''' & set the default value to '''0'''. | |
− | + | [[File:playtime_counter2_001.png|800px]] | |
− | |||
− | [[File: | ||
Revision as of 22:26, 22 February 2015
Name | By |
---|---|
Playtime Counter (action part, value & lua) | AFRLme |
This tutorial shows you how to create a playtime counter using a single value, some action parts & a few lines of Lua script.
Tutorial
1. Create a new script, inside of the script section of the editor & add the script inside of the code block below into it.
local d, h, m, s -- empty variables which will be used to store converted time values
--* function which converts seconds to days, hours, minutes & seconds * --
function secondsToTime(v)
d = math.floor(v / 86400)
h = math.floor(v % 86400 / 3600)
m = math.floor(v % 3600 / 60)
s = math.floor(v % 3600 % 60)
-- + --
if d < 10 then d = tostring("0" .. d) end
if h < 10 then h = tostring("0" .. h) end
if m < 10 then m = tostring("0" .. m) end
if s < 10 then s = tostring("0" .. s) end
-- + --
return tostring( d .. ":" .. h .. ":" .. m .. ":" .. s )
end
-- * function which converts seconds to days * --
function secondsToDays(v)
v = math.floor(v / 86400)
-- + --
if v < 10 then v = tostring("0" .. v) end
-- + --
return tostring( v )
end
-- * function which converts seconds to hours * --
function secondsToHours(v, b)
if b then v = math.floor(v % 86400 / 3600) else v = math.floor(v / 3600) end
-- + --
if v < 10 then v = tostring("0" .. v) end
-- + --
return tostring( v )
end
-- * function which converts seconds to minutes * --
function secondsToMinutes(v)
v = math.floor(v % 3600 / 60)
-- + --
if v < 10 then v = tostring("0" .. v) end
-- + --
return tostring( v )
end
-- * function which converts seconds to seconds (remainder) * --
function secondsToSeconds(v)
v = math.floor(v % 3600 % 60)
-- + --
if v < 10 then v = tostring("0" .. v) end
-- + --
return tostring( v )
end
2. Next you are going to want to create a value somewhere. Name it playtime & set the default value to 0.
Resources
Name | Description |
---|---|
playtime_counter-2.zip | A working .ved file, complete with resources. Check out the readme.txt file for instructions. |