Using Variables in Shop Scriptcall

Status
Not open for further replies.

MrB

Veteran
Veteran
Joined
Nov 7, 2018
Messages
58
Reaction score
52
First Language
C#
Primarily Uses
RMMV
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!
 

Astfgl66

Veteran
Veteran
Joined
Jan 5, 2016
Messages
722
Reaction score
578
First Language
French
Primarily Uses
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.
 
  • Like
Reactions: MrB

MrB

Veteran
Veteran
Joined
Nov 7, 2018
Messages
58
Reaction score
52
First Language
C#
Primarily Uses
RMMV
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! :)
 

MrB

Veteran
Veteran
Joined
Nov 7, 2018
Messages
58
Reaction score
52
First Language
C#
Primarily Uses
RMMV
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!
 

Astfgl66

Veteran
Veteran
Joined
Jan 5, 2016
Messages
722
Reaction score
578
First Language
French
Primarily Uses
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!
 
  • Like
Reactions: MrB

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,374
Reaction score
8,536
First Language
English
Primarily Uses
RMMV

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.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,035
Messages
1,018,455
Members
137,821
Latest member
Capterson
Top