You may know what a shop is in Undertale. Well, here you'll learn how to make one in Create Your Frisk!
Shop scripts contain some of the same functions and objects that are in all scripts, such as the Audio object,
the NewAudio object, the Inventory object, the Input object,
the Misc object, and the Time object, as well as RealGlobals
and AlMightyGlobals.
The variables isCYF, safe, windows
and CYFversion are also accessible (see Overworld - Basics).
Finally, the functions CreateSprite, CreateLayer and
CreateText are all accessible (see Overworld - Basics for differences in functionality),
as well as the Game Event OnTextAdvance.
Shop scripts have their own State system. You can't directly access them, but here is a list of the shop's states:
If you don't know what to do or where to start, I suggest you look at the file Examples 2/Lua/Shops/Dummy.lua to visualize how it's done.
Other than that, other functions and variables are available, to personalize your shop. The following is a detailed list of those.
CYF's shops are different from what you've seen so far.
Your shop scripts are to be put in the directory YOURMOD/Lua/Shops/.
A shop can be loaded with this function:
General.EnterShop( scriptName)
Enters a shop scene from the overworld.
scriptName should be the name of your shop's lua file, without the extension.
So, if you have want to load YOURMOD/Lua/Shops/shop.lua, you would use
General.EnterShop("shop").
talklist = { { "Job", "Hobbies", "Threaten", "Sell?" }, { { "Me?", "I'm just a shopkeeper." }, "Just a shopkeeper.", { "Threats? I'm not impressed, I'm just a shopkeeper." }, { "So you have items to sell?", "I guess some of them could be useful to me...", "Alright, I'll see what you have next time you want to sell something to me!" } } }
Start()
This event is called when entering the shop.
It is advised to set the background's image here.
Update()
Every well-functioning script needs an Update() function.
This function is called once per frame.
EnterMenu()
Entered when entering the main Shop menu.
EnterBuy()
Entered when entering the Buy menu.
SuccessBuy( itemName)
Entered when an item is successfully purchased.
itemName is the name of the item bought.
FailBuy( error)
Entered when the Player tries to buy an item, but can't.
error has two possible values:
ReturnBuy()
Entered when the player selects an item to buy, then chooses "No" or presses the Cancel button.
EnterSell()
Entered when entering the Sell menu.
To prevent the player from selling, use the function Interrupt() here (see below).
SuccessSell( itemName)
Entered when an item is successfully sold.
itemName is the name of the item sold.
FailSell( error)
Entered when failing to enter or use the Sell menu.
error has two possible values:
ReturnSell()
Entered when the player selects an item to sell, then chooses "No" or presses the Cancel button.
EnterTalk()
Entered when entering the Talk menu.
SuccessTalk( talkOption)
Entered when a Talk option is successfully selected.
talkOption is the name of the option selected.
EnterExit()
Entered when choosing the Exit option.
Interrupt( text, newState = "MENU")
Interrupts any current state (except the INTERRUPT state) to display the message given in
text.
At the end of the message, the state newState will be entered.
I advise for you to not use this to enter the states BUYCONFIRM,
SELLCONFIRM or TALKINPROGRESS.
OnInterrupt( newState)
This function is called when entering the Interrupt state.
newState is the name of the state the Player will enter when the
Interrupt state finishes its text.
The layers in the Shop scene aren't the same as everywhere else.
This is the Shop script's layering system: