ID:171767
 
I'm trying to get my usr.mobs to relocate to a certain point on a map after they are created when they login. This is what I got now:

mob/create_character    //the default mob
var/mob/character //later we'll be switching client to this
Login()
var/charactername = input("What is your name?","Name",src.key) //you should know this..
switch(input("What race do you wish to be?","Race","Daba") in list("Daba","Baiy"))
if("Daba") //if they chose to be a monkey
character = new /mob/daba()
if("Baiy")
character = new /mob/baiy()
character.name = charactername
src.client.mob = character
del(src) //delete the old mob
if(usr.team == 1) usr.Move("dabastart") //relocate the daba to the daba start point
if(usr.team == 2) usr.Move("baiystart") //relocate the baiy to the baiy start point


For some reason, it won't work. Can somebody fix my "if" statements or whatever is necessary to be able to warp my mobs to a different location? (Yes, I have already created a turf named "dabastart" and "baiystart", and placed them on the map, to note.)
Mizumon wrote:
I'm trying to get my usr.mobs to relocate to a certain point on a map after they are created when they login. This is what I got now:

> mob/create_character    //the default mob
> var/mob/character //later we'll be switching client to this
> Login()
> var/charactername = input("What is your name?","Name",src.key) //you should know this..
> switch(input("What race do you wish to be?","Race","Daba") in list("Daba","Baiy"))
> if("Daba") //if they chose to be a monkey
> character = new /mob/daba()
> if("Baiy")
> character = new /mob/baiy()
> character.name = charactername
> src.client.mob = character
> del(src) //delete the old mob
> if(usr.team == 1) usr.Move("dabastart") //relocate the daba to the daba start point
> if(usr.team == 2) usr.Move("baiystart") //relocate the baiy to the baiy start point
>

For some reason, it won't work. Can somebody fix my "if" statements or whatever is necessary to be able to warp my mobs to a different location? (Yes, I have already created a turf named "dabastart" and "baiystart", and placed them on the map, to note.)

I think it should be:
        if(usr.team == 1) usr.loc = locate(/area/dabastart) //relocate the daba to the daba start point
if(usr.team == 2) usr.loc = locate(/area/baiystart) //relocate the baiy to the baiy start point


This is assuming that dabastart and baiystart are areas
Also, whe they join a races you need to do something like

usr.team = 1

so that the value is set for the if to check
In response to Jik
Thanks, Jik, but the variables for "team 1" and "team 2" are already set, and the new inputed code:

        if(usr.team == 1) usr.loc = locate("area/dabastart") //relocate the daba to the daba start point
if(usr.team == 2) usr.loc = locate("area/baiystart") //relocate the baiy to the baiy start point


Still doesn't work. I've already defined daba start and baiy start using this:

area/dabastart
area/baiystart


But after creating either a Daba or a Baiy, the user still ends up at the lower left corner (where Baiy's are supposed to end up, but Daba's end up there, too.)
Don't use usr. Use src.
In response to Garthor
Thanks for the tip, Garthor, but even after altering the code to "src", it still doesn't work. My daba still ends up in the lowest left corner.

The code looks like this right now:
mob/create_character    //the default mob
var/mob/character //later we'll be switching client to this
Login()
var/charactername = input("What is your name?","Name",src.key) //you should know this..
switch(input("What race do you wish to be?","Race","Daba") in list("Daba","Baiy"))
if("Daba") //if they chose to be a monkey
character = new /mob/daba()
daba += 1
src.team = 1
if("Baiy")
character = new /mob/baiy()
baiy += 1
src.team = 2
character.name = charactername
src.client.mob = character
if(src.team == 1)
src.Move(locate(/turf/dabastart))//relocate the daba to the daba start point,
if(src.team == 2)
src.Move(locate(/turf/baiystart)) //relocate the baiy to the baiy start point
del(src) //delete the old mob


In response to Mizumon
Because Login() is called for the new mob when you change your mob to it. Login() is called when you change mobs, not when you log into the game. client/New() is called when you log into the game. client/Del() is called when you log out.
In response to Mizumon
Mizumon wrote:
Thanks for the tip, Garthor, but even after altering the code to "src", it still doesn't work. My daba still ends up in the lowest left corner.

The code looks like this right now:
> mob/create_character    //the default mob
> var/mob/character //later we'll be switching client to this
> Login()
> var/charactername = input("What is your name?","Name",src.key) //you should know this..
> switch(input("What race do you wish to be?","Race","Daba") in list("Daba","Baiy"))
> if("Daba") //if they chose to be a monkey
> character = new /mob/daba()
> daba += 1
> src.team = 1
> if("Baiy")
> character = new /mob/baiy()
> baiy += 1
> src.team = 2
> character.name = charactername
> src.client.mob = character
> if(src.team == 1)
> src.Move(locate(/turf/dabastart))//relocate the daba to the daba start point,
> if(src.team == 2)
> src.Move(locate(/turf/baiystart)) //relocate the baiy to the baiy start point
> del(src) //delete the old mob
>


Basicly you have just made a new mob which is refered to as "character" and then you switch the client.mob of src to this new mob. But then you try to move the old mob then you delete the old mob straight after. You should be doing if(character.team == 1) character.Move(locate(whatever))
In response to Wanabe
Also, the default first argument for input() is usr. You should use input(src, whatever).
In response to Garthor
Garthor wrote:
Also, the default first argument for input() is usr. You should use input(src, whatever).

True, I overlooked that.
In response to Garthor
[edit] I switched the if statements to "character.team" and the Move() to "character.move", but the teleportation still doesn't work. I'm going to see if I can use something else to alter positions.