ID:149126
 
I tried usr.techs += new/obj/Kaede/(whatever)
But...
It keeps giving me a type mismatch error after the first one.
I need to add all the techs at once for that person. Please help. x.x

mob/var/list/techs

obj/var/ali
obj/var/vigor = 0
obj/var/power
obj/var/use

mob
icon = 'Basic.dmi'
var
Life
MLife
Skill
MSkill
Type
Speed
weaponpower
Power
opponent
ali
power
Vigor
VigorMax
Equipped
EquipAli
frozen = 0
Stat()
statpanel("Stats")
stat("Life","[usr.Life]/[usr.MLife]")
stat("Skill Points","[usr.Skill]/[usr.MSkill]")
stat("Basic Aliment","[usr.Type]")
stat("Power/Speed","[usr.Power]/[usr.Speed]")
stat("Weapon/Weapon Aliment","[usr.Equipped]/[usr.EquipAli]")
stat("Weapon Power","[usr.weaponpower]")
stat("Vigor","[usr.Vigor]/[usr.VigorMax]")
statpanel("Inventory")
stat(usr.contents)
statpanel("Techs")
stat(usr.techs)

mob/Login()
usr << "Welcome to Last Blade RPG! Please choose a character..."
var/char = input("Which character do you want?","Character")in list("Kanzaki Juzoh","Ichijou Akari","Kaede")
if(char == "Kaede")
usr << "" // This is what I need help with.


obj/Click()
if(istype(src,/obj/Kaede) || istype(src,/obj/Juzoh) || istype(src,/obj/Akari))
usr << src.name
usr << "Power: [src.power]"
usr << "Aliment: [src.ali]"
usr << "Skill Point Usage: [src.use]"

obj/Kaede
thunder
name = "Thunder and Lightning"
ali = "Rock"
power = 2
use = 2
bundled
name = "Bundled Wind"
ali = "Rock"
power = 1
use = 1
stroke
name = "Single Stroke"
ali = "Scissors"
power = 0.5
use = 0
tusk
name = "Sky Tusk"
ali = "Paper"
power = 2
use = 5
tempest
name = "Tempest Conquer"
ali = "Paper"
power = 5
use = 10
dragon
name = "Dragon of High Spirits"
ali = "Rock"
power = 8
use = 20
splitter
name = "Helmet Splitter"
ali = "Scissors"
power = 3
use = 5
vigor
name = "(Vigor) Nine Headed Dragon"
ali = "Rock"
power = 10
use = 0
vigor = 1
You get the type mismatch error because you never initialized the list. You need to initialize it in mob.New():
mob
New()
techs=list()

If you don't do that, the list is null; += with an obj will set techs to an obj. Calling += again will be adding an obj to an obj, and it fails with the error. Technically this error should happen the first time too.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
You get the type mismatch error because you never initialized the list. You need to initialize it in mob.New():
mob
> New()
> techs=list()

If you don't do that, the list is null; += with an obj will set techs to an obj. Calling += again will be adding an obj to an obj, and it fails with the error. Technically this error should happen the first time too.

Lummox JR
Same error...
In response to Hanns
I tried usr.techs.Add(/obj/Kaede/[whatever]) as well, but, it gives me...

runtime error: Cannot execute null.Add().
proc name: Login (/mob/Login)
source file: LastBlade.dm,45
usr: Hanns (/mob)
src: Hanns (/mob)
call stack:
Hanns (/mob): Login()
In response to Hanns
Nevermind..It's working now.
In response to Hanns
Hanns wrote:
I tried usr.techs.Add(/obj/Kaede/[whatever]) as well, but, it gives me...

runtime error: Cannot execute null.Add().
proc name: Login (/mob/Login)
source file: LastBlade.dm,45
usr: Hanns (/mob)
src: Hanns (/mob)
call stack:
Hanns (/mob): Login()

I don't think you should be getting this error if you did in fact put in the code I suggested. The null.Add() problem is happening because usr.techs is null (BTW, even though it's supposedly safe, you should use src, not usr, in Login()); this shouldn't happen if New() executed correctly. Is techs being reset at some point?

Lummox JR