mudgangster

Tiny, scriptable MUD client
Log | Files | Refs | README

main.lua (1227B)


      1 mud = {
      2 	connected = false,
      3 	os = package.config:sub( 1, 1 ) == "\\" and "windows" or "linux"
      4 }
      5 
      6 table.unpack = table.unpack or unpack
      7 
      8 require( "utils" )
      9 
     10 require( "event" )
     11 
     12 local script = require( "script" )
     13 local handlers = require( "handlers" )
     14 
     15 local printMain, newlineMain, printChat, newlineChat,
     16 	setHandlers, urgent, setStatus,
     17 	sock_connect, sock_send, sock_close,
     18 	get_time, set_font,
     19 	exe_path = ...
     20 
     21 local socket_api = {
     22 	connect = sock_connect,
     23 	send = sock_send,
     24 	close = sock_close,
     25 }
     26 
     27 local socket_data_handler = require( "socket" ).init( socket_api )
     28 
     29 mud.printMain = printMain
     30 mud.newlineMain = newlineMain
     31 mud.printChat = printChat
     32 mud.newlineChat = newlineChat
     33 
     34 mud.urgent = urgent
     35 mud.now = get_time
     36 
     37 mud.last_human_input_time = mud.now()
     38 
     39 require( "mud" ).init( handlers.data )
     40 require( "chat" ).init( handlers.chat )
     41 
     42 mud.alias( "/font", {
     43 	[ "^(.-)%s+(%d+)$" ] = function( name, size )
     44 		size = tonumber( size )
     45 		if not set_font( name, size ) then
     46 			mud.print( "\n#s> Couldn't set font" )
     47 		end
     48 	end,
     49 }, "<font name> <font size>" )
     50 
     51 require( "status" ).init( setStatus )
     52 
     53 setHandlers( handlers.input, handlers.macro, handlers.close, socket_data_handler, handlers.interval )
     54 
     55 script.load( exe_path )