Using Variables in Shop Scriptcall

● ARCHIVED · READ-ONLY
Started by MrB 6 posts View original ↗
  1. Sorry for making another topic so soon, but this all this scripting all so confusing for me!

    ---

    I want to make a shop that updates it's wares based on switches/variables.

    Example: if Switch 001 is on, the shop will sell ethers, in addition to it's usual wares(let's say potions and antidotes).

    After a LOT of trial and error I figured out how to add items and open a shop through a scriptcall.

    Code:
    var shopItems = [[0,1,0,0],[0,2,0,0],[0,3,0,0]];
    SceneManager.push(Scene_Shop);
    SceneManager.prepareNextScene(shopItems, false);

    Though, I have no clue how I add for example, the switch example.
    Or perhaps, a variable that's at least 3 or something.



    Furthermore... I'd like to know what I've done there.
    I understand most of the code luckily, but I don't understand why I have to use this format for the items, and what the numbers stand for.

    I figured out that the first number is the catagory(0 = items, 1 = weapons, 2 = armours). The second number is the ID number.. But what is the third number? I found out that the 4th number has something to do with the shop price(if I leave it empty, all items sell for 0). But it doesn't change anything from normal value, if I set it to 500 or so, so that's weird as well.

    Ugh, I hope I make sense.

    Anyways, if anyone could help me with the first part at least, that's what matters for me most :)

    Thanks a lot!
  2. As you've seen now, items that are sold in the shop are contained in an array, so just add to it using if statements like this:
    Code:
    if ($gameSwitches.value(id)) {shopItems.push([itemCode])}
    That should do the trick.

    I can't help you with item formatting in the array, though. Never messed with scene shop.
  3. Wait, that's all? That seems so simpel haha. I thought I had to open up multiple instances to get it work or something.

    I have a busy day today, but I'll be sure to test it when I get back, thank you so much for answering this fast! :)
  4. Okay, so I couldn't get this function to work

    Code:
    if ($gameSwitches.value(id)) {shopItems.push([itemCode])}

    But I did find a work around. You telling me that the shop functions as an array was super useful(Yes I did not realise!). So I figured out that could can just list the variables before opening the shop, with an if/else function to see if they can appear in the shop.

    This is working as intented:

    Code:
    if ($gameSwitches.value(1)) {
       var WoodenRing = [0,4,0,0];
       } else {
          var WoodenRing = "Not Unlocked";
       }
    var shopItems = [
    [0,1,0,0], [0,2,0,0], [0,3,0,0], WoodenRing];
    SceneManager.push(Scene_Shop);
    SceneManager.prepareNextScene(shopItems, false);

    This works amazing. But... I'm limited to 12 lines of code. And this shop is going to handle literally ALL of my wares, so I'm going to need to write my own plugin.

    Again, thank you @Astfgl66 ! I guess my next step is to dive into the dark world of plugin writing!
  5. Thankfully plugin writing is just like script calls, only in its own text file so you should be fine.
    I'm glad you got it sorted out.
    Happy making!
  6. This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.