Quantcast
Channel: Answers for "Making a Market Script"
Viewing all articles
Browse latest Browse all 8

Answer by Siegeon

$
0
0

There is no easy answer for this question because you are not very clear on what your environment looks like.Do you already store the items, are there already scripts for the player or the store keeper, have you modified the GUI system at all, are you using a database, ect. If you want a very specific answer to this question you need to provide more information on what we are working with. Since you asked the question in a general way I will answer it general way.

First "I need a way to set it up so that items can be added and viewed in the inspector"

Like you mentioned the best way to achieve this part is a public list, lets put this list in the store keepers script.

public List<string> listedItems;

The best bet for dealing with the individual items would be to store them in a database along side their value, level, and other unique attributes. Setting up that database is a topic for another time, but for this discussion lets assume you already have a way to store items and their levels.

The next part would be to build the list for the menu, so when the store keeper is clicked he could ask the player he is, lets assume you have a basic get set on the player for his level.

playersLevel = player.PlayersLevel()

And now that we have the players level we can build the list, I would add the name of the items to our public list listItems (allowing us to see the menu items in the inspector). And finally make the list in the GUI.

Borrowing some code from Bobadebob

EDIT i cant seem to make the code tags work, but you can use the code Bobadebob posted, but I would foreach though the string list, and match the items with the ones in your data base.

Really I would like to address this question with a more honest/direct answer but I need better details from you. Good luck.


Viewing all articles
Browse latest Browse all 8

Latest Images

Trending Articles





Latest Images