ID:263413
 
Code:
mob
verb
PlayCard(var/obj/Cards/C in usr.trunk)
new C(locate(usr.x-2,usr.y+1,usr.z))
trunk.Remove(C)


Problem description:

I tried to make it so it would play any type of card that you have in your trunk, not just /obj/Cards/Test.
Now I get this runtime error when I try to play a card:

runtime error: Cannot create objects of type /obj/Cards/Test2.
proc name: PlayCard (/mob/verb/PlayCard)
usr: Dead_Demon (/mob/Player)
src: Dead_Demon (/mob/Player)
call stack:
Dead_Demon (/mob/Player): PlayCard(Dark Monster (/obj/Cards/Test2))


C is an obj, not a type path. You need to use a type path with new for it to work properly.

Lummox JR
In response to Lummox JR
e.e I cannot think today. I need it to play a card in the players trunk, but what if they have two different types of cards? So I tweaked it abit, but now I cannot get it to call off the objects variable.

obj
icon='items.dmi'
Cards
Monster
var/typePath
verb
Grab(mob/M)
set src in oview(1)
if(istype(M,/mob/))
M.trunk.Add(src)

Test
typePath=/obj/Cards/Monster/Test //The variable to define this cards path
name="Earth Monster"
icon_state="test"
Test2
typePath=/obj/Cards/Monster/Test2 //the Variable to define this cards path
name="Dark Monster"
icon_state="test2"


And here is my proc

mob
proc
PlayCard(var/obj/C in src.trunk)
C= /obj/Cards/Monster/
new C.typePath(src.loc)


But it keeps telling me that C.typePath is an undefined variable. What do I do to fix it?

In response to Dead_Demon
Dead_Demon wrote:
And here is my proc

> mob
> proc
> PlayCard(var/obj/C in src.trunk)
> C= /obj/Cards/Monster/
> new C.typePath(src.loc)
>

But it keeps telling me that C.typePath is an undefined variable. What do I do to fix it?

Ack, stop doing really silly stuff. You just need
mob
verb //or verb, decide
PlayCard(var/obj/Cards/C in src.trunk)
new C.type(locate(src.x-2,src.y+1,src.z))
trunk.Remove(C)


(Sorry but I'm too tired currently to help more than that).
In response to Kaioken
Kaioken wrote:
mob
> verb //or verb, decide
> PlayCard(var/obj/Cards/C in src.trunk)
> new C.type(locate(src.x-2,src.y+1,src.z))
> trunk.Remove(C)


DM is really picky with its 'new' keyword.

You may need to put C.type into another variable, and then reference that variable with 'new'.

Edit:
Oh uhmm... why create a new card in the first place? Why not move the existing card from the trunk list onto its new location, then remove it from the list?
In response to Kaioken
Yes, but now C has no defined path. Isn't there a way to have it draw from the objects variables?
In response to Yota
Yota wrote:
Kaioken wrote:
mob
> > verb //or verb, decide
> > PlayCard(var/obj/Cards/C in src.trunk)
> > new C.type(locate(src.x-2,src.y+1,src.z))
> > trunk.Remove(C)

DM is really picky with its 'new' keyword.

You may need to put C.type into another variable, and then reference that variable with 'new'.

Edit:
Oh uhmm... why create a new card in the first place? Why not move the existing card from the trunk list onto its new location, then remove it from the list?

I've tried that, but it keeps moving the card that is on the field to my position.
In response to Yota
Yota wrote:
DM is really picky with its 'new' keyword.

You may need to put C.type into another variable, and then reference that variable with 'new'.

I know. Though IIRC directly using property vars works alright with it.
In response to Dead_Demon
So what should I do? I'm lost, I've tried alot of suggestions and stuff, but none of them seem to work.