ID:140782
 
Code:
        draw_card(mob/m)
if(!m.deck.len)
world<<"[m] does not have a deck, or cards to draw."
return
m.deck-=m.deck[m.deck.len]
world<<m.deck[m.deck.len]
m.hand += m.deck[m.deck.len]


Problem description:

I'm trying to make a proc to draw the top card of your deck. However there seems to be more issues than just a runtime error: the last card of the deck vanishes..?

Anyways, what's wrong with this?

EDIT: This is how I'm adding cards to the deck for testing:

mob
verb
create_card()
var/obj/card/c=new/obj/card/basic(src)
deck+=c
The trouble is that, once you've removed the last element of the list, the last element of the list is different. You pretty much just have to swap the two lines around (add to hand before removing from deck).
In response to Garthor
Easy as that? Cool!

On a sidenote:

I can't seem to find a proc for right click... There's "Click()" For left click, where did the right click go?
In response to Speedro
You don't use any other proc for right-clicks. Stuff like right-clicks are flagged in the params variable; look up mouse control to read about it.
In response to Speedro
Speedro wrote:
Easy as that? Cool!

On a sidenote:

I can't seem to find a proc for right click... There's "Click()" For left click, where did the right click go?

atom/proc
LClick(Loc,Control,Params)
world<<"Left Click"

RClick(Loc,Control,Params)
world<<"Right Click"

MClick(Loc,Control,Params)
world<<"Middle Click"


atom/Click(Loc,Control,Params)
Params=params2list(Params)
switch(Params[3])
if("left") LClick(Loc,Control,Params)
if("middle") MClick(Loc,Control,Params)
if("right") RClick(Loc,Control,Params)


This is a situation similar to the Bump/Bumped one.
There is no Bumped() proc, so pretty much everyone just makes their own.

If you use the code above that means you CANT use Click() alone, otherwise it will override the functionality that calls the other clicks. For normal left clicks you have to use LClick().

Also, don't forget you need to check 'Send right clicks to mouse procs' in the map settings.