- Pokémon Essentials Version
- v16.2 ➖
What's this?
This is a simple script that downloads information from an API to geolocate the player, since the one included in Pokémon Essentials died sometime ago.
Usage
Place in a section above Main in your Script Editor:
Use 'getLocation' in a script call.
Design Notes
As far as I'm aware, only Vivillion forms need to rely on this, but you can be creative with it!
Instead of using it in a text message, you could also store the values for future use, all inside the script. The values are stored into an array, that will look something like:
Where "status" will be either "success" or "fail", if the API failed to retrieve the information. The script will not print the information in a message unless the API returns "status" as "success". You should also be doing that all times, and stop storing the remaining (faulty or non-existant) information.
That said, you can store 'formatted[x]' at will instead of printing it into a text message. Where X is 1 for Country, 2 for City, 0 for Status. See the API's Documentation for other possible fields it can return.
This is a simple script that downloads information from an API to geolocate the player, since the one included in Pokémon Essentials died sometime ago.
Usage
Place in a section above Main in your Script Editor:
Code:
def getLocation
# See http://ip-api.com/docs/api:returned_values#selectable_output
# for other returned values
query=pbDownloadToString("http://ip-api.com/line/?fields=status,country,city")
formatted=query.split(/\n+/)
if formatted[0]=="success"
Kernel.pbMessage(_INTL("You came from {1}, {2}.",formatted[2],formatted[1]))
end
end
Design Notes
As far as I'm aware, only Vivillion forms need to rely on this, but you can be creative with it!
Instead of using it in a text message, you could also store the values for future use, all inside the script. The values are stored into an array, that will look something like:
Code:
formatted=[status,country,city]
Where "status" will be either "success" or "fail", if the API failed to retrieve the information. The script will not print the information in a message unless the API returns "status" as "success". You should also be doing that all times, and stop storing the remaining (faulty or non-existant) information.
That said, you can store 'formatted[x]' at will instead of printing it into a text message. Where X is 1 for Country, 2 for City, 0 for Status. See the API's Documentation for other possible fields it can return.
- Credits
Please give credit if used to:
Mr. Gela
Please do not redistribute this anywhere resource anywhere else. If you wish to share this, link to this site.
Por favor da créditos si lo utilizas a:
Mr. Gela
Por favor no redistribuyas este recurso en ningún otro lugar. Si quieres compartir esto, utiliza un enlace a este sitio.