ID:137997
 
Resolved
This became possible at some point:
var/obj/item/myType = /obj/item/sword
var/itemCost = initial(myType.cost)
Status: Resolved (354)

This issue has been resolved.
I don't know if this would be easy or hard... depends on how BYOND works internally. Anyway, my idea is that you could permit initial() to accept a type, like so:

var/myType = /obj/portable/outfit/male_outfit/business_suit
var/myVar = "name"
var/promptName = initial(myType, myVar)

What do you think?
Bump! Heh.

Gughunter wrote:
I don't know if this would be easy or hard... depends on how BYOND works internally. Anyway, my idea is that you could permit initial() to accept a type, like so:

var/myType = /obj/portable/outfit/male_outfit/business_suit
var/myVar = "name"
var/promptName = initial(myType, myVar)

What do you think?
Good idea. It's on the list!

--Dan
In response to Dan
Dan wrote:
Good idea. It's on the list!

--Dan

Eheh, bump. This must be on a 4.0-esque list or something. >_>

Hiead
In response to Hiead
Hiead wrote:
Dan wrote:
Good idea. It's on the list!

--Dan

Eheh, bump. This must be on a 4.0-esque list or something.

Unfortunately the one who knew how to do that was Dan. I may or may not be able to figure it out, but it's an investment of time best spent on other things to get 4.0 out the door.

Lummox JR

It would be very handy to be able to grab the initial value of a variable of a type without having to initialize the type with new().

An example possible syntax:
// Syntax:
// initial(type, "variable")

// Allows you get information about a path without having to create it
mob/verb/ReadPaths()
for(var/datumType in typesof(/datum))
world<<"[datumType] is derived from [initial(datumType, "parent_type")]"


// Allows you to get an item's cost without having to create it
proc/getItemCost(itemType)
if(!ispath(itemType,/obj/Item))
return -1
return initial(itemType, "cost")


If the type doesn't have the passed variable associated with it, an error should be thrown.

The idea is that because you don't know what specific type you might be working with at runtime, you don't know what it might do in New(), or even what to pass it.

I guess this could be worked around by not using New(), and instead writing an Init() function of some kind that you call manually when you actually want the object to exist and aren't just using a temporary copy. However, that would be a real pain in the butt, especially for libraries that don't have control over the user's coding practices.
In response to DarkCampainger
This has been on my own wish list for a while now as well. I know I've looked into it but I don't remember where it stands. I think at the time it was just considered too minor a feature to spend time on but I definitely like the idea.
Bump.
Wow....thats a serious bump. You should get that checked out man
DarkCampainger resolved issue with message:
This became possible at some point:
var/obj/item/myType = /obj/item/sword
var/itemCost = initial(myType.cost)
what the dan

talk about undocumented features, jeez
seriously haha but still nice