ID:271234
 
for(var/obj/selection/square[DHDOwner:CurrentDialLoc]/S in usr.client.screen)
S.overlays +=src


Ofcourse, this aint working, how can I input the variable DHDOwner:CurrentDialLoc in a path
(And how do I get rid of using the damn : operator)
CurrentDialLoc is a var of the reference DHDOwner, which is a var of another object..(of which the above code applies to)
Okay, we have no idea what you're doing...

You don't explain really give enough code. You don't say what you're trying to accomplish. And the code you gave makes no sense we can hardly figure anything out from that.
If /obj/selection/square[DHDOwner:CurrentDialLoc] is a real type-path, you can use text2path().

var/obj/selection/A = text2path("/obj/selection/square[DHDOwner:CurrentDialLoc]")
for(A in usr.client.screen)
A.overlays += src


The : operator is usually used as a way to get around properly typecasting variables. I suggest you only use it if you know precisely what you're doing, and I don't think you do seeing as you don't know how to get rid of it.

If DHDOwner is a mob, you want to typecast the varaible as a mob.
var/mob/DHDOwner


If the variable only belongs to a certain type of mob, you want to typecast that certain type.

//certain type = /mob/player
var/mob/player/DHDOwner


Then you can use the proper and safe . operator. I suggest you read Green Programming by Lummox Jr, as I believe it covers typecasting in there, and Type Casting by YMIHere, because it is all about typecasting.

In response to LastTroubadour
Actually I understood what he was trying to say, he wants an embed in a path.

Stop trying to bring people down.
In response to LastTroubadour
LastTroubadour wrote:
Okay, I have no idea what you're doing...

You don't explain really give enough code. You don't say what you're trying to accomplish. And the code you gave makes no sense I can hardly figure anything out from that.

Much better.
In response to Lord of light
Yes, my problem is that I wish to use a variable in a path >_>

Any solution?
In response to SSJ4 Compufreak
Here's what I think you're saying:

mob
person/black/icon='people.dmi'
kettle/black/icon='irony.dmi'
tar/black/icon='road.dmi'
coffee/black/icon='beverages.dmi'
mob/verb/something_black()
var/what = input("What would you like?","Black...") in list("person","kettle","tar","coffee")
new text2path("/mob/[what]/black") (src)


Is that the idea? Using a variable (what, in this case) as part of a path?
In response to PirateHead
                if(CurrentDial[1]>0)
var/A = text2path("var/obj/selection/square[i]")
for(A in M.client.screen)
var/D = CurrentDial[1]
var/TmpD = text2path("/obj/symbols/symbol[D]")
S.overlays += new TmpD


As you can see, I'm trying to use the variable path, in a for(), but I cannot assign a variable(which I want to be S), to A
for(var/M as mob in view)
M.kill()
(not actual code)


The above is what I'm talking about, I cannot set thing currently handled in For() to a variable to edit.
In response to SSJ4 Compufreak
Okay, I finally get it. Try this:

var/A = // whatever
for(var/datum/i in M.client.screen)
if(i.type != A) continue
// whatever
In response to PirateHead
I solved the problem,
            for(var/i=1, i<=7, i++)
if(CurrentDial[i]>0)
var/obj/A = text2path("/obj/selection/square[i]")
for(A in M.client.screen)
var/E = text2path("/obj/symbols/symbol[CurrentDial[i]]")
A.overlays += new E


Just had to assign the variable BEFORE the for() >_> dumb me

NEW PROBLEM

It now assigns a 0 to

var/obj/A = text2path("/obj/selection/square[i]")

even though /obj/selection/square1 and so on, is a real path..(I even tried removing [i] and it it still returns 0)
In response to CaptFalcon33035
(If you re-read this, you'll see that you messed this part up, so correct it to whatever you've initially meant)

CaptFalcon33035 wrote:
If the variable only belongs to a certain type of mob, you want to typecast that certain type.

> //certain type = /mob/player
> var/mob/player/DHDOwner
>
In response to Lord of light
Yes, it is pretty easy to figure out if you think enough and have enough knowledge I suppose, but it might not be as easy for everyone, y'know...

Stop trying to bring people down.

For the record: stop trying to tell people what to do? :p
In response to Kaioken
Id dont know WHO brought this up, but itīs already typecasted to a specific OBJECT..
In response to SSJ4 Compufreak
That code will really not work as intended:

--If text2path("/obj/selection/square[i]") returns 0, then there must be no path like that. Perhaps you have it as /obj/selection/square/0 etc instead?

--The for() type filter is used as a TYPECASTED var; the current value of the variable doesn't matter and is scrapped, so you can't do something like
var/type_path = /mob/player
for(type_path in List)

which will just use type_path's typecasted type as the filter, or none if it isn't typecasted.

If you want a dynamic filter, you're limited to a more softcoded filter, eg
for(var/X in List)
if(!istype(X,filter_type)) continue
//...


--You're setting A to a path, but later you're trying to use it as an object without setting it to one first.