Dynamic pricesSuggestion

How about add dinamyc prices... Add new parametrs in config to slot.
Example:

Max Stock: 10
Seconds Between Refills: 10
Refill Amount: 1​

Dynamic Need Transaction: 1
Dynamic Add Cost: 10
Dynamic Reduce Cost: 5
Dynamic Cost Limit: 30
Dynamic Second Cost: 180

1 paper for 10 scrap... if i buy this, vending machine up the price (cost) to 20 scrap for 1 paper. if players buy this again, price up again, and again to 30 scrap max {Cost Limit}...
Then if nobody buy paper {Second Cost} time, price reduce to {Reduce Cost} 25... 20... 15... and 10 scrap to minimum (base price) limit...

Every {Dynamic Need Transaction} transaction up price to current price+{Dynamic Add Cost}. And every time {Dynamic Second Cost}, lower (reduce) price to {Dynamic Reduce Cost}...

Maybe make compact

Max Stock: 10
Seconds Between Refills: 10
Refill Amount: 1​
Dynamic Price: 1, 10, 5, 30, 180

I will look into creating extension points to make this possible via an addon plugin, but I don't think this should be in the core.

Anyway... I don't se this avaliable via addon plugin... In now! I mean it should work in one edit system. In one notice item... 

Yeah we can do that with extension points.

Hm... You mean API in plugin? Or edit your plugin? :D

I have to edit CVS to add hooks and APIs, so that other plugins can add settings to the note, get settings out of the note, save settings in the same data file (mostly automatic), detect purchases and get the necessary context, and alter the price of specific items.

Then an addon plugin needs to be made.

While this approach is a bit more complex than doing it all inside CVS, this feature is already a significant chunk of work in the first place, so the API approach doesn't add that much implementation effort to the feature overall.

The reason I lean toward extension points is that, at a certain point, it no longer scales to keep adding features. It makes maintaining the core plugin difficult. If there is a feature that somebody wants but is not in the core plugin, people are inclined to fork the plugin. Forking creates more problems, as the fork needs to stay updated with changes from the original, which creates more work for people which isn't very fun. Allowing the core plugin to be extended by other addon plugins reduces the likelihood of the core plugin needing to be forked, therefore reducing maintenance burden for the community to maintain of all the features.

Ok. I understand you :) Thank for advice. I need study CVS, because all my own "extension" migrate to new versions plugins, manualy from simply compare soft )))

I made some commits last month to add extension points, which has solved the following use cases.

  • Allow plugins to add options to the note when the note is generated
  • Allow plugins to read options from the note and designate them to be saved
  • Allow plugins to detect purchases that have custom settings associated with them

Still incomplete is the ability to change prices dynamically. That was in progress but I had to prioritize other work.

Here's an example of how to add a single field to the note.

// When clicking Save on a vending machine, this is called for each offer, so you can parse the note to save custom settings
void OnCustomVendingSetupOfferSettingsParse(Dictionary<string, string> localizedSettings, Dictionary<string, object> customSettings)
{
    string costIncreasePerTransactionString;
    if (localizedSettings.TryGetValue("Cost Increase Per Transaction", out costIncreasePerTransactionString))
    {
        float costIncreasePerTransaction;
        if (float.TryParse(costIncreasePerTransactionString, out costIncreasePerTransaction))
        {
            customSettings["DynamicCostIncrease"] = costIncreasePerTransaction;
        }
    }
}

// When clicking Edit on a vending machine, this is called for each offer, so you can display custom settings in the note
void OnCustomVendingSetupOfferSettingsDisplay(Dictionary<string, object> customSettings, Dictionary<string, string> localizedSettings)
{
    object costIncreasePerTransactionObject;
    if (customSettings.TryGetValue("DynamicCostIncrease", out costIncreasePerTransactionObject))
    {
        if (costIncreasePerTransactionObject is float || costIncreasePerTransactionObject is double)
        {
            var amount = costIncreasePerTransactionObject is double
                ? Convert.ToInt32((double)costIncreasePerTransactionObject)
                : (float)costIncreasePerTransactionObject;

            localizedSettings["Cost Increase Per Transaction"] = amount.ToString();
            return;
        }
    }

    // No value is saved, so display the default value
    localizedSettings["Cost Increase Per Transaction"] = "0.0";
}

Whenever you click the Edit button, each note will have a Cost Increase Per Transaction: 0.0 option. When clicking Save, the data file will have a "CustomSettings" entry with field "DynamicCostIncrease", like below.

"Offers": [
  {
    "SellItem": {
      "ShortName": "tshirt",
      "Amount": 1
    },
    "CurrencyItem": {
      "ShortName": "scrap",
      "Amount": 5
    },
    "CustomSettings": {
      "DynamicCostIncrease": 2.0
    }
  },

To detect that a sale was made for an item that has custom settings, use the following hook.

void OnCustomVendingSetupTransactionWithCustomSettings(NPCVendingMachine vendingMachine, Dictionary<string, object> customSettings)
{
    // TODO: Check customSettings for "DynamicCostIncrease", and maybe change the price
}

I haven't gotten to creating an example plugin. I was going to make a simple dynamic prices plugin, but I realize that the design is unclear. For example, if price should go up when a player makes a purchase, what if they buy in bulk? It's not really feasible to change the price in the middle of their transaction, so it would probably have to change after their transaction, which would create an inconsistency where if they buy individually they have to pay more. If you can clarify the behavior, I can possibly develop an example plugin. If you have other ideas on how to use this API, I can possibly implement an example for those.