ID:164013
 
hey there, how would i go about making power pellets that disappear when you move into them and they give you 5 points (10 for power pellets)?
mob
Move()
..()
var/obj/pellet/P = locate() in src.loc
if(P)
src.points += 5
del(P)
In response to Nadrew
thx for the help--scratch that, dont work..

mob
Move()
..()
var/turf/pellet/P = locate() in src.loc
if(P)
src.points += 5
del(P)

mob/var/points=0
turf
pellet
icon='pellets.dmi'
icon_state="sm"
layer=5
power_pellet
icon='pellets.dmi'
icon_state="bg"
layer=5

mob/var/moving=1
client
North()
usr.dir=NORTH
South()
usr.dir=SOUTH
East()
usr.dir=EAST
West()
usr.dir=WEST

mob
proc
Walk_Loop()
while(usr.moving)
sleep(2)
step(usr, usr.dir)
In response to VolksBlade
Don't make the pellets turfs. Make them objects. Turfs are for ground, blocks, walls, etc. Objects are for items and such.
In response to Phas
Also don't copy paste. Most of the time, example given will not work for your code, but will only serve and an example and will only work for the example given.
In response to VolksBlade
VolksBlade wrote:
thx for the help--scratch that, dont work..

> mob
> Move()
> ..()
> var/turf/pellet/P = locate() in src.loc
> if(P)
> src.points += 5
> del(P)
>
> mob/var/points=0
> turf
> pellet
> icon='pellets.dmi'
> icon_state="sm"
> layer=5
> power_pellet
> icon='pellets.dmi'
> icon_state="bg"
> layer=5
>
> mob/var/moving=1
> client
> North()
> usr.dir=NORTH
> South()
> usr.dir=SOUTH
> East()
> usr.dir=EAST
> West()
> usr.dir=WEST
>
> mob
> proc
> Walk_Loop()
> while(usr.moving)
> sleep(2)
> step(usr, usr.dir)
>


Your code is trying to find a turf inside the turf that you just entered -- generally speaking, two turfs won't occupy the same space (especially in this specific case -- pellets should be objects). You're going to want to do something like this;

obj/pellet
var/pointValue // This will let you easily assign values to each pellet.
SmallPellet
pointValue=5
BigPellet
pointValue=10
mob
Move()
..() // This will call the default process for the Move() procedure.
for(var/obj/pellet/locPellet in loc) // This will find all types of /obj/pellet in your new location, and then add their pointValue variable to your totalScore variable.
totalScore += locPelet.pointValue