From 7c322739715e7661b3fe86045290b7a2156d1b77 Mon Sep 17 00:00:00 2001 From: --global <--global> Date: Sat, 1 Jul 2023 23:15:14 -0400 Subject: [PATCH] Alias Lua random functions to Love2D's --- main.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main.lua b/main.lua index 52fecf9..093a95f 100644 --- a/main.lua +++ b/main.lua @@ -1,5 +1,4 @@ function love.load() - math.randomseed(os.time()) highscores = {} love.graphics.setDefaultFilter("linear", "nearest") require "load.rpc" @@ -24,6 +23,11 @@ function love.load() -- used for screenshots GLOBAL_CANVAS = love.graphics.newCanvas() + -- aliasing to prevent people using math.random by accident + math.random = love.math.random + math.randomseed = love.math.setRandomSeed + math.randomseed(os.time()) + -- init config initConfig() @@ -285,8 +289,8 @@ function love.focus(f) end function love.resize(w, h) - GLOBAL_CANVAS:release() - GLOBAL_CANVAS = love.graphics.newCanvas(w, h) + GLOBAL_CANVAS:release() + GLOBAL_CANVAS = love.graphics.newCanvas(w, h) end local TARGET_FPS = 60