Shop System's Stumped Me...
by Orion the Hunter · in Torque Game Builder · 05/08/2013 (1:42 pm) · 6 replies
Hello,
Recently, I've been working on a shop system. I had a really, really complex one but I tore out the functionality to make it simplified. What I have so far is a gui that has items from a list. However, I need to make it so that when you select one of the items from the list, it sets the text of a text object. I have this so far:
itemShop.cs:
Obviously, PINE::onClick() doesn't work. I put that there as a placeholder for now. So... how would I go about making an effective shop system? Tutorials, snippets, any of that stuff is welcome! :)
Recently, I've been working on a shop system. I had a really, really complex one but I tore out the functionality to make it simplified. What I have so far is a gui that has items from a list. However, I need to make it so that when you select one of the items from the list, it sets the text of a text object. I have this so far:
itemShop.cs:
function itemShopGui::onWake()
{
itemlist.addRow(PINE, "PineCone", 1);
itemlist.addRow(BPNE, "Burning PineCone", 2);
itemlist.addRow(FPNE, "Frozen PineCone", 3);
itemlist.addRow(PPNE, "Poisoned PineCone", 4);
itemlist.addRow(MPNE, "Multi-PineCone", 5);
itemlist.addRow(MBPN, "Multi-Burning PineCone", 6);
itemlist.addRow(MFPN, "Multi-Frozen PineCone", 7);
itemlist.addRow(MPPN, "Multi-Poisened PineCone", 8);
itemlist.addRow(CRRT, "Carrot", 9);
itemlist.addRow(APPL, "Apple", 10);
itemlist.addRow(SOUP, "Soup", 11);
}
function PINE::onClick()
{
echo("Clicked!");
}Obviously, PINE::onClick() doesn't work. I put that there as a placeholder for now. So... how would I go about making an effective shop system? Tutorials, snippets, any of that stuff is welcome! :)
#2
05/22/2013 (10:26 am)
I've got some MIT version work at my GitHub repository, but it would need to have some re-work done to back-port to TGB. However, you should get the general idea from it.
#3
Well, I looked through your GitHub respiratory (which looks awesome, I might add) but maybe you could point me to a specific script? Thanks!
05/23/2013 (11:20 am)
Loads of thanks for a response!Well, I looked through your GitHub respiratory (which looks awesome, I might add) but maybe you could point me to a specific script? Thanks!
#4
What you have to do is create a GUI - InventoryGui.cs - and then represent the inventory of a store and a player (the actual list of what each has) - Inventory.cs.
There are some extraneous scripts - pretty much all of the stuff in scripts/previewWindows can be ignored, and most of the stuff without "inventory" in the script name - though the VsDynamicButton methods in verticalScrollContainer.cs are important for dealing with moving items from my store container.
Your problem was that you have items but no way to interact with them. This module presents a sample of how to do that. However, ordinarily I'd separate the store portion and an item "database" into their own modules and use some sort of tag system to identify the objects. This would separate the inventory representation of the items from the game attributes of the items - less data to pass around just for shopping.
05/23/2013 (10:24 pm)
The whole Inventory module.What you have to do is create a GUI - InventoryGui.cs - and then represent the inventory of a store and a player (the actual list of what each has) - Inventory.cs.
There are some extraneous scripts - pretty much all of the stuff in scripts/previewWindows can be ignored, and most of the stuff without "inventory" in the script name - though the VsDynamicButton methods in verticalScrollContainer.cs are important for dealing with moving items from my store container.
Your problem was that you have items but no way to interact with them. This module presents a sample of how to do that. However, ordinarily I'd separate the store portion and an item "database" into their own modules and use some sort of tag system to identify the objects. This would separate the inventory representation of the items from the game attributes of the items - less data to pass around just for shopping.
#5
05/24/2013 (4:36 pm)
Thanks a lot! I'm sure it will help.
#6
05/25/2013 (12:04 am)
I've cleaned up all unused script files in there, so update and clean up to get a clearer view of what I was doing.
Orion the Hunter
Fritterflames