-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial attempt at a basic vending machine, located in the breakroom #322
Conversation
- Added a vending machine scene, which uses a cogito button and the currency check - Added cogito_vendor.gd which handles spawning, manages its own inventory and provides interaction hints - I moved some code in cogito_button.gd from interact() to press() which is both more appropriate and prevents a bug in which I would be charged for a transaction, but the press() signal would never go through because the transaction was invalid
- Limiting spawn delay to always be less than the button press cooldown time prevents any issues in which the wrong number of items is spawned (due to spamming the vending machine button)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking solid!
However, I do notice a soft error on picking up a health potion with this update. This is because the 2D health potion sprite auto-converts to a 3D texture at runtime because it's being used on a 3D Sprite node in the vending machine scene.
I have a fix for that on my own version of vending-machine
, which I can push if I have change permissions (I removed the sprite and made a jokey soda brand with text), or you can do a similar change.
It's a very minor thing, but probably best not to introduce any errors at all.
- Duplicated the health potion texture and assigned the duplicate to the vending machine's Sprite3D to avoid auto-converting the health potion item icon to the wrong format. Thanks to @BrodyB for spotting this!
Hey thanks @BrodyB! I couldn't figure out how to grant you change permissions 😖 so I went ahead and made the changes. Let me know if you spot anything wrong with it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work, thanks so much for this!
cogito_button
andCurrencyCheck
cogito_vendor.gd
which handles spawning, manages its own inventory and provides interaction hintsinteract()
topress()
which is both more appropriate and prevents a bug in which I would be charged for a transaction without thepressed()
signal ever being sent because they were handled independently. In short, the transaction only goes through oncecogito_button.gd press()
is actually calledis_dispensing
which allows the player to save the game while dispensing of the object is running a timed delay. This means when loading the game, any items that hadn't yet been dispensed (saving and quitting prior to dispensing the item) will still be dispensed.