JPAN
Steampunker
This mod introduces Vending Machines to the world of Terraria. These vending machines can be custom shops or any Town NPC shop, including both vanilla and modded npc shops.
To create a NPC based shop, you need a Soul Extractor(
), a deadly weapon that can only hit Town NPCs (and the Skeleton Merchant) and, as of Version 1.2, NPCs that spawn the Town NPCs (bound, sleeping,etc). This weapon is crafted with 12 Gold/Platinum bars, 1 Guide/Clothier Voodo Doll and 5 Diamonds. Killing a Town NPC (or spawning version) with this weapon will cause it to drop a Soul of <NPC> item, essential to craft a Town NPC Shop. To craft a Vending Machine, you need 15 iron/lead bars, 25 glass blocks, 10 wire, one switch and the NPC soul. This will create a "Vending Machine (<NPC>)" Example below:
Note: When creating the Vending Machine, it will display as "Vending Machine (Empty)". This is due to the way the item is programmed, and most likely cannot be fixed. The final item should be called "Vending Machine (Nurse)" or whatever NPC's soul you used.
Whey you finish crafting, place the Vending Machine anywhere and then right click it (from close enough) to open the shop. If the shop doesn't appear to open, try from closer (the range is really small). It works even with most Modded town NPCs (example here the Mutant from Fargo's Mutant Mod):
The Nurse Vending Machine is special: It will heal you at the cost the nurse would with a right click (it had to be implemented like that due to limitations).
The Travelling and Skeleton Merchant's shops change based on the day you are on, or if one of them spawns in your world.
This mod also includes the "Easy Vending Machine", an example vending machine that sells health and mana potions that is coded completely without an equivalent NPC.
As of version 1.1, it also includes the "Guide's Crafting Help Machine", that allows for access to the crafting help interface from the Guide, which requires the "Soul of the Guide" and the remaining regular vending machine crafting items, and a "Reforge Machine" crafted from the "Soul of the Goblin Thinkerer" and vending machine crafting items, which allows for reforging, same as the Goblin Tinkerer. Both these machines can be used as an example for building machines with custom Right-click code.
Version 1.2 adds the ATM, a Tax Collector based Machine that collects taxes, the Dye Ball Machine, a Dye Trader machine that allows for trading Strange Plants for Dyes, and the Hair Dryer, a Stylist based machine that allows you to color and style your hair. All machines are made the same as the others (requiring specific souls) except for the Hair Dryer, which requires Silk instead of Glass. The Hair Dryer also counts as a chair for your house, if you need one.
With this update, the only NPCs with a secondary function remaining require the NPC dialog screen, so I shouldn't be able to implement them.
Also the Right click code interface for VendingMachineItems was changed to include the VendingMachineData of the vending machine being used, and the Invisible NPC spawner was made "public static"
Creating your own Vending Machine
This mod is meant as an easy-to-use Framework for anyone wishing to implement their own Vending Machines. To create one, you need to include this mod as a dependency on your mod build.txt. Feel free to use any of the provided graphics and code as reference. To decompile the mod you need the tModReader from the tModLoader thread.
To end, here's the mod and source code for those who cannot open the mod with tModReader. I would prefer if you download the mod from the browser, however, as this one might not be always up to date.
EDIT: Find all latest released in the github : JPANv2/VendingMachines
To create a NPC based shop, you need a Soul Extractor(
Whey you finish crafting, place the Vending Machine anywhere and then right click it (from close enough) to open the shop. If the shop doesn't appear to open, try from closer (the range is really small). It works even with most Modded town NPCs (example here the Mutant from Fargo's Mutant Mod):
The Travelling and Skeleton Merchant's shops change based on the day you are on, or if one of them spawns in your world.
This mod also includes the "Easy Vending Machine", an example vending machine that sells health and mana potions that is coded completely without an equivalent NPC.
As of version 1.1, it also includes the "Guide's Crafting Help Machine", that allows for access to the crafting help interface from the Guide, which requires the "Soul of the Guide" and the remaining regular vending machine crafting items, and a "Reforge Machine" crafted from the "Soul of the Goblin Thinkerer" and vending machine crafting items, which allows for reforging, same as the Goblin Tinkerer. Both these machines can be used as an example for building machines with custom Right-click code.
Version 1.2 adds the ATM, a Tax Collector based Machine that collects taxes, the Dye Ball Machine, a Dye Trader machine that allows for trading Strange Plants for Dyes, and the Hair Dryer, a Stylist based machine that allows you to color and style your hair. All machines are made the same as the others (requiring specific souls) except for the Hair Dryer, which requires Silk instead of Glass. The Hair Dryer also counts as a chair for your house, if you need one.
With this update, the only NPCs with a secondary function remaining require the NPC dialog screen, so I shouldn't be able to implement them.
Also the Right click code interface for VendingMachineItems was changed to include the VendingMachineData of the vending machine being used, and the Invisible NPC spawner was made "public static"
Creating your own Vending Machine
This mod is meant as an easy-to-use Framework for anyone wishing to implement their own Vending Machines. To create one, you need to include this mod as a dependency on your mod build.txt. Feel free to use any of the provided graphics and code as reference. To decompile the mod you need the tModReader from the tModLoader thread.
- Create a new class inheriting the VendingMachineItem class.
- On that item's SetDefaults, include the following lines:
hasShop = true;
npcType = SoulOfNPC.ItemToTag(item); - On that same class, create a method
"public override bool SetupShop(Item[] shop)" - fill it with your shop's contents, same as a NPC setupShop method.
- Create a new class inheriting the VendingMachineItem class.
- On that item's SetDefaults, include the following lines:
item.createTile = mod.TileType<*your vending machine Tile>();
hasShop = true;
npcType = SoulOfNPC.ItemToTag(item); - On that same class, create a method
"public override bool SetupShop(Item[] shop)" - fill it with your shop's contents, same as a NPC setupShop method.
- Create a new class inheriting the VendingMachine (Tile) Class
- write
public override void SetDefaults()
{
base.SetDefaults();
dropID = mod.ItemType<*Your Vending machine Item Type here*>();
}
- (Optional) If you want to change the tile style from 3x4 to something else, write
"public override void VendingMachineTileStyle()"
and then fill in the "TileObjectData.newTile" fields. DO NOT USE TileObjectData.newTile.addTile. The base does that for you.
- (Optional) If you want to change what shows on the map when you hover over the tile, write
public override void VendingMachineMapEntry()
{
base.AddMapEntry(new Microsoft.Xna.Framework.Color(*your r, g, b*), "*your name to show*");
}
- (*Really* Optional) Change the Mouse Over/ Mouse Over Far methods to display something entirely different. By default (no change required) the method displays the Item Name of your vending machine item.
To end, here's the mod and source code for those who cannot open the mod with tModReader. I would prefer if you download the mod from the browser, however, as this one might not be always up to date.
EDIT: Find all latest released in the github : JPANv2/VendingMachines
Attachments
Last edited: