A recent break through in CG Technology , The completly lua console! ( without using console commands apart from opening the conolse [ but that can be fixed ] )
This is the current code :)
Place in autorun
[LUA]
// Console By Ningaglio
require("datastream")
module("Console", package.seeall)
if CLIENT then
local _labels = { }
// This function was made by lexi ( in a way ), so full
// credits to him! ( for parsing strings with quotes correctly )
local function ParseStrings( str )
local text = str
local quote = text:sub(1,1) ~= '"'
local ret = {}
for chunk in string.gmatch(text, '[^"]+') do
quote = not quote
if quote then
table.insert(ret,chunk)
else
for chunk in string.gmatch(chunk, "%a+") do
table.insert(ret,chunk)
end
end
end
return ret
end
function SendCommand( con, tab )
datastream.StreamToServer( "Console.Parse", { con, unpack(tab) } );
end
local function OnSend( str )
local parsed = ParseStrings( str )
SendCommand( parsed[1] , parsed )
end
function OpenConsole()
local DFrame1 = vgui.Create('DFrame')
DFrame1:SetSize(500, 75)
DFrame1:Center()
DFrame1:SetTitle('Console')
DFrame1:SetSizable(true)
DFrame1:SetDeleteOnClose(false)
DFrame1:SetScreenLock( true )
DFrame1:SetDraggable(false)
DFrame1:SetBackgroundBlur(true)
DFrame1:SetSizable(false)
DFrame1:MakePopup()
local DPanel2 = vgui.Create('DPanel', DFrame1)
DPanel2:SetPos(5, 27)
DPanel2:SetSize(490, 40)
local DTextEntry1 = vgui.Create('DTextEntry',DPanel2)
DTextEntry1:SetPos(5, 10)
DTextEntry1:SetSize(390, 25)
DTextEntry1:SetText('Enter A Command')
DTextEntry1.OnEnter = function()
OnSend( DTextEntry1:GetValue() )
DFrame1:SetVisible( false )
end
local DButton2 = vgui.Create('DButton',DPanel2)
DButton2:SetPos(400, 10)
DButton2:SetSize(70, 25)
DButton2:SetText('Send.')
DButton2.DoClick = function()
OnSend( DTextEntry1:GetValue() )
DFrame1:SetVisible( false )
end
end
concommand.Add("Open_Console", OpenConsole )
else
local function AcceptStream( pl, handler, id )
if handler == "Console.Parse" then
return true
end
end
hook.Add( "AcceptStream", "Console.AcceptStream", AcceptStream )
local _commands = { }
function AddCommand( name , func )
if name && func then
_commands[name] = func
end
end
function RemoveCommand( name )
if name then
_commands[name] = nil
end
end
function CallCommand( ply, name, args )
local con = _commands[name]
if con and con != nil and ply then
if args then
con( ply, name, args )
else
con( ply, name, { } )
end
end
end
function IncomingHook( pl, handler, id, encoded, decoded )
local cmd = table.remove( decoded, 1 )
CallCommand( pl, cmd, decoded )
end
datastream.Hook( "Console.Parse", IncomingHook );
AddCommand( "Test", function( ply, cmd, args )
ply:PrintMessage( HUD_PRINTCENTER, "You entered : " .. string.Implode( " , ", args ) )
end)
end
[/LUA]
it pareses string correctly with quotes ( thanks to lexi ) and is a really good replacement for the console offered by the source engine. Sadly , it doesnt have a complete UI and does not offer the option of viewing results. In the near futur, i will update it so its like the source console and i will add functions like Print to it :)
Hope this helps for provate developers
That does seem quite interesting. Ahh the brilliance of people who think up these ideas.
Sarcasm? Sorry but I am naive when it comes to citisism :3
So now you would be able to release a series of lua concole commands able use in map development :D.
[QUOTE=_axe_;22675500]So now you would be able to release a series of lua concole commands able use in map development :D.[/QUOTE]
You don't need a lua console to use lua console commands.
What exactly can this do the other one can't?
[editline]01:46AM[/editline]
I mean appart from lacking auto-complete.
Well .... seeing as its lua, it should be really to customise it :). Also, some nice developer or gamemode maker might pick this up and make it the console of his admin menu :).
[QUOTE=Ningaglio;22680561]Well .... seeing as its lua, it should be really to customise it :). Also, some nice developer or gamemode maker might pick this up and make it the console of his admin menu :).[/QUOTE]
"Well .... seeing as its lua, it should be really to customise it :)."
it should be really EASY to customize it. Sorry, it's just a bit weird reading that sentence. And that is probably true, a customizable console eh?(YES IM CANADIAN NOT JKING)
Sorry, you need to Log In to post a reply to this thread.