ID:146522
 
mob
var/list/uchihajutsus
...

New()
..()
uchihajutsus=list()

var/list/skill_needed_uchihajutsus=list(\
if(src.ninjutsu >= 2000 && genjutsu >= 1500 && Taijutsu >= 1500)
src.contents += new/obj/sharingan()


I get these two errors,
Naruto Legacies.dm:299:error: src: missing comma ',' or right-paren ')'
Naruto Legacies.dm:299:error: src: expected end of statement

You put an if() statement inside of a list. I'm not sure why you expected that to work. Lists hold values, not program instructions.

Lummox JR
In response to Lummox JR
meh, I never knew your not supposed to stick if statements in lists.Is there another way they can learn that skill only with the requirments
In response to Broly103
Broly103 wrote:
meh, I never knew your not supposed to stick if statements in lists.

Well it's kinda common sense. Very very few languages allow you to stick code any old place. (And actually, the ones that do are basically fudging it.) It always has to be in the context of some sort of routine that's running it. Lists are just arrays; they only hold data. You can't stick a statement in a var, either.

Is there another way they can learn that skill only with the requirments

Yes; write a proc for it.

It is possible to write a more general proc in which you could store in a list all the requirements you'd need. It'd basically be like var_name, minimum_value, etc. and you'd use vars[var_name]>=minimum_value to test each one. However if you have a lot of potential skills, I advise against this approach; unless you structured it very well so as to use a single list, you'd end up with a great many lists. Files are another option, because you could read the requirements that way. For example, if you set up a file called skills.txt, part of which looked like this:

uchihajutsus
item = /obj/sharingan
ninjutsu = 2000
genjutsu = 1500
Taijutsu = 1500


Then you'd read the file like so:

var/savefile/S = new
S.ImportText("/", "skills.txt")
skillloop:
for(var/skill in S.dir)
S.cd = "/[skill]"
for(var/req in S.dir)
if(req == "item") continue
var/minval
S[req] >> minval
if(vars[req] < minval) continue skillloop
// all tests passed
var/item
S["item"] >> item
new item(src)


This proc belongs to a mob, which is src.

Lummox JR