ID:179221
 
The compiler has a problem with this line
(_piece: expended end of statement):

var/obj/pieces/[color]_piece/[answer]/L = new()

(note: the above line is within a mob/player/proc)

other relevant code:

obj/pieces/red_piece/thief

mob/player/var/color (set to red or other color upon login)
var/answer (set to thief or something else within the proc)


I'm hoping I can still do this but simply have the wrong syntax. If this is not possible, can someone suggest an alternative approach?

Thanks!
Please post the lines surrounding the problem, and what exactly you are attempting to do.

Alathon
In response to Alathon
I'm trying to create a new piece object using the player's color and the type of piece which the player has just selected:

//(var/answer defined above)
var/list/men_types = list("thief","knight","farmer","monk")
answer = input("What will he become?") in men_types
var/obj/pieces/[color]_piece/[answer]/L = new()
//(end of function for now)
In response to Dramstud
dramstud wrote:
I'm trying to create a new piece object using the player's color and the type of piece which the player has just selected:

//(var/answer defined above)
var/list/men_types = list("thief","knight","farmer","monk")
answer = input("What will he become?") in men_types
var/obj/pieces/[color]_piece/[answer]/L = new()
//(end of function for now)

You cannot specify a path like that. You're going to have to use a really long switch() statement, or mayby try having one piece object and setting its vars according to what they pick.

obj/Piece
var/color
var/answer
New(O)
..()
if(!ismob(O)) return 0
var/mob/M = O
var/c = input(M,"What color do you want to pick?") in list("Red","Green","Blue")
var/a = input(M,"Whats...the ANSWER?!") as text
color = c
answer = a

Alathon
In response to Alathon
I was considering switching to just one object, with more vars, but I have 5 different icon files (one for each color), each with 9 different states. Can I switch icon files on the fly during run time as easily as I can change icon states?


Alathon wrote:
dramstud wrote:
I'm trying to create a new piece object using the player's color and the type of piece which the player has just selected:

//(var/answer defined above)
var/list/men_types = list("thief","knight","farmer","monk")
answer = input("What will he become?") in men_types
var/obj/pieces/[color]_piece/[answer]/L = new()
//(end of function for now)

You cannot specify a path like that. You're going to have to use a really long switch() statement, or mayby try having one piece object and setting its vars according to what they pick.

obj/Piece
var/color
var/answer
New(O)
..()
if(!ismob(O)) return 0
var/mob/M = O
var/c = input(M,"What color do you want to pick?") in list("Red","Green","Blue")
var/a = input(M,"Whats...the ANSWER?!") as text
color = c
answer = a

Alathon
In response to Dramstud
dramstud wrote:
Can I switch icon files on the fly during run time as easily as I can change icon states?

Yep.

I almost had a reply with an easy way to do what you originally tried, but I'm not sure if it would work. We can ask Tom on Sunday. ;-)
In response to Dramstud
dramstud wrote:
var/obj/pieces/[color]_piece/[answer]/L = new()

Try this:
var/path = "/obj/pieces/[color]_piece/[answer]"
var/L = new path()


That said, I can't say I really recommend this notation, since it doesn't give you type-checking and may encourage use of the always dangerous colon operator.