ID:144584
 
obj
Pp
icon='pp.dmi'
icon_state="PG"
var/pppower=0
var/Radio=0
var/Battery=0
DblClick()
set src in oview(1)
usr.client.screen += new/obj/HUD/power1
usr.client.screen += new/obj/HUD/X
verb
insertbattery()
set src in oview(1)
if(locate(/obj/battery) in usr.contents)
src.Move(/obj/battery)

checkpower()
set src in oview(1)
usr<<"Power is at [pgpower]"

obj
battery
icon='pp.dmi'
icon_state="battery"
var/power=100000
var/active=0
verb
Pickup()
set src in oview(1)
src.Move(usr)
proc
powering()
while(active)
power-=100


How would i put the battery into the powerpack, than the power pack would draw the energy from the battery if certain things was on like head phones and CD spining would use more power. I think i'm being really silly here i can't concentrate so have a look if you can.
Yorae wrote:
> obj
> Pp
> verb
> insertbattery()
> set src in oview(1)
> if(locate(/obj/battery) in usr.contents)
> src.Move(/obj/battery)


This part is the part that is the problem, I believe. It can be rewritten like so:

obj/Pp/verb/insertbattery()
set src in oview(1)
var/obj/battery/b = locate() in usr
if( !b ) return
b.loc = src.contents // We want to deal with adding/removing from contents as little as possible. It's a tad bit buggy.

In response to Audeuro
Thanks for the help audeuro works perfectly.