.------.
|A.--. |
| :/\: |
| (__) |
| '--'A|
`------'
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Multi line messages being one variable
Started by Cranium, 14 August 2012 - 01:41 PMPosted 14 August 2012 - 03:41 PM
I am wanting to use some ASCII art, and have a certain image equal a variable, and be able to call upon that variable later. How would I define that? Here's an example of what I want to display as one variable:
Posted 14 August 2012 - 03:50 PM
local ascii = [[.------.
|A.--. |
| :/: |
| (__) |
| '--'A|
`------']]
Posted 14 August 2012 - 03:53 PM
There are a couple of ways to do it example
Spoiler
-- this method is not the best as you cant position it where you want.
local ace = [[.------.
|A.--. |
| :/: |
| (__) |
| '--'A|
`------']]
term.clear()
term.setCursorPos(1,1)
print(ace)
-- or this method is better
local ace = {[[.------.]],
[[|A.--. |]],
[[| :/: |]],
[[| (__) |]],
[[| '--'A|]],
[[`------']]}
local offX,offY = 2,8
for i = 1,#ace do
term.setCursorPos(offX,offY+i-1)
write(ace[i])
end
Posted 14 August 2012 - 03:59 PM
So for the second method, I just want to know how you came up with the offX,offY = 2,8?There are a couple of ways to do it exampleSpoiler
-- this method is not the best as you cant position it where you want. local ace = [[.------. |A.--. | | :/: | | (__) | | '--'A| '------']] term.clear() term.setCursorPos(1,1) print(ace) -- or this method is better local ace = {[[.------.]], [[|A.--. |]], [[| :/: |]], [[| (__) |]], [[| '--'A|]], [['------']]} local offX,offY = 2,8 for i = 1,#ace do term.setCursorPos(offX,offY+i-1) write(ace[i]) end
Posted 14 August 2012 - 04:09 PM
Also, wouldn't I need to define those lines as strings in order to print them?
Posted 14 August 2012 - 04:15 PM
I wanted to place it bellow the other card it is in collom 2 at row 8
here is advanced demo
Use up down left right keys to move ace around
here is advanced demo
Use up down left right keys to move ace around
Spoiler
local function draw(tCard,offX,offY)
for i = 1,#tCard do
term.setCursorPos(offX,offY+i-1)
write(tCard[i])
end
end
term.clear()
term.setCursorPos(1,1)
local ace = {[[.------.]],
[[|A.--. |]],
[[| :/: |]],
[[| (__) |]],
[[| '--'A|]],
[[`------']]}
local winX,winY = term.getSize()
local curX,curY = 1,1
draw(ace,curX,curY)
while true do
local e,e1 = os.pullEvent()
if e == "key" then
if e1 == 200 then -- up
curY = curY - 1
elseif e1 == 208 then -- down
curY = curY + 1
elseif e1 == 203 then -- left
curX = curX - 1
elseif e1 == 205 then -- right
curX = curX + 1
end
if curX > winX-8 then curX = 1 end
if curX < 1 then curX = winX-8 end
if curY > winY-6 then curY = 1 end
if curY < 1 then curY = winY-6 end
end
term.clear()
local text = "Pos : X "..curX.." Y "..curY
term.setCursorPos(winX-string.len(text)-1,winY)
write(text)
draw(ace,curX,curY)
end
Posted 14 August 2012 - 04:17 PM
Multiline quotes
http://lua-users.org/wiki/StringsTutorial
http://lua-users.org/wiki/StringsTutorial
Posted 14 August 2012 - 04:19 PM
And that's why you guys are the pros. Than you! I think this will get me closer to finishing my GUI for a slot machine.Multiline quotes
http://lua-users.org...StringsTutorial
Posted 14 August 2012 - 04:27 PM
The sign above my avatar lies I am no pro just armature LUA user I should get it changes actually.And that's why you guys are the pros. Than you! I think this will get me closer to finishing my GUI for a slot machine.
I have been scripting since JAN this year so definitely not PRO.
offX and offY are offsets It is how far i want it from the corners. using the draw function in my second code would also allow for scripted movement of cards.
Posted 15 August 2012 - 01:16 AM
You need to edit the design a bit since some of those won't display properly. Unless lua supports string literals.
Posted 15 August 2012 - 02:00 PM
The sign above my avatar lies I am no pro just armature LUA user I should get it changes actually.And that's why you guys are the pros. Than you! I think this will get me closer to finishing my GUI for a slot machine.
I have been scripting since JAN this year so definitely not PRO.
offX and offY are offsets It is how far i want it from the corners. using the draw function in my second code would also allow for scripted movement of cards.
haha, don't stress dude you're better than most of us, I myself have been using lua for maybe 3 months max, I got no experience. most people on the site are the same (a few exceptions though, take a look at some of cloudy's posts :P/>/> ) so in comparison you really do know what you are doing
Posted 16 August 2012 - 07:53 AM
I reckon some people have had prior experience with Garry's mod but aren't admitting it lolThe sign above my avatar lies I am no pro just armature LUA user I should get it changes actually.And that's why you guys are the pros. Than you! I think this will get me closer to finishing my GUI for a slot machine.
I have been scripting since JAN this year so definitely not PRO.
offX and offY are offsets It is how far i want it from the corners. using the draw function in my second code would also allow for scripted movement of cards.
haha, don't stress dude you're better than most of us, I myself have been using lua for maybe 3 months max, I got no experience. most people on the site are the same (a few exceptions though, take a look at some of cloudy's posts :(/>/> ) so in comparison you really do know what you are doing
Posted 16 August 2012 - 08:04 AM
and what is Garry's mod ??I reckon some people have had prior experience with Garry's mod but aren't admitting it lol
Posted 16 August 2012 - 08:10 AM
I'd love to know as well
Posted 16 August 2012 - 08:26 AM
Ah the glory of Google :(/>/> http://en.wikipedia.org/wiki/Garry's_Mod
Posted 16 August 2012 - 09:09 AM
I've only ever played it once myself (realism in games and FPSs aren't really my thing), but from what I know, it's basically a creative free-roaming game developed by Valve-software (I still think they need a better logo) and you can edit your own items to go in it, and program their functionality in lua. Essentially it's a bit like minecraft in that you can make stuff, but it requires more effort to make your own stuff, so mostly it's playing around with pre-existing models.
At least, that's what I get the impression it is. I only played it once lol
(I know, most gamers will say I should be ashamed, but so what, I say they should be ashamed for not having played little king's story or zack and wiki).
At least, that's what I get the impression it is. I only played it once lol
(I know, most gamers will say I should be ashamed, but so what, I say they should be ashamed for not having played little king's story or zack and wiki).