ValuesAndPrices.lua
I’m going to transition here into setting up a custom mod and explaining the parts of ValuesAndPrices and then we’ll discuss the global shop, player shops, and vehicle shops.
Please note, I’ll be adding 3 new mods to the load order, the entire load order is now. I’m including damnlib and the M998 to be used as examples, they are not required. The last mod is the example mod I’ll be loading which will include the ValuesAndPrices.lua. This VlauesAndPrices.lua was taken from Bikini’s Example mod under media/lua/shared/ValuesAndPrices.lua
BTSE_Base
BTSE_Economy
damnlib
92amgeneralM998
Fallens_Guide_Mod
Defining exchangeable values
From the example page you can see the included definition.
BTSE.Economy:addValuablesEntry("Base.Money", 1);
Let’s make another. This time we’ll give players 10 money for exchanging a box of .38 Special Rounds.
BTSE.Economy:addValuablesEntry("Base.Bullets38Box", 10);
Note: It’s important to note that the module is REQUIRED for the item. Module.ItemType
The next screenshot is what it looks like in vs code.
This is what the Valuables tab looks like now.
Note: Valuables ONLY return the primary currency.
Defining vehicles purchasable from the global vehicle shop.
We’ll start with the vanilla vehicle Base.CarNormal
To create this shop entry we’ll use the following code.
BTSE.Economy:addVehicleShopEntry("Base.CarNormal", {
["cash_primary"] = 5000,
});
This will create the shop entry and set the price of the car to 5000 cash of the primary currency.
You can add multiple types of currency here as well.
Note: The currency at the top of the list is used first if a player has enough of each currency.
BTSE.Economy:addVehicleShopEntry("Base.CarNormal", {
["cash_primary"] = 5000,
["primary"] = 6000,
["tessera"] = 3000,
});
You can also add a custom description of the vehicle.
BTSE.Economy:addVehicleShopEntry("Base.CarNormal", {
["cash_primary"] = 5000,
}, {
description = "A really normal car"
});
This also accepts IGUI for translations.
BTSE.Economy:addVehicleShopEntry("Base.CarNormal", {
["cash_primary"] = 5000,
}, {
description = "IGUI_Fallenstestmod_normalcardesc"
});
Note: So far when someone buys a car, it will follow the Sandbox Option “General Condition” under the vehicles tab.
Now, let’s get a bit more dynamic with how the vehicles come out of the shop.
We can have a car be fully repaired as it spawns with the repairAllParts option.
Note: This does not add parts to cars.
BTSE.Economy:addVehicleShopEntry("Base.CarNormal", {
["cash_primary"] = 5000,
}, {
description = "IGUI_Fallenstestmod_normalcardesc",
repairAllParts = true,
});
We’re going to change the vehicle here to KI5’s M998 General Humvee.
Next we’re going to look at the addSpecialParts option.
BTSE.Economy:addVehicleShopEntry("Base.92amgeneralM998", {
["cash_primary"] = 35000,
["primary"] = 40000,
}, {
addSpecialParts = {
["M998Bullbar"] = "Base.M998Bullbar2_Item",
["M998Roofrack"] = "Base.M998Roofrack1_Item",
["M998Muffler"] = "Base.M998Muffler2_Item",
}
});
This allows you to specify which part can be installed into which vehicle slot. To spell out the option above [“M998Bullbar”] is the item slot and "Base.M998Bullbar2_Item" is the item itself. As a reminder you need both the module and the item type itself, so Module.itemtype.
Once you have specified new items to be installed you can include repairAllParts to have all of these the original items and the newly added items to be 100% on spawn.
BTSE.Economy:addVehicleShopEntry("Base.92amgeneralM998", {
["cash_primary"] = 35000,
["primary"] = 40000,
}, {
repairAllParts = true,
addSpecialParts = {
["M998Bullbar"] = "Base.M998Bullbar2_Item",
["M998Roofrack"] = "Base.M998Roofrack1_Item",
["M998Muffler"] = "Base.M998Muffler2_Item",
}
});
A couple of other options worth mentioning are skinIndex and thumbnailPath.
BTSE.Economy:addVehicleShopEntry("Base.92amgeneralM998", {
["cash_primary"] = 35000,
["primary"] = 40000,
}, {
repairAllParts = true,
addSpecialParts = {
["M998Bullbar"] = "Base.M998Bullbar2_Item",
["M998Roofrack"] = "Base.M998Roofrack1_Item",
["M998Muffler"] = "Base.M998Muffler2_Item",
},
skinIndex = 6,
thumbnailPath = "media/ui/example/nomad-humvee.png",
});
The skinIndex allows you to force a vehicle to spawn with a specific skin available to it. The index starts with 0.
The thumbnailPath allows you to specify a different thumbnail to load for this sale vehicle.
Defining items purchasable from the global vehicle shop.
Let’s first define an item to be sold for a single currency.
BTSE.Economy:addItemShopEntry("Base.Money", {
["cash_primary"] = 1,
});
This creates a shop entry for 1 vanilla money item that costs 1 cash of the primary currency.
Like vehicles you can also add multiple currencies. The first currency listed is the one with priority.
BTSE.Economy:addItemShopEntry("Base.Money", {
["cash_primary"] = 1,
["primary"] = 1,
});
You can also add an amount modifier to the item entry.
BTSE.Economy:addItemShopEntry("Base.Money", {
["cash_primary"] = 5,
}, {
amount = 5,
});
This will return 5 of the item for that listed price.