[Command] Paste string coming from outside in a script

Hello, this is my first question, and of course really love how cool is Aseprite supporting scripts.

What I want to do is to paste an hex string like #33ff44ff and set the foreground color with the chosen one.

I have tried to use app.command.Paste() and app.command.PasteText()

local colortext =app.command.Paste()

app.alert(tostring(colortext))

but in the alert appears command: and the number of the command, but I cannot paste the value.

Is this possible? I think it would be great for scripting.

Thank you!

Hello Juan! :smiley:

I think that what you want is not paste, but something like this:

local strColor = "#33ff44ff" --your string
local yourColor = Color{ 
	r=tonumber(strColor:sub(2,3)), 
	g=tonumber(strColor:sub(4,5)), 
	b=tonumber(strColor:sub(6,7)), 
	a=tonumber(strColor:sub(8,9))
}
app.fgColor = yourColor

I hope it helps! :slight_smile:

Also, I recommend you to use these links for future references:

1 Like