ID:1561182
 
(See the best response by FKI.)

obj 
Plane
icon = 'Plane1.dmi'
density = 0
verb
Fly()
set src in oview(3)
world << "There is no Fuel in the tanks!"

Refuel()
set src in oview(2)
for(var/obj/Fuel/a in usr.contents) //cycle through the contents
if(istype(a)) //if the obj in contents is the type /obj/Fuel, lets reload
world << "You have succesfully Refueled the Plane!" //tell the user
. = 1 //return a 1
break //break (or return)
new /obj/FueledPlane (src.loc)
del (a)
del src
if(!.)//if it wasn't found
world << "There isn't Fuel in your inventory!"


Fuel
icon = 'Fuel.dmi'
verb
Pick_Up()
set src in oview(0)
world << "You found some fuel!"
src.Move (usr)

FueledPlane
icon = 'Plane1.dmi'
verb
Fly()
set src in oview(3)
usr.icon = 'Plane1.dmi'
usr.density = 0


I think my problem is somewhere in the invent search part, the code won't delete my unfueled plane and it won't give me the fueled plane. I don't know what im doing wrong, but I think one of me del codes is messing up the rest of the code. Please help!

Best response
I think you want to get rid of that break. It exits the loop and goes straight to the code that follows it (in this case, the if(!.)).
Flying1ace wrote:

obj
Plane
icon = 'Plane1.dmi'
density = 0
var/isfueled = 0
verb
Fly()
set src in oview(3)
if(isfueled)
usr.icon = 'Plane1.dmi'
usr.density = 0
else
world << "There is no Fuel in the tanks!"

Refuel()
set src in oview(2)
for(var/obj/Fuel/a in usr.contents) //cycle through the contents
if(istype(a)) //if the obj in contents is the type /obj/Fuel, lets reload
world << "You have succesfully Refueled the Plane!" //tell the user
. = 1 //return a 1

del (a)
isfueled = 1
break //break (or return)

if(!.)//if it wasn't found
world << "There isn't Fuel in your inventory!"


Fuel
icon = 'Fuel.dmi'
verb
Pick_Up()
set src in oview(0)
world << "You found some fuel!"
src.Move (usr)



Deleting is expensive and can be complicated. You can toggle an isfueled var in order to get the same behavior without the initialize/dispose overhead. You also wouldn't have to account for setting src to null.
Thanks to both of you, um, how can I make the usr travel faster when in his plane? Is this possible?
In response to Flying1ace
Flying1ace wrote:
Thanks to both of you, um, how can I make the usr travel faster when in his plane? Is this possible?

If you are using pixel movement (turned on by default) then just change the step_size variable to a higher number on the plane's atom *I believe it starts at 8)
so for instance: src.steps_size = 16?
In response to Flying1ace
Flying1ace wrote:
so for instance: src.steps_size = 16?

^^ Correct! though you had a typo. step_size=16
In response to Dariuc
a bit of topic but you said if your using pixel based movement, does that mean there are other ways to govern the movement of the user
You can add a delay on Move(), which causes a slower moving effect.
In response to Pirion
how would you do that?
Whats Move()?
In response to Flying1ace
Thanks!
In response to Neatht
Neatht wrote:
how would you do that?


You add a constraint and wait on Move(), this example will affect all types of move. You would probably want to go on to add a move source and only apply this constant when the mob moves themselves.
mob/Move()
if(Moving) return //if we're moving, exit
Moving = TRUE //set move to moving
..()
sleep(10) //this waits before allowing a new move
Moving = FALSE //allow a new move now
In response to Pirion
thanks