• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

getDescription issue

  • Thread starter Thread starter Emky
  • Start date Start date
E

Emky

Guest
\n doesn't seem to be working , doesn't do a new line


Code:
else if (it.allowDistRead){
        s << std::endl;

        if (item && item->getText() != ""){
            if (lookDistance <= 4){
                if (item->getWriter().length()){
                    s << item->getWriter() << " wrote: ";
                }
                else{
                    s << "You read: ";
                }
             
                s << item->getText();
            }
            else{
                s << "You are too far away to read it.";
            }
        }
        else{
            s << "Nothing is written on it.";
        }
 
Last edited by a moderator:
I'm confused, you set the text in the mapeditor, right? Just make a new line with the enter button, no need to put \n
 
they are already set \n in (map editor), on everything, that's why it would be faster to do this in source i think, rather than pressing enter in every single description

got it to work in blackboards, not sure where i can change it for books tho


dist: othire
 
Last edited by a moderator:
The nasty workaround is to replace all the "\\n" instances to "\n":
Let's use the function from boost:
Code:
#include<boost/algorithm/string.hpp>


boost::replace_all(myString, "\\n", "\n");

But, as the topic owner said: we couldn't find where the string for book text is built so we can use that workaround there.
We tried to use it before calling getText() in item.h but that messed up the string.

The proper way of solving this is to edit in map editor, but that is a very annoying task to do.

If anyone knows where the book string content is built please post it here.
Thanks
 
The nasty workaround is to replace all the "\\n" instances to "\n":
Let's use the function from boost:
Code:
#include<boost/algorithm/string.hpp>


boost::replace_all(myString, "\\n", "\n");

But, as the topic owner said: we couldn't find where the string for book text is built so we can use that workaround there.
We tried to use it before calling getText() in item.h but that messed up the string.

The proper way of solving this is to edit in map editor, but that is a very annoying task to do.

If anyone knows where the book string content is built please post it here.
Thanks
https://github.com/TwistedScorpio/O...bf8d86485/source/protocolgame.cpp#L2032-L2057

You can change it there. Or here: https://github.com/TwistedScorpio/O...60109b8cad3317c13bf8d86485/source/item.h#L140

It will be easier to change the getText.
 

Emky did that, he changed:
Code:
const std::string& getText() const {return getStrAttr(ATTR_ITEM_TEXT);}
to:
Code:
const std::string& getText() const {
        std::string itemText = getStrAttr(ATTR_ITEM_TEXT);
        boost::replace_all(itemText, "\\n", "\n");
        return itemText;
    }

and everything got messed up.
Code:
17:50 You see a blackboard
You read: ôòÊ

onLook
match "\\n" gsub "\n"
I don't get it.
 
Emky did that, he changed:
Code:
const std::string& getText() const {return getStrAttr(ATTR_ITEM_TEXT);}
to:
Code:
const std::string& getText() const {
        std::string itemText = getStrAttr(ATTR_ITEM_TEXT);
        boost::replace_all(itemText, "\\n", "\n");
        return itemText;
    }

and everything got messed up.
Code:
17:50 You see a blackboard
You read: ôòÊ


I don't get it.
Change
const std::string& getText() const {

To:
Code:
std::string getText() const {
 
Back
Top