diff --git a/docs/changes.md b/docs/changes.md index 98d1588..7f74315 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -61,6 +61,18 @@ Table of contents # Update 16.0.0 - Connecting the dots Added --- +- THREAD.setENV(table) -- Set a simple table that will be merged into the global namespace + + **Note:** To maintain compatibility between each integration use simple tables. No self references, and string indices only + ```lua + THREAD.setENV({ + shared_function = function() + print("I am shared!") + end + }) + ``` + When this function is used it writes to a special variable that is read at thread spawn time. If this function is then ran later it can be used to set a different env and be applied to future spawned threads. +- THREAD.getENV() can be used to manage advanced uses of the setENV() functionality - Connection objects now support the % function. This supports a function % connection object. What it does is allow you to **mod**ify the incoming arguments of a connection event. ```lua local conn1 = multi:newConnection() diff --git a/integration/lanesManager/threads.lua b/integration/lanesManager/threads.lua index eadbf80..5a91813 100644 --- a/integration/lanesManager/threads.lua +++ b/integration/lanesManager/threads.lua @@ -139,6 +139,10 @@ local function INIT(__GlobalLinda, __SleepingLinda, __StatusLinda, __Console) GLOBAL["__env"] = env end + function THREAD.getENV() + return GLOBAL["__env"] + end + return GLOBAL, THREAD end diff --git a/integration/loveManager/threads.lua b/integration/loveManager/threads.lua index 354f46e..250b2ec 100644 --- a/integration/loveManager/threads.lua +++ b/integration/loveManager/threads.lua @@ -171,6 +171,10 @@ function threads.setENV(env) (threads.getGlobal())["__env"] = threads.packENV(env) end +function threads.getENV() + return threads.unpackENV((threads.getGlobal())["__env"]) +end + function threads.createTable(n) local _proxy = {} local function set(name,val) diff --git a/integration/pseudoManager/threads.lua b/integration/pseudoManager/threads.lua index 51e060a..2a3dadd 100644 --- a/integration/pseudoManager/threads.lua +++ b/integration/pseudoManager/threads.lua @@ -106,6 +106,10 @@ local function INIT(thread) GLOBAL["__env"] = env end + function THREAD.getENV() + return GLOBAL["__env"] + end + return GLOBAL, THREAD end diff --git a/tests/conf.lua b/tests/conf.lua new file mode 100644 index 0000000..1381163 --- /dev/null +++ b/tests/conf.lua @@ -0,0 +1,39 @@ +function love.conf(t) + t.identity = nil -- The name of the save directory (string) + t.version = "12.0" -- The LOVE version this game was made for (string) + t.console = true -- Attach a console (boolean, Windows only) + + t.window.title = "GuiManagerTest" -- The window title (string) + t.window.icon = nil -- Filepath to an image to use as the window's icon (string) + t.window.width = 1280 -- The window width (number) + t.window.height = 720 -- The window height (number) + t.window.borderless = false -- Remove all border visuals from the window (boolean) + t.window.resizable = true -- Let the window be user-resizable (boolean) + t.window.minwidth = 1 -- Minimum window width if the window is resizable (number) + t.window.minheight = 1 -- Minimum window height if the window is resizable (number) + t.window.fullscreen = false -- Enable fullscreen (boolean) + t.window.fullscreentype = "desktop" -- Standard fullscreen or desktop fullscreen mode (string) + t.window.vsync = false -- Enable vertical sync (boolean) + t.window.fsaa = 2 -- The number of samples to use with multi-sampled antialiasing (number) + t.window.display = 1 -- Index of the monitor to show the window in (number) + t.window.highdpi = false -- Enable high-dpi mode for the window on a Retina display (boolean) + t.window.srgb = false -- Enable sRGB gamma correction when drawing to the screen (boolean) + t.window.x = nil -- The x-coordinate of the window's position in the specified display (number) + t.window.y = nil -- The y-coordinate of the window's position in the specified display (number) + + t.modules.audio = true -- Enable the audio module (boolean) + t.modules.event = true -- Enable the event module (boolean) + t.modules.graphics = true -- Enable the graphics module (boolean) + t.modules.image = true -- Enable the image module (boolean) + t.modules.joystick = true -- Enable the joystick module (boolean) + t.modules.keyboard = true -- Enable the keyboard module (boolean) + t.modules.math = true -- Enable the math module (boolean) + t.modules.mouse = true -- Enable the mouse module (boolean) + t.modules.physics = true -- Enable the physics module (boolean) + t.modules.sound = true -- Enable the sound module (boolean) + t.modules.system = true -- Enable the system module (boolean) + t.modules.timer = true -- Enable the timer module (boolean) + t.modules.window = true -- Enable the window module (boolean) + t.modules.thread = true -- Enable the thread module (boolean) +end +--1440 x 2560 diff --git a/tests/main.lua b/tests/main.lua new file mode 100644 index 0000000..b14de79 --- /dev/null +++ b/tests/main.lua @@ -0,0 +1,5 @@ +require("threadtests") + +function love.update() + +end \ No newline at end of file diff --git a/tests/multi b/tests/multi new file mode 120000 index 0000000..d78adc0 --- /dev/null +++ b/tests/multi @@ -0,0 +1 @@ +D:/VSCWorkspace/multi \ No newline at end of file