Hello There, Guest! Login Register


how to you pc
#1
need a script to use pc
will implement it in other scripts
 
Reply
#2
It depends on how do you want to use it..
I do NOT publish script and don't accept script requests.
I just help people do their own scripts.
 
Reply
#3
just to withdraw pokemon from pc box 1 which are less than 60 level
 
Reply
#4
Have a look at my unit test: link.
 
Reply
#5
I guess this should works. (not tested tho)
local BoxID = 1
local PokeID = 1
local deposedpkm = 0
local u = 1
function sendPokeToPC()
--DEPOSIT
log("Deposing your level 100 pokemons.")
    if getPokemonLevel(u) == 100 then
      log("Deposed "..getPokemonName(u))
        if u > 1 then  u = u - 1 end
        return depositPokemonToPC(u)
    else
        u = u + 1
        return
    end

function getFromPC()
local boxCount = getPCBoxCount()
local BoxSize = getCurrentPCBoxSize()

if currentBoxId > BoxCount then
   return log("All box browsed. 5 pokemons has been taken.")
end
if getCurrentPCBoxId() == BoxID then
log("--- Box #"..BoxID.." ---")
  for i=1,BoxSize do
     if getPokemonLevelFromPC(BoxID,i) < 60 then
      log("Getting"..getPokemonNameFromPC(BoxID,i).." from PC.")
        withdrawPokemonFromPC(BoxID,i)
     end
  end
end
end

function onPathAction()
  if isPCOpen() then
   if isCurrentPCBoxRefreshed() then
       for i=1,5 do if getPokemonLevel(i) == 100 then
           sendPokeToPC()
          else
             getFromPC()
       end
       end
    else
      log("Box not refreshed")
      return
    end
  else
    if usePC() then
      log("PC Closed, using PC (SUCCESS)")
    else
      log("PC Closed, using PC (FAILURE)")
    end
  end
end
--NOT TESTED : Could you feedback please ? (says me if it works)
--Thanks to Silv3r for helping me on the loop Smile.
I do NOT publish script and don't accept script requests.
I just help people do their own scripts.
 
Reply
#6
if getPokemonLevel(u) == 100 then
      log("Deposed "..getPokemonName(u))
        depositPokemonToPC(u)
        if u > 1 then  u = u - 1 end
    else
        u = u + 1
    end

The above code is incorrect.
You are only supposed to execute one action per frame, not five.
 
Reply
#7
It's one action per frame.
I don't get the error here o_o.
I do NOT publish script and don't accept script requests.
I just help people do their own scripts.
 
Reply
#8
It's inside a loop, depositPokemonToPC might get called more than once.
 
Reply
#9
a for loop.
So, not in the same time.
I do NOT publish script and don't accept script requests.
I just help people do their own scripts.
 
Reply
#10
Not at the same time but definitely in the same frame.
 
Reply
#11
How could i fix it then?
I don't see any other way '-'.

function getPokeFromPC()
--DEPOSIT
log("Deposing your level 100 pokemons.")
  for k in pairs(getTeamSize) do
    if getPokemonLevel(u) == 100 then
      log("Deposed "..getPokemonName(u))
        depositPokemonToPC(u)
        if u > 1 then  u = u - 1 end
    else
        u = u + 1
    end
  end
end
Maybe?
I do NOT publish script and don't accept script requests.
I just help people do their own scripts.
 
Reply
#12
The easiest way would probably be to just stop the current function after depositing one pokémon:

return depositPokemonToPC(u)
 
Reply
#13
Oh, right! and then do the loop out of the function, like
if isCurrentPCBoxRefreshed() then
       for i=1, 5 do
           getPokeFromPC()
       end
    else
      log("Box not refreshed")
      return
    end
I do NOT publish script and don't accept script requests.
I just help people do their own scripts.
 
Reply
#14
No, it defeats the entire purpose if you do that, you will still call the action multiple times in the same frame.
When onPathAction is called, you must execute one and only one action. This is because the bot has to wait for the server answer before doing anything else.
 
Reply
#15
Each time onPathAction() is called, it can only execute one action. As many conditions as it wants but only one action.
That means you cannot do a loop of actions. Instead you need to way for the next call of onPathAction() to execute the next action.
You need to keep track of your counter, increment it after using it to call an action then exit the function and wait for the next call that will then use your incremented counter.

Look at my example, I never call any action in a loop. Instead I open the next box, return, wait for a new call and call a lot of getter on that new box.
You cannot deposit multiple pokemons in one call the same way I cannot open multiple boxes in one call of onPathAction().
 
Reply
  


Forum Jump:


Browsing: 1 Guest(s)