[Coding] Broken semicolon

RedSwordRedSword Join Date: 2006-12-07 Member: 58947Members, Reinforced - Shadow, WC 2013 - Supporter
edited January 2016 in Technical Support
Hi,

I was trying various arguments in lua for a function callback, but it seems I cannot find anyway to use a semicolon without breaking my argument.

If you type, with the code in the spoiler, "sv_testsemicolonarg2 qwe;qaz", the following will be shown :
1) Arg qwe
2) Arg qwe
3) Arg qwe

And using the double-quotes doesn't solve the problem; 'sv_testsemicolonarg2 "qwe;qaz"' :
1) Arg "qwe
2) Arg "qwe
3) Arg "qwe

Also, if I only do "sv_testsemicolonarg2 ;", I get an error "failed attempt to contatenate local "aMsg" (a nil value).

I'd like to know how I am supposed to use semicolons in LUA. I did ask on discord and @SamusDroid (Samus on discord) told me to make a thread about it.

Code :
local function CommandCallback_TestSemiColonArg1(aClient, myArg)
	
	Print("My arg = " .. myArg)
	
	-- can't use ... here
	
end
local function CommandCallback_TestSemiColonArg2(aClient, ...)
	
	local aMsg = ""
	local args = {...}
	
	-- used by Console_sv_spawnteams
	aMsg = StringConcatArgs(...)
	Print("1) Arg " .. aMsg)
	aMsg = ""
	
	-- same as OnCommandBind@ConsoleBindings.lua
	for arg = 1, #args do
		aMsg = aMsg .. args[arg]
	end
	Print("2) Arg " .. aMsg)
	aMsg = ""
	
	-- used by ClientSay / ClientTeamSay (normal chat) ; @Lucky fkers
	for _, word in ipairs(args) do
		if aMsg == "" then
			aMsg = word
		else
			aMsg = aMsg .. " " .. word
		end
	end
	Print("3) Arg " .. aMsg)
	
end
CreateServerAdminCommand("Console_sv_testsemicolonarg1", CommandCallback_TestSemiColonArg1, "") -- arg
CreateServerAdminCommand("Console_sv_testsemicolonarg2", CommandCallback_TestSemiColonArg2, "") -- ...

And on a side note, using "name ;;" in console gives a lua error : http://pastebin.com/x5c4khRu

And of course I am able to talk normally in chat using semicolons. Just never in console it seems. Also google didn't help much (so it doesn't seem to be LUA related).

Red

Comments

  • GhoulofGSG9GhoulofGSG9 Join Date: 2013-03-31 Member: 184566Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Reinforced - Supporter, WC 2013 - Supporter, Pistachionauts
    ";" is read as end of line by the text parser which is used to split the console terms. Which means everything behind a ; will be discarded.
  • RedSwordRedSword Join Date: 2006-12-07 Member: 58947Members, Reinforced - Shadow, WC 2013 - Supporter
    edited January 2016
    ";" is read as end of line by the text parser which is used to split the console terms. Which means everything behind a ; will be discarded.

    I understand that; but that's the case even between double-quotes (i.e. '"qwe;qaz"'); shouldn't this be seen as a bug ? Shouldn't you be able to write anything that the game allow from within the console ? A bit like Source console (yes I know, not the same game/engine) ?

    Edit : You can't even escape it with % or \
  • _INTER__INTER_ Join Date: 2009-08-08 Member: 68392Members, NS2 Playtester, Reinforced - Shadow
    edited January 2016
    Lua seems to be pretty weird as its apparently only capable of escaping ( ) . % + - * ? [ ^ $ with %.
    I don't code Lua. What kind of parser does it use? (UWE provided or Lua provided)

    How about
    utf8.char(59)
    
    Link (Is this the official manual? I might be spoiled but this is horrible)
  • RedSwordRedSword Join Date: 2006-12-07 Member: 58947Members, Reinforced - Shadow, WC 2013 - Supporter
    @_INTER_, we're saying that ";" is used to separate commands. It doesn't seem to be related to incorrect parsing; it seems (to me) that it could be incorrectly used. I'm not entirely sure console parsing was made while having quotes in mind. Sadly.

    Red
Sign In or Register to comment.