[ create a new paste ] login | about

Link: http://codepad.org/AZ8YAgoY    [ raw code | output | fork ]

shmup - Lua, pasted on Jan 6:
program = [[ >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-
             ]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+
             ++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.]]
 
p, counter, marker = 0, 1, 1
cells = {}
 
for i = 1, 30000 do
    cells[i] = 0
end
 
repeat
    local c = string.sub(program, counter, counter)
    if c == '>' then
        marker = marker + 1
    elseif c == '<' and marker ~= 1 then
        marker = marker - 1
    elseif c == '+' then
        cells[marker] = cells[marker] + 1
    elseif c == '-' then
        if cells[marker] ~= 0 then cells[marker] = cells[marker] - 1 end
    elseif c == '[' then
        p = counter
    elseif c == ']' then
        if cells[marker] ~= 0 then counter = p end
    elseif c == '.' then
        io.write(string.char(cells[marker]))
    elseif c == ',' then
        cells[marker] = string.byte(io.read())
    end
    counter = counter + 1
until counter == #program + 1


Output:
1
Hello world!


Create a new paste based on this one


Comments: