-- screen functions
function border()
local w, h = term.getSize()
local s = "+"..string.rep("-", w - 2).."+"
term.setCursorPos(1, 1)
term.write(s)
for y = 2, h - 1 do
term.setCursorPos(1, y)
term.write("|")
term.setCursorPos(w, y)
term.write("|")
end
term.setCursorPos(1, h)
term.write(s)
end
function kirbyEnter()
local mY = mY/2
term.setCursorPos(2,mY)
write(">")
term.setCursorPos(2,mY)
sleep(.2)
write("')>")
term.setCursorPos(2,mY)
sleep(.2)
write(".')>")
term.setCursorPos(2,mY)
sleep(.2)
write("('.')>")
term.setCursorPos(2,mY)
sleep(.2)
write("<('.')>")
term.setCursorPos(2,mY)
sleep(.2)
write(" ( V') ")
term.setCursorPos(2,mY)
sleep(.2)
write(" <( )>")
term.setCursorPos(2,mY)
sleep(.2)
write(" ('V )")
term.setCursorPos(2,mY)
sleep(.2)
write(" <('.')>")
term.setCursorPos(2,mY)
sleep(.2)
write(" ( V')")
term.setCursorPos(2,mY)
sleep(.2)
write(" <( )>")
term.setCursorPos(2,mY)
sleep(.2)
write(" ('V )")
term.setCursorPos(2,mY)
sleep(.2)
write(" <('.')>")
term.setCursorPos(2,mY)
sleep(.2)
write(" ( V')")
term.setCursorPos(2,mY)
sleep(.2)
write(" <( )>")
term.setCursorPos(2,mY)
sleep(.2)
write(" ('V )")
term.setCursorPos(2,mY)
sleep(.2)
write(" <('.')>")
term.setCursorPos(2,mY)
sleep(.2)
write(" ( V')")
term.setCursorPos(2,mY)
sleep(.2)
write(" <( )>")
term.setCursorPos(2,mY)
sleep(.2)
write(" ('V )")
term.setCursorPos(2,mY)
sleep(.2)
write(" <('.')>")
term.setCursorPos(2,mY)
sleep(.2)
write(" <('.')>")
term.setCursorPos(2,mY)
sleep(.2)
write(" <('.')>")
end
function kirbyDance(mX,mY)
local mX = mX/2
local mY = mY/2
term.setCursorPos(mX - 4,mY)
write("^('.')>")
sleep(.5)
term.setCursorPos(mX - 4,mY)
sleep(.5)
write("<('.')^")
term.setCursorPos(mX - 4,mY)
sleep(.5)
write("^('.')>")
term.setCursorPos(mX - 4,mY)
sleep(.5)
write("<('.')^")
term.setCursorPos(mX - 4,mY)
sleep(.5)
write("^('.')>")
term.setCursorPos(mX - 4 ,mY)
sleep(.5)
write("<('.')^")
term.setCursorPos(mX - 4,mY)
sleep(.5)
write(" (>'.')>")
term.setCursorPos(mX - 4,mY)
sleep(.5)
write("<('.'<) ")
term.setCursorPos(mX - 4,mY)
sleep(.5)
write(" (>'.')>")
term.setCursorPos(mX - 4,mY)
sleep(.5)
write("<('.'<) ")
term.setCursorPos(mX - 4,mY)
sleep(.5)
write(" (>'.')>")
term.setCursorPos(mX - 4,mY)
sleep(.5)
write("<('.'<) ")
term.setCursorPos(mX - 4,mY)
sleep(.5)
write("<('.')> ")
sleep(.5)
term.setCursorPos(mX - 4,mY)
end
function select()
term.setCursorPos(2,10)
write("Make your selection")
term.setCursorPos(2,12)
write("Dance")
term.setCursorPos(2,17)
write("Selection: ")
--other options available in the future
local input = read()
if input == "dance" then
kirbyDance(mX, mY)
else
print("INVALID")
term.clear()
border()
select()
end
end
function kirbyIdle()
local mX = mX/2
local mY = mY/2
while true do
term.setCursorPos(mX - 4,mY)
write("<('.')>")
sleep(5)
term.setCursorPos(mX - 4,mY)
write("<(-.-)>")
sleep(.5)
end
end
-- end screen functions
mX, mY = term.getSize()
term.clear()
border()
kirbyEnter()
parallel.waitForAny(kirbyIdle,select)
So far, I only want this to run once. Waiting for the input, and then just stopping.
Proof of concept help, with parallel API.
Started by Cranium, Aug 04 2012 12:10 AM
13 replies to this topic
#1
Posted 04 August 2012 - 12:10 AM
I have been trying to complete a proof of concept, whereas a user could have an animated menu, while it is waiting for an input from the user. So far, I have it waiting for an input just fine, but I have been having problems with it trying to execute other code, since for an animation to work, I need for the first animation to loop. My goal with the proof of concept is to have a character, in this case Kirby, enter, and then wait in the middle of the screen for the user input. I have only one command to give Kirby at this time, and that is to DANCE! Problem is, when I give him the dance command, the idle command is still running due to the parallel API. Here is the code I have so far, and much of it has been generously worked on by the other members of the Ask a Pro section:
#2
Posted 04 August 2012 - 12:36 AM
Well, I guess you could break the menu/selection loop, so the parallel call will return, then you use the selection from the menu to run the corresponding function. Put that in a loop and it should work. But there's an easier way: don't use parallel. Use another menu that doesn't call read, so you can simply use events. I'll work on it and post what I get.
#3
Posted 04 August 2012 - 12:56 AM
I have made some modifications to your code fixed part of the animation and set up some control functions Please try this.
Spoiler
#5
Posted 04 August 2012 - 01:17 AM
Ok, a little late but here's what I have:
/>
Spoiler
It uses another menu, so it doesn't need parallel, and the animations are easier to change. I tested it and works fine, although I'm not sure if the enter animation should look like that #6
Posted 04 August 2012 - 01:25 AM
MysticT, on 04 August 2012 - 01:17 AM, said:
Ok, a little late but here's what I have:
-- snip --
It uses another menu, so it doesn't need parallel, and the animations are easier to change. I tested it and works fine, although I'm not sure if the enter animation should look like that
/>
-- snip --
It uses another menu, so it doesn't need parallel, and the animations are easier to change. I tested it and works fine, although I'm not sure if the enter animation should look like that
#7
Posted 04 August 2012 - 01:30 AM
MysticT, I only have one question about your code:
What is the _,s in the drawAnimation() function, and what does it do? I have never seen that before.
What is the _,s in the drawAnimation() function, and what does it do? I have never seen that before.
#8
Posted 04 August 2012 - 01:32 AM
craniumkid22, on 04 August 2012 - 01:30 AM, said:
MysticT, I only have one question about your code:
What is the _,s in the drawAnimation() function, and what does it do? I have never seen that before.
What is the _,s in the drawAnimation() function, and what does it do? I have never seen that before.
#9
Posted 04 August 2012 - 01:40 AM
Ok, that's neat. BTW, the code you have is great, but it did not keep looping the idle after giving the initial command. Any way around this?
#10
Posted 04 August 2012 - 01:45 AM
Did you try it? The idle animation works fine for me, even after doing the dance.
#13
Posted 04 August 2012 - 01:55 AM
fixed MysticT's code
Spoiler
#14
Posted 04 August 2012 - 01:55 AM
Hmm, you'r right, I forgot to reset the timer. This should work:
That would work, but it would reset the timer each time you press a key, so the idle animation wouldn't work correctly.
Spoiler
BigSHinyToys, on 04 August 2012 - 01:55 AM, said:
fixed MysticT's code
-- snip --
-- snip --
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











