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

[1.41] Watermark v 1.0 - Make an always-visible text on your monitor

Started by Jan, 06 August 2012 - 05:43 PM
Jan #1
Posted 06 August 2012 - 07:43 PM
Watermark v 1.0 - Make an always-visible text on your monitor

About

This little program hacks the term API and adds some code to print a Watermark text on top of the screen.
Also it tricks the running programs, by telling them the monitor is one-line smaller, so that all programs run normally, and no text is overwritten by the watermark.

Screenshot


Playing worm after watermark was activated

Instructions

1. Simply save this program as 'mark'
Now run the program ONCE, and the text appears The effect stays until you reboot the computer.

2. You can also give the program the name 'startup', for automatic startup.

Code

Spoiler

function waterUpdate()
waterx,watery=watero.getCursorPos()
watero.setCursorPos(1,1)
watero.clearLine()
term.write(watertext)
watero.setCursorPos(waterx,watery)
end
function setWaterMark(text)
watertext=text
waterUpdate()
end
watero = {}
watero.getCursorPos = term.getCursorPos
term.getCursorPos = function()
waterx,watery=watero.getCursorPos()
return waterx,watery-1
end
watero.setCursorPos = term.setCursorPos
term.setCursorPos = function(waterx,watery)
watero.setCursorPos(waterx,watery+1)
end
watero.getSize = term.getSize
term.getSize = function()
waterx,watery=watero.getSize()
return waterx,watery-1
end
watero.clear = term.clear
term.clear = function()
watero.clear()
waterUpdate()
end
watero.clearLine = term.clearLine
term.clearLine = function()
watero.clearLine()
waterUpdate()
end
watero.scroll = term.scroll
term.scroll = function(watern)
watero.scroll(watern)
waterUpdate()
end
setWaterMark("[ Place some cool text here! ]")

Configuration

To change the text:
1. Use the API: type 'lua' and then 'setWaterMark("New Text")'
2. Hard-code it. Edit the last line of the program.

License

1. I am not responsible for damage
2. Don't remove the license when sharing
3. please give me credit if you share it :P/>/>
ardera #2
Posted 06 August 2012 - 07:49 PM
First report a bug you explored in your program, and then post the program :P/>/>
Jan #3
Posted 06 August 2012 - 08:03 PM
First report a bug you explored in your program, and then post the program :P/>/>
Yes indeed, it was the same program ;)/>/>
But the bug wasnt as critical as it seemed: it didnt crash the hole minecraft, but because CRTL+T didnt work, and there was an error in the console, I thought it was crashed.