how to spawn a custom npc only in a custom world

Discussion in 'Released Mods' started by >:SYNTAX, Dec 19, 2012.

  1. >:SYNTAX Mouse

    so im working on my mod with sonicR and so far he has been a great help but where a bit stuck, just wondering if anyone has or has any knowledge about how to spawn a custom npc only in a certain world, because at the moment i have a portal item that teleports you to another world (Robot land) and i wanted only my npc to spawn there so far i have tried these codes.

    Code:
    public static bool SpawnNPC(int x, int y, int playerID)
    {
        if(ModPlayer.currentWorld = "Robot Land")
            return true;
     
        return false;
    }
    and
    Code:
    public static bool SpawnNPC(int x, int y, int playerID)
    {
        if(Main.worldName == "Robot Land")
            return true;
     
        return false;
    }
    and they don't work it dose not compile
  2. SonicR Bone Serpent

    Fixed it, code needs to be:

    Code:
    public static bool SpawnNPC(int x, int y, int playerID)
    {
        if(ModPlayer.currentWorld == "Robot Land")
            return true;
     
        return false;
    }
    An extra '=' was missing! :p

    BTW, the second example compiled fine for me, don't know what went wrong for you.
  3. >:SYNTAX Mouse

    ok as soon as we get the enemy npc working right it should be good, i think this may be the same for the town npc that i was trying to do there not spawning but everything elce dose

    and every once and a while i get these big holes in the ground that usualy have wood in them :confused:
    Untitled.png
    i just can think of what might have been there to cause this, maby curuption or jungle or somthing
  4. SonicR Bone Serpent

    The wood'll be a result of the killTrees line of code, but I've no idea what causes the holes. :confused:

Share This Page