Skip to content
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

Merged
merged 3 commits into from
Oct 30, 2024

Conversation

OvercastInteractive
Copy link
Collaborator

@OvercastInteractive OvercastInteractive commented Oct 25, 2024

  • Added a vending machine scene, which utilizes the existing cogito_button and CurrencyCheck
  • 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 without the pressed() signal ever being sent because they were handled independently. In short, the transaction only goes through once cogito_button.gd press() is actually called
  • I also use a saved variable called is_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.

- 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)
Copy link
Contributor

@BrodyB BrodyB left a 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!
@OvercastInteractive
Copy link
Collaborator Author

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.

Copy link
Contributor

@BrodyB BrodyB left a 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!

Copy link
Owner

@Phazorknight Phazorknight left a 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!

@Phazorknight Phazorknight merged commit a5180c5 into main Oct 30, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants