ID:169925
 
Ok, has anyone played one of the BYOND .Hack games, if so you will know what I'm talking about.

Question: How would you make it to were, if you use the verb PSay, you say the name of a place you wish to go in the text bar, and if that place exists, you get teleported there?


Thanks in Advance.

~C



{Edit}I figure it would involve like a bunch of ifs I think, but, I could make it a input, but I'd much rather have it as a text thing.
Try this:

First create a list of the places you can go to:

var/list/places = list("City1","City2")


Now we'll first save a variable in PSay() which holds the place we want to go to. Then check to see if our place exists in the list.

mob/verb/PSay(place as text) //declare the variable place
if(places.Find(place)) //if we found the place in our list.
*Transportation code*


If you don't have a transportation code, use this simple one(which by the way sucks to be honest).

         if(place=="City1") //if then that place was City1
usr.loc = locate(1,5,1) //transport to City1
else if(place=="City2")
usr.loc = locate(2,10,1) //transport to City2
In response to DeathAwaitsU
Thanks, I'll try it out.
In response to Chwgt
Ok, I've got that, but there occured to me another problem, I want it were if the obj/Gate is in(oview(1)) the verb PSay() works, if not it doesn't work, but I don't know if that would still be just a in(oview(1)) or done a diffrent way. Could someone please explain.
In response to DeathAwaitsU
DeathAwaitsU wrote:
>          if(place=="City1") //if then that place was City1
> usr.loc = locate(1,5,1) //transport to City1
> else if(place=="City2")
> usr.loc = locate(2,10,1) //transport to City2
>


This is very inflexible - if you ever change the map (and you will), suddenly you'll have to redo all of the locations in the code. Not very fun!

Instead, use tags. In the map editor, edit the tag variable of the turf (or area) you want to be the first city and make its value "City1". Same for City2 and the rest of them. Then your teleport code is simply:

usr.loc = locate(place)


See http://bwicki.byond.com/ByondBwicki.dmb?TeleportingMobs for a more complete explanation of this technique.
In response to Mike H
Or, an even quicker way would be:
mob/verb/teleport(T as text)
for(var/obj/gate/t in oview(src,1))
t.operate(src,T)
break
obj
gate
proc/operate(mob/M,T as text)
if(T in warps)
M.loc=locate(text2path("/area/[ckey(a)]"))
var/list/warps=list("Chicken","Beef","Shrimp","Hell")
area
chicken
beef
shrimp
hell


I think something like that would work. =/ (Put the areas on the map)
In response to Chwgt
Ok, when you use the verb, it wont locate you were it should can someone help?

mob
verb
PSay(place as text) //declare the variable place
if(places.Find(place))
if(/obj/Gate in oview(1)) //if we found the place in our list.
if(place=="Home") //if then that place was City1
flick("Gate",usr)
sleep(8)
usr.loc = locate(11,4,1) //transport to City1
flick("Return",usr)
else
return