I was needing some help I’m looking in multiple places and not finding any info on how to use the event graph… what I want to do is when an object is placed in itemA’s inventory, check does object match itemQ if so get the count of how many was added to the inventory and then use the itemquantity value multiplied by the count and create that many itemz and delete all of the itemQ. I’m trying to get away from blueprint crafting because no matter what I do it’s locking up clients for full minutes if not longer most give up and restart so I want to take all the crafts out of my mod and just do a little math and create the item with a quantity.
it would work best if I can actually fire it on the item added and not recheck all items in the shop everytime but I’ll figure something out if someone could show me how to fire the event on inventory change and how to create an item using events?
P.S. I want this scenario if it helps
I put 5 wood in a craft station… event fires says inventory has changed finds what was added “match wood to wood” once it finds a match see that 5 was put in delete all 5 and use blueprint for “woodcopy” find the “item quantity” variable in that blue print and then multiply 5 * itemquantity. Then create item Q with this new quantity (5 * itemquantity).
and when I put in 5 thatch same exact thing… creating 5*itemquantity(of “thatchcopy”) of item Q again and because they both create the same item they should stack.
I’m making a shop and the item Q is the currency I’ll be using the problem is the craft method I’ve been using just cause huge lag (autocrafting) and I need this to stop locking up the clients. thinking if I can use 1 event fired when inventory changes and then find the item it matches and then fire an event based on the match … it wouldn’t keep locking up because to many were changing
EDIT: most of this I have figured out finally … I just can’t get an event to fire…I’d love to fire it (onactivate) but that doesn’t seem to be an option
Isn’t there something like this in like the refiner? You put in oil and hide and get gas. If this is the method that is causing lag you might have to put a delay in so that it doesn’t just spam a bunch of cycles. Maybe it makes that 1 wood every 2 seconds or something would work?
Even so it could meet your needs. You could give everyone some engram in start that used your “trade store” structure aka a renamed fabricator.
Turn it on and it converts xyz ingredients into the blueprint they select.
I was actually thinking about using this exact approach, but instead of getting “trade” engrams I wanted people to learn them when they retrieved an artifact.
I have it in place already and it works but it is locking clients up for full minutes (game not responding happens) but I’ll try the delay on it that might help
yea, seems like the engine isnt treating it as its own threadable object and when it gets into a big loop it locks everything up till its loop is done instead of processing along side everything else.
Anyone know how to do this the way i was asking though I want to get away from the blueprint method because it’s either slow (delays added) or it locks up because it tries to do too much.
The delay fixed it the issue is the tick check true but it was because when they are all set to auto craft they all craft at same time and they don’t que up like when you craft stuff manually, I was just hoping for a way to count how many there is and just make the item directly instead of crafting them in small stacks because the shop I’m working isn’t supposed to actually be crafting it’s supposed to be buying and selling. So when you throw in 3 stacks of 100 wood I’d like it to just count 100 multiply by price and give the money instead of crafting in sets of 10 or 20 or whatever I choose and then crafting into smaller bits it would be much better if I could just take the quantity and create the new quantity without the craft step period but I’m not finding a way to do that with this toolkit
Auto-crafted recipes work almost like manual ones, except they are triggered as soon as the required materials are present and the structure is turned on. If you want your structure to work w/o needing power or fuel, just set “activation requires power” to false, leave the “active requires fuel item” blank and set “can toggle activation” to true. It will have an option to turn on and off (you can call it trade and stop trade) w/o requiring anything. You could not set the ability to toggle activation and instead set “auto-activate” to true, to have the structure go active upon placement and never turn off, but it might increase CPU load a little (insignificantly per object, but it could add up on a server).
Auto-crafted recipes work in parallel, but only one item per entry in the default engrams. That’s why a campfire will only cook one piece of meat at a time, regardless of how many stacks are inside it, and why a grill will cook many pieces at once even with a single raw stack (because its “default inventory items” lists cooked meat many times in a row).
To set up buying, create child items for the items you want to be buy-able. You can set their cost by editing the recipe to be X of your currency and the “item quantity”, which controls how many items are returned per crafting operation (in this case, per trade). As child items, they will be eligible in any recipes that use their parent materials (like chitin and keratin are child to a hidden “ChitinOrKeratin” item which you see in most recipes, but some recipes require chitin specifically and neither keratin nor their parent will work).
The problem is selling.
One solution would be to set up a fuel burner structure and make it use items you want to be sell-able as fuel for a very short time, returning your currency (just like wood is converted to charcoal). Unfortunately, it will only return one item per unit of “fuel”, so if you want to exchange (for example) 1 polymer for 5 coins, you’ll have to create a separate “5 coins” item and make it convertible to your basic coin item via another recipe.
Another solution would be to once again use auto-craft recipes. Create a child currency item for each item you want to be sell-able and adjust their recipes and “item quantity”.
If you set the crafting/burning time of each of these recipes to 0.1, it will be very fast without overloading your computer with checks or crafting ticks.
This is a roundabout solution, but I feel like it will work better with the current state of things.
Using a delay node before tasks is actually a very good practice to get into. Even if its just a 100ms delay, it’s going to help with performance in blueprints before most actions (especially loops & related tasks). This was a little trick I picked up from a YouTube tutorial on blueprinting in UE4 months ago, and have used since then. I highly suggest making full use of delay nodes where you can as it really does make a big difference ESPECIALLY with Event Tick
It’s not hidden. Take a look under “Fuel Consumption” when searching the BP
This is also a very good way to handle it to avoid lockups in my opinion. Would be a good work around if you don’t want to use delay nodes (I still suggest you do)
Ok, thank you. I have added a 1 sec delay and a 1 sec craft time so now it isn’t stacking over and over causing the client to lag lock for full minutes I’ve changed them all to 1sec and it’s being tested now… the only issue is large sells will now take a really long time so I was hoping to use events to multiply the number in shop by the number it crafts to do 1 time craft instead of a loop craft but as I haven’t been able find a event to trigger on item added, I’ll just have to live with the slow craft method at least it is working now. Thank you all for your help
I did all of this, didn’t have fuel cost because it’s a shop that would be silly. but I did the child currency also the issue I ran into is child won’t stack with main so if I sold wood/thatch they were two separate child objects and though they both could be used to buy stuff they wouldn’t stack… which in turn meant everything I sell would be a different stack (not good). so I made a craft of a currency that used the newly created sell item and it’s children and made 1 new currency.
basically this is what I did:
masterblack - everything that didn’t sell for a full gold was a child of this.
mastergold - everything that sold for gold was a child of this.
GOLD - crafted from 1 mastergold(so all child would be used also)
BLACK - crafted from 1 masterblack(and all it’s children)
But then I had to make blacks become gold … so
100 black is crafted into a child of mastergold
and to save some time I made 100 masterblack(and children) become 1 master gold (this would skip the black convert and then gold).
Unfortunately this makes a lot of conversions that seem pointless but there wasn’t a way to have Children stack with master so would make litterally 128 separate piles of “gold” pearls that wouldn’t stack. So I was trying to find a solution to create the items using programming instead of crafting so I could avoid the extra steps needed to make everything stack correctly, at first I tried spoiling the item but that made lag even worse. The mod I’m working on is called shopping mod.
and though it’s working great I would love to be able to clean it up so that it works more efficient while still being able to sell small and large quantities of things without lagging out the clients.
I have no experience with graphs, so forgive me if I’m talking nonsense.
Would it be possible to trigger an event upon pressing a UI button? Once triggered, the game would look up all possible trades and execute them. Instead of using crafting, it would replace item X with N “coins” (and do this for all items). Prices could be listed in a custom note (or a few). This would work for selling, at least. If the UI button in question is the structure activation, it would also help to automatically deactivate it after.
You really have to use recipes for buying though, as that is the only way to let the game know which items you want. To fix the non-stacking, you could set all the child items to spoil into their parent after like 1 second (maybe even less) using the basic item parameters. It would solve the problem automatically and using a system that the game handles fine.
You don’t have to use a 1 second delay, since for your case it’s not very convenient/efficient, so you should compromise in my opinion and go with 0.5 second delay or even a little less.
Glad to be of service with the advice
Yes, but because those are all mapped and used already, I could see unwanted conflicts occurring via this method
yes this is what I’m wanting to do; wood is worth 5 black pearls… you put in 100 wood give you 500 black pearls … done no craft 1 at a time no reconverting
Everything is working with the delays, no lag above the games normal lag (if I removed the mod I get this lag so I know it’s not my mod). Large groups of things take a long time to sell but without a way to just count the avail items of type “x” and if you get 5 for each x then multiplying 5x to make that many Y items I guess this method will have to do. Thank everyone for the help the mod is almost complete not happy with the way I had to do the buy/sell but at least it works