One of the problems I'm running into, and not quite sure how to solve it yet, is how to specify which object to get.
For example:
mob/verb/look()
var/obj/O
for(O in usr.loc)
usr << O.name
return
obj/verb/get()
set src in oview(0)
src.Move(usr)
return
Now if look() returns multiple names, all of the same like:
wood
wood
wood
it becomes difficult to specify which one to get. I know about using the wood.0 wood.1 wood.2 but it's very unwieldly and doesn't work very well when using the auto-complete command line due to the command line putting a space after the word (have to backspace and type a period and the number).
I was thinking about tagging all the objects with the same name with something like tag=i++ but wasn't sure how well I could get it to work in practice. I could then have the usr specify a number with the object (or just a number)... like
System Output:
wood(1)
wood(2)
wood(3)
User Input:
get wood 1
get wood one
get 1
get one
These examples are an oversimplification of what my actual code is, but it demonstrates the principle.
Any thoughts, ideas or inspiration?
Regards,
Gabriel
ID:180894
Nov 14 2000, 6:24 pm
|
|
Are either of these any use?
proc multiprompt(mob/M, title, list/choice) var/indexed[0] var/i var/reply for(i = 1, i <= choice.len, i++) indexed += "[i] [choice[i]]" reply = prompt(M,"[title]") in indexed i = text2num(reply) return(choice[i]) objprompt(mob/M, title, list/choice) var/indexed[0] var/obj/O var/i var/reply for(i = 1, i <= choice.len, i++) O = choice[i] indexed += "[i] [O.name] [O.desc]" sleep(10) reply = prompt(M,"[title]") in indexed i = text2num(reply) return(choice[i]) Sorry about formatting, I'm a bit pushed for time. |
Sure, this could work. You could do:
get(O as obj in view(),thenum as null|anything in Numlist(O,view()))
if (thenum) O = Which(thething,thenum,view())
var/extra = ""
if (thenum) extra = " number [thenum]"
usr << "You get [O][extra]."
proc
Numlist(obj/thething,list/inlist)
var/obj/O
var/numberup = 1
var/list/outlist = new /list
for (O in inlist)
if (O.name == thething.name)
outlist += "[numberup]"
numberup++
return outlist
Which(obj/thething,thenum,list/inlist)
var/obj/O
var/numberup = 0
for (O in inlist)
numberup++
if (O.name == thething.name && thenum == num2text(numberup)) return O
Now if there are 4 woods, a player can type "get wood 3" and see "You get wood number 3." And should also be able to type just "get wood". I haven't tested this particular code.
Z