Reading and parsing a text file

I want to create a Pokemon game, and need the information a text file from Pokemon Essentials. This is an example of the format it is in:

Name = Bulbasaur
InternalName = BULBASAUR
Type1 = GRASS
Type2 = POISON
BaseStats = 45,49,49,45,65,65
GenderRate = FemaleOneEighth
GrowthRate = Parabolic
BaseEXP = 64
EffortPoints = 0,0,0,0,1,0
Rareness = 45
Happiness = 70
Abilities = OVERGROW
HiddenAbility = CHLOROPHYLL
Compatibility = Monster,Grass
StepsToHatch = 5120
Height = 0.7
Weight = 6.9
Color = Green
Shape = Quadruped
Habitat = Grassland
Kind = Seed
Pokedex = Bulbasaur can be seen napping in bright sunlight. There is a seed on its back. By soaking up the sun’s rays, the seed grows progressively larger.
Generation = 1
BattlerPlayerX = -4
BattlerPlayerY = 0
BattlerEnemyX = -1
BattlerEnemyY = 26
BattlerShadowX = 0
BattlerShadowSize = 2
Evolutions = IVYSAUR,Level,16

Is there a way to have the program parse all this information and stick it into global variables, rather than manually typing it in? There are a lot of Pokemon!

Thanks for any help you can offer :slight_smile:

1 Like

Making a pokemon game too :D, any chance you can direct me to where you got those files? Pokemon essentials wiki or the download itself??

It contains all the graphics and stuff too :slight_smile:

1 Like

Personally I would rather recommend using pokeapi, it also outputs everything as JSON which plays nice with GDevelop (as JSON can be easily converted to a GDevelop variable using the built in action).

Otherwise to answer the original question you would have to create a parser by yourself. A simple example (just for the simple IDENTIFIER = VALUE syntax):

GDevelop parser.json

1 Like

I’m checking out pokeapi, but I’m not sure I understand how it works. It looks like in order to get any of the information, I have to call up the website each time? Is there a json file with all this info that I can use offline?

Edit: Actually, it looks like pokeapi contains way more information than I need, I might stick with making my own parser. Thanks for the help!

1 Like