• Welcome to The Cave of Dragonflies forums, where the smallest bugs live alongside the strongest dragons.

    Guests are not able to post messages or even read certain areas of the forums. Now, that's boring, don't you think? Registration, on the other hand, is simple, completely free of charge, and does not require you to give out any personal information at all. As soon as you register, you can take part in some of the happy fun things at the forums such as posting messages, voting in polls, sending private messages to people and being told that this is where we drink tea and eat cod.

    Of course I'm not forcing you to do anything if you don't want to, but seriously, what have you got to lose? Five seconds of your life?

Cleaner Sprite Generator?

Yenaa

kid a
Pronoun
he
Hi.

For my site, I've been using a PHP Sprite Generator, where you input the Pokemon's name, number (without leading zeros) and number (with zeros), and I'm worried that it's still too confusing.

This is the form:
PHP:
<form action="sprite_finder_results.php" method="POST">
<input name="name" style="text-transform: lowercase"> <input size="3" name="number" maxlength="3" onkeypress="return inputOnlyNumbers(event)"> <input size="3" name="number2" maxlength="3" onkeypress="return inputOnlyNumbers(event)">

<input type="submit"></form>

Basically, it sends the inputted information to a process page. I have three types of folders containing images; four folders where the images are saved by name (ie: dunsparce.png), 6 that are saved by number without leading zeroes (ie: 12.png) and 3 with plain numbers (ie: 097.png). Basically, the form plugs in the inputs in a php and image "sandwhich" like below:

PHP:
<img src="../images/dp_art/<?php echo $_POST["name"]; ?>.png"

  onerror="this.style.display='none'">

So whatever is put in for name on sprite_finder.php is inputted into a certain string on sprite_finder_results.php. However, if there is no such file, the image destroys itself.

Does anyone know an easier way to do this? The generator can be seen here.
 
Include an array of Pokémon and do something like this:

HTML:
<label for="pokemon">Name or number:</label>
<input type="text" name="pokemon" id="pokemon" />

PHP:
$pokemon_input = strtolower( ltrim( trim($_POST['pokemon']), '0') );

if( ! isset($pokemon_list[$pokemon_input]) && ! $tmp = array_search($pokemon_input, $pokemon_list))
{
	echo '<p>No results found.</p>';
}
else
{
	if(ctype_digit($pokemon_input))
	{
		$dex_no = $pokemon_input;
		$pokemon_name = $pokemon_list[$pokemon_input];
	}
	else
	{
		$dex_no = $tmp;
		$pokemon_name = $pokemon_input;
	}
	$dex_no_zerofill = str_pad($dex_no, 3, '0', STR_PAD_LEFT);
	
	echo 'Name: ' . $pokemon_name . '<br /> Number: ' . $dex_no . '<br /> Number with leading zeroes: ' . $dex_no_zerofill;
}
 
Last edited:
If they wish to exclude those Pokemon, they can use placeholders for those spaces, too. >_>

It is not hackish, it is efficient and makes for easier coding.
 
Well, you don't have to necessarily have to unset() them; you could just put something thre that's obviously wrong.

They're ugly and difficult to maintain/scale.

(I'd beg to differ on 'ugly', but that wouldn't solve any problems.)

BUT, since you're on the problem of 'ugly and difficult to maintain/scale', you shouldn't be putting static data in the code. That's not particularly pretty either.

You could do something like this:

in pkmn.txt
Code:
bulbasaur
ivysaur
venusaur
...
misdreavus
!unown
wobuffett
...

and have something read that and process it on-the-fly.

or if you have to generate the code for the associative array.

Perl version (using PHP highlighting, because it works, more or less):

PHP:
print "\$pokemon_list = array(\n";
for (my $i = 1; my $pn = <>; ++$i) {
  $pn =~ s/'/\\'/g;
  print "\t$i => '$pn',\n" unless $pn =~ /^!/;
}
print ");\n";

The '-escaping is really necessary, because your (probably similarly generated) list has farfetch'd listed as farfetch.

Edit: look, I generated the whole list!
Code:
bulbasaur
ivysaur
venusaur
charmander
charmeleon
charizard
squirtle
wartortle
blastoise
caterpie
metapod
butterfree
weedle
kakuna
beedrill
pidgey
pidgeotto
pidgeot
rattata
raticate
spearow
fearow
ekans
arbok
pikachu
raichu
sandshrew
sandslash
nidoran (f)
nidorina
nidoqueen
nidoran (m)
nidorino
nidoking
clefairy
clefable
vulpix
ninetales
jigglypuff
wigglytuff
zubat
golbat
oddish
gloom
vileplume
paras
parasect
venonat
venomoth
diglett
dugtrio
meowth
persian
psyduck
golduck
mankey
primeape
growlithe
arcanine
poliwag
poliwhirl
poliwrath
abra
kadabra
alakazam
machop
machoke
machamp
bellsprout
weepinbell
victreebel
tentacool
tentacruel
geodude
graveler
golem
ponyta
rapidash
slowpoke
slowbro
magnemite
magneton
farfetch'd
doduo
dodrio
seel
dewgong
grimer
muk
shellder
cloyster
gastly
haunter
gengar
onix
drowzee
hypno
krabby
kingler
voltorb
electrode
exeggcute
exeggutor
cubone
marowak
hitmonlee
hitmonchan
lickitung
koffing
weezing
rhyhorn
rhydon
chansey
tangela
kangaskhan
horsea
seadra
goldeen
seaking
staryu
starmie
mr. mime
scyther
jynx
electabuzz
magmar
pinsir
tauros
magikarp
gyarados
lapras
ditto
eevee
vaporeon
jolteon
flareon
porygon
omanyte
omastar
kabuto
kabutops
aerodactyl
snorlax
articuno
zapdos
moltres
dratini
dragonair
dragonite
mewtwo
mew
chikorita
bayleef
meganium
cyndaquil
quilava
typhlosion
totodile
croconaw
feraligatr
sentret
furret
hoothoot
noctowl
ledyba
ledian
spinarak
ariados
crobat
chinchou
lanturn
pichu
cleffa
igglybuff
togepi
togetic
natu
xatu
mareep
flaaffy
ampharos
bellossom
marill
azumarill
sudowoodo
politoed
hoppip
skiploom
jumpluff
aipom
sunkern
sunflora
yanma
wooper
quagsire
espeon
umbreon
murkrow
slowking
misdreavus
!unown
wobbuffet
girafarig
pineco
forretress
dunsparce
gligar
steelix
snubbull
granbull
qwilfish
scizor
shuckle
heracross
sneasel
teddiursa
ursaring
slugma
magcargo
swinub
piloswine
corsola
remoraid
octillery
delibird
mantine
skarmory
houndour
houndoom
kingdra
phanpy
donphan
porygon2
stantler
smeargle
tyrogue
hitmontop
smoochum
elekid
magby
miltank
blissey
raikou
entei
suicune
larvitar
pupitar
tyranitar
lugia
ho-oh
celebi
treecko
grovyle
sceptile
torchic
combusken
blaziken
mudkip
marshtomp
swampert
poochyena
mightyena
zigzagoon
linoone
wurmple
silcoon
beautifly
cascoon
dustox
lotad
lombre
ludicolo
seedot
nuzleaf
shiftry
taillow
swellow
wingull
pelipper
ralts
kirlia
gardevoir
surskit
masquerain
shroomish
breloom
slakoth
vigoroth
slaking
nincada
ninjask
shedinja
whismur
loudred
exploud
makuhita
hariyama
azurill
nosepass
skitty
delcatty
sableye
mawile
aron
lairon
aggron
meditite
medicham
electrike
manectric
plusle
minun
volbeat
illumise
roselia
gulpin
swalot
carvanha
sharpedo
wailmer
wailord
numel
camerupt
torkoal
spoink
grumpig
spinda
trapinch
vibrava
flygon
cacnea
cacturne
swablu
altaria
zangoose
seviper
lunatone
solrock
barboach
whiscash
corphish
crawdaunt
baltoy
claydol
lileep
cradily
anorith
armaldo
feebas
milotic
!castform
kecleon
shuppet
banette
duskull
dusclops
tropius
chimecho
absol
wynaut
snorunt
glalie
spheal
sealeo
walrein
clamperl
huntail
gorebyss
relicanth
luvdisc
bagon
shelgon
salamence
beldum
metang
metagross
regirock
regice
registeel
latias
latios
kyogre
groudon
rayquaza
jirachi
deoxys
turtwig
grotle
torterra
chimchar
monferno
infernape
piplup
prinplup
empoleon
starly
staravia
staraptor
bidoof
bibarel
kricketot
kricketune
shinx
luxio
luxray
budew
roserade
cranidos
rampardos
shieldon
bastiodon
burmy
wormadam
mothim
combee
vespiquen
pachirisu
buizel
floatzel
cherubi
!cherrim
!shellos
!gastrodon
ambipom
drifloon
drifblim
buneary
lopunny
mismagius
honchkrow
glameow
purugly
chingling
stunky
skuntank
bronzor
bronzong
bonsly
mime jr.
happiny
chatot
spiritomb
gible
gabite
garchomp
munchlax
riolu
lucario
hippopotas
hippowdon
skorupi
drapion
croagunk
toxicroak
carnivine
finneon
lumineon
mantyke
snover
abomasnow
weavile
magnezone
lickilicky
rhyperior
tangrowth
electivire
magmortar
togekiss
yanmega
leafeon
glaceon
gliscor
mamoswine
porygon-z
gallade
probopass
dusknoir
froslass
rotom
uxie
mesprit
azelf
dialga
palkia
heatran
regigigas
giratina
cresselia
phione
manaphy
darkrai
!shaymin
!arceus

I think I got all the ones with multiple forms.
 
Last edited:
Back
Top Bottom