ID:149898
 
Ok i'm writing an auction function, but it's driving me up the wall, here's the code so far:
var/AuctionLib_Progress = 0
var/obj/AuctionLib_Object = null
var/AuctionLib_Bid = 0
var/mob/AuctionLib_owner = null
var/mob/AuctionLib_Bidder = null
proc
Auction_Object(var/obj/O in view(usr,0))
if(AuctionLib_Progress > 0)
usr << "An auction is already taking place!"
return
if(!(O in usr.contents))
usr << "You must be holding this item to auction it!"
return
if(O.Equipped=="True")
usr << "You must unequip this item first!"
return
var/Amt = input("Starting Price:","Auction") as num
AuctionLib_owner = usr
AuctionLib_Progress = 1
AuctionLib_Object = O
del(O)
AuctionLib_Bid = Amt
var/tmp/Gnd
if(AuctionLib_owner.key=="female")
Gnd="her"
else
Gnd = "his"
world << "<b>Auction:</b><font color=#0000AA> [AuctionLib_owner.Name] is auctioning [Gnd] [AuctionLib_Object.name] for [AuctionLib_Bid]GOLD!</font>"


But when I try to use AuctionLib_Object, it freaks... All I want to do is store the player, auctioner, and object so I can know who to give what... ANY help woud be greatly appreciated :D
How exactly does it 'freak'? If you give me more detail on it, I could possibly help.

-Rcet
In response to Rcet
Gives me this runtime error when i click auction on an object:
runtime error: Cannot read null.name.
proc name: Auction Object (/verb/Auction_Object)
source file: AuctionLib.dm,62
usr: Dreq (/mob/player)
src: Dreq (/mob/player)
call stack:
Dreq (/mob/player): Auction Object(null)


Btw, line 62 is:
world << "<b>Auction:</b><font color=#0000AA> [AuctionLib_owner.Name] is auctioning [Gnd] [AuctionLib_Object.name] for [AuctionLib_Bid]GOLD!</font>"
In response to Dreq
So then...we can narrow the problem down to "AuctionLib_Object" being null by the time we get to line 62...because that's the one with the "name" variable...

And, looking through your code... I found the folowing...

        AuctionLib_Object = O
del(O)


So you've seemingly deleted "AuctionLib_Object"....thereby causing "AuctionLib_Object.name" to be a reference to something that is now null...which gives you that error...

At least, that's what it looks like to my semi-untrained eye...

As for how to make the auction code work...I don't have any help to give...lol
Dreq wrote:
AuctionLib_Object = O
del(O)


Im not sure, but I think this is your problem...

I believe AuctionLib_Object is at this point simply a reference, not an actual object. You would have to declare it as new before you del(O), or it references a deleted object.

In response to Flick
Thank you very much!
*quickly restores DreamMaker and finishes his code*