Gordon_G Posted February 22, 2017 Share Posted February 22, 2017 Hello, I would like to get the last updates by an xml file and write it in a memo. But ; for this I need to pass lines. My xml : <settings> <news>something \n other</news> </settings> server : -- Server : function showNews(source) local settings = xmlLoadFile(":script/settings.xml") triggerClientEvent(source,"shownews",source,xmlNodeGetValue(xmlFindChild(settings, "news", 0))) end -- I made a bind a bind to this function somewhere else in my script and it work so, it's not the problem client : -- Client : function showNews(news_) if news then destroyElement(news) else local screenW, screenH = guiGetScreenSize() news = guiCreateMemo((screenW - 505) / 2, (screenH - 304) / 2, 505, 304, news_, false) end end addEvent("shownews",true) addEventHandler("shownews",getLocalPlayer(),showNews) So, when I push my key who is bind, I can see the memo, I can see the text but, I would like to see it like this : "something other" not like this "something \n" Thanks ! Link to comment
Adolfram Posted February 22, 2017 Share Posted February 22, 2017 i had a similar issue, i did a magic fix with string gsub. it goes news_:gsub("\n", "\\n"); Link to comment
Addlibs Posted February 22, 2017 Share Posted February 22, 2017 (edited) news_ = news_:gsub("\\n", "\n") (replaces literal \n into a \n character (new line) Edited February 22, 2017 by MrTasty Link to comment
Adolfram Posted February 22, 2017 Share Posted February 22, 2017 3 hours ago, MrTasty said: news_ = news_:gsub("\\n", "\n") (replaces literal \n into a \n character (new line) yeah this one is correct Link to comment
Gordon_G Posted February 22, 2017 Author Share Posted February 22, 2017 It's working, thanks ! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now