mudgangster

Log | Files | Refs

main.lua (1417B)


      1 mud = {
      2 	connected = false,
      3 }
      4 
      5 -- local function luarocks_path( opt, orig )
      6 -- 	local pipe = io.popen( "luarocks path " .. opt, "r" )
      7 -- 	if not pipe then
      8 -- 		return nil
      9 -- 	end
     10 --
     11 -- 	local contents = pipe:read( "*all" )
     12 -- 	pipe:close()
     13 --
     14 -- 	if not contents then
     15 -- 		return orig
     16 -- 	end
     17 --
     18 -- 	return contents:gsub( "%s*$", "" ) .. ";" .. orig
     19 -- end
     20 --
     21 -- package.path = luarocks_path( "--lr-path", package.path )
     22 -- package.cpath = luarocks_path( "--lr-cpath", package.cpath )
     23 
     24 table.unpack = table.unpack or unpack
     25 
     26 require( "utils" )
     27 
     28 socket = require( "socket" )
     29 ev = require( "ev" )
     30 
     31 require( "event" )
     32 
     33 local script = require( "script" )
     34 local handlers = require( "handlers" )
     35 
     36 require( "chat" ).init( handlers.chat )
     37 require( "connect" ).init( handlers.data )
     38 
     39 local xFD, handleXEvents,
     40 	printMain, newlineMain, drawMain,
     41 	printChat, newlineChat, drawChat,
     42 	setHandlers, urgent, setStatus = ...
     43 
     44 mud.printMain = printMain
     45 mud.newlineMain = newlineMain
     46 mud.drawMain = drawMain
     47 
     48 mud.printChat = printChat
     49 mud.newlineChat = newlineChat
     50 mud.drawChat = drawChat
     51 
     52 mud.urgent = urgent
     53 
     54 require( "status" ).init( setStatus )
     55 
     56 setHandlers( handlers.input, handlers.macro, handlers.close )
     57 
     58 local loop = ev.Loop.default
     59 
     60 mud.handleXEvents = handleXEvents
     61 
     62 ev.IO.new( handleXEvents, xFD, ev.READ ):start( loop )
     63 ev.Timer.new( handlers.interval, 0.5, 0.5 ):start( loop )
     64 
     65 script.load()
     66 
     67 loop:loop()
     68 
     69 script.close()