Difference between revisions of "SecondsToSeconds (CMS)"
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" | Type !! style="text-align:left" | By |- | secondsToSeconds(v) || Definition |...") |
m |
||
(One intermediate revision by the same user not shown) | |||
Line 19: | Line 19: | ||
2a. To use this function, create an ''execute a script'' containing... | 2a. To use this function, create an ''execute a script'' containing... | ||
<syntaxhighlight> | <syntaxhighlight> | ||
− | secondsToSeconds(86400) -- will return (00) 0 | + | secondsToSeconds(86400) -- will return (00) 0 seconds, because it's bang on 24 hours; the key word being '''hour'''. |
</syntaxhighlight> | </syntaxhighlight> | ||
2b. Here is an example of how you could use this function... | 2b. Here is an example of how you could use this function... | ||
Line 42: | Line 42: | ||
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width:80%" | Description | ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width:80%" | Description | ||
|- | |- | ||
− | | v || integer || This should be an integer (number) value of the amount of seconds you want to split into the | + | | v || integer || This should be an integer (number) value of the amount of seconds you want to split into the ss time format. |
|}{{toc}} | |}{{toc}} |
Latest revision as of 14:48, 22 February 2015
Name | Type | By |
---|---|---|
secondsToSeconds(v) | Definition | AFRLme |
This small function allows you to quickly convert seconds into the ss time format.
d = day, h = hour, m = minute, s = seconds. |
There are 86400 seconds in a day, 3600 seconds in an hour & 60 seconds in a minute. |
Instructions
1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2a. To use this function, create an execute a script containing...
secondsToSeconds(86400) -- will return (00) 0 seconds, because it's bang on 24 hours; the key word being '''hour'''.
2b. Here is an example of how you could use this function...
Values["seconds"].String = secondsToSeconds(Values["play_time"].ValueInt) -- here we are converting the integer value stored in the integer field of the value into a string time format which can be returned in a displayed text action part using the <vs=value_name> field.
Main Script
function secondsToSeconds(v)
v = math.floor(v % 3600 % 60)
-- + --
if v < 10 then v = tostring("0" .. v) end
-- + --
return tostring( v )
end
Syntax Breakdown
Name | Type | Description |
---|---|---|
v | integer | This should be an integer (number) value of the amount of seconds you want to split into the ss time format. |