Socket | A Macro Manager Plugin

Is there a workaround for the fact that we are we unable to yield within the macro function? I would like to run a command to generate a large map with terrain, and need waits between generating chunks etc.

Great question! Yes this is possible using the task library

Code

	task.defer(function()
		print("This")
		task.wait(1)
		print("Function")
		task.wait(1)
		print("Yields!")
	end)

Output (see timestamps)

  22:35:03.944  This  -  Studio
  22:35:04.959  Function  -  Studio
  22:35:05.961  Yields!  -  Studio

Edit: Bit less nesting version:

local function macroFunction(macro: PopulatedMacroDefinition, plugin: Plugin)
	print("This")
	task.wait(1)
	print("Function")
	task.wait(1)
	print("Yields!")
end

local macroDefinition: MacroDefinition = {
    Name = "Macro",
    Group = "Macros",
    Icon = "đź’ˇ",
    Description = "Macro Description",
	Function = function(...)
		task.defer(macroFunction, ...)	
	end,
}

.

Also might I suggest (a new setting) to only activate the plugin on startup if the “SocketPlugin” folder was already added to ServerStorage? This way it won’t get added to every place I join if it was previously open.

This is a great suggestion! I was able to quickly add this as default behaviour (no setting to toggle this). See the changelog for v1.2.4: Changelog | Socket

You’ll just need to update your plugin to get these changes :smile: thank you for your comment!

1 Like