Help with cashing out an item

oriongates

Veteran
Veteran
Joined
Dec 26, 2019
Messages
116
Reaction score
23
First Language
english
Primarily Uses
RMMV
So, I'm trying to create a scenario where the player has the option to sell all (only all or none) an NPC for 50$ per item.

So...as far as I can tell I need to create a variable based on the amount of item X in the player's inventory, then remove a number of that item equal to that variable.

The problem is that I then want to add $ based on that variable, but I can only add a fixed amount or an amount equal to the variable. If I want to add 50 $ per item I'd have to create 50 "add gold" commands with an amount equal to the variable.


The only other thing I can think of is to multiply the original variable by 50, do an add gold command equal to the new variable amount, and then divide the variable by 50 and then reduce the player's inventory of items by an amount equal to the variable.

Is there an easier way, or is this my best bet?
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
965
Reaction score
708
First Language
English
Primarily Uses
RMMV
@oriongates What you need is a good-old loop! Store the total number of the item into a variable, wipe all of the item from the inventory of the player, then create a loop that decrements that variable by one and hands out $50 each time. Make sure to create a conditional branch within the loop that breaks out once the variable reaches zero.

Code:
◆Change Items:Potion + 99
◆Text:None, Window, Bottom
:    :Are you sure you want to sell all your Potions?
◆Show Choices:Yes, No (Window, Right, #1, #2)
:When Yes 
  ◆Control Variables:#0005 itemTotal = The number of Potion
  ◆Change Items:Potion - {itemTotal}
  ◆Loop
    ◆Control Variables:#0005 itemTotal -= 1
    ◆Change Gold:+ 50
    ◆If:itemTotal = 0
      ◆Break Loop
      ◆
    :End
    ◆
  :Repeat Above
  ◆Text:None, Window, Bottom
  :    :Nice doing business with you!
  ◆
:When No 
  ◆Text:None, Window, Bottom
  :    :Well, alright!
  ◆
:End
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,837
Reaction score
12,250
First Language
English
Primarily Uses
RMMV
No loop needed, actually.

Code:
Show Choices: [Sell One] [Sell All]
When [Sell One]
  Change Items: [item] -= 1
  Change Gold += 50
When [Sell All]
  Control Variables: [Counter] = Number [item] in Inventory
  Change Items: [item] -= Variable [Counter]
  Control Variables: [Counter] *= 50
  Change Gold += Variable [Counter]
End
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

I usually don't enjoy survival games, but I absolutely love Conan Exiles.
Basically Everyone: Dont make a long game the first time. Me: I guess i'll make a REALLY long game in that case >:p
I've developed a habit of thanking cleaning ladies for their work.
Sorry Aerith... I will abandon your shoes... :guffaw:
Spent a whole bunch of time today reworking the area in the video because someone said it was too illusory. So I reworked it so it changes less, moved the grass up to the same level as the player.... And found enough extra resources to make the grass moves when the player touches it. Also lots more water, because it looks amazing. I'll probably put up a short updated video later today.

Forum statistics

Threads
95,774
Messages
931,787
Members
126,173
Latest member
emmanuelglover
Top