←  Programs

ComputerCraft | Programmable Computers for Minecraft

»

chpal -- Palette changer for ComputerCraft...

CrazedProgrammer's Photo CrazedProgrammer 06 Jul 2017

chpal is a cool program that lets you load and export palettes with the new features of ComputerCraft 1.8.

Posted ImagePosted Image

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 by CrazedProgrammer, 06 July 2017 - 11:53 PM.
Quote

Lignum's Photo Lignum 09 Jul 2017

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.
Quote

CrazedProgrammer's Photo CrazedProgrammer 09 Jul 2017

View PostLignum, on 09 July 2017 - 10:08 AM, said:

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
Quote

MineRobber___T's Photo MineRobber___T 15 Jul 2017

Regarding lines 39-45:

Quote

-- 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)
Quote

CrazedProgrammer's Photo CrazedProgrammer 15 Jul 2017

View PostMineRobber___T, on 15 July 2017 - 09:49 PM, said:

Regarding lines 39-45:

Quote

-- 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
Quote

Bomb Bloke's Photo Bomb Bloke 16 Jul 2017

Not so bad that I wouldn't just avoid it completely, though.

Spoiler
Quote