Defect report: functions.lua:920

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
Cindy
Posts: 237
Joined: Fri Sep 28, 2012 4:23 pm

Defect report: functions.lua:920

#1 Post by Cindy »

"attempt to index local 'skill_from_db' (a nil value)'

I tried to run a script (elfdaily2 ) to level alts, and it worked fine yesterday, croaked with the above message today. I suspect that a new skill my scout elf got at level 6 causes a nil return in the code below (the error appears to happen on the if condition line, most likely because its null from the first line?):

Code: Select all

	local skill_from_db = database.skills[_skillname];	-- read skill parameters from database

	-- check is skill has an aslevel in skills.xml
	if ( skill_from_db.aslevel ~= nil and
		 skill_from_db.aslevel > player.Level ) then
		cprintf(cli.yellow, "You need at least level %d to levelup skill %s. Your level is %d.\n",
		   skill_from_db.aslevel, _skillname, player.Level );
		return false;
	end
Happened on two different accounts on two different characters, both level6 and both scouts.
Cindy
Posts: 237
Joined: Fri Sep 28, 2012 4:23 pm

Re: Defect report: functions.lua:920

#2 Post by Cindy »

So debugged with:

Code: Select all

	local skill_from_db = database.skills[_skillname];	-- read skill parameters from database
	print(_skillname)
	-- check is skill has an aslevel in skills.xml
got:

SCOUT_SHOT
SCOUT_WIND_ARROWS
SCOUT_RANGED_WEAPON_MASTERY

Perhaps some defensive coding for skill_from_db == nil would be appropriate after the db lookup.
Cindy
Posts: 237
Joined: Fri Sep 28, 2012 4:23 pm

Re: Defect report: functions.lua:920

#3 Post by Cindy »

This is a temporary fix, but i think a better one is needed (one that considers the design of this function fully)

Code: Select all

	local skill_from_db = database.skills[_skillname];	-- read skill parameters from database
	print(_skillname)

	if (skill_from_db == nil) then return false end
	
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Defect report: functions.lua:920

#4 Post by rock5 »

Good work on debugging it yourself. This has actually been around for a long time. It's one of the very many things I'm fixing in the upcoming version of the bot that I've been working on. :D Your fix should do nicely until the update.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Defect report: functions.lua:920

#5 Post by lisa »

hmm wouldn't this do that anyway

Code: Select all

skill_from_db.aslevel ~= nil
because if skill_from_db is nil so would skill_from_db.aslevel be nil.

NVM i looked it up in the file, yeah needs a check for nil
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Defect report: functions.lua:920

#6 Post by rock5 »

Yeah, you can't index a non table. So you can't do

Code: Select all

skill_from_db.aslevel ~= nil
unless skill_from_db is a table.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
Cindy
Posts: 237
Joined: Fri Sep 28, 2012 4:23 pm

Re: Defect report: functions.lua:920

#7 Post by Cindy »

the first object, if its nil, then it generally doesnt have fields/members.. so the compiler would fail trying to resolve the field.
Cindy
Posts: 237
Joined: Fri Sep 28, 2012 4:23 pm

Re: Defect report: functions.lua:920

#8 Post by Cindy »

This now has a new form, this time on line 1006:

.../rom/functions.lua:1006: attempt to index local 'skill_from_db' (a boolean value)


Seems to crash my warden character(s) this time.
Cindy
Posts: 237
Joined: Fri Sep 28, 2012 4:23 pm

Re: Defect report: functions.lua:920

#9 Post by Cindy »

my print debug got me:

WARDEN_THORNY_VINE
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Defect report: functions.lua:920

#10 Post by rock5 »

Double check your skills names. You would get that error if one of them was spelled wrong. Sorry the error message wasn't more helpful.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
Cindy
Posts: 237
Joined: Fri Sep 28, 2012 4:23 pm

Re: Defect report: functions.lua:920

#11 Post by Cindy »

I don't even have that skill in my profile. This is a fresh install of the bot from yesterday.
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Defect report: functions.lua:920

#12 Post by rock5 »

You probably have "levelupSkills1To10" in your profile and it's misspelt in that function. The line to fix is 1079 of functions.lua

Code: Select all

								 [3] = { aslevel = 2, skillname="WARDEN_THORNY_VINE" },
should be

Code: Select all

								 [3] = { aslevel = 2, skillname="WARDEN_THORNY_VINES" },
Or if you don't really need or want to use levelupSkills1To10 then you can just remove it from your profile.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
Cindy
Posts: 237
Joined: Fri Sep 28, 2012 4:23 pm

Re: Defect report: functions.lua:920

#13 Post by Cindy »

Code: Select all

								 [3] = { aslevel = 2, skillname="WARDEN_THORNY_VINE" },  

You are half right. The problem is skill name, but its in the fuctions.lua file :)

EDIT: Never mind, you found it also.
Post Reply