Mods / Lottery Tickets

Tags:
NPC Economy Meme lottery code
Author:
Vykax
Side:
Both
Created:
4 days ago
Last modified:
13 hours ago
Downloads:
83
Follow Unfollow 10
Recommended download (for Vintage Story 1.21.6 - 1.22.0-pre.5):
lotterytickets.zip  1-click install

What it adds:

This mod adds a machine that allows players to buy lottery tickets, scratch them off, and then redeem them from the machine.

Tickets:

Tickets are very simple right now. Simply right-click with one in your hand to scratch it off and see what you've won (if anything.) Then take it to the machine and redeem it.

There are three varieties of scratchers that cost different amounts and have correspondingly higher or lower payouts. Payout chance weights can be changed, as well as payout amounts through this mod's config file. You can also change what items you want for payment and redemption so you can make it fit with whatever you use for money.

Ticket Defaults:

  • Fool's Gold - 1 Rusty Gear
  • Dragon's Hoard - 10 Rusty Gears
  • Meteoric Moolah - 25 Rusty Gears
  • Mushroom Farmer - 10 Rusty Gears
  • Temple of Jewels - 10 Rusty Gears
  • Pharaoh's Temple - 10 Rusty Gears


The dialogue config has it such that the machine does not disclose how much each ticket costs, I figured people would want to fiddle with the config and change everything anyway. So make sure to put a sign or or edit the lottery machine's dialogue config, I apparently can't have a json file read another json file in order to change the text automatically. If I replace the interface with a trade interface it just gets more difficult to redifine it so that it accepts different currencies, this is the best way I can think to do this without getting a lot more in-depth with the code.


SERVER
OWNERS: After loading this mod for the first time, make sure to go into the config. Your tickets are pretty generous by default. Offering a signigicant chance for tickets to break even. Great for testing or really casual servers, but you'll probably want to adjust them a bit harsher if you're serious about a balanced economy.

 

Planned features:

  • Something a little more exciting than simply right-clicking to scratch. I'm probably not going to do some sort of interface, but maybe a timer, describing the player scratching off individual boxes and calculating the results. Who knows.
  • More scratch-offs. More variety is inevitable, the more types of tickets there are the funnier it gets.
  • Seasonal scratchers. It would actually be pretty simple to have this thing check the in-game calendar and offer you funny seasonal scratchers. Expect a lot of weird in-jokes you're not going to get unless you've played on my server.

 

What's under the hood

The lottery machine is essentially just the Library Resonator (if you know you know), a basic entity with no health, movement, or animation, just there as a host for dialogue. Because of this every lottery machine you place is effectively a clone of itself. There is no way to have one lottery machine sell one thing or another sell another, it's all one NPC reading from the same config files.

The behavior for purchasing tickets is handled through a .cs script. The script reads a config file that is generated in your modconfigs folder when it runs for the first time. This config tells the script how much each ticket type costs.

When a player right-clicks with the ticket in their hand it will be scratched off. This involves destroying the ticket and replacing it a seperate item that looks like the same one only scratched off. The mod has the ticket thrown at the feet of the player, this avoid it being destroyed if there is not a slot for the new ticket to go into. When the scratched ticket is generated, a .cs script assigns attributes to it that tell you what the results of the card ard. These attributes can be changed under the config that generates when you first load the mod. You can adjust weights for the liklihood of any individual result and can change the amounts for those payout. You can also change item codes to match custom economy mods like CAN Market.

Redemption of tickets runs another .cs script that double checks the config, decoding the ticket's attributes and paying the player the desired amount. Players must have their winning tickets in their hotbar during this process, they'll be prompted to do so.

Mod Version Mod IdentifierFor Game version Downloads Released Changelog Download 1-click mod install*
1.0.9 lotterytickets
1.21.6 - 1.22.0-pre.5
2 13 hours ago lotterytickets.zip 1-click install
  • Replaced a crapply looking ticket with one that doesn't look as crappy.
  • Fixed the swapped shapes for mushroom farmer
  • Oh hey, I made everything stack. I'm just going to leave it. It seems to solve more problems than it introduces.
1.0.8 lotterytickets
1.21.6 - 1.22.0-pre.5
15 1 day ago lotterytickets.zip 1-click install

Fixed an oversight

1.0.7 lotterytickets
1.21.6 - 1.22.0-pre.5
2 1 day ago lotterytickets.zip 1-click install
  • Added 3 new scratch offs with 10rg price default so you can customize as you like
1.0.6 lotterytickets
1.21.6 - 1.22.0-pre.3
35 4 days ago lotterytickets.zip 1-click install

Reverting. The mod really didn't like having losing tickets stack.

1.0.5 lotterytickets
1.21.6 - 1.22.0-pre.3
4 4 days ago lotterytickets.zip 1-click install

Hotfix

1.0.4 lotterytickets
1.21.6 - 1.22.0-pre.3
3 4 days ago lotterytickets.zip 1-click install

Made it so that losing scratchoffs can stack up to 64. Good for getting fires started, not much else.

1.0.3 lotterytickets
1.21.6 - 1.22.0-pre.3
7 4 days ago lotterytickets.zip 1-click install

per suggestion, made scratched off lottery tickets burnable in a firepit. Make sure you don't burn a winner!

1.0.2 lotterytickets
1.21.6 - 1.22.0-pre.3
4 4 days ago lotterytickets.zip 1-click install

Fixed a bug where there was a chance for lottery tickets to scratch off and reveal default prizes even after the config was changed. While funny, I determined this is undesirable. Let me know if it still happens. It shouldn't.

1.0.1 lotterytickets
1.21.6 - 1.22.0-pre.3
6 4 days ago lotterytickets.zip 1-click install

Fixed an oversight in the config. It now properly allows you to change the item used to purchase lottery tickets, not just what they pay out.

1.0.0 lotterytickets
1.21.6 - 1.22.0-pre.3
5 4 days ago Empty lotterytickets.zip 1-click install

4 Comments (oldest first | newest first)

Draftybag346, 1 day ago

PLEASE ADD SLOTS NEXT

deathmaker2580, 2 days ago

YEAAAHHH!! Who won the lottery? I DID!!

Vykax , 4 days ago

andersonian_mind

Isn't Coinage the one that lets people mint their own currency? If the goal is for different factions with different currencies to be able to have their own lottery machines, that's a little beyond this mod. I don't know how Coinage handles its coins either, I'm assuming they're all the same item code with different attributes to tell it what coin it is?

andersonian_mind, 4 days ago

Any way you could make it compatible with Coinage?