ID:263238
 
Code:
obj/spawnpoints
MaleTeacher1_Spawn_Point
new/mob/NPC/MaleTeacher1=locate(/obj/spawnpoints/MaleTeacher1_Spawn_Point)

mob/NPC
MaleTeacher1
icon='Light.dmi'


Problem description:I haven't bothered to start coding the teacher yet because I wanted to get the spawn to work first. Okay, What I was trying to do was place obj/spawnpoints/MaleTeacher1_Spawn_Point on the map then when the game comes up the NPC spawns there. I really didn't have any clue how to do it and I tried but can't seem to do it.

You haven't even set his spawn point. Try something like this.

mob
NPC
New()
loc = spawn_point
..()
npc_1
icon = "icon.dmi'
spawn_point = "49,49,1"




Not completely sure if I'm assasigning the x,y,z locations correctly, I just woke up.

By keeping new where it is, under NPC, it will locate all of them everytime an NPC is created, so you don't needa long ass codes of New().
In response to Pyro_dragons
Well can't you just have that person spawn wherever the obj/spawnpoint is??
In response to Kurosaki_Ichigo-San
I just edited that post, reread it please.
In response to Kurosaki_Ichigo-San
You can. Have a look at my spawner demo. http://developer.byond.com/hub/Jmurph/SpawnerExample

It shows how to create spawner objs.
In response to Pyro_dragons
Okay thanks.
In response to Kurosaki_Ichigo-San
The way I showed you is a very effiecient way. There really isn't any need for long and involved code. Just set the spawn_point var for each NPC, have New() indented as I showed you, and it will relocate everytime an NPC is created. NO long amounts of code invovled, just the setting of a variable.
In response to Pyro_dragons
mob/var/spawn_point

mob
NPC
New()
spawn_point=loc
loc = spawn_point
..()
Teacher1
icon='Light.dmi'
spawn_point = "54,79,12"


Well that's what I got so far and it still isn't spawning. Anyone know what i'm doing wrong?
In response to Kurosaki_Ichigo-San
This should work for basic purposes:
mob
NPC
var/spawn_point //Unless you need this variable for all mobs in general, don't define it under just /mob.
New()
spawn_point=loc //When an NPC is created, set their spawn_point to that location
..()
Teacher1
icon='Light.dmi'


Then whenever you want to move them back to their spawn, just do "loc=spawn_point". However, if you plan to have players kill the teacher, and you'll need for another one to be created, something like this should do the trick:

obj/spawnpoints
var/SpawnType
New(L,T)
SpawnType = T
..()
proc/respawn()
spawn(100) //Wait 100 ticks (ten seconds) before spawning
new SpawnType(loc)

mob
NPC
var/obj/spawnpoints/spawn_point
New()
spawn_point=locate() in loc //When an NPC is created, first check if there is a spawn point already for them to use.
if(!spawn_point || spawn_point.SpawnType!=type) //If there isn't a spawn point, or it's not for this type of NPC...
spawn_point= new/obj/spawnpoints(loc,type) //...create a new one
..()
Teacher1
icon='Light.dmi'


And then when you kill a teacher and need them to respawn, just do something like this:
spawn_point.Respawn()


If you wanted to be fancy, you could even create a varaible so different NPCs can have different spawn times.

Hope that helps
In response to DarkCampainger
This isnt working....
mob/NPC
Teacher
icon='Light.dmi'
New()
var/obj/spawnpoints/MaleTeacher1_Spawn_Point/M
loc=locate(M)
obj/spawnpoints
MaleTeacher1_Spawn_Point


I've been trying all day and I dont think im even comnig close....Someone please help @_@
In response to Kurosaki_Ichigo-San
mob/NPC
var/tmp/homeloc
New(lok,homeloc)
if(!homeloc)=initial(loc)//usually mobs that are placed on maps have initial(loc) as TRUE... spawned has it as FALSE
..()
if(lok)
loc=lok
if(!homeloc) homeloc=lok
else if(homeloc) loc=homeloc

Ichigo
icon='I.dmi'//lets say we placed this on the map, when created homeloc should be set
Kon
homeloc=locate(1,2,3)//lets say we can only spawn it here via creation... you get the idea


Really, this is the important line[s]:
  var/tmp/homeloc
New()
if(!homeloc)=initial(loc)


- GhostAnime

Edit: If you wanna try your method, I suggest trying this:
loc=(locate(M) in world)
In response to GhostAnime
In wiz_chat, we suggested (Multiple times, might I add, to this same guy) creating a new object of type /turf/spawn or something, then placing them on the map and setting the tags up to do a simple locate.
In response to Audeuro
...that way sounds a lot better... Funny thing is that I have the same system for teleporting in many games (cuz I use different map files) and I totally forgot about it :x

- GhostAnime