ShopSystem.lua [v1.1] - in Episode/Level purchases!

Share and discuss custom LunaLua code and content packs for SMBX2.
Marioman2007
Lakitu
Lakitu
Posts: 465
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

ShopSystem.lua [v1.1] - in Episode/Level purchases!

Postby Marioman2007 » Tue Mar 22, 2022 1:58 am

A basic shop library on which I've been working on for a while!
This script is based on anothercurrency.lua

GIF:
Spoiler: show
Image

Credits:
Me
Enjl

Special thanks:
Rednaxela - for helping me to add support for multiple shops
Enjl - for providing lots of useful feedback

Notes:
It is preferable to use anothercurrency.lua for your currencies, variable-based currencies are tedious to use in this shop system.

Documentation:
https://docs.google.com/document/d/1qJR ... sp=sharing

Download:
https://drive.google.com/file/d/1dR1Z3x ... sp=sharing

Enjoy and please give credits!
Last edited by Marioman2007 on Thu May 19, 2022 4:24 am, edited 2 times in total.

MegaDood
Torpedo Ted
Torpedo Ted
Posts: 1722
Joined: Wed Nov 01, 2017 2:43 am

Re: ShopSystem.lua [v1] - in Episode/Level purchases!

Postby MegaDood » Tue Mar 22, 2022 2:04 am

This is an amazing script! I'm glad to see it released.

georgespezi12
Dolphin
Dolphin
Posts: 99
Joined: Mon Jun 01, 2020 3:45 am

Re: ShopSystem.lua [v1] - in Episode/Level purchases!

Postby georgespezi12 » Tue Mar 22, 2022 4:58 am

An excellent thing about the shopsystem is that the music can be chosen for the shop itself to suit the theme of the episode!

Mal8rk
Snifit
Snifit
Posts: 200
Joined: Mon Oct 25, 2021 11:04 pm
Flair: English Speaking Spanish Speaker
Pronouns: He/Him
Contact:

Re: ShopSystem.lua [v1] - in Episode/Level purchases!

Postby Mal8rk » Tue Mar 22, 2022 9:02 am

You have no idea how long I wanted an actually woking shop system

Thanks

AirShip
Panser
Panser
Posts: 1063
Joined: Wed Jan 01, 2014 1:30 am
Flair: The Flying Ghost
Contact:

Re: ShopSystem.lua [v1] - in Episode/Level purchases!

Postby AirShip » Tue Mar 22, 2022 11:42 am

Incredible work! I will definitely use it in my next projects!

Bboyfergie
Goomba
Goomba
Posts: 1
Joined: Sun Mar 27, 2022 1:54 pm
Pronouns: he/him

Re: ShopSystem.lua [v1] - in Episode/Level purchases!

Postby Bboyfergie » Tue Mar 29, 2022 4:23 pm

Thank you for this! It's super useful! How would I go about making a separate shop that only uses Dragon Coins?

Luna
Lakitu
Lakitu
Posts: 482
Joined: Sat Feb 10, 2018 2:17 am
Flair: Cuteness overload <3
Pronouns: she/her
Contact:

Re: ShopSystem.lua [v1] - in Episode/Level purchases!

Postby Luna » Tue Apr 05, 2022 1:40 pm

read the title and hoped i could finally add microtransactions to my episodes : (

Cool Script!

Marioman2007
Lakitu
Lakitu
Posts: 465
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: ShopSystem.lua [v1] - in Episode/Level purchases!

Postby Marioman2007 » Wed Apr 06, 2022 9:48 am

Thanks everyone for the positive comments!!

Bboyfergie wrote:
Tue Mar 29, 2022 4:23 pm
Thank you for this! It's super useful! How would I go about making a separate shop that only uses Dragon Coins?
You can use anothercurrency.lua to create a currency for dragon coins and then use that currency for that shop.

Mal8rk
Snifit
Snifit
Posts: 200
Joined: Mon Oct 25, 2021 11:04 pm
Flair: English Speaking Spanish Speaker
Pronouns: He/Him
Contact:

Re: ShopSystem.lua [v1] - in Episode/Level purchases!

Postby Mal8rk » Wed Apr 13, 2022 7:39 pm

Hey there

So this might be more of a thing with anothercurrency.lua, but whenever I use the shop in a level, there are two numbers in the top left that say either 0 or nil.

Is there a way to disable them?

Marioman2007
Lakitu
Lakitu
Posts: 465
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: ShopSystem.lua [v1] - in Episode/Level purchases!

Postby Marioman2007 » Wed Apr 13, 2022 10:11 pm

POPME wrote:
Wed Apr 13, 2022 7:39 pm
Hey there

So this might be more of a thing with anothercurrency.lua, but whenever I use the shop in a level, there are two numbers in the top left that say either 0 or nil.

Is there a way to disable them?
The test level's luna.lua file is full of examples
Those two are examples for variable currencies
You can look for "Text.print" and remove the lines that have them.

Brian
Goomba
Goomba
Posts: 1
Joined: Thu Apr 28, 2022 10:49 pm

Re: ShopSystem.lua [v1] - in Episode/Level purchases!

Postby Brian » Thu Apr 28, 2022 10:55 pm

Hello, first of all this script is just amazing.
I was just wondering, on the world map, the coins always stay at 0, while in the rest of my levels, the counter is correct. Is there any way to change the value of the coins for the world map?

Marioman2007
Lakitu
Lakitu
Posts: 465
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: ShopSystem.lua [v1] - in Episode/Level purchases!

Postby Marioman2007 » Mon May 02, 2022 4:37 am

Brian wrote:
Thu Apr 28, 2022 10:55 pm
Hello, first of all this script is just amazing.
I was just wondering, on the world map, the coins always stay at 0, while in the rest of my levels, the counter is correct. Is there any way to change the value of the coins for the world map?

create a file called "map.lua" and put this code inside it:

Code: Select all

local HUDOverride = require("hudoverride")
local anothercurrency = require("anothercurrency")

HUDOverride.overworld.offsets.coins.value.y = -500

local coins = anothercurrency.registerCurrency("coins", true)
coins:registerLimit(9999, function() end)

local coinsY = 90
local coinsX = 190

function onDraw()
	Text.printWP(coins:getMoney(), 1, coinsX, coinsY, 5)
end

Marioman2007
Lakitu
Lakitu
Posts: 465
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: ShopSystem.lua [v1.1] - in Episode/Level purchases!

Postby Marioman2007 » Thu May 19, 2022 4:26 am

Version 1.1 is out!

- Fixed the item drawing system
- added a new argument to registerItem that allows to change the color of the egg

Coldcolor
Koopa
Koopa
Posts: 17
Joined: Tue Oct 23, 2018 1:15 pm
Pronouns: he/him
Contact:

Re: ShopSystem.lua [v1.1] - in Episode/Level purchases!

Postby Coldcolor » Mon Jun 13, 2022 3:22 pm

i wonder if I can make this compatible with my Bowsers Fury Inventory library...

Ness-Wednesday
Purple Yoshi Egg
Purple Yoshi Egg
Posts: 1579
Joined: Sun Jun 28, 2015 3:50 pm
Flair: Diverse Scouts
Pronouns: He/Him

Re: ShopSystem.lua [v1.1] - in Episode/Level purchases!

Postby Ness-Wednesday » Mon Jun 13, 2022 4:55 pm

Such emotional poetry...
"a"
"b"
"c"
"gfhfghjfgkjghjkhvbgkjghkghjghjgcfydsrtawerftaewsygdrefuyhreuyraetgdrfyhdfjuyfcikjfiuypfuipluikhujkfgyujdt7yusrtesdtfgdsreyhftjuyo8uy9i56d7y43es5r3awr4eswfdxbvgmhj,iuj;89p7yg8uid4e52357569i7689itgjnhfcgbs5437r5ujgyhkhvgjdfgaew36547"

Jokes aside, this is a great API. I'm really excited to see how people use it

Marioman2007
Lakitu
Lakitu
Posts: 465
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: ShopSystem.lua [v1.1] - in Episode/Level purchases!

Postby Marioman2007 » Tue Jun 14, 2022 3:38 am

Coldcolor900 wrote:
Mon Jun 13, 2022 3:22 pm
i wonder if I can make this compatible with my Bowsers Fury Inventory library...
If you have a function to add items to the inventory, it will be pretty easy.

KurttheKing
Dolphin
Dolphin
Posts: 80
Joined: Tue Mar 15, 2022 4:55 pm
Flair: Certified Nerd
Pronouns: He/Him
Contact:

Re: ShopSystem.lua [v1.1] - in Episode/Level purchases!

Postby KurttheKing » Fri Jul 29, 2022 7:19 pm

It doesn't seem to be working for me. Any ideas why?

Image

Error I got from the Test Level

Edit: it's because "anothercurrency.lua" isn't in the Folder. It works now and...yeah it's incredible :)

Mal8rk
Snifit
Snifit
Posts: 200
Joined: Mon Oct 25, 2021 11:04 pm
Flair: English Speaking Spanish Speaker
Pronouns: He/Him
Contact:

Re: ShopSystem.lua [v1] - in Episode/Level purchases!

Postby Mal8rk » Wed Jan 04, 2023 3:22 pm

Added in 1 minute 17 seconds:
Marioman2007 wrote:
Mon May 02, 2022 4:37 am
Brian wrote:
Thu Apr 28, 2022 10:55 pm
Hello, first of all this script is just amazing.
I was just wondering, on the world map, the coins always stay at 0, while in the rest of my levels, the counter is correct. Is there any way to change the value of the coins for the world map?

create a file called "map.lua" and put this code inside it:

Code: Select all

local HUDOverride = require("hudoverride")
local anothercurrency = require("anothercurrency")

HUDOverride.overworld.offsets.coins.value.y = -500

local coins = anothercurrency.registerCurrency("coins", true)
coins:registerLimit(9999, function() end)

local coinsY = 90
local coinsX = 190

function onDraw()
	Text.printWP(coins:getMoney(), 1, coinsX, coinsY, 5)
end
It doesn't seem to work on smwMap though. The counter always stays at 0

Marioman2007
Lakitu
Lakitu
Posts: 465
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: ShopSystem.lua [v1.1] - in Episode/Level purchases!

Postby Marioman2007 » Fri Jan 06, 2023 10:23 pm

Mal8rk wrote:
Wed Jan 04, 2023 3:24 pm
It doesn't seem to work on smwMap though. The counter always stays at 0

Yeah, smwMap is level based, what you can do is:
EDIT (2-Feb-23): I just realized that there was an issue with this code, its fixed now.

Code: Select all

local smwMap = require("smwMap")

local function getCoins()
    return coinCounter:getMoney()
end

function onTick()
	if Level.filename() == smwMap.levelFilename then
		smwMap.hudCounters[2].getValue = getCoins
	end
end


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari