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.
Superglass Make
- Ceikry
- Site Admin
- Posts: 591
- Joined: Wed Aug 10, 2022 11:48 pm
- Location: Draynor Village
- Has thanked: 84 times
- Been thanked: 109 times
Re: Superglass Make
you could post your codebushtail 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.
Nerds
- ryannathans
- Staff
- Posts: 501
- Joined: Thu Aug 11, 2022 12:25 am
- Location: ɐᴉlɐɹʇsn∀
- Has thanked: 40 times
- Been thanked: 97 times
- bushtail
- Tech Support
- Posts: 40
- Joined: Thu Aug 11, 2022 11:43 pm
- Location: Snow Mexico
- Been thanked: 4 times
- Contact: