Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Look at my program: Its a server

Name: Anonymous 2015-02-10 0:47

In the spirit of wanting to see more programs on this board, I am posting this programlet. Its the beginnings of a server so I can talk to my universe LispM program as though its a BBS through a terminal program like putty.

Please post your programs as also well too mutually also together. I would like to see them. If they are graphical or audioful or gameful or simulationful programs are preferred, but of course, post any program.

Don't forget to comment, rate and subscribe.

WISHFUL THINKING

function svrRunLuaPromptServer(sck)
local s = svrReceive(sck)
if s ~= "" then
luaCall(s)
local err = getErrorText()
if err ~= "" then
svrSend(err, sck)
clearError()
end
-- svrSend("Ready.\n")
--svrSend("\n> ")
svrSend("> ", sck)
end
end

function svrRunEchoServer(sck)
-- echo server
local s = svrReceive(sck)
if s~="" then
clearTrace()
for i=1,#s,1 do
print(string.byte(s,i))
end
end
svrSend(s, sck)
end

function initServer()
svrStart()
print("Server started")
coroutine.yield()

print("Waiting for terminal client...")
repeat
sck1 = svrAccept()
coroutine.yield()
until svrIsValidSocket(sck1)

print("Terminal client connected.")

svrSend("You are the lua prompt terminal\n> ", sck1)
coroutine.yield()

print("Waiting for echo client...")

repeat
sck2 = svrAccept()
coroutine.yield()
until svrIsValidSocket(sck2)

print("Echo client connected.")

svrSend("You are the echo terminal", sck2)
end

function restartServer()
initServerRoutine = coroutine.create(initServer)
coroutine.resume(initServerRoutine)
end

if initServerRoutine == nil then
restartServer()
end

function update()
if coroutine.status(initServerRoutine) ~= "dead" then
coroutine.resume(initServerRoutine)
else
svrRunLuaPromptServer(sck1)
svrRunEchoServer(sck2)
end
end

Name: Anonymous 2015-02-11 8:55

>>14
This is >>1-san. Here is a tty text viewer for the echo server, on its way to becoming a tty text editor.

first_visible_line = 1
first_visible_column = 1
buffer = ""
position = 1
screenstring = "line 1\nline 2\nline 3\n"

csi = string.char(27) .. "["

function move_cursor(x,y)
svrSend(csi .. x .. ";" .. y .. "H")
end

function clear_screen()
svrSend(csi .. "2J")
end

-- stile di pensiero desideroso

function position_to_line(s, pos)
for i=1,pos,1 do

end
end

function position_to_linecol(pos)
end

function linecol_to_screen(pos)
--
end

function screen_to_linecol(line,col)
end

function linecol_to_position(line,col)
end

function handle_up()
first_visible_line = first_visible_line - 1
if first_visible_line < 1 then
first_visible_line = 1
end
draw_string(s)
end

function handle_down()
first_visible_line = first_visible_line + 1
if first_visible_line < 1 then
first_visible_line = 1
end
draw_string(s)
end

function handle_left()
first_visible_column = first_visible_column - 1
if first_visible_column < 1 then
first_visible_column = 1
end
draw_string(s)

position = position - 1
if position < 1 then position = 1 end
--draw_string(screenstring)
end

function handle_right()
first_visible_column = first_visible_column + 1
if first_visible_column < 1 then
first_visible_column = 1
end
draw_string(s)

position = position + 1
if position > s:len() then position = s:len() end
end

function handle_key(k)
-- insert character into string
end

function draw_string(s)
-- set cursor to 1,1
-- write string to console starting from the
-- first_visible_line until first_visible_line+num_visible_lines
-- or the end of the string, whichever is first.
-- also from first_visible_column until num_visible_columns

--local cx = 1
--local cy = 1
move_cursor(1,1)
clear_screen()
local s2 = s
if s2:byte(s2:len()) ~= 10 then
s2 = s2 .. "\n"
end
local linenum = 1
for line in s2:gmatch('([^\n]*)\n') do
if linenum >= first_visible_line and linenum < first_visible_line + 20 then
svrSend(line:sub(first_visible_column, first_visible_column + 50).."\n")
end
linenum = linenum + 1
end
end

lastkey = {}

function svrRunEchoServer(sck)
-- echo server
local s = svrReceive(sck)
-- detect up, down, left, right, backspace, delete, insert, etc
-- shift arrows, more and more and more
if s~="" then
clearTrace()
lastkey = {}
for i=1,#s,1 do
print(string.byte(s,i))
table.insert(lastkey, string.byte(s, i))
end

local handled = false

if #lastkey==3 then
if lastkey[1] == 27 and lastkey[2] == 91 then
if lastkey[3] == 65 then
handle_up()
handled = true
end
if lastkey[3] == 66 then
handle_down()
handled = true
end
if lastkey[3] == 67 then
handle_right()
handled = true
end
if lastkey[3] == 68 then
handle_left()
handled = true
end
end
end

if handled == false then
svrSend(s, sck)
end
end
end

function showkey()
for i=1,#lastkey,1 do
svrSend(""..lastkey[i],sck1)
if i<#lastkey then
svrSend(",", sck1)
end
end
svrSend("\n",sck1)
end

function make_lines(s)
local lines = {}
for line in s:gmatch('([^\n]*)\n') do
-- svrSend("->" .. line .. "\n", sck1)
table.insert(lines, line)
end
return lines
end


Note the deranged comment in italian, and the incomplete functions. These are signs of a mind that has damaged itself by reinforcing pleasure pathways so often that it satisfies itself too soon, so soon that it won't even make the minimum effort to finish something that would take about 3 minutes of mild concentration.

I made praxis so I could experience flow at any time. Flow when making a midi recorder. Flow when making a server I can change at a whim. And I still find it difficult to devote the tiny amount of energy it would take to make things with it. Instead I browse the retarded intertubes and read and get distracted with bullshit because the habits are such a powerful attractor, these shitty distractions are the new steady state of my brain.

HALP

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List