ID:138971
 
Code:
obj //IMPORTANT OBJECTS
var/obj/Piece/RealPiece //


Move_Cards //Move Cards needs to be fixed.
icon = 'Graphics.dmi'
New()
verbs += /obj/Piece/proc/Move_Spaces
Click()


verb/Use(mob/Player/M in view(0))
src = M
src.UseCard(icon_state)
usr << "Feature not implemented yet."
Piece
var
mob/owner // This is here so the piece can connect with the mob who owns it
moving // This is so Click can know if the piece is still moving or done.
movecarding = 0 // If the player is using a movecard..

proc
Move_Spaces(spaces) //This handles spaces to move.
moving = 1
usr << "You rolled a [spaces]!"
sleep 10 //Sleep for one second so everyone can look at what they got.
while(spaces-- > 0) //While the spaces are over 0, make sure I'm with my piece.
owner.loc = src.loc //If the user isn't focused, then it doesn't matter because he's with his piece.

step(src,src.dir)
sleep(3.3) //If it doesn't sleep, the proc kind of crashes.
moving = 0
if(movecarding)
Land()
movecarding = 0
else
usr << "Use a card?"
sleep(20)

Land()


mob/Player/proc/UseCard(number)
piece.movecarding = 1
piece.Move_Spaces(number)


Problem description:

Ugh, I can't figure out how to get my Mob's Piece obj to Move_Spaces(icon_state) when I Click on a Move Card in the inventory. As you can see, I've tried adding the Move_Spaces proc as verbs to Move Cards so it could recognize it and move my Piece with the proc, but to no avail. I've tried making a verb and setting the mob in the argument, and I know click is blank, it's like that because well, it didn't work either when I was trying to achieve my goal. I've been stuck on this for awhile sadly, and I'm growing more and more desperate, I don't care if you slap me in the face, just help me out and quick.

-Thanks a lot.

This is probably no help. but does an obj have a direction? seeing as src is your piece.

step(src,src.dir)

Do you have to set the pieces direction too?
In response to Slic3y (#1)
Because of what I'm trying to achieve, yes it does have to have a direction, and yes objects do have directions. I think I ran into a problem before in my code because the direction wasn't set.
You probably need to do a verb setting.
If the card is in the player's contents, then you can use
<code>set src in usr.contents</code>
(Add it to the Move_Spaces proc)
Or, if it's not, you could use world, etc.

I think that's what you were asking.
In response to Complex Robot (#3)
Does anyone also mind explaining to me why I can't use src = usr, then src."flinching". DM doesn't know what it is.

Complex, what exactly is set src in usr contents doing and adding the /obj/Move_Cards to /obj/Piece messed things up a bit since the Move_Card seemed to call the proc. (The move card appeared on the map and moved instead of the mob/Player's obj/Piece o.o)

I need the Move_Card object to find mob/Player and reference his vars and mob/Player's vars, I can't seem to find a way to do that..
In response to Truseeker (#4)
By chance, did you looked up what src actually is?

src is the sorce of that verb/proc, the container. If you try to overwrite it, bad things will happen.

You should call/use procedures/variables using variables that are typecast such as the "M" in your verb has the path /mob/Player and inherits all proc/verbs/vars associated to that path:
var/path/Variable
ex:
var/mob/X <-- X has the proc/vars/etc of /mob...
var/obj/Item/I <-- I has the properties of /obj/Item


Make sure whatever you assign to the variable belongs to that path (otherwise you'll get runtime errors if you try to access something that doesn't have it, ex: trying to access the 'hp' variable defined in a /mob but the variable had an /obj referened)
In response to Truseeker (#4)
Truseeker wrote:
Does anyone also mind explaining to me why I can't use src = usr, then src."flinching". DM doesn't know what it is.

."flinching"? That's not proper syntax. Maybe src.flinching or src.vars["flinching"] (Both are identical, but one ignore type.)

Complex, what exactly is set src in usr contents doing
This makes the verb available if the object (card?) is in usr.contents.

I need the Move_Card object to find mob/Player and reference his vars and mob/Player's vars, I can't seem to find a way to do that..

var/mob/Player/P = usr
if (istype(P))
P.somevarname = something
In response to Complex Robot (#6)
Complex Robot wrote:
Truseeker wrote:
Does anyone also mind explaining to me why I can't use src = usr, then src."flinching". DM doesn't know what it is.

."flinching"? That's not proper syntax. Maybe src.flinching or src.vars["flinching"] (Both are identical, but one ignore type.)

Complex, what exactly is set src in usr contents doing
This makes the verb available if the object (card?) is in usr.contents.

I need the Move_Card object to find mob/Player and reference his vars and mob/Player's vars, I can't seem to find a way to do that..

> var/mob/Player/P = usr
> if (istype(P))
> P.somevarname = something
>

Thanks ComRO, I kind of figured that out a little while ago. Still, thanks a lot you guys.