Jump to content

Recommended Posts

Hello i have a couple of questions regarding LUA scripting for a quest.

1. Can i use the npc.chat."some text" function with a function that returns a string? I tried but it didn't work. Example:

```lua

npcVNUM.chat.someFuncReturningString()

```

2. by using the 'define' keyword can i define an array on the top of the lua script? Because although i tried, when i compile my code, i get error when trying to iterate this array. When Im using the same array as a local variable there it's no problem, it compiles.

 

Thanks for your time.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Premium

Adapt your qc's sourcecode to support functions within trigger chat strings.

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

If I'm not mistaken, in the qc.cc after searching `// make when argument`

i should replace what's below with 
 

ostringstream os;
while (lexstate.lookahead.token == '.')
{
  next(&lexstate);
  os << '.';
  next(&lexstate);
  t = lexstate.t;
  if (t.token == TK_NAME) {
    os << getstr(t.seminfo.ts); // Append the function name
    if (lexstate.lookahead.token == '(') {
      os << '('; // Append the opening parenthesis
      lookahead(&lexstate);
      // Parse function arguments
      while (lexstate.lookahead.token != ')') {
        os << lexstate.t;
        lookahead(&lexstate);
      }
      os << ')'; // Append the closing parenthesis
      lookahead(&lexstate);
    }
  } else {
    os << t;
  }
  lookahead(&lexstate);
}
current_when_argument += os.str();

 

I'm going to test it out, and come back, but if somebody knows, you could let me know.

 

Thanks.

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.