Getting Error and don't know what it means

Posted by Ptrayal on Mon 21 Nov 2011 03:17 PM — 9 posts, 28,962 views.

#0
Hello:
I'm getting this error:
Run-time error
Plugin: Generic_GUI (called from world: Project Twilight)
Function/Sub: OnPluginTelnetSubnegotiation called by Plugin Generic_GUI
Reason: Executing plugin Generic_GUI sub OnPluginTelnetSubnegotiation
[string "Plugin"]:879: attempt to concatenate field 'GEN' (a nil value)
stack traceback:
[string "Plugin"]:879: in function 'draw_score'
[string "Plugin"]:1230: in function <[string "Plugin"]:1169>
Error context in script:
875 : y_offset = y_offset + 22
876 : -- text_line = 'Level '..msdp["LEVEL"]..' '..msdp["RACE"]..' '..msdp["CLAN"]
877 : text_line = msdp["CLAN"]
878 : if msdp["RACE"] == "Vampire" then
879*: outlined_text (colourGold, score_window, msdp["GEN"]..'th '..msdp["CLAN"]..'', 10, 5, y_offset, score_width)
880 : else
881 : outlined_text (colourGold, score_window, msdp["RACE"]..' ('..msdp["CLAN"]..')', 10, 5, y_offset, score_width)
882 : end -- if
883 :

And I can figure out it is saying that GEN is nil, but that cannot be the case. The code is:
MSDPSetNumber( d, eMSDP_GEN, d->character->gen );
and when I look at the pfile, it is saying it's 8th. So, I'm a bit confused. Can anyone help?
USA Global Moderator #1
I don't know what any of this means:
Quote:
MSDPSetNumber( d, eMSDP_GEN, d->character->gen );
and when I look at the pfile, it is saying it's 8th.

But your error message means that msdp["GEN"] is nil. "Cannot be the case" is obviously wrong.

Quote:
outlined_text
Hey, that looks familiar. :D
Amended on Mon 21 Nov 2011 06:01 PM by Fiendish
#2
OK, but I know it's wrong because it is giving me the correct number when I do a normal score, just not through MUSHclient.
USA Global Moderator #3
Ptrayal said:
OK, but I know it's wrong because...

No. The code interpreter is not lying to you. It is not saying "I think maybe msdp["GEN"] is nil". It is saying "at this point in the code the memory address referenced by msdp["GEN"] is nil!" So listen to the interpreter and then try to figure out why.

Quote:
it is giving me the correct number when I do

Don't use words like "it" without describing what "it" is. "it" doesn't mean anything to anyone else.

Quote:
do a normal score
Again, this is not a meaningful phrase to people who are not you. Describe what "do a normal score" entails.
Amended on Mon 21 Nov 2011 06:35 PM by Fiendish
#4
OK, you are right. When I run the do_score command, it also calls the gen with this:
if(IS_VAMPIRE(ch))
{
sprintf(buf, " Generation: %d", ch->gen);
send_to_char(buf, user);
}

Now, when I parse it to MSDP, it get's parsed like this:
MSDPSetNumber( d, eMSDP_GEN, d->character->gen );

Just like I've done all the others. However, this one isn't working for MSDP. So, I know there is a variable assigned to it because when I do my score function, I get the correct number.
Australia Forum Administrator #5
How about some debugging? Change:


if msdp["RACE"] == "Vampire" then
  outlined_text (colourGold, score_window, msdp["GEN"]..'th '..msdp["CLAN"]..'', 10, 5, y_offset, score_width)
else


to:


if msdp["RACE"] == "Vampire" then

  -- debugging

  if msdp["GEN"] == nil then
    Note "Problem with GEN in script!"
    require "tprint"
    tprint (msdp)
  end -- if

  outlined_text (colourGold, score_window, msdp["GEN"]..'th '..msdp["CLAN"]..'', 10, 5, y_offset, score_width)
else
#6
Well, I'm very confused. I got this.

Problem with GEN in script!
Run-time error
Plugin: Generic_GUI (called from world: Project Twilight)
Function/Sub: OnPluginTelnetSubnegotiation called by Plugin Generic_GUI
Reason: Executing plugin Generic_GUI sub OnPluginTelnetSubnegotiation
C:\Mushclient\lua\tprint.lua:36: attempt to call global 'type' (a string value)
stack traceback:
C:\Mushclient\lua\tprint.lua:36: in function 'tprint'
[string "Plugin"]:885: in function 'draw_score'
[string "Plugin"]:1239: in function <[string "Plugin"]:1178>

I'm not sure why it would be giving me gen in my telnet score but not here. Thoughts?
USA Global Moderator #7
Ptrayal said:

OK, you are right. When I run the do_score command, it also calls the gen with this:
if(IS_VAMPIRE(ch))
{
sprintf(buf, " Generation: %d", ch->gen);
send_to_char(buf, user);
}

Now, when I parse it to MSDP, it get's parsed like this:
MSDPSetNumber( d, eMSDP_GEN, d->character->gen );

I don't know what or where "do_score" is. You're talking about these things as if I'm sitting there looking over your shoulder, but I'm not. In any case it seems clear to me that ch->gen and d->character->gen are not even remotely the same thing as msdp["GEN"] as they are clearly different references in different codes. Just because you want them to ultimately have the same value in them doesn't make them related in any solid way.

I'm guessing you're working with both the server and client end on this? Make sure the raw value is being sent by the server. Make sure the raw value is being received by the client. Make sure the client is doing the right thing with the raw value. If it helps, you know where the client is saying that the value is nil. So start working backwards from there.

Quote:
So, I know there is a variable assigned to it because when I do my score function, I get the correct number.
No, you know there is a value assigned to something else in a different piece of code.

Quote:
attempt to call global 'type' (a string value)

This means that your script has overridden the type function with a string by creating a variable with the name "type" and assigning it a value. Just don't create a variable with the name "type".

The following BAD code will do the same thing:
type = "hello"
print(type(5))
Amended on Mon 21 Nov 2011 08:58 PM by Fiendish
Australia Forum Administrator #8
Agreed, don't do that.

Leave the "type" function to do its normal thing. Who knows what else is going wrong because of that?