Hello There, Guest! Login Register


team order scripts not working
#1
i tried to input a team ordering command and its not working  the script runs perfectly fine.  just wont change team order like the command says.      maybe its in the wrong place or im missing lines.    still learning all this.



function advanceSorting()
    local pokemonsUsable = getUsablePokemonCount()
    for pokemonId=1, pokemonsUsable, 1 do
        if not isPokemonUsable(pokemonId) then --Move it at bottom of the Team
            for pokemonId_ = pokemonsUsable + 1, getTeamSize(), 1 do
                if isPokemonUsable(pokemonId_) then
                    swapPokemon(pokemonId, pokemonId_)
                    return true
                end
            end
            
        end
    end
    if not isTeamRangeSortedByLevelAscending(1, pokemonsUsable) then --Sort the team without not usable pokemons
        return sortTeamRangeByLevelAscending(1, pokemonsUsable)
    end
    return false
end
function onPathAction()
    if isPokemonUsable(1) then
        if getMapName() == "Pokecenter Pewter" then
            moveToMap("Pewter City")
        elseif getMapName() == "Pewter City" then
            moveToMap("Route 2")
        elseif getMapName() == "Route 2" then
            moveToGrass()
        end
    else
        if getMapName() == "Route 2" then
            moveToMap("Pewter City")
        elseif getMapName() == "Pewter City" then
            moveToMap("Pokecenter Pewter")
        elseif getMapName() == "Pokecenter Pewter" then
            usePokecenter()
        end
    end
end

function onBattleAction()
    if isWildBattle() and isOpponentShiny() then
        if useItem("Ultra Ball") or useItem("Great Ball") or useItem("Pokeball") then
            return
        end
 
Reply
#2
You added a function called "advanceSorting", but the bot is never using this function, since it is only executing "onPathAction" (when not in battle) and "onBattleAction" (when in battle).

You have to call this function inside "onPathAction" by adding the following line:

if advanceSorting() then return end

Your path function becomes:

function onPathAction()
   if advanceSorting() then return end
   if isPokemonUsable(1) then
       if getMapName() == "Pokecenter Pewter" then
           moveToMap("Pewter City")
       elseif getMapName() == "Pewter City" then
           moveToMap("Route 2")
       elseif getMapName() == "Route 2" then
           moveToGrass()
       end
   else
       if getMapName() == "Route 2" then
           moveToMap("Pewter City")
       elseif getMapName() == "Pewter City" then
           moveToMap("Pokecenter Pewter")
       elseif getMapName() == "Pokecenter Pewter" then
           usePokecenter()
       end
   end
end
 
Reply
#3
(2017-08-11, 20:13:23)Silv3r You added a function called "advanceSorting", but the bot is never using this function, since it is only executing "onPathAction" (when not in battle) and "onBattleAction" (when in battle).

You have to call this function inside "onPathAction" by adding the following line:

if advanceSorting() then return end

Your path function becomes:

function onPathAction()
   if advanceSorting() then return end
   if isPokemonUsable(1) then
       if getMapName() == "Pokecenter Pewter" then
           moveToMap("Pewter City")
       elseif getMapName() == "Pewter City" then
           moveToMap("Route 2")
       elseif getMapName() == "Route 2" then
           moveToGrass()
       end
   else
       if getMapName() == "Route 2" then
           moveToMap("Pewter City")
       elseif getMapName() == "Pewter City" then
           moveToMap("Pokecenter Pewter")
       elseif getMapName() == "Pokecenter Pewter" then
           usePokecenter()
       end
   end
end
Thank you so much.  ill go change it and try again.

tried the new line and this is what my log says

[1:51:19 PM] Bot started
[1:51:19 PM] Error during the script execution: chunk_1Sad2,4-28): attempt to call a nil value
[1:51:19 PM] Bot stopped
[1:52:00 PM] Script "" by "" successfully loaded
[1:52:02 PM] Bot started
[1:52:02 PM] Error during the script execution: chunk_1Sad2,3-27): attempt to call a nil value
[1:52:02 PM] Bot stopped
[1:52:08 PM] System: You are now AFK!


the code looks just like you showed

function onPathAction()
if advanceSorting() then return end
if isPokemonUsable(1) then
if getMapName() == "Pokecenter Pewter" then
moveToMap("Pewter City")
elseif getMapName() == "Pewter City" then
moveToMap("Route 2")
elseif getMapName() == "Route 2" then
moveToGrass()
end
else
if getMapName() == "Route 2" then
moveToMap("Pewter City")
elseif getMapName() == "Pewter City" then
moveToMap("Pokecenter Pewter")
elseif getMapName() == "Pokecenter Pewter" then
usePokecenter()
end
end
end
function onBattleAction()
if isWildBattle() and isOpponentShiny() then
if useItem("Ultra Ball") or useItem("Great Ball") or useItem("Pokeball") then
return
end
end
if getActivePokemonNumber() >= 1 then
return attack() or sendUsablePokemon() or run() or sendAnyPokemon()
end
end
 
Reply
#4
The error means the function advanceSorting could not be found. Make sure it is present in your code.
 
Reply
  


Forum Jump:


Browsing: 1 Guest(s)