ID:178728
 
This is my butterfly code...


Butterfly
icon='npcs.dmi'
icon_state="butterfly"
walk_rand(src,5)
density=0
layer=5

can someone help me i get an error that says

Mobcode.dm:24:error:src:duplicate definition
Mobcode.dm:24:error:5:duplicate definition

please if you know whats wrong tell me
Because there is no src, you have no parent type for the datum.

mob/butterfly
icon = 'npc.dmi'
icon_state = "butterfly"
density = 0
layer = 5
New()//when it's created
walk_rand(src,5)
is there anyway to make it so that when the butterfly gets to the end of an area it will go back and not into the other area?
In response to SuperGoku15
SuperGoku15 wrote:
is there anyway to make it so that when the butterfly gets to the end of an area it will go back and not into the other area?

Yes. There are two basic ways to do this.

The first is to create a special area type, and set up its Exit() proc so that the butterfly can't leave:
area/ButterflyRange
Exit(atom/movable/A)
if(istype(A,/obj/butterfly))
return 0 // can't leave!
return ..()

The other way is for the butterfly's Move() proc to do the checking for it:
obj/butterfly
var/area/A

New()
..()
if(isturf(loc)) A=loc.loc
walk_rand(src,5)

Move(atom/newloc)
if(isturf(newloc))
if(newloc.loc!=A) return 0 // not the same area
return ..()

There may be reasons to prefer one method over the other.
Hope that helps.

Lummox JR