Page 1 of 1

problem while scripting

Posted: Tue Dec 12, 2006 12:35
by Sjizo
Hey all,

Im trying to make some sort of simple console. For now I use an editbox and a static text. The functionality I wanna do in a Lua script, but i ran into a problem. when trying to combine 2 strings like this

Code: Select all

local text = winMgr:getWindow("Root/ConsoleInputLine"):getText()
      local oldText = winMgr:getWindow("Root/ConsoleWindow"):getText()
      winMgr:getWindow("Root/ConsoleInputLine"):setText("")
      local newText = oldText + text

I get this error
[string "../datafiles/lua_scripts/consoleGui.lua"]:11: attempt to perform arithmetic on local 'oldText' (a string value)

What is the correct way of combining 2 strings in Lua?

Posted: Tue Dec 12, 2006 12:48
by Habba
I recall it was ..

so "this is a string and " .. "this is an another string."

Would equal: "this is a string and this is an another string."

Posted: Tue Dec 12, 2006 12:55
by Sjizo
Thanks for the quick reply, that was exactly it.