Twisted

Villager
Member
Joined
Jun 6, 2020
Messages
22
Reaction score
7
First Language
english
Primarily Uses
RMMV
Hi folks :p
So im looking for a little help as im abit stumped.
So i am trying to make it so a player can enter a password/code and receive specific item(s).
The code i have so far is this:

if ($gameActors.actor(9).name() == "M")

{

$gameSwitches.setValue(20, true);

}

which works fine for 1 code = 1 item(s).

What i need is something along the lines of:
Password:M = Item(s): 7 gold, 1 sword
Password:S = Item(s): 30 gold, 1 sword, 2 potions
Etc etc.
But i need it to all be in one event, common event. I also need it so each password can only be used once, while the rest of the event/script/passwords remain working until purchased.

Does this make sense?

I am currently not good with variables or the script, which is why im struggling.

Many Thanks
Mat
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
35,879
Reaction score
9,511
First Language
German
Primarily Uses
RMMV
absolutely no need for any script here - there should be an official blog post about how to use a fake actor to hold a password without any scripts at all.

then you only need a series of conditional branches that compare the actor name with the different possible passwords. It is important to disable the else branches for better readability here.
In each case if the password is detected, check by switch if that password has been used before.
if no give the reward and turn on the switch for "password used".

no need for a script, the conditional branch option for a name check is on page two of the conditional branch window. And it is better to use a conditional branch than a script sequence if you want to provide multiple different passwords.
 

Twisted

Villager
Member
Joined
Jun 6, 2020
Messages
22
Reaction score
7
First Language
english
Primarily Uses
RMMV
absolutely no need for any script here - there should be an official blog post about how to use a fake actor to hold a password without any scripts at all.

then you only need a series of conditional branches that compare the actor name with the different possible passwords. It is important to disable the else branches for better readability here.
In each case if the password is detected, check by switch if that password has been used before.
if no give the reward and turn on the switch for "password used".

no need for a script, the conditional branch option for a name check is on page two of the conditional branch window. And it is better to use a conditional branch than a script sequence if you want to provide multiple different passwords.
Thanks @Andar
This seems like the answer, not tried it yet.

It amazes me how things that are so simple can confuse anyone.
Cant see the forest for the trees
:p
 

Twisted

Villager
Member
Joined
Jun 6, 2020
Messages
22
Reaction score
7
First Language
english
Primarily Uses
RMMV
@Andar
Hi there,
i have tried this method and believe i am make some mistakes as i cannot get it to work.
is there any chance you could send some visual examples of the process please?

Many Thanks
Mat
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
35,879
Reaction score
9,511
First Language
German
Primarily Uses
RMMV
can you post what you have? I have some problems with making example pictures, but I can spot and correct your mistakes
 

Twisted

Villager
Member
Joined
Jun 6, 2020
Messages
22
Reaction score
7
First Language
english
Primarily Uses
RMMV
can you post what you have? I have some problems with making example pictures, but I can spot and correct your mistakes
@Andar
i hope this helps, its just confusing me a little
 

Attachments

  • prntscrn1.png
    prntscrn1.png
    758.9 KB · Views: 4
  • prntscrn2.png
    prntscrn2.png
    712.8 KB · Views: 4
  • prntscrn3.png
    prntscrn3.png
    710.5 KB · Views: 4

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
35,879
Reaction score
9,511
First Language
German
Primarily Uses
RMMV
first problem is that if you have a switch as a condition, you don't need to check it as a conditional branch.

second problem is that if one of the codes is used, the first page is disabled in both cases so the other code can no longer be executed.

both together comes from using multiple pages - this is one of the few cases where using multiple pages is a bad thing.

what you should have done is doing all on a single page.

one sequence for one code would be:

if name of redeem code is A
>if switch rc1 is on
>> code is already used
>else
>> give gold
>> control switch rc1 = ON

and then repeat for each code
 

Twisted

Villager
Member
Joined
Jun 6, 2020
Messages
22
Reaction score
7
First Language
english
Primarily Uses
RMMV
first problem is that if you have a switch as a condition, you don't need to check it as a conditional branch.

second problem is that if one of the codes is used, the first page is disabled in both cases so the other code can no longer be executed.

both together comes from using multiple pages - this is one of the few cases where using multiple pages is a bad thing.

what you should have done is doing all on a single page.

one sequence for one code would be:

if name of redeem code is A
>if switch rc1 is on
>> code is already used
>else
@Andar
Ok so here is what i have done, now it seems to work as i want it.
If you could just give it a quick check i would be most appreciative.
Many Thanks
Mat
>> give gold
>> control switch rc1 = ON

and then repeat for each code
 

Attachments

  • prnt1.png
    prnt1.png
    870.1 KB · Views: 3

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
35,879
Reaction score
9,511
First Language
German
Primarily Uses
RMMV
looks ok
by the way, it is easier to do screenshots with alt-prtscrn instead of just prtscrn. that limits the screenshot to the active window, making them better readable.
 

Twisted

Villager
Member
Joined
Jun 6, 2020
Messages
22
Reaction score
7
First Language
english
Primarily Uses
RMMV
@Andar
Everyday is a school day!
Thank you for your help
This issue has cost me a day lol
next question: Can i +1 you or similar. Your response was both timely and exact in solving my issue.
Regards
Mat
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,138
Reaction score
2,524
First Language
English
Primarily Uses
RMMV
next question: Can i +1 you or similar. Your response was both timely and exact in solving my issue.
You should see a button on the bottom of every post that says "Like."
 

Latest Threads

Latest Posts

Latest Profile Posts

Have you ever wondered what the lives of the NPC's are like in your hero's story? Come an find out with us as we play, "A Story Beside" by Wayward Prophet :LZSexcite:

Never in my life did I dream that I would be the proud owner of 5 jellyfish.
Working on Project Zelda!

The title screen lacked enough sparkles... this oversight has been rectified. :kaopride:
67 frames for a dragon transformation? Eh, seems about right. XD

Forum statistics

Threads
122,090
Messages
1,146,437
Members
160,379
Latest member
Mechazard
Top