Need help creating my own krist store software.

Started by MonkeyButt, Aug 09, 2020, 01:51 AM

Previous topic - Next topic
I wrote a gui but I don't know how to use touch events for my gui especially since I want it to be dynamic and scalable; interact and manage the storage as well as manage and make transactions.

Most people on switchcraft are too busy to tell me more than "use os.pullEvent()", "use chest.list()", and "use websockets" that tells me nothing.

How do I actually access, read from, sort pull items from chests that the user specified?  How do I listen for touch events on a dynamic gui where I can add a new category; scalable gui is not necessary to me, it's something I can add at the very end.  How does the turtle recognize somebody made a transaction, how does it refund an overpay, how does it deny a transaction to an item that is out of stock or not sold?  Etc.

I already made a gui and have a categories tab that will add any new category you put in the txt file.  But I don't have drawing a main page added where I display a home page with items and can display a page of one item with a description.  This is another thing I'm a bit hard trying to figure out.

Summary:  I mainly just need help understanding how to interact and manage the inventory for a krist store as well as managing and logging transactions.

Thank you.

Lupus590

It sounds like you need to break your problem down into many smaller more manageable problems. Given the scope of the program using a GUI API could be useful. I would also suggest checking the wiki when you get stuck if you aren't in the habit already.

A side note, you are more likely to find GUI APIs on the old forum (see the link above), the program/API selection on this forum is comparatively limited. Oh and don't bother trying to sign up to them, the reason this forum was made is because the old one's signup is broken.

#2
I want to know how stores interact with the inventory using plethora and turtle api as well as managing krist transactions.

Lupus590

Well, that's probably purely plethora stuff, you can find the relevant documentation here: https://squiddev-cc.github.io/plethora/methods.html#targeted-methods-net.minecraftforge.items.IItemHandler

The turtle probably does very little. As for Krist, it has its own web API and, I assume, documentation somewhere so you will have to google for that yourself (or see if someone else can tell you, maybe you could ask on the discord?)

You might also want to look at other people programs as inspiration on how they solved the same problems, this is one of the advantages of open-source software, just check the license and give credit where you need to.

I've read both documentations but it doesn't tell me how I can use it to build a shop.  I need to know how to use the tools I'm working with because I already know about the tools.


As for other shop programs, I've read a few, the comments don't provide insight and the variable names are cryptic.

Lupus590

No documentation is going to tell you how to solve a problem as specific as making a shop. You need to break down the problem into smaller ones. Read the tutorial that I linked to you in my first reply if you haven't yet. It will teach you techniques to help you to break your shop down into more generalised problems, like how to move items around (plethora's documentation that I linked should be a good start on that) and using the Krist web API.

Yes I said the docs don't teach me how to make a shop which is why I ask here.  I already know how to decomp as well.  I just don't know how to construct a shop program I've never done it before.

Lupus590

I don't know how to help you without breaking down the problem for you or writing the program for you.

Is there a specific part of your shop program that you are currently stuck on? Looking at this might help you explain it well which will help you get effective help.

Right now I'm stuck on how to make a section of my screen change based on what category has been selected and how to listen for the touch event without the program crashing because it didn't yield.

If someone right clicks an area of the screen like a "button" then the page would display different contents based on that category and the rest of the screen will stay the same.  A real life example is Wojbie's enchantment shop.  Unfortunately he aint on much and I've tried pinging him about it.  He probably gets the metadata and displays it but I'm wanting to get metadata of multiple items and display them on tiles.

I think what's hard for me is I can't make classes; it would be so easy to do this if I could make classes but lua doesn't have a class system else I'd just make a tile class and create new tiles which already know what they information they have so I don't need to get messy trying to display their metadata per tile.

I may just scrap my idea and instead display all items on one page and make the categories tab a pages tab.

Lupus590

The way I would do multiple pages is to have multiple windows using the window API and hiding them and showing them as different pages are picked. You could also have pages as different draw functions, preferably where they overwrite a shared draw function so that the update frame code just has to worry about one function and not figuring out which draw to call. As for detecting buttons, you want to listen for click or touch events (depending on using a screen or a monitor) and test whether they are within a bound of your button and then call its callback function. You might want to try touchpoint if your own code is too annoying to use.

As for getting item metadata, the docs for plethora that I linked to you detail that. Also, you can kinda do objects in Lua via the prototype method. Some people have made class systems too, but I always find the syntax out of place.