NaN gold

Where bugs go to lie down and rest

Moderator: Moderator

Message
Author
bricks
Sher'Tul
Posts: 1262
Joined: Mon Jun 13, 2011 4:10 pm

NaN gold

#1 Post by bricks »

I can't really say when this onset. Once when I checked my character sheet, my gold showed up as nan, and then later at the Ring of Blood I noticed that my gold now showed up as nan on the main screen, too. Couldn't spend it, and when I saved and quit, I came back with 0 gold. Trying to transmogrify anything threw an LUA error, as did saving and quitting. b30, OSX, dwarf doomed.

Edit: Also get errors when I try to pick up money off the ground and check my character sheet.

Edit2: Going into the console and redefining game.player.money fixed it. Looks like money got undefined somehow.

Edit3: It seems to be a bug with the transmogrification chest? After using it on a staff, I got an error, my money was back to nan, and it looks like my fortress is just not getting energy.

Edit4: Was able to reset Fortress energy and money, and now no more errors. Hopefully this will last.

Edit5: Ugh. At least I caught it in the act this time. It all starts when transmogrifying a cursed halfing rough leather sling, which gave me nan gold.
Sorry about all the parentheses (sometimes I like to clarify things).

madmonk
Reaper
Posts: 2257
Joined: Wed Dec 12, 2007 12:21 am
Location: New Zealand

Re: NaN gold

#2 Post by madmonk »

The VM has changed from standard to Luajit2.

Loading an old savegame on a new VM will break.

Start again! I had to as well.
Regards

Jon.

bricks
Sher'Tul
Posts: 1262
Joined: Mon Jun 13, 2011 4:10 pm

Re: NaN gold

#3 Post by bricks »

Erm, great to hear, but I have no idea what that means. :lol: Guess I'll reinstall and start a new character...
Sorry about all the parentheses (sometimes I like to clarify things).

Hirumakai
Thalore
Posts: 192
Joined: Wed Aug 11, 2010 2:39 pm

Re: NaN gold

#4 Post by Hirumakai »

I also ran into this bug in b30 with a new character.

Basically I had a transmutation using the transmogrification chest report that I received nan gold. I had a level 17 Dwarven Wyrmic transmuting a cloak on the ground in the Shalore starting dungeon. was on a cloak. (I generally go hit the bosses in the starting dungeons for the Blood of Life in the 15-20 level range).

You can save once, but upon reload, 0.0 gold is reported. But if you try to buy something or go to save, it runs into lua errors dealing with the NaN nature of the gold amount. So basically game breaking.

Edit: This was on a MacBook Pro running OS 10.6.8

darkgod
Master of Eyal
Posts: 10751
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: NaN gold

#5 Post by darkgod »

I'd like a savefile please
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

bricks
Sher'Tul
Posts: 1262
Joined: Mon Jun 13, 2011 4:10 pm

Re: NaN gold

#6 Post by bricks »

Hmm, both of our character were dwarves around the same level and on OSX. Interesting, wonder if it is tied to Power is Money and the way our OSes handle NaN. I've since cheated to fix the character, but I'll send you a save next time I catch it in the act. It hasn't happened in a while.
Sorry about all the parentheses (sometimes I like to clarify things).

Hirumakai
Thalore
Posts: 192
Joined: Wed Aug 11, 2010 2:39 pm

Re: NaN gold

#7 Post by Hirumakai »

That character did not have Money is Power. I believe it is more likely to stem from a bug in the transmogrification code, since I saw a NaN in the log when transmuting, at which point the problems seemed to start.

I've sent a PM to Darkgod with a link to my save.

Did your character have the transmogrification chest and had been using it?

madmonk
Reaper
Posts: 2257
Joined: Wed Dec 12, 2007 12:21 am
Location: New Zealand

Re: NaN gold

#8 Post by madmonk »

When I had the problem that is exactly when it started. Using the transmog chest. Resolved in my case by a clean compile and a new character.
Regards

Jon.

bricks
Sher'Tul
Posts: 1262
Joined: Mon Jun 13, 2011 4:10 pm

Re: NaN gold

#9 Post by bricks »

Yes, happened after getting the transmo chest. Happened again, too. I think it's time to start over...
Sorry about all the parentheses (sometimes I like to clarify things).

Jules
Halfling
Posts: 117
Joined: Tue Jun 24, 2003 2:40 pm

Re: NaN gold

#10 Post by Jules »

I hit this too, whilst transmogrifying some purple weapon in an ambush.

The lua errors are caused by 'money' and 'shertul_energy' being missing from the savefile - adding them back in manually to the appropriate objects fixes the symptom. I don't know what it was about the object I transmogrified that broken it - a divide by zero in the code which calculates item values, perhaps?

darkgod
Master of Eyal
Posts: 10751
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: NaN gold

#11 Post by darkgod »

Perhaps fixed
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

bricks
Sher'Tul
Posts: 1262
Joined: Mon Jun 13, 2011 4:10 pm

Re: NaN gold

#12 Post by bricks »

I'm still getting this bug :( (b31). It only seems to show up after loading a save, too, though I can't be certain. Sending you the savefile, DG.
Sorry about all the parentheses (sometimes I like to clarify things).

lukep
Sher'Tul Godslayer
Posts: 1712
Joined: Mon Mar 14, 2011 10:32 am
Location: Canada

Re: NaN gold

#13 Post by lukep »

got the bug too. b31 OSX Thaloren Cursed, I noticed it in Daikara when I was level 19.
Some of my tools for helping make talents:
Melee Talent Creator
Annotated Talent Code (incomplete)

lukep
Sher'Tul Godslayer
Posts: 1712
Joined: Mon Mar 14, 2011 10:32 am
Location: Canada

Re: NaN gold

#14 Post by lukep »

Got a more specific situation for it now. Ring of Blood, I had 280-something gold on the next to last level, went down, next to the orb then saved. When I tried to use the orb, I had nan gold.

EDIT: it was from transmorgrifying a cursed bloodhexed iron pickaxe. reproducible, and I'm keeping a copy of the save (from before it happened).
Some of my tools for helping make talents:
Melee Talent Creator
Annotated Talent Code (incomplete)

Jules
Halfling
Posts: 117
Joined: Tue Jun 24, 2003 2:40 pm

Re: NaN gold

#15 Post by Jules »

I spent some time looking at this bug.

I expect you'll find it's not the pickaxe - load that save and transmogrify *anything* and it will go to NaN. At least, that's what it was like with my save file.

You can paper over the bug by setting game.player.money and game.player.quests["shertul-fortress"].shertul_energy explicitly (with lua console, or savefile edit) and, in my experience, it will be OK for a while and then break again.

I think this is a very strange luajit bug, because I was able to make it go away by adding the following lines to the transmogrifier transmo_inven code:

Code: Select all

					print("Entering transmo_use")
					print("  o:getPrice = ",o:getPrice(),type(o:getPrice()))
					print("  self.pricemod(o) = ",self.pricemod(o),type(self.pricemod(o)))
					print("  o.getNumber = ",o:getNumber(),type(o:getNumber()))
					print("  min = ",math.min(o:getPrice() * self.pricemod(o), 25),type(math.min(o:getPrice() * self.pricemod(o), 25)))
					print("  calculation = ",math.min(o:getPrice() * self.pricemod(o), 25) * o:getNumber())
					local price = math.min(o:getPrice() * self.pricemod(o), 25) * o:getNumber()
					print("  price = ",price)
Note that the only thing I added is a bunch of print statements to force it to evaluate those numbers first, I haven't changed anything. One of those will come out as 'nan' and that seems to 'flush' the bug and makes price calculate correctly.

It's not completely straightforward to try this out on a saved game, as the code for transmo_inven is saved with the object in your savefile; you have to manually copy it over in the lua console.

I'm really hoping it's fixed in luajit2beta8 which DG is using in SVN now, because I'm mystified. And if there is some weird bug with loading/saving numbers there is no reason to think it will only affect this subroutine, we could get weird bugs anywhere.

Post Reply