mirror of https://github.com/LDDestroier/CC/
Update pain2.lua
This commit is contained in:
parent
d4ea02f4fb
commit
ab5075b347
109
pain2.lua
109
pain2.lua
|
@ -48,7 +48,42 @@ local pain = {
|
||||||
[2] = {
|
[2] = {
|
||||||
" ",
|
" ",
|
||||||
"f",
|
"f",
|
||||||
"e"
|
"a"
|
||||||
|
},
|
||||||
|
[3] = {
|
||||||
|
" ",
|
||||||
|
"f",
|
||||||
|
"b"
|
||||||
|
},
|
||||||
|
[4] = {
|
||||||
|
" ",
|
||||||
|
"f",
|
||||||
|
"c"
|
||||||
|
},
|
||||||
|
[5] = {
|
||||||
|
" ",
|
||||||
|
"f",
|
||||||
|
"d"
|
||||||
|
},
|
||||||
|
[6] = {
|
||||||
|
" ",
|
||||||
|
"f",
|
||||||
|
"2"
|
||||||
|
},
|
||||||
|
[7] = {
|
||||||
|
" ",
|
||||||
|
"f",
|
||||||
|
"3"
|
||||||
|
},
|
||||||
|
[8] = {
|
||||||
|
" ",
|
||||||
|
"f",
|
||||||
|
"4"
|
||||||
|
},
|
||||||
|
[9] = {
|
||||||
|
" ",
|
||||||
|
"f",
|
||||||
|
"5"
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
tool = "pencil"
|
tool = "pencil"
|
||||||
|
@ -478,6 +513,12 @@ local render = function(x, y, width, height)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if false then
|
||||||
|
term.setCursorPos(1,1)
|
||||||
|
write(textutils.serialize(miceDown))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- every tool at your disposal
|
-- every tool at your disposal
|
||||||
|
@ -556,23 +597,30 @@ local tools = {
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
text = function(arg)
|
text = {
|
||||||
pain.paused = true
|
info = {
|
||||||
pain.barmsg = "Type text to add to canvas."
|
name = "Text",
|
||||||
pain.barlife = 1
|
swapTool = "pencil",
|
||||||
render()
|
swapArg = {},
|
||||||
term.setCursorPos(arg.x, arg.y)
|
},
|
||||||
term.setTextColor(to_colors[arg.dot[2]])
|
run = function(arg)
|
||||||
term.setBackgroundColor(to_colors[arg.dot[3]])
|
pain.paused = true
|
||||||
local text = read()
|
pain.barmsg = "Type text to add to canvas."
|
||||||
-- re-render every keypress, requires custom read function
|
pain.barlife = 1
|
||||||
for i = 1, #text do
|
render()
|
||||||
placeDot(arg.sx + i - 1, arg.sy, frame, {text:sub(i,i), pain.dots[dot][2], pain.dots[dot][3]})
|
term.setCursorPos(arg.x, arg.y)
|
||||||
|
term.setTextColor(to_colors[arg.dot[2]])
|
||||||
|
term.setBackgroundColor(to_colors[arg.dot[3]])
|
||||||
|
local text = read()
|
||||||
|
-- re-render every keypress, requires custom read function
|
||||||
|
for i = 1, #text do
|
||||||
|
placeDot(arg.sx + i - 1, arg.sy, frame, {text:sub(i,i), pain.dots[dot][2], pain.dots[dot][3]})
|
||||||
|
end
|
||||||
|
pain.paused = false
|
||||||
|
keysDown = {}
|
||||||
|
miceDown = {}
|
||||||
end
|
end
|
||||||
pain.paused = false
|
},
|
||||||
keysDown = {}
|
|
||||||
miceDown = {}
|
|
||||||
end,
|
|
||||||
line = {
|
line = {
|
||||||
info = {
|
info = {
|
||||||
name = "Line",
|
name = "Line",
|
||||||
|
@ -657,14 +705,32 @@ local tryTool = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
local getInput = function()
|
local getInput = function()
|
||||||
local evt
|
local evt, adjX, adjY, paletteListX
|
||||||
while true do
|
while true do
|
||||||
evt = {os.pullEvent()}
|
evt = {os.pullEvent()}
|
||||||
if evt[1] == "mouse_click" or evt[1] == "mouse_drag" then
|
if evt[1] == "mouse_click" or evt[1] == "mouse_drag" then
|
||||||
if evt[3] >= pain.size.x and evt[3] <= -1 + pain.size.x + pain.size.width and evt[4] >= pain.size.y and evt[4] <= -1 + pain.size.y + pain.size.height then
|
|
||||||
if evt[4] == -1 + pain.size.y + pain.size.height then
|
-- start X for the list of color palettes to choose from
|
||||||
-- openBarMenu()
|
paletteListX = 5 + #tostring(pain.scrollX) + #tostring(pain.scrollY)
|
||||||
|
|
||||||
|
-- (x, y) relative to (pain.size.x, pain.size.y)
|
||||||
|
adjX, adjY = 1 + evt[3] - pain.size.x, 1 + evt[4] - pain.size.y
|
||||||
|
|
||||||
|
if adjX >= 1 and adjX <= pain.size.width and adjY >= 1 and adjY <= pain.size.height then
|
||||||
|
|
||||||
|
if adjY == pain.size.height then
|
||||||
|
|
||||||
|
if evt[1] == "mouse_click" then
|
||||||
|
if adjX >= paletteListX and adjX <= -1 + paletteListX + #pain.dots then
|
||||||
|
dot = 1 + adjX - paletteListX
|
||||||
|
setBarMsg("Selected palette " .. dot .. ".")
|
||||||
|
else
|
||||||
|
-- openBarMenu()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
dragPoses[evt[2]] = {
|
dragPoses[evt[2]] = {
|
||||||
{
|
{
|
||||||
x = dragPoses[evt[2]][1].x or evt[3],
|
x = dragPoses[evt[2]][1].x or evt[3],
|
||||||
|
@ -681,6 +747,7 @@ local getInput = function()
|
||||||
x = evt[3],
|
x = evt[3],
|
||||||
y = evt[4],
|
y = evt[4],
|
||||||
}
|
}
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif evt[1] == "key" then
|
elseif evt[1] == "key" then
|
||||||
|
|
Loading…
Reference in New Issue