ID:177925
 
Its changing vars to things that have been created with
new().

Say something like

proc/Make(obj/makeable/T)
new T(usr)
T.skillvarthing = usr.skillofmaking



That would provide me with runtime errors.


Thanks

-ST
Don't use usr in procs. I'm not sure if that's the problem, but it's not a safe habit.
In response to ACWraith
Heh, funny. When I changed it to src.loc, it gave me undefined error ;)
Sariat wrote:
Its changing vars to things that have been created with
new().

Say something like
proc/Make(obj/makeable/T)
new T(usr)
T.skillvarthing = usr.skillofmaking

Aside from what ACWraith said about usr, you forgot that "new T" won't work unless T is a type path; if T is an object, then you need it to be "new T.type".

Lummox JR
In response to Lummox JR
Hrmmm, didn't do much either.

mob/verb/create(A in typesof(/turf) - /turf)
Create(A)

proc/Create(atom/T)
new T.type(usr.loc)
T.testvar = 1


runtime error: Cannot read /turf/water (/turf/water).type


Thats what I'm getting.

-ST
In response to Sariat
Sariat wrote:
Hrmmm, didn't do much either.

> mob/verb/create(A in typesof(/turf) - /turf)
> Create(A)
>
> proc/Create(atom/T)
> new T.type(usr.loc)
> T.testvar = 1
>

runtime error: Cannot read /turf/water (/turf/water).type

A is a type. You pass A to Create() and inside that proc, T is now a type. A type does not have a "type" variable.
In response to Sariat
Sariat wrote:
Hrmmm, didn't do much either.
mob/verb/create(A in typesof(/turf) - /turf)
Create(A)

proc/Create(atom/T)
new T.type(usr.loc)
T.testvar = 1

My advice was based on the idea that when you were defining T as an atom, you actually were passing an atom, not a type. If you're passing a type, then don't call T an atom and don't use T.type; just use T as you did before.

The real problem appears to be in your calling routine, the verb. Why, exactly, did you think a type path is allowable as an argument to a verb, and why did you think it could be restricted to an arbitrary list of your choosing? NO VERB works this way. DS has no idea what to do with this, so the create verb doesn't ask for a type; it merely thinks A is null, and you're calling Create(null).

What you need to do instead is this:
mob/verb/create()
var/list/L=typesof(/turf)-/turf
var/T=input("Create which turf?","Create") as null|anything in L
if(T) Create(T)

And then change your Create() proc back to what it was before, but don't call T a turf or an atom or anything; just make it Create(T).

Lummox JR
In response to Lummox JR
I still can't change the var after it has been created...


runtime error: Cannot modify /turf/grass.somevar


I tried:

proc/Create(atom/T)
new T(usr.loc)
T.somevar = 1

and

proc/Create(atom/T)
new T.type(usr.loc)
T.somevar = 1


Sorry if I missed something, I'm just not seeing how I can chage a var of something after it has been created in this example...

-ST
In response to Sariat
Sariat wrote:
I still can't change the var after it has been created...


runtime error: Cannot modify /turf/grass.somevar


I tried:
proc/Create(atom/T)
new T(usr.loc)
T.somevar = 1

and
proc/Create(atom/T)
new T.type(usr.loc)
T.somevar = 1

You didn't read through my post, did you?
I said for one thing, atom/T is totally wrong in the argument, and it should just be T, since you're passing a type path, not an atom. And I said that since you're intending to pass a type path along, T.type is obviously wrong, because again, T is a type, not an atom. I originally only suggested you use T.type when I thought T was in fact an atom, until I saw the verb you used to call it; then I realized you just totally botched the argument to Create(), and explained that telling you exactly what to change, and you just paid zero attention and botched it even worse. Gads.

Now the rest of the problem: You're never assigning the new atom to a var.
proc/Create(T)
var/atom/A = new T(usr.loc)
A.somevar = 1

That's it. That's all there is to it.

Lummox JR