MAJOR UPDATE!
Script Stash now passes a ‘ctx’ (context) argument to the Run function of your Stashes. As of now, the ctx argument is a table with the following elements:
ctx.Selection -- The current selection in Studio, convenience for game.Selection:Get()
ctx.UI -- Mini UI library to add options to your Stash.
Here’s what’s available in ctx.UI:
ctx.UI.Switch(name: string, defaultValue: boolean)
ctx.UI.Slider(name: string, defaultValue: number, min: number, max: number, step: number?)
ctx.UI.Input(name: string, defaultValue: string)
Here’s a fully featured example of what you can do with the UI library in a Stash:
return {
Name = 'Outputter',
Description = 'Write to the output.',
Run = function(ctx)
local doWarn = ctx.UI.Switch('Warn', false);
local reps = ctx.UI.Slider('Repetitions', 1, 1, 10);
local content = ctx.UI.Input('Content', 'Hello, world!');
for i = 1, reps() do
if doWarn() then
warn(content());
else
print(content());
end;
end;
task.wait(1);
local fun = ctx.UI.Switch('Was that cool?', true);
warn(if fun() then 'Yay!' else 'No!!!');
end,
};
See it in action! https://www.youtube.com/watch?v=BePru-2tvNg