• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Forum moderator applications are now open! Click here for details.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Pokemart Help

Harvey_Create

Pokemon Apex Team Member
187
Posts
11
Years
  • Age 27
  • Iowa
  • Seen Jul 12, 2015
Why do I seem to get all of the errors? I guess i'll come here again. I made the Guy for my Pokemart. The thing is, when i talk to him in-game, he gives me an error report. Any help? I am not sure what version of Essentials we are using. I should probably upgrade to V12 soon.

Spoiler:
 
189
Posts
14
Years
  • Seen Nov 23, 2023
You dropped the closing square bracket and parenthesis after :REPEL onto the next line. Lines are only allowed to end on a comma or a parenthesis/bracket.
 

Harvey_Create

Pokemon Apex Team Member
187
Posts
11
Years
  • Age 27
  • Iowa
  • Seen Jul 12, 2015
You dropped the closing square bracket and parenthesis after :REPEL onto the next line. Lines are only allowed to end on a comma or a parenthesis/bracket.

YOu've got to be kidding me. Thats all thats wrong? O_O
 
189
Posts
14
Years
  • Seen Nov 23, 2023
Nah, no kidding here. Ruby is a very syntax-pedantic language from my experience. There are a lot of things that are implicit and assumed where in other languages it would be expressly defined. The reason this can work is because it enforces a very strict syntax for its code. Since lines are ended at the physical end of the line, rather than with a defined character (often a semicolon), you have to ensure that any time that you do have to chop a line down, it is done so in one of the few ways that Ruby can see that "hey, this line is actually still going, man"; that is, commas, parenthesis and brackets.
 

Harvey_Create

Pokemon Apex Team Member
187
Posts
11
Years
  • Age 27
  • Iowa
  • Seen Jul 12, 2015
Nah, no kidding here. Ruby is a very syntax-pedantic language from my experience. There are a lot of things that are implicit and assumed where in other languages it would be expressly defined. The reason this can work is because it enforces a very strict syntax for its code. Since lines are ended at the physical end of the line, rather than with a defined character (often a semicolon), you have to ensure that any time that you do have to chop a line down, it is done so in one of the few ways that Ruby can see that "hey, this line is actually still going, man"; that is, commas, parenthesis and brackets.

Okay, then what about this?
Spoiler:


From what i see in the error, it's telling me the array is messed up? I might be reading that wrong. I have editted it around and can't seem to fix it. It says something about Pbisimportantitem?
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
Have a look at the top of def pbPokemonMart. Does it look like this:

Code:
def pbPokemonMart(stock,speech=nil,cantsell=false)
  for i in 0...stock.length
    stock[i]=getID(PBItems,stock[i]) if !stock[i].is_a?(Integer)
    if !stock[i] || stock[i]==0 ||
       (pbIsImportantItem?(stock[i]) && $PokemonBag.pbQuantity(stock[i])>0)
      stock[i]=nil
    end
  end
  stock.compact!
  commands=[]
Because it should.

:POTION, with the colon in front of it, is what's known as a symbol. It needs to be turned into an integer, which is what the getID method does. That's the really important line, and it needs to happen before you try using it to look up information from an array (which is what pbIsImportantItem? does).
 
189
Posts
14
Years
  • Seen Nov 23, 2023
Okay, I've looked at the examples in my clean Essentials 12. It seems that closing brackets/parentheses can be on the next line. My bad. Anyway, that's not relevant to the problem.

That IsImportantItem thing returns true if the item passed to it is a key item, an HM or a TM if Gen V TMs are in effect. It is called by PokemonMart with a bit of code that examine the array of items passed (your list) and discards any value that is either a) not an item, b) equal to 0 or c) a key item that has already been acquired.

Now, I can't see anything there that should be subject to IsImportantItem, but you're getting an error there nonetheless. The only thing I can think of is that, in an older version of Essentials, :POKEBALL was formatted differently. If you're using one of those versions, then the formatting discrepancy may be the root of the solution. Take a look at the raw Essentials for whatever version you're using, and see what the example Mart script says.
 

Harvey_Create

Pokemon Apex Team Member
187
Posts
11
Years
  • Age 27
  • Iowa
  • Seen Jul 12, 2015
Have a look at the top of def pbPokemonMart. Does it look like this:

Code:
def pbPokemonMart(stock,speech=nil,cantsell=false)
  for i in 0...stock.length
    stock[i]=getID(PBItems,stock[i]) if !stock[i].is_a?(Integer)
    if !stock[i] || stock[i]==0 ||
       (pbIsImportantItem?(stock[i]) && $PokemonBag.pbQuantity(stock[i])>0)
      stock[i]=nil
    end
  end
  stock.compact!
  commands=[]
Because it should.

:POTION, with the colon in front of it, is what's known as a symbol. It needs to be turned into an integer, which is what the getID method does. That's the really important line, and it needs to happen before you try using it to look up information from an array (which is what pbIsImportantItem? does).
The PokemonMart script i have is:
Spoiler:
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
You're using an old version of Essentials which doesn't support this:

Code:
pbPokemonMart([
:POKEBALL,
:POTION,
:ANTIDOTE,
:PARLYZHEAL,
:ESCAPEROPE,
:REPEL
])
You need to use this instead:
Code:
pbPokemonMart([
PBItems::POKEBALL,
PBItems::POTION,
PBItems::ANTIDOTE,
PBItems::PARLYZHEAL,
PBItems::ESCAPEROPE,
PBItems::REPEL
])
Also, you obviously didn't read what I said, even though what I said was the answer.
 

Harvey_Create

Pokemon Apex Team Member
187
Posts
11
Years
  • Age 27
  • Iowa
  • Seen Jul 12, 2015
You're using an old version of Essentials which doesn't support this:

Code:
pbPokemonMart([
:POKEBALL,
:POTION,
:ANTIDOTE,
:PARLYZHEAL,
:ESCAPEROPE,
:REPEL
])
You need to use this instead:
Code:
pbPokemonMart([
PBItems::POKEBALL,
PBItems::POTION,
PBItems::ANTIDOTE,
PBItems::PARLYZHEAL,
PBItems::ESCAPEROPE,
PBItems::REPEL
])
Also, you obviously didn't read what I said, even though what I said was the answer.

Well, considering since as short as it was, i thought it was a snippet, not the entire code. Second, I did read your answer, you didnt tell me to add "PBItems:" to the front of all of the things i want to sell.
But anyways, Thanks, because it works now.(I REALLY need to learn to script dammit)
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
Have a look at the top of def pbPokemonMart. Does it look like this:
.
.
.
Because it should.
In other words: "make this part of your code look like this." I don't think it was that subtle a message.

The alternative solution is to put PBItems: everywhere. I said this because I was surprised you didn't pick up on the first solution.
 

Nickalooose

--------------------
1,309
Posts
16
Years
  • Seen Dec 28, 2023
Harvey, why don't you just upgraded to 12.1... Saves all these unnecessary problems, and we can all help you quicker and more effective, sometimes we don't have time to look up older versions for simple problems as this, just some advice, because all these errors you're posting and things you want doing, you're not telling people you're using an older version which is confusing everyone. Consider it. I would.
 

Harvey_Create

Pokemon Apex Team Member
187
Posts
11
Years
  • Age 27
  • Iowa
  • Seen Jul 12, 2015
Harvey, why don't you just upgraded to 12.1... Saves all these unnecessary problems, and we can all help you quicker and more effective, sometimes we don't have time to look up older versions for simple problems as this, just some advice, because all these errors you're posting and things you want doing, you're not telling people you're using an older version which is confusing everyone. Consider it. I would.

Well, i would upgrade, but I am not the one fully in charge of Apex, so i can't do things like that. I'll take to Dillon later about upgrading to 12.1
 
Back
Top