2016-09-11, 01:43:18
Alright guys,
since i want to be a part of this community i decided to release a few snippet's from my script to provide your guys hopefully "usefull" informations and tricks when it comes to a "I want to make a script by myself now" scenario. There are maybe easier or better solutions for the Code on the snippets and since im not a professional lua programmer thats okay for me. You are not forced to use my snippets !
As the most of the scripts here support a limit of 5 Maps that can be traveled i want to show you how i made "Umlimited Map support" for my ExpShare script.
The setup:
Thats a basic table filled with the MapNames your want to be moved to, you can either set them by your own or let the "users" set them on a configuration file. This table is needed in further progress !
The core functions:
function firstMap()
• This is basicly just a check if you are on the first Map or your Pathtable. Should be self explanatory
function lastMap()
• Same as the "firstMap" function this is just a check if your are on the last Map of your Pathtable
function getCurrentMap()
• This functions checks where you currently at by comparing your current MapName with the ones on the Pathtable, when the MapName on the Pathtable is equal to your current position it return the index value ( 'i' on that case )
function moveTo(id)
• This function let your bot finally move, its basicly just a movement based on the Pathtable's index numbers. The desired map still have to be "reachable" from your current position. Its not a pathfind !
function onPathAction()
• This is our last function for the unlimited map support, its calls the 'moveTo' function until the last map on your Pathtable is reached by calling the 'getCurrentMap()' function and increasing the returning value by 1 or incase you want to go back ( if Pokemon 1 is not longer usable for example ) by decreasing the value by 1
Congratulations !
You finally can offer the "unlimited Map support" feature on your script, or use it private if you dont want to release it
since i want to be a part of this community i decided to release a few snippet's from my script to provide your guys hopefully "usefull" informations and tricks when it comes to a "I want to make a script by myself now" scenario. There are maybe easier or better solutions for the Code on the snippets and since im not a professional lua programmer thats okay for me. You are not forced to use my snippets !
As the most of the scripts here support a limit of 5 Maps that can be traveled i want to show you how i made "Umlimited Map support" for my ExpShare script.
The setup:
Path = {
"Pokecenter Cerulean",
"Cerulean City",
"Route 4",
}
The core functions:
function firstMap()
• This is basicly just a check if you are on the first Map or your Pathtable. Should be self explanatory
function firstMap()
if getMapName() == Path[1] then
return true
else
return false
end
end
function lastMap()
• Same as the "firstMap" function this is just a check if your are on the last Map of your Pathtable
function lastMap()
if getMapName() == Path[#Path] then
return true
else
return false
end
end
function getCurrentMap()
• This functions checks where you currently at by comparing your current MapName with the ones on the Pathtable, when the MapName on the Pathtable is equal to your current position it return the index value ( 'i' on that case )
function getCurrentMap()
for i = 1, #Path, 1 do
if getMapName() == Path[i] then
return i
end
end
end
function moveTo(id)
• This function let your bot finally move, its basicly just a movement based on the Pathtable's index numbers. The desired map still have to be "reachable" from your current position. Its not a pathfind !
function moveTo(id)
return moveToMap(Path[id])
end
function onPathAction()
• This is our last function for the unlimited map support, its calls the 'moveTo' function until the last map on your Pathtable is reached by calling the 'getCurrentMap()' function and increasing the returning value by 1 or incase you want to go back ( if Pokemon 1 is not longer usable for example ) by decreasing the value by 1
function onPathAction()
if isPokemonUsable(1) then
if not lastMap() then
moveTo(getCurrentMap() + 1)
else
-- Do stuff on destination / lastMap
end
else
if not firstMap() then
moveTo(getCurrentMap() - 1 )
else
-- Do stuff on first Map ( healing for example )
end
end
end
Congratulations !
You finally can offer the "unlimited Map support" feature on your script, or use it private if you dont want to release it
No support for scripts from other authors or edited scripts ( except config.lua ). If you change something on the "core" and it isnt working anymore then you can fix it by your own.
Feel free to contact me for informations and tips !
Feel free to contact me for informations and tips !