This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
CrazedProgrammer's profile picture

chpal -- Palette changer for ComputerCraft 1.8 and later

Started by CrazedProgrammer, 06 July 2017 - 10:35 PM
CrazedProgrammer #1
Posted 07 July 2017 - 12:35 AM
chpal is a cool program that lets you load and export palettes with the new features of ComputerCraft 1.8.



Download
pastebin get 1XBzKKrT chpal

Usage
chpal <path>
Change palette to the palette in path.
chpal --export <path>
Exports the current palette to path.
chpal --reset
Resets the palette to the default ComputerCraft palette.

Palette format
The palette format chpal uses is a limited version of the .Xresources format.
An example palette entry is
*.color0: #000000

The only criterium for an entry is
*.color<n>: #<hex>


Example palettes
You can find examples here.

pacpal
pastebin get xk8pjsJY pacpal
pacpal shows an image with all the colours, so you can get a quick look of all the colours.
Edited on 06 July 2017 - 10:53 PM
Lignum #2
Posted 09 July 2017 - 11:08 AM
I'm surprised this isn't getting much attention, it's a simple but useful tool, and those examples are pretty nifty, as well! Cheers for making this.
CrazedProgrammer #3
Posted 09 July 2017 - 01:10 PM
I'm surprised this isn't getting much attention, it's a simple but useful tool, and those examples are pretty nifty, as well! Cheers for making this.
Thanks, glad it was of use to someone :D/>
MineRobber___T #4
Posted 15 July 2017 - 10:49 PM
Regarding lines 39-45:


-- oh god why
local imgpath = "/tmpimg"..math.random(1, 9999)
local handle = fs.open(imgpath, "w")
handle.write(imgstr)
handle.close()
local img = paintutils.loadImage(imgpath)
fs.delete(imgpath)

I've submitted a PR to ComputerCraft so that that could be simplified to:


local img = paintutils.loadImage(imgstr,true)

PR here (https://github.com/dan200/ComputerCraft/pull/378)
CrazedProgrammer #5
Posted 15 July 2017 - 11:55 PM
Regarding lines 39-45:


-- oh god why
local imgpath = "/tmpimg"..math.random(1, 9999)
local handle = fs.open(imgpath, "w")
handle.write(imgstr)
handle.close()
local img = paintutils.loadImage(imgpath)
fs.delete(imgpath)

I've submitted a PR to ComputerCraft so that that could be simplified to:


local img = paintutils.loadImage(imgstr,true)

PR here (https://github.com/d...rCraft/pull/378)
Thanks! That would make the paintutils API a little less bad :P/>
Bomb Bloke #6
Posted 16 July 2017 - 02:08 AM
Not so bad that I wouldn't just avoid it completely, though.

Spoiler
local imgstr = {
	" 1111  ccc   ddd   bbb   aaa   999",
	"111   c8c8c d8d8d b8b8b a8a8a 98989",
	"11    cfcfc dfdfd bfbfb afafa 9f9f9",
	"111   ccccc ddddd bbbbb aaaaa 99999",
	" 1111 c c c d d d b b b a a a 9 9 9",
	"                                   ",
	" 4444  eee   555   333   222   666",
	"444   e0e0e 50505 30303 20202 60606",
	"44    e7e7e 57575 37373 27272 67676",
	"444   eeeee 55555 33333 22222 66666",
	" 4444 e e e 5 5 5 3 3 3 2 2 2 6 6 6"
}

for i = 1, #imgstr do
	term.setCursorPos(tcx, tcy + i - 1)
	term.blit(imgstr[i], imgstr[i], imgstr[i])
end