ID:1308383
 
(See the best response by Jittai.)
Code:
mob/Stat()
statpanel("Skills")
stat(src.Jutsus)

obj/Cards
icon='Cards.dmi'
layer=MOB_LAYER+1000
var/list/Jutsu=list()
Click()
if(src.Owner==usr)
usr<<"You click [src]. Select an Attack to use from the Skills tab."
usr.Jutsus+=src.Jutsu
return


Problem description:Problem is the Rasengan Obj spam adds into the skills panel.

We tried:

Click()
if(src.Owner==usr)
usr<<"You click [src]. Select an Attack to use from the Skills tab."
//usr.Jutsus+=src.Jutsu
for(var/obj/Cards/Skills/S in src.Jutsu)
usr.Jutsus+=S


But i get the following runtime:

runtime error: type mismatch: Rasengan (/obj/Cards/Skills/Rasengan) += Rasengan (/obj/Cards/Skills/Rasengan)
proc name: Click (/obj/Cards/Click)
source file: Main.dm,294
usr: Runney001 (/mob)
src: Naruto (/obj/Cards/MySlots/Slot1)
call stack:
Naruto (/obj/Cards/MySlots/Slot1): Click(null, "mapwindow.map", "icon-x=19;icon-y=19;left=1;scr...")

line 294 is usr.Jutsus+=src.Jutsu

Any assistance would be greatly appreciated. Thanks in advance

Edit: Interestingly enough, despite this Runtime error only one Rasengan Obj is added to the Skills
In response to Runney001
Runney001 wrote:
We tried:

> Click()
> if(src.Owner==usr)
> usr<<"You click [src]. Select an Attack to use from the Skills tab."
> //usr.Jutsus+=src.Jutsu
> for(var/obj/Cards/Skills/S in src.Jutsu)
> usr.Jutsus+=S

But i get the following runtime:

runtime error: type mismatch: Rasengan (/obj/Cards/Skills/Rasengan) += Rasengan (/obj/Cards/Skills/Rasengan)
proc name: Click (/obj/Cards/Click)
source file: Main.dm,294
usr: Runney001 (/mob)
src: Naruto (/obj/Cards/MySlots/Slot1)
call stack:
Naruto (/obj/Cards/MySlots/Slot1): Click(null, "mapwindow.map", "icon-x=19;icon-y=19;left=1;scr...")

line 294 is usr.Jutsus+=src.Jutsu

Any assistance would be greatly appreciated. Thanks in advance

Edit: Interestingly enough, despite this Runtime error only one Rasengan Obj is added to the Skills

Shot in the dark here, but what I'm understanding from line 294 is that you are adding the list to itself with the "+=" operator, which then deletes the list on the right hand side of the operator. But the list on the right hand side, is both lists because they are one and the same...
Is mob/Jutsus[] initialized before you add to it?
In response to Kaiochao
Kaiochao wrote:
Is mob/Jutsus[] initialized before you add to it?

mob/var/list/Jutsus=list() is defined yes

The error described in post #1 tells me that it's null at the time of addition.

I'm still not clear on the original issue, though. What's spam adding?
In response to Kaiochao
Kaiochao wrote:
The error described in post #1 tells me that it's null at the time of addition.

I'm still not clear on the original issue, though. What's spam adding?

The obj/Rasengan adds repeatedly. The user ends up having 10+ obj/Rasengan in their skills/list

In response to Runney001
Does this just happen if the player repeatedly clicks on the thing?
Nope
Best response
Mob's jutsus isn't a list.
In response to Jittai
Jittai wrote:
Mob's jutsus isn't a list.

Yeah that was the problem all along. I can't believe I overlooked such an obvious detail. Thanks a lot everyone for your responses.
In response to Runney001
Runney001 wrote:
mob/var/list/Jutsus=list() is defined yes
Where did this come from?
I assumed I defined the list/Jutsu.. turns out i didn't