ID:140776
 
Code:
//This is how i create the element.
mob
verb
Extract_Element()
var/time=input("how much energy do you want to put in the extracted element?","energy")as num
if(time > usr.energy)
usr << output("You do not have enough energy!","SM")
return
else
new/obj/glimmer( locate(src.x,src.y+1,src.z),time)
usr.energy -= time
// This is the object created
obj
glimmer
icon = 'DevilFruitPowers.dmi'
icon_state = "Glimmer"
density = 0
var/owner
//.. time proc etc.. i have left out, dont think its relevant?

//this is how i intended to control the element(obj).
turf
Click()
for(var/obj/glimmer/G in world)//possibly use view/oview?
if(G.owner == usr)
walk_towards(Q,src,0)

//what i have tryed:
mob
verb
Extract_Element()
var/time=input("how much energy do you want to put in the extracted element?","energy")as num
if(time > usr.energy)
usr << output("You do not have enough energy!","SM")
return
else
var/G = new/obj/glimmer( locate(src.x,src.y+1,src.z),time)
G:owner = usr
usr.energy -= time
//this doesn't work.


Problem description:How to make the user who extracted the element(obj) the owner of it, and so able to move it around with click.

Here you go
mob
var/tmp/list/GlimmerPets
verb
Extract_Element()
var/time=input("how much energy do you want to put in the extracted element?","energy")as num
if(time > usr.energy)
usr << output("You do not have enough energy!","SM")
return
var/obj/glimmer/G = new()
G.loc=locate(src.x,src.y+1,src.z)
G.energy=time
usr.energy -= time
if(!usr.GlimmerPets)
GlimmerPets=new()
GlimmerPets+=G
obj
glimmer
icon = 'DevilFruitPowers.dmi'
icon_state = "Glimmer"
density = 0
var/energy=0
var/owner
turf
Click()
if(!usr.GlimmerPets) return
for(var/obj/glimmer/G in usr.GlimmerPets)
walk_towards(G,src)

It probably wont integrate seamlessly because its dependent on things I can't see. If you post whatever problems you have next it shouldn't be that hard to fix.
In response to Chowder
hello, it works like a charm! almost :P

the movement parts work great, (click and it moves to where i click and only where i (the owner) click)

however, the time function of it does not work. it wont delete itself. here is how it is set up atm.
obj
glimmer
icon = 'DevilFruitPowers.dmi'
icon_state = "Glimmer"
density = 0
var/owner
var/time= 0 // under obj/ball since only ball needs it
Bump(mob/M)
if(istype(M)) // type check
M.hp -= time
time=0 // make the ball time 0 so it'll delete itself ? Your call
New(loc,timechosen,owner) //Receive the time chosen by the creator of the ball
src.time=timechosen
time()
src.owner = owner
..()
proc
time() // this can be under obj/ball since that's where you need the time()
while(src.time > 0)
sleep(10)
src.time -= 1
if(src.time <= 0)
del(src)
Click()
switch(input("What do you want to do?","choose") in list("Density","Manipulate Area","Cancel"))
if("Density")
if(src.density != 1)
src.density = 1
usr << output("The Element is now dense","SM")
return
else
src.density = 0
usr << output("The Element is now undense","SM")
return
if("Manipulate Area")
if(src.mparea != 1)
src.mparea = 1
else
src.mparea = 0
if("Cancel")
return
Move()
if(src.mparea == 1)
var/time = src.time
new/obj/light( src.loc,time)
..()
else
..()

mob
var/tmp/list/GlimmerPets
verb
Extract_Element()
var/time=input("how much energy do you want to put in the extracted element?","energy")as num
if(time > usr.energy)
usr << output("You do not have enough energy!","SM")
return
var/obj/glimmer/G = new()
G.loc=locate(src.x,src.y+1,src.z)
G.energy =time
usr.energy -= time
if(!usr.GlimmerPets)
GlimmerPets=new()
GlimmerPets+=G

i tryed this:
mob
var/tmp/list/GlimmerPets
verb
Extract_Element()
var/time=input("how much energy do you want to put in the extracted element?","energy")as num
if(time > usr.energy)
usr << output("You do not have enough energy!","SM")
return
var/obj/glimmer/G = new(locate(src.x,src.y+1,src.z),time)
//G.loc=locate(src.x,src.y+1,src.z)
//G.energy =time
usr.energy -= time
if(!usr.GlimmerPets)
GlimmerPets=new()
GlimmerPets+=G

- now this makes the time work and the object is deleted after 'time' seconds, but now i no longer can control it, when i click it wont move.
In response to Narutostory
Replace your call to time() with spawn() time(). Otherwise, New() waits for time() to finish before continuing, so it never reaches the owner = blah line.

Also, your Move() should look like this:

Move()
if(src.mparea == 1)
var/time = src.time
new /obj/light( src.loc, time)
return ..()


It's important for Move() to return a value.

Also, you should replace your locate() with get_step(src,NORTH).
In response to Garthor
Sorry to revive an old topic but i've suddenly gotten a problem again, and im soo fired i can't see the problem :o
problem: can't move the object anymore.

obj
glimmer
icon = 'DevilFruitPowers.dmi'
icon_state = "Glimmer"
density = 0
var/owner
var/time= 0
Bump(mob/M)
if(istype(M))
M.hp -= time
time=0
New(loc,time,owner)
src.time=time
spawn() time()
src.owner = owner
..()

proc
time()
while(src.time > 0)
sleep(10)
src.time -= 1
if(src.time <= 0)
usr.GlimmerPets = null
del(src)
Click()
switch(input("What do you want to do?","choose") in list("Density","Cancel"))
if("Density")
if(src.density != 1)
src.density = 1
usr << output("The Element is now dense","SM")
return
else
src.density = 0
usr << output("The Element is now undense","SM")
return
if("Cancel")
return

mob
var/tmp/list/GlimmerPets

mob/glimmer
verb
Extract_Element()
var/time=input("how much energy do you want to put in the extracted element?","energy")as num
if(time > usr.energy)
usr << output("You do not have enough energy!","SM")
return
var/obj/glimmer/G = new(get_step(src,NORTH),time)
usr.energy -= time
usr.Energy_Bar()
if(!usr.GlimmerPets)
usr.GlimmerPets= new()
usr.GlimmerPets+=G


For some reason i can no longer move the object around.
this is what i have for moving:

turf
Click()
if(!usr.GlimmerPets)
return
else
for(var/obj/glimmer/G in usr.GlimmerPets)
walk_towards(G,src)


where is my mistake?
In response to Narutostory
You are nulling out the entire list as soon as one goes away.

The EnergyBar() proc might also be blocking and preventing the rest of the proc from finishing.

You also are using usr in procs, which you shouldn't be. You already have an owner variable, use that (properly) instead.
In response to Garthor
thanks again for clearing things up. Problem solved.