Switching Scripts on/off by switch and if cases

Ksi

~RTP Princess~
Restaff
Joined
Mar 13, 2012
Messages
2,083
Reaction score
1,674
First Language
English
Hey guys~

Right, so I need a bit of help and I figure it'll probably be pretty basic stuff all told.

Basically I'm trying to make it so that if a certain switch is on, one script will be referenced but if the switch is off, another is instead. In this case I've two shop scenes. One allows only selling items, the other won't let you leave the shop unless you spend all of your money. As you can probably tell, the two don't like each other - using both at the same time ends up in having a sell shop that won't let you leave because you have money... XD

The first script is Tsukihime's Sell-only Shop. The second script is very basic - just makes it so that I can't leave the shop scene without spending all your money. Yeah. The original form of it is below.

Here's a demo including the scripts and a simple call event. Change switch 23 via F9 to see what occurs (there's two shop calls in the event. One after turning off the switch so that it should always be the locked shop). What happens with this is that whichever shop gets triggered first stays as the default shop. So if the switch isn't turned on it gets locked to the Locked shop, even if you later do call the sell shop script in the event/turn on switch 23. If the switch is turned on then the sell shop is triggered and even if you later turn it off or don't call that script it still affects the shop scene.

Basically, this is what I currently have:

class Scene_Shop < Scene_MenuBase #-------------------------------------------------------------------------- # * RETURN TO PREVIOUS SCENE # Aborts the method if the player has gold. Otherwise, calls the normal # "return_scene" method found in Scene_Base #-------------------------------------------------------------------------- def return_scene if $game_switches[23] == true @shop_type = "SellOnlyShop" else if $game_party.gold > 0 @help_window.set_text("MILES: Now, now. We have a deal, remember? Don't be stingy.") Sound.play_buzzer @command_window.activate return end super end end endYeah, there's definitely something hinky there, I know. >.<;

The original script, without my edits, is like so:

class Scene_Shop < Scene_MenuBase #-------------------------------------------------------------------------- # * RETURN TO PREVIOUS SCENE # Aborts the method if the player has gold. Otherwise, calls the normal # "return_scene" method found in Scene_Base #-------------------------------------------------------------------------- def return_scene if $game_party.gold > 0 @help_window.set_text("MILES: Now, now. We have a deal, remember? Don't be stingy.") Sound.play_buzzer @command_window.activate return end super end endTo call the sell shop: @shop_type = "SellOnlyShop"

Now what happens is either only the sell shop activates or only the normal shop scene does. No matter what the switch is set to. In the case that the Sell Shop is the one that activates, it then won't allow me to leave the shop scene and freezes. >.<;

I tried checking online for how to use if cases and switch checks but I couldn't find anything bar one topic in this forum - which led to my adding the == (instead of just one) and changing how I was referencing the switches to the proper way. Usually I can brute force my way through scripts by just changing bits here and there but that doesn't seem to be working for me at the moment. >.<

If anyone could help I'd really appreciate it!
 
Last edited by a moderator:

Venka

Veteran
Veteran
Joined
Jun 20, 2012
Messages
945
Reaction score
365
First Language
English
Primarily Uses
I haven't play tested the scripts, but I did go look at the original script a little bit.

You might try setting the event to do a condtional branch to see if $game_switches[23] is ON.

If it's on then do script call: @shop_type = "SellOnlyShop"

then call the shop.

The shop should only be sell only IF the shop is on.

Then in the script try:

def return_scene if $game_party.gold > 0 && $game_switches[23] == false @help_window.set_text("MILES: Now, now. We have a deal, remember? Don't be stingy.") Sound.play_buzzer @command_window.activate return end super end endIf that still doesn't work a little demo project might help. So I (or anyone else) could tinker with it
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
You can enclose a whole script inside an if-clause, not sure if it works with non-constants though as I've only tried it using constants...


Anyway, Venka's method would be better and simpler to do. :)
 
Last edited by a moderator:

Ksi

~RTP Princess~
Restaff
Joined
Mar 13, 2012
Messages
2,083
Reaction score
1,674
First Language
English
That was fast! I'll give both a go and see how that works out. ^.^

e: Okay, so that was a no go. Basically what happened was that if the sell shop triggered first every other shop call became sell shop and if the lock shop triggered first, even if sell shop was script called, all shops became lock shop. No matter if the switch was on or off.

The event that is set up I removed the switch change (allowing for manual turning on/off via F9). Just change the switch before talking to the event (switch 23) and you'll see how it reacts. >.<;

Here's the demo
 
Last edited by a moderator:

Venka

Veteran
Veteran
Joined
Jun 20, 2012
Messages
945
Reaction score
365
First Language
English
Primarily Uses
It seems to be working.. unless I'm missing something. I will say I'm extremely tired so sorry if I'm missing the issue.

https://www.dropbox.com/s/e9er8eh3uygacam/MakeDemoDur.exe?dl=0

The shop on the left is sell only, the shop on the right won't let you leave unless you've spent all your money. I do some issues.. like I sold a potion the first time to get 125 coins. I bought 2 potions and had 25 gold so I couldn't buy anything else..nor could I leave the shop because I still had money. So you would probably need to write another check or have stock items that sell for 1 gold. Also you might need two switches or another script call for when you only want to use the shop that requires you to spend all your money.

I'm crashing for the night, but I'll check back in the morning :)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I would rename the sell-only shop script from Scene_Shop to Scene_Sell_Only_Shop and inherit from Scene_Shop instead of Scene_MenuBase.


Then call Scene_Sell_Only_Shop when you want that version, and Scene_Shop when you want the original.


That might require the windows to be renamed (I haven't looked at the script) and the new name used in the custom script. Basically look at each class used and see if it replaces an existing one. Then ask whether you want the functionality in both or just the sell-only one - if you only want it in sell-only, also rename that.
 
Last edited by a moderator:

Ksi

~RTP Princess~
Restaff
Joined
Mar 13, 2012
Messages
2,083
Reaction score
1,674
First Language
English
@Venka: the only change you made seems to be setting the line checking the switch to false instead of true and that doesn't change what is happening at all, unfortunately. Thanks for trying though.

@Shaz: I'm not exactly sure what you mean. The Sell Shop needs to refer to the shop scene in some way so renaming it just removes that link completely. Unless I'm mistaken. >.<; I tried but it kept just sending back errors so... orz

Thank you for trying to help, even if I'm too big a nub to really understand what you mean. ^.^;

So there's no way to make a script trigger only when a switch (or variable) is used? Because that is basically all I want - to have it so that the Sell shop only triggers when a switch is turned on (I'll settle for variable activation instead).
 
Last edited by a moderator:

Selchar

Veteran
Veteran
Joined
Dec 28, 2012
Messages
299
Reaction score
81
First Language
English
Primarily Uses
After some experimenting I'd hazard a guess and say an event that calls a shop is locked down to the first shop type that passes any checks given to it, regardless of how you go about it.  For example in the scriptcall calling the shop type.  I used @shop_type = "SellOnlyShop" if $game_switches[1], but the sell shop only appeared if the switch was on the 1st time the event was activated.  I believe this has something to do with how the Shop Manager operates.

To get around this, the only thing I can think of would be to have an event "switch" the "sell only shop" event with a "regular shop" event based on the status of that particular switch.
 

Ksi

~RTP Princess~
Restaff
Joined
Mar 13, 2012
Messages
2,083
Reaction score
1,674
First Language
English
So separate event pages based on which shop I need? Ugh, this will mess up a ton of the planned eventing though. Let me see if that will work before I say anything though.

Nope, that doesn't work. As soon as one is referenced once, it's the go-to shop of the game, no matter what event it's referenced in. There's no way to 'swap' shops from the looks of it (which is surprisingly silly - what if people wanted different kinds of shops in their games?)

Slay me please. ;.;

Okay, so I removed the Shop Manager script (instead of having Sell Shop refer back to that script I made it refer back to Scene_Shop instead - I just changed the Game_Shop to Scene_Shop.) It still doesn't work which means it's not Shop Manager causing the issue (as far as I can tell).
 

Selchar

Veteran
Veteran
Joined
Dec 28, 2012
Messages
299
Reaction score
81
First Language
English
Primarily Uses
What I meant was having 2 separate events be shops, and using a 3rd event switch between them, but if it's going to mess with whatever events you have planned, another way to go about it would be to use an unrelated sell shop script: http://www.rpgmakervxace.net/topic/558-sell-only-shop-ported-from-vx/

Just tested on it's, it can indeed switch between shop types in a single event without problems.  I used the scriptcall

$game_temp.shop_sell_only = true if 

$game_switches[1]

 

as my test right before calling a shop.
 
Last edited by a moderator:

Ksi

~RTP Princess~
Restaff
Joined
Mar 13, 2012
Messages
2,083
Reaction score
1,674
First Language
English
Woo! It works now! Thank you so much, Selchar! I really appreciate it. ^.^

And to everyone else who tried to help as well - thank you very much! ^.^)b
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
After some experimenting I'd hazard a guess and say an event that calls a shop is locked down to the first shop type that passes any checks given to it, regardless of how you go about it.  For example in the scriptcall calling the shop type.  I used @shop_type = "SellOnlyShop" if $game_switches[1], but the sell shop only appeared if the switch was on the 1st time the event was activated.  I believe this has something to do with how the Shop Manager operates.


To get around this, the only thing I can think of would be to have an event "switch" the "sell only shop" event with a "regular shop" event based on the status of that particular switch.
Yes, that's one of the limitations of shop manager: you can't have a shop change its type around.


You can specify custom shop ID's so that you can switch to another shop explicitly.


I don't really have an idea how to allow you to set up a shop that allows you to buy, and a shop that allows you to sell, while keeping track of all of the items that have been moved in and out, and any other custom properties that may not make sense if the shop type were to change around.
 

Ksi

~RTP Princess~
Restaff
Joined
Mar 13, 2012
Messages
2,083
Reaction score
1,674
First Language
English
That's okay, I did get it working (in a way). ^.^

(I really appreciate your scripts, by the way. They're very useful. Thanks for sharing them with the community!)
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,863
Messages
1,017,053
Members
137,571
Latest member
grr
Top