Kramnik Posted January 11, 2020 Share Posted January 11, 2020 Hi, I have trouble thinking of way to track script progress for one of scripts I am working on. The trouble is doesn't have simple way of tracking progress like checking chat message to do ++itemsMade as it is very variable. So let's say I am killing monsters and they drop coins (5-500) amount, So whenever I pick up some coins they add to total amount picked. Can't just simple use getInventory.getAmount("Coins") since it will be using them later or banking. At this stage would be good to know how to track whole progress of this item gained. Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted January 11, 2020 Share Posted January 11, 2020 (edited) To retrieve how much coins you have picked up you would first set a temp variable to hold the old coin amount and than once you have picked up the coins you would just simply subtract the current amount of coins in your inventory with the old amount. IE. 100 coins in inventory before picking up the coins on the ground. 200 coins after picking up coins. 200 - 100 = 100 coins were picked up. Or you could get the ground item amount than add that amount to your variable. You would still need to make sure you picked it up before adding that value though. Edited January 11, 2020 by BravoTaco Quote Link to comment Share on other sites More sharing options...
Kramnik Posted January 11, 2020 Author Share Posted January 11, 2020 2 minutes ago, BravoTaco said: To retrieve how much coins you have picked up you would first set a temp variable to hold the old coin amount and than once you have picked up the coins you would just simply subtract the current amount of coins in your inventory with the old amount. I fail to understand how to script these So I have temp viriable as int oldCoin and then after looting I have newCoin, then I just calculate int coinChange = newCoin - oldCoin. But how do I keep track of all these gains? I guess I would need some private int but how to I add coinChange to it to make it cumulative after every loop? Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted January 11, 2020 Share Posted January 11, 2020 (edited) First declare the variable coinChange as a private or public field depending on how you are using it. Than in your script before you go to pick up the coins you set a local temp variable as the current amount of coins in your inventory this will be the old amount. Than once you have picked up the coins you would than take the current amount of coins in the inventory and subtract that from the old amount. Than add that to the coinChange variable. I can write up a code example if you need Edited January 11, 2020 by BravoTaco Quote Link to comment Share on other sites More sharing options...
FuryShark Posted January 11, 2020 Share Posted January 11, 2020 1 hour ago, BravoTaco said: Or you could get the ground item amount than add that amount to your variable. You would still need to make sure you picked it up before adding that value though. Id pick it up first since ground item amount cant go above 65535 Quote Link to comment Share on other sites More sharing options...
IR0N Posted January 12, 2020 Share Posted January 12, 2020 I just need to test my signature. Quote Link to comment Share on other sites More sharing options...
theanimals Posted January 12, 2020 Share Posted January 12, 2020 (edited) onstart note starting coins/whatever else you are picking up every time you bank take note of what you deposit (or withdraw if you need coins for some other reason) at the end just do current + total banked - start = gain, you can update this every time you bank for an overlay OR same deal onstart check what you have, every time you take something update total picked up = total - starting amount for your overlay Edited January 12, 2020 by theanimals Quote Link to comment Share on other sites More sharing options...
Kramnik Posted January 12, 2020 Author Share Posted January 12, 2020 (edited) 7 hours ago, BravoTaco said: First declare the variable coinChange as a private or public field depending on how you are using it. Than in your script before you go to pick up the coins you set a local temp variable as the current amount of coins in your inventory this will be the old amount. Than once you have picked up the coins you would than take the current amount of coins in the inventory and subtract that from the old amount. Than add that to the coinChange variable. I can write up a code example if you need I understand everything besides how to add to coinChange This is because of my lack of java knowledge. Only know how to calculate integer valuables by creating new variable like: int coinsLooted = oldCoin - newCoin; or add 1 value by coinsLooted++; Trying to google how to do it but until now no luck 21 minutes ago, theanimals said: onstart note starting coins/whatever else you are picking up every time you bank take note of what you deposit (or withdraw if you need coins for some other reason) at the end just do current + total banked - start = gain, you can update this every time you bank for an overlay OR same deal onstart check what you have, every time you take something update total picked up = total - starting amount for your overlay @theanimals Can't seem to be able to use onStart int in the loop it self for calculations Edited January 12, 2020 by Kramnik Quote Link to comment Share on other sites More sharing options...
MasonStorm Posted January 12, 2020 Share Posted January 12, 2020 13 hours ago, Kramnik said: @theanimals Can't seem to be able to use onStart int in the loop it self for calculations I put my variables outside of onLoop and not in onStart. Haven't ran into any issues with that. Why not do oldCoins - newCoins = coinChange, and when banking/using do oldCoins = coinChange, so you don't mess it up after you've banked? I hope I haven't misunderstood the question here. Quote Link to comment Share on other sites More sharing options...
theanimals Posted January 12, 2020 Share Posted January 12, 2020 private int startingGP; private int displayedGain; onstart -> startingGP = get coins from inv; displayedGain = 0; onloop -> pickupcoins(); pickupcoins -> take; displayedGain = get coins from inv - startingGP; Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted January 12, 2020 Share Posted January 12, 2020 (edited) 16 hours ago, Kramnik said: I understand everything besides how to add to coinChange This is because of my lack of java knowledge. Only know how to calculate integer valuables by creating new variable like: int coinsLooted = oldCoin - newCoin; or add 1 value by coinsLooted++; Trying to google how to do it but until now no luck @theanimals Can't seem to be able to use onStart int in the loop it self for calculations There are different types of variables. Main ones in java I think are class variables, local variables, and instance variables. Local variables - These are created inside of a method and are destroyed once the method that contains it has been exited. Instance variables - These are declared outside of any method and will hold the value assigned unto it until the program has finished executing or until you assign a different value to it. Methods inside of the class can reference this variable and other classes can as well, as long as, the variable is set to public or you have Getters and Setters. Class variables - These are very similar to Instance variables, except they are declared static. Having this type of variable means that there will only ever be one version of it. And to access this variable you have to call the class name than the variable or a method that returns the variable. Code Example: public class Driver { private static String string = "Example String"; // This is an example of a Class variable. private int amountOfCoins; // This is an example of a Instance variable, Not setting a value will set it to its default which is 0. public static void main(String... args) { // In order to access the amountOfCoins I will have to create a new object from the class that contains it. Driver driver = new Driver(); // Creating of the class and setting it to a local variable. // To modify or retrieve the value of amountOfCoins in a different class I would have to use Getters and Setters since it is declared private, // but since I am trying to use it in the same class I can access it directly regardless if it is public or not. // To access the variable I will first call the local variable that I created than call the amountOfCoins variable. System.out.println(driver.amountOfCoins); // To change the amountOfCoins variables I do the same thing except set it equal to a different value or do some math with it. driver.amountOfCoins = 1_000; // Setting the amount of coins to equal 1000. System.out.println(driver.amountOfCoins); driver.amountOfCoins += 1_231; // Adding 1231 to the amountOfCoins. System.out.println(driver.amountOfCoins); // To access the Class variable you would have to call the class directly followed by the Getter or the Setter method if you are using it outside the class. // Since I am in the same class, I can just call it. System.out.println(string); string = "New String"; // Setting the string to equal "New String" System.out.println(string); } } Edited January 12, 2020 by BravoTaco Quote Link to comment Share on other sites More sharing options...