Hi, I'm having a bit of difficulty getting my 'get' command to function properly. I'm working on a primarily text-based mud (with a very crude/basic text map of the rooms in view). I just recently implemented EbonShadow's Parser (hat's off to EbonShadow and Foomer for releasing such a useful library). My 'get' command works perfectly, IF you don't already have the item. You can't pickup two knives or two of the same sets of armor. Its probably somthing really simple, but I'm not seeing it. I've tried several rewrites of the command, but I can't seem to get it working right. Here is my current code;
get
name = "get"
desc = "pick-up an item"
template = "get obj in view"
category = "social"
function(obj/O)
var/turf/T = usr.loc
if(O in T)
if(O.Move(usr))
usr.Msg23("You get [O].","[usr] gets [O].")
usr.enc = usr.CheckEnc(usr)
return
usr << "Failed"
If I change the 'if(O in T)' to 'for(O in T)' I can pickup multiples of the same item, BUT the parser simply picks up the first item in the room (ie, 'get knife' would pickup armor if it was listed first). Any help would be greatly appreciated. Thank you.
ID:175483
Apr 18 2003, 10:37 am
|
|
In response to Foomer
|
|
I tried, but can't pick up any items now :)
'get knife' runtime error: list index out of bounds proc name: scan for num (/proc/scan_for_num) source file: Foomer.dm,29 usr: Rothchild (/mob/player) src: null call stack: scan for num(the knife (/weapon/edged/knife), -1) FoomerParse(the knife (/weapon/edged/knife), Kitchen (3,1,1) (/turf/Kitchen)) get (/Command/get): function(the knife (/weapon/edged/knife)) mb parseline("get knife", get (/Command/get), "obj in view") Rothchild (/client): Parse("get knife") Rothchild (/client): Command("get knife") Failed. Foomer.dm, line 29 is the first if statement for the switch in the san_for_num proc |
In response to Rothchild
|
|
Okay, I have no idea what I'm doing then, nevermind. :)
|
In response to Foomer
|
|
Thanks for the help though. I still miss your MUDdesign forum... :)
|
Rothchild wrote:
Hi, I'm having a bit of difficulty getting my 'get' command to function properly. I'm working on a primarily text-based mud (with a very crude/basic text map of the rooms in view). I just recently implemented EbonShadow's Parser (hat's off to EbonShadow and Foomer for releasing such a useful library). My 'get' command works perfectly, IF you don't already have the item. You can't pickup two knives or two of the same sets of armor. Its probably somthing really simple, but I'm not seeing it. I've tried several rewrites of the command, but I can't seem to get it working right. Here is my current code; Im not quite sure what your question is, but I think your problem is here. If you don't want the user to pick up items he already has, then 'view' should be 'oview' If there are two of the same types of knife in the room, to get the second one simply type 'get 2.knife' or something like that. |
<code>get name = "get" desc = "pick-up an item" template = "get obj in view" category = "social" function(obj/O) var/turf/T = usr.loc if(O in FoomerParse(O, T)) if(O.Move(usr)) usr.Msg23("You get [O].","[usr] gets [O].") usr.enc = usr.CheckEnc(usr) return usr << "Failed."</code>
I can't guarantee that it wil work, since I don't know where or if the library uses that elsewhere as a default action, but it couldn't hurt to try.