IRC errors list help

Started by Icey, Thu 20/01/2011 20:26:29

Previous topic - Next topic

Icey

What does it mean or what do I have to do or check to get rid of a error like this? (is not a )

Full error code
Code: ags

Chat.asc(303): Error (line 303): '.IRCSplit' is not a public member of 'String'. Are you sure you spelt it correctly (remember, capital letters are important)?


Ryan Timothy B

It sounds like IRCSPlit is an extender of 'string'.

You'll see something like this:
Code: ags

struct sIRC
{
  ..
  import string IRCSplit();
  ..
};

string IRCSplit()
{
  ..
}


You'd have to change 'string' in both the struct and the function definition to 'String'. I believe. No idea though man, I've never looked at this TCP/IRC or whatever it's called module. I'm just assuming it's doing this by the error you're giving, which btw, is quite vague.

Icey

Sorry if I didnt explain enough. I didnt really know alot to say but I will take a look in the scripts and give it a try.


Icey

Oh I know! I will just post the section were the code error is.
Code: ags

void Act(this Character *, String action)
{
    if (action.Length < 1)
      return;

    
      String msg[] = action.IRCSplit();
    if ((msg[0] == "walks") && (msg[1] == "to"))
    {
      this.Walk(msg[2].AsInt, msg[3].AsInt, eNoBlock, eAnywhere);
    }
    else if ((msg[0] == "is") && (msg[1] == "at"))
    {
      if (!this.Moving)
      {
        this.x = msg[2].AsInt;
        this.y = msg[3].AsInt;
      }
    }
    // else if (msg[0] == "")
    // ...
}



I also noticed this in another script.
Code: ags

import String []IRCSplit(this String *);

Khris

You are trying to call String.IRCSplit or something.IRCSplit with something being String, yet that function doesn't exist/isn't defined.
E.g. if you used:

Code: ags
  String a;
  String b;
  b = a.IDontExist();


you'd get the same error.

Edit: Ok, the solution is to move the script that has the import line in its header to a higher place in the script list than the script with the Act function.

Icey


monkey0506

Ryan, the error specifically mentioned String, so I don't know why you'd assume it meant string.

You identified the method as an extender, but you clearly have no idea of how extender methods are defined. What you've done there is declared but never defined a normal struct method, and then defined a global function by the same name.

Also, actual extender methods are not possible for the old-style string type because it is not a struct type. Oh, and returning a string from a function was never formally supported.

@Studio3:

Any time you are using a module, always make sure that it is higher in the script list than any custom scripts that you will be using the module functions in.

Khris

Quote from: Studio3 on Thu 20/01/2011 21:29:52
Ok. I try it.

And just because this is the umpteenth time:
If you look at the MANUAL's section for modules, it says:
QuoteThe order of the scripts is important. A script can only use functionality from other scripts that come before it in the list, so the Move Up and Move Down options allow you to adjust the order. The global script is always at the bottom so that it can access all other scripts, and room scripts are automatically provided with access to all the scripts.

Icey

#8
Ok, I think I get now.

When I imported the scripts from the IRC tech demo I didnt import it right yet I put the scripts in a different order. So that's why the IRC game works fine and my game doesn't.

Well it seems this has come to a end but there is now a bonus question.

After the switch I got this error

error code:IRC.asc(651): Error (line 651): Local variable cannot have the same name as an import

Code: ags

  int j;


So what is an import?

Khris

There's a global variable or pointer somewhere in your game called "j". This could be the name of a GUI button, an inventory item, a character, pretty much anything that's accessible from everywhere and thus has their own "import [datatype] j;" line in the auto-generated AGS script.

There's a chance you can narrow it down; open a random script and type "j" into an empty line, then a dot "."
This should open the auto-complete window; from what it offers you should be able to deduct at least of what type j is.
Say the first entry is "ActiveInventory", then j is a Character.

Icey


Icey

#11
NVM I found it

Thanks Khris

SMF spam blocked by CleanTalk