Lua Scripts for Pokemon

Collaborate on projects all around the community (coding, wiki, etc.)
MKDasher
Schoolkid
Posts: 41
Joined: Fri May 02, 2014 5:31 pm

Lua Scripts for Pokemon

Post by MKDasher » Sat Aug 16, 2014 8:10 pm

I thought this was the best section to post this, so there we go.

For those who don't know what a lua script is, it is a text file with code that some emulators can execute and run along side the game. Some of the interesting things you can do with this scripts are for example reading / writing memory addresses, automatic inputs or displaying stuff on the emulator screen. Since a script is basically a code, it's neccesary to have a bit of programming knowledge to make them or understand them, but you don't if you just want to use them.

Lua scripting is really useful for the TAS community, since we are able to control what happens during the run and therefore getting better results. However, I recently thought that it would help speedrunners for routing purposes, so I decided that it would be good if I shared some of the scripts I have been working on.

If anyone would happen to have any more lua scripts useful for the pokemon community, I could add them to this thread too

Generation 4 and 5 Lua Script

Author: MKDasher

This lua script displays most of the Pokemon data (IV, EV, stats, HP, etc.) for your pokemon, wild pokemon and trainer pokemon.

Games that are supported:

- Pearl
- HeartGold
- Platinum
- Black
- White
- Black 2
- White 2

Download file: https://www.dropbox.com/s/qx2fo1zc44p1j ... script.rar

Video (demostration): https://www.youtube.com/watch?v=XmK51su0Z5w (When this video was done, the script only accepted heartgold).

Extract both lua files and make sure you place them in the same folder.

To use this script on Desmume, go to Tools / Lua Scripting / New Lua Script Window... Then click on Browse and search for "gen4_and_5_pokemon.lua". Click on run. Then you should be able to see a window like this:

Image

Controls:

- Press "1" to change game mode (Pearl, Platinum or HeartGold)
- Press "0" to change view (Either displaying the script on top screen or touch screen)
- Press "3" or "4" to change mode (Modes are: Party, Enemy, Enemy 2, Wild)
- Press "7" or "8" to change Pokemon number slot (from 1 to 6)

Modes:

- Party: checks the data of your own Pokemon.
- Enemy: checks the data of the trainers you battle. Roamer Pokemon will appear on this mode and not on wild's mode.
- Enemy 2: checks the data of the second trainer's pokemon (For 2vs2 battles)
- Partner: checks the data of your partner's Pokemon (For 2vs2 battles)
- Wild: check the data of wild Pokemon. (Not including roamers). On Pearl / Platinum, all wild Pokemon will also appear on Enemy mode, but they won't appear on that mode on Heartgold.

Extra notes:

- Current foe's HP / Cur. partner's HP, will display the HP of the foe/partner Pokemon that is currently on battle, and not the Pokemon that is being checked.
- I didn't implement current foe's HP on gen 5.
- For Party mode, the current HP is updated when the fight ends. I guess this is not a big issue since you can check your own HP on screen.

Generation 3 Lua Script

Author: FractalFusion

This lua script will display Stats, IVs, EVs, moves, etc. from your Pokemon, trainer Pokemon and wild Pokemon.

Information and download link: http://tasvideos.org/forum/viewtopic.ph ... 862#351862

Make sure the 3 lua files are in the same folder, then on the emulator (VBA-RR) go to Tools / Lua Scripting / New Lua Script Window... Then click on Browse and search for "pokemonstatsdisplayv2.0.lua".

Before running the lua script, click on Edit. A notepad should be opened. You will see in the first line "local game = 1" (or another number). You need to change that number depending on which game you are using. These are the games supported by this lua script:

1: Ruby/Sapphire U
2: Emerald U
3: FireRed/LeafGreen U
4: Ruby/Sapphire J
5: Emerald J (incomplete)
6: FireRed/LeafGreen J (1360)

So for example, if you want to run the lua script with Pokemon Emerald (U), change first line of the code to "local game = 2".

Now you can run the lua script.

Controls:

- Press "9" to change from Party mode to Enemy mode.
- Press "7" or "8" to change Pokemon Number Slot.

Wild Pokemon and trainer Pokemon will both be displayed on Enemy mode.

Extra notes

- The lua script displays the item the Pokemon is carrying, but instead of displaying the item's name, it displays its index number. Here there is a list of which index number correspongs to each item:

http://bulbapedia.bulbagarden.net/wiki/ ... dex_number

Then click on Generation III
Last edited by MKDasher on Tue Aug 19, 2014 12:49 am, edited 7 times in total.

MKDasher
Schoolkid
Posts: 41
Joined: Fri May 02, 2014 5:31 pm

Re: Lua Scripts for Pokemon

Post by MKDasher » Sat Aug 16, 2014 8:10 pm

And this is it for now :D

Reserving this post just in case I need more space.

Darcovian
Schoolkid
Posts: 49
Joined: Wed Jul 09, 2014 5:39 pm

Re: Lua Scripts for Pokemon

Post by Darcovian » Sat Aug 16, 2014 9:58 pm

Wow that could actually be really really helpful, im currently routing some fun categories for Emerald, I don't suppose you have one/ know someone who has something like this that works for Pokemon Emerald? This is basically exactly what I have been looking for.

MKDasher
Schoolkid
Posts: 41
Joined: Fri May 02, 2014 5:31 pm

Re: Lua Scripts for Pokemon

Post by MKDasher » Sat Aug 16, 2014 10:25 pm

Darcovian wrote:Wow that could actually be really really helpful, im currently routing some fun categories for Emerald, I don't suppose you have one/ know someone who has something like this that works for Pokemon Emerald? This is basically exactly what I have been looking for.
There actually is, and just added it. It's not made by me so I'm just going to link to the original thread where FractalFusion released his script. I'm adding some comments here about how it works.

User avatar
Amoeba
Cooltrainer
Posts: 280
Joined: Thu Apr 24, 2014 12:26 am
Contact:

Re: Lua Scripts for Pokemon

Post by Amoeba » Sun Aug 17, 2014 12:33 am

Nice, I'll certainly get use out of the gen3 one, thanks!
~

MoneyHypeMike
Schoolkid
Posts: 25
Joined: Fri May 09, 2014 10:59 pm

Re: Lua Scripts for Pokemon

Post by MoneyHypeMike » Sun Aug 17, 2014 3:22 am

Awesome script, thanks mkdasher!

I was wondering, is it possible to add the enemy ability for gen 4?

anirocks99
Schoolkid
Posts: 30
Joined: Thu Apr 24, 2014 12:27 am
Location: California, United States

Re: Lua Scripts for Pokemon

Post by anirocks99 » Sun Aug 17, 2014 12:03 pm

Nice Script MK, can be used to easily test seeds of Pokemon a little quicker than before in Gen 4 along with testing ID's.
I must say that seeing an enemy's stats and all for gen 4 is an awesome idea, but isn't necessary for Pearl since its already been made here: https://www.dropbox.com/s/utieptnrxl64k ... 0data.xlsx. However, expediting the process of doing enemy stats script shouldn't occur if Round 2 is going to be a thing in D/P/Pt.

MKDasher
Schoolkid
Posts: 41
Joined: Fri May 02, 2014 5:31 pm

Re: Lua Scripts for Pokemon

Post by MKDasher » Sun Aug 17, 2014 12:05 pm

MoneyHypeMike wrote:Awesome script, thanks mkdasher!

I was wondering, is it possible to add the enemy ability for gen 4?
Yes, I updated the script with a few new things:

- Ability
- Checking if a Pokemon is an egg
- Steps to hatch (if egg)
- Friendship (if not egg)

Darcovian
Schoolkid
Posts: 49
Joined: Wed Jul 09, 2014 5:39 pm

Re: Lua Scripts for Pokemon

Post by Darcovian » Sun Aug 17, 2014 12:18 pm

wow thank you very much that is gonna be a massive help you are a gentleman and a scholar sir!

MoneyHypeMike
Schoolkid
Posts: 25
Joined: Fri May 09, 2014 10:59 pm

Re: Lua Scripts for Pokemon

Post by MoneyHypeMike » Sun Aug 17, 2014 3:37 pm

Thanks a lot!

MKDasher
Schoolkid
Posts: 41
Joined: Fri May 02, 2014 5:31 pm

Re: Lua Scripts for Pokemon

Post by MKDasher » Sun Aug 17, 2014 5:00 pm

Added the possibility to check your partner's Pokemon on gen 4.

I'll probably add Pokemon gen 5 compatibility now.

MKDasher
Schoolkid
Posts: 41
Joined: Fri May 02, 2014 5:31 pm

Re: Lua Scripts for Pokemon

Post by MKDasher » Tue Aug 19, 2014 12:51 am

Added Gen 5 support to the DS Lua script.

Vulajin
Schoolkid
Posts: 46
Joined: Thu Apr 24, 2014 4:47 am

Re: Lua Scripts for Pokemon

Post by Vulajin » Tue Aug 19, 2014 3:13 am

Neat, that saves me having to bother uploading mine. >_>

(edit) Does finding the stats of double battle trainers work for gen 5? If so, I fucking love you.
Last edited by Vulajin on Tue Aug 19, 2014 5:46 am, edited 1 time in total.

User avatar
werster
Site Admin
Posts: 110
Joined: Thu Apr 24, 2014 4:38 am

Re: Lua Scripts for Pokemon

Post by werster » Tue Aug 19, 2014 5:26 am

Based MKDasher <3

MKDasher
Schoolkid
Posts: 41
Joined: Fri May 02, 2014 5:31 pm

Re: Lua Scripts for Pokemon

Post by MKDasher » Tue Aug 19, 2014 9:05 am

Vulajin wrote:Neat, that saves me having to bother uploading mine. >_>

(edit) Does findineg the stats of double battle trainers work for gen 5? If so, I fucking love you.
Yes, it should work as well. I'm not very familiar with BW and only tested it with one battle (cheren and you vs plasma on route 3), but it should work. On B2W2 I tested it with 2 battles.

Also notice that if you are battling against twins, or other trainers that would always battle together, all their Pokemon will appear on the Enemy section, since the game consider those trainers as a single trainer.

User avatar
GarfieldTheLightning
Youngster
Posts: 54
Joined: Thu Apr 24, 2014 5:04 pm
Location: Scotland

Re: Lua Scripts for Pokemon

Post by GarfieldTheLightning » Wed Aug 20, 2014 2:03 pm

Thanks for the script! I found a couple of bugs - hopefully they won't be hard to fix:

The script only shows the stats for the first Pokémon your opponent has. When it's knocked out, the data doesn't update for the next Pokémon.

The nature returned is incorrect in gen 5 because the nature is not stored in the personality value in said gen (I don't know how it's stored in gen 5, though).
I speedrun Pokémon Pearl, White 2 and X!

MKDasher
Schoolkid
Posts: 41
Joined: Fri May 02, 2014 5:31 pm

Re: Lua Scripts for Pokemon

Post by MKDasher » Wed Aug 20, 2014 2:10 pm

GarfieldTheLightning wrote:Thanks for the script! I found a couple of bugs - hopefully they won't be hard to fix:

The script only shows the stats for the first Pokémon your opponent has. When it's knocked out, the data doesn't update for the next Pokémon.

The nature returned is incorrect in gen 5 because the nature is not stored in the personality value in said gen (I don't know how it's stored in gen 5, though).
The script shows the stats of the whole team. Press "7" and "8" to change the pokemon you want to watch.

Didn't know about the nature thing, I'll try to fix that.

User avatar
GarfieldTheLightning
Youngster
Posts: 54
Joined: Thu Apr 24, 2014 5:04 pm
Location: Scotland

Re: Lua Scripts for Pokemon

Post by GarfieldTheLightning » Wed Aug 20, 2014 2:11 pm

MKDasher wrote:The script shows the stats of the whole team. Press "7" and "8" to change the pokemon you want to watch.
Oh, whoops. My bad.
I speedrun Pokémon Pearl, White 2 and X!

MKDasher
Schoolkid
Posts: 41
Joined: Fri May 02, 2014 5:31 pm

Re: Lua Scripts for Pokemon

Post by MKDasher » Wed Aug 20, 2014 3:07 pm

Fixed natures for gen 5. Thanks for notifying that :)

User avatar
GarfieldTheLightning
Youngster
Posts: 54
Joined: Thu Apr 24, 2014 5:04 pm
Location: Scotland

Re: Lua Scripts for Pokemon

Post by GarfieldTheLightning » Wed Aug 20, 2014 3:49 pm

Thanks, natures look to be correct now! It still highlights the stats red or blue as if the natures were incorrect, though.
I speedrun Pokémon Pearl, White 2 and X!

MKDasher
Schoolkid
Posts: 41
Joined: Fri May 02, 2014 5:31 pm

Re: Lua Scripts for Pokemon

Post by MKDasher » Wed Aug 20, 2014 6:21 pm

GarfieldTheLightning wrote:Thanks, natures look to be correct now! It still highlights the stats red or blue as if the natures were incorrect, though.
Okay that was me being dumb solving just half of the problem. It's NOW fixed I think, hehe.

User avatar
spitfire
Bug Catcher
Posts: 24
Joined: Sat Apr 26, 2014 4:52 am

Re: Lua Scripts for Pokemon

Post by spitfire » Sun Aug 24, 2014 1:43 pm

Thanks heaps for this, definitely gonna come in handy

User avatar
Amoeba
Cooltrainer
Posts: 280
Joined: Thu Apr 24, 2014 12:26 am
Contact:

Re: Lua Scripts for Pokemon

Post by Amoeba » Thu Oct 16, 2014 8:31 pm

Out of interest, for the gen3 lua script, what do the numbers in the top left represent? I'm guessing the top one is the current frame since the last soft/hard reset, or something equivalent to that, but the other 2 have me baffled.
~

MKDasher
Schoolkid
Posts: 41
Joined: Fri May 02, 2014 5:31 pm

Re: Lua Scripts for Pokemon

Post by MKDasher » Sat Oct 25, 2014 11:47 am

They are some values related to the pokemon data structure but I'm not really sure what those are. I guess FractalFusion displayed those as a debug but forgor to hide them.

waterise
Preschooler
Posts: 1
Joined: Tue Oct 14, 2014 3:26 pm

Re: Lua Scripts for Pokemon

Post by waterise » Tue Jun 09, 2015 4:44 pm

So, how can I modify this to not display stuff all over my screen, but only export the stats, level, & gender somewhere so I can display them on my live stream?

Gen 3

Locked

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 4 guests