ID:1071188
 
(See the best response by Jemai1.)
Code:
mob
Login()
..()
loc=locate(x,y,2)

verb/Spawn_Random_Pokemon()
var/obj/Pokemon/P=new(5,2,2)
var/Pokemon=rand(1,649)
P.icon=file("BW/[Pokemon].png")


Problem description:
I want the icon of P to become a random number from 1 to 649, but I dunno how to do that since you can't embed variables in them single apostrophes. I tried using file() but of course that didn't work.

Any help?

Best response
That is quite nasty. It is better to define each pokemon then use typesof.
obj/Pokemon
Bulbasaur
icon = 'BW/1.png'
Charmander
icon = 'BW/4.png'
Squirtle
icon = 'BW/7.png'

mob
verb/Spawn_Random_Pokemon()
var/types = typesof(/obj/Pokemon)
types -= /obj/Pokemon // we don't wanna make one of this
var/type = pick(types)
var/obj/Pokemon/pokemon = new type( locate(5,2,2) ) // I assume the numbers are coordinates?
// more stuff
Well yeah, I thought of that, but that's going to take approximately eleven years with 649 sprites. Is there really no way to do it without defining every single Pokemon? :(
Well, you can create a code generator for that.
Fair enough.