ゲーム時間取得

ゲーム時間取得

Spawn Checkerで使ったコードのメモです。
引数に「os.time()」での値を入れてあげるとゲーム時間の「月」、「日」が取得できます。

function get_game_time_m(now)
    -- 変数の局所化
    local time_differenc;
    local gtm;

    time_difference = now -- 1323788460;
    gtm = math.floor(time_difference / 223200);
    gtm = math.floor(gtm % 12);
    gtm = gtm + 1;

    return gtm;
end

function get_game_time_d(now)
    --- 変数の局所化
    local time_differenc;
    local gtd;

    time_difference = now -- 1323788460;
    gtd = math.floor(time_difference / 7200);
    gtd = math.floor(gtd % 31);
    gtd = gtd + 1;

    return gtd;
end

Profile

Kazuki Hayashi

I'm a full stack engineer.
I love programming and alcohol.