Jump to content

Draw (Program): Difference between revisions

From Tekkit Lite Server
Created page with "'''Draw''' is a custom ComputerCraft program used to display table image information (for example from the Paint program) on an Advanced Monitor. == Lua Code == <code>local defaultTerm = term.native</code> {{Code|test}}"
 
No edit summary
Line 2: Line 2:


== Lua Code ==
== Lua Code ==
<code>local defaultTerm = term.native</code>
{{Code|1=local defaultTerm = term.native


{{Code|test}}
local function printUsage()
    print("draw <monitorSide> <pathToImage> <scale>")
end
 
local tArgs = { ... }
if #tArgs < 3 then
    printUsage()
    return
end
 
local monitor = peripheral.wrap(tArgs[1])
local image = paintutils.loadImage(tArgs[2])
 
local function draw()
    term.redirect(monitor)
    if image then
        term.setBackgroundColor(colors.white)
        monitor.setTextScale(tonumber(tArgs[3]))
        term.clear()
        paintutils.drawImage(image, 1, 1)
    else
        print("Image not found")
    end
 
    term.redirect(defaultTerm)
end
 
draw()|lang=lua}}

Revision as of 11:35, 17 May 2026

Draw is a custom ComputerCraft program used to display table image information (for example from the Paint program) on an Advanced Monitor.

Lua Code

local defaultTerm = term.native

local function printUsage()
    print("draw <monitorSide> <pathToImage> <scale>")
end

local tArgs = { ... }
if #tArgs < 3 then
    printUsage()
    return
end

local monitor = peripheral.wrap(tArgs[1])
local image = paintutils.loadImage(tArgs[2])

local function draw()
    term.redirect(monitor)
    if image then
        term.setBackgroundColor(colors.white)
        monitor.setTextScale(tonumber(tArgs[3]))
        term.clear()
        paintutils.drawImage(image, 1, 1)
    else
        print("Image not found")
    end

    term.redirect(defaultTerm)
end

draw()