Jump to content

[get_language()] in when ... begin


Go to solution Solved by ridetpro,

Recommended Posts

Hello i did simple multi lang system but with one problem.

compiler dont work with []  in "when function"

when xxxx.chat.Global[get_language()].blacksmith._title begin

 

8Q7Y.png

 

BOIt.png

i think  problem is in luaX_lex(liblua -llex.c) calling read_long_string function

2nVm.png

 

(luaX_lex) i just need skip this case for "when.. begin" without affect other quests functions

      case '[': {
        next(LS);
        if (LS->current != '[') return '[';
        else {
          read_long_string(LS, seminfo);
          return TK_STRING;
        }
      }

(luaX_lex) after skip continue to this.

        else if (isalpha(LS->current) || LS->current == '_' || LS->current>=0xa0) {
          /* identifier or reserved word */
          size_t l = readname(LS);
          TString *ts = luaS_newlstr(LS->L, luaZ_buffer(LS->buff), l);
          if (ts->tsv.reserved > 0)  /* reserved word? */
            return ts->tsv.reserved - 1 + FIRST_RESERVED;
          seminfo->ts = ts;
          return TK_NAME;
        }

with defined something like.

|| LS->current == '[' || LS->current == ']',..

I tried it myself, but  i dont have enough knowledge with liblua. I could cause other problems

Does anyone know how to do or is there another possible solution? Thank you

 

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

  • Solution

qc.cc

parse()

case ST_WHEN_NAME

before current_when_argument += os.str();

bb3f7d3f13c35e32ab8f7f684c03ccd7.png

I did something similar some time ago, I gave you the clues to look for. If you fail, I'll give you the codes. Follow the example above.

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

Fixed

  

{
							// make when argument
							ostringstream os;
							while (lexstate.lookahead.token == '.')
							{
								next(&lexstate);
								os << '.';
								next(&lexstate);
								t = lexstate.t;
								//if (t.token == TK_STRING)
								//t.token = TK_NAME;
								os << t;
								lookahead(&lexstate);
							}
							current_when_argument += os.str();

change to

                        {
                            // make when argument
                            ostringstream os;
                            while (lexstate.lookahead.token == '.')
                            {
                                next(&lexstate);
                                os << '.';
                                next(&lexstate);
                                t = lexstate.t;
                                if (t.token == TK_STRING)
                                t.token = TK_NAME;
                                os << t;
                                lookahead(&lexstate);
                            }
                            current_when_argument += os.str();

and in quest use

when xxxx.chat."Global[get_language()].blacksmith._title" begin

 

  • Love 1
  • Love 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.