Script call help

J-G

Veteran
Member
Joined
Oct 4, 2019
Messages
505
Reaction score
125
First Language
English
Primarily Uses
RMMV
2020-06-04 16_53_16-Database.png
I am pretty close but i cannot seem to get the gold to actually subtract once reaches 100 or greater.
Since i need gold to never go above 100 because for every 100 gold, my other variable goes up 1, then 100 gold is subtracted, leaving the remainder.
Same for the 2nd variable, once that too reaches 100, 3rd variable will go up by 1, and 2, variable will need to lose 100 leaving any remainder so 2nd variable never goes over 100.

Can anyone point out what i did wrong?
Thanks in advance.
 

Raizen

Veteran
Veteran
Joined
Oct 24, 2012
Messages
256
Reaction score
277
First Language
Portuguese
Primarily Uses
RMMV
$gameParty.loseGold(amount)
$gameParty.gainGold(amount)

use these functions instead
Doesn't the event gold function serves you already?
anyway the logic seems fine
 

J-G

Veteran
Member
Joined
Oct 4, 2019
Messages
505
Reaction score
125
First Language
English
Primarily Uses
RMMV
how would i set it up? Im still lacking in the variable usage department.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,251
Reaction score
7,136
First Language
German
Primarily Uses
RMMV
why do you use scripts for this if you don't know how?
This can be done completely with event commands, absolutely no script needed.

1) control variable gold: other/gold (can be read out from the game data section of the control variable command, the one that defaults to map id if you don't change it to other/gold)

2) conditional branch variable gold > 100
3) change gold decrease 100

and the rest like you have it.
 
  • Like
Reactions: J-G

J-G

Veteran
Member
Joined
Oct 4, 2019
Messages
505
Reaction score
125
First Language
English
Primarily Uses
RMMV
your absolutely right, i had forgot about those, i did want to use variables as practice, since i have another project that will rely heavy on it, since it won't be a typical rpg game.
i will just go with your suggestion for now, thank you
 

J-G

Veteran
Member
Joined
Oct 4, 2019
Messages
505
Reaction score
125
First Language
English
Primarily Uses
RMMV
sorry for double posting, everytime i try and hit the edit, my browser doesn't seem to load.

Okay i changed it but i still have the same issue.
Money overlaps, it doesn't go above 200 but it's not suppose to go over 100 either lol.
below are images for examples.

2020-06-04 17_41_36-Legend of the Shield Hero.png2020-06-04 17_42_21-Database.png
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,251
Reaction score
7,136
First Language
German
Primarily Uses
RMMV
what is gold and what is silver?

I'm assuming that you use the official gold number as something like copper, because when you substract 100 from there you add one silver.
If that is the case then you should name that variable "copper", because most likely you messed up with the game-gold and the variable-gold, which adds one if there were 100 silver. But if you add that one to the game-gold instead, then you'll loose money in a repeating circle.
Rename the first variable to copper even if it loads the game-gold and the mistake should become obvious
 

J-G

Veteran
Member
Joined
Oct 4, 2019
Messages
505
Reaction score
125
First Language
English
Primarily Uses
RMMV
yes gold reads as copper but the thing is, i changed it, the first symbol may show a copper coin but its the actual in game gold amount, so the supposed copper variable will no longer be needed right? the silver goes up, no issue but it only happens when the copper(in game gold) goes up past 200, the issue remains where the in game gold(copper icon) doesn't go down appropriately.

so im confused on what you said.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,251
Reaction score
7,136
First Language
German
Primarily Uses
RMMV
so im confused on what you said.
you're using a variable called gold in the conditional branch, and another (?) variable #10 called gold near the end of your commands.
These two variables MUST NOT BE THE SAME!!!
Because the first variable is what stands for your copper number, and the second one is what stands for your real gold number.

I can't be sure because I don't know the ID of the variable used in the conditional branch and thereby can't say if they are the same variable or not, and that is exactly why I said you should rename that first variable to copper.
If you do and then suddenly the later line for gold also reads copper then you found your error.
 

J-G

Veteran
Member
Joined
Oct 4, 2019
Messages
505
Reaction score
125
First Language
English
Primarily Uses
RMMV
But the first is no longer a variable, its a condition set within the game. The 10variable is actual only tied to silver, so it's not really repeating.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,251
Reaction score
7,136
First Language
German
Primarily Uses
RMMV
then I don't know where your problem comes from - most likely either from the trigger or other changes to the variables as you have always posted incomplete screenshots that are missing half of the event details.
 

J-G

Veteran
Member
Joined
Oct 4, 2019
Messages
505
Reaction score
125
First Language
English
Primarily Uses
RMMV
What Info is missing from pictures? The trigger is set to none as it should be for a common event. The actual event itself to test is set to active so npc can give me gold while I test.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,251
Reaction score
7,136
First Language
German
Primarily Uses
RMMV
if the trigger is none then the common event has to be called from somewhere, and that call has to be triggered in a way. That is the info that is missing, as well as an example to show how the party gets gold.
 

J-G

Veteran
Member
Joined
Oct 4, 2019
Messages
505
Reaction score
125
First Language
English
Primarily Uses
RMMV
Yes from the npc event set to active. I talk to him, he gives me 99 gold each time. Common event runs each time. Of course above gold so it runs first and does the work.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,251
Reaction score
7,136
First Language
German
Primarily Uses
RMMV
then show a screenshot of that event if you want us to check it for errors.
 

J-G

Veteran
Member
Joined
Oct 4, 2019
Messages
505
Reaction score
125
First Language
English
Primarily Uses
RMMV
I don't think that event has any errors.
I'm not on computer but it's set like this.

Common event(2)
Gold + 99

Same as player
Active
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,251
Reaction score
7,136
First Language
German
Primarily Uses
RMMV
and that already shows an error - you need to call the common event after you add the gold, not before. because if the gold is 99 before the event will do nothing, then you add 99 to a total of 198 and the event will not run again until you add even more gold
 

TSR

The Northern Frog
Veteran
Joined
Nov 14, 2019
Messages
196
Reaction score
145
First Language
French
Primarily Uses
RMMV
Hello!
Here's another way that should work:
simple script lines in an event script box, no conditionnal...
Code:
let copper = $gameParty.gold();
let silver = Math.floor(copper / 100);
copper -= silver * 100;
let gold = Math.floor(silver / 100);
silver -= gold * 100;
$gameParty._gold = copper;
$gameVariables.setValue(9, silver);
$gameVariables.setValue(10, gold);
 

J-G

Veteran
Member
Joined
Oct 4, 2019
Messages
505
Reaction score
125
First Language
English
Primarily Uses
RMMV
Thanks both of you. Sorry I'm just answering. I'm trying to get a huge digital portrait done for a job and was consumed by it. I will try them both out as soon as I can. Starting with your @Andar then yours @TSR. Thanks again

Edit @Andar I did switch them and it works right. Thanks for the help!
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts


:3c here's a thing i made a while while while back
Tried mochi for the first time. It's quite nice. Has a pleasant smell and taste, and is nice and chewy.
made a bio for the protag in my project!
Beggar : "I haven't eat for days..."
Kid : "Just do crime! You will get daily necessity for free in prison~"

Forum statistics

Threads
99,159
Messages
962,454
Members
130,725
Latest member
teendinsaikha
Top