Page 1 of 1

Superglass Make

Posted: Sun Aug 28, 2022 12:21 am
by bushtail
So I know the issue I'm facing - there's no cool-down so a player can keep spamming the spell, removing their runes but adding experience. I know I somehow have to make sure that the game knows two things before it even does anything:

1. Ensure the player has enough valid materials in their inventory
2. Ensure the player has enough runes

However both of these checks must happen either at the same time or both have to return true in order for the spell to do anything.

The way I'm thinking of doing it is by having a count variable that keeps track of whether or not everything's taken care of, and putting it in the for(item in inv) block. Something like IF count of valid removes EQUALS size (the result of determining which is the lower of the two variables, one for sand and one for the amount of weed in the player's inventory), removeRunes and add XP.

The result of this I'm not sure the impact of - an edge case where it takes all the items without removing any runes or adding any xp (or heaven forbid it takes the runes too), so I'm hoping on some insight as to whether or not there's a "smarter" way of doing things efficiency-wise.

Re: Superglass Make

Posted: Sun Aug 28, 2022 1:16 pm
by Ceikry
bushtail wrote: Sun Aug 28, 2022 12:21 am So I know the issue I'm facing - there's no cool-down so a player can keep spamming the spell, removing their runes but adding experience. I know I somehow have to make sure that the game knows two things before it even does anything:

1. Ensure the player has enough valid materials in their inventory
2. Ensure the player has enough runes

However both of these checks must happen either at the same time or both have to return true in order for the spell to do anything.

The way I'm thinking of doing it is by having a count variable that keeps track of whether or not everything's taken care of, and putting it in the for(item in inv) block. Something like IF count of valid removes EQUALS size (the result of determining which is the lower of the two variables, one for sand and one for the amount of weed in the player's inventory), removeRunes and add XP.

The result of this I'm not sure the impact of - an edge case where it takes all the items without removing any runes or adding any xp (or heaven forbid it takes the runes too), so I'm hoping on some insight as to whether or not there's a "smarter" way of doing things efficiency-wise.
you could post your code

Re: Superglass Make

Posted: Sun Aug 28, 2022 1:27 pm
by ryannathans

Re: Superglass Make

Posted: Sun Aug 28, 2022 6:39 pm
by bushtail
thank you ryan