MachineAIExp 0 Share Posted May 22, 2020 Hey all! I am wondering how to access the string values of a widget as an integer. Suppose I have the following code: String upper = getWidgets().getWidgetChild(383,3,11).getText(); String lower = getWidgets().getWidgetChild(383,3,5).getText(); String upperv = upper.replace("coins", ""); String lowerv = lower.replace("coins", ""); int uppervalue = Integer.parseInt(upperv); log(Integer.toString(uppervalue)); int lowervalue = Integer.parseInt(lowerv); int margin = uppervalue - lowervalue; WidgetChild lowest = getWidgets().getWidget(383).getChild(3).getChild(5); if (lowest != null && margin > 2) { lowest.interact(); sleep(Calculations.random(3000, 4000)); WidgetChild limit = getWidgets().getWidget(465).getChild(24).getChild(49); if (limit != null) { limit.interact(); getKeyboard().type(Integer.toString(GElim)); sleep(Calculations.random(1000, 1500)); } Here I try to calculate the margin of an item by taking the widget values of the upper and lower limit. I try to convert the strings into an integer and then substract them to have the margin. I then use this margin to set an if-statement, but when I am running this code, it breaks on the string conversion part, so anyone has an idea?? Really appreciate any help! Link to comment Share on other sites More sharing options...
Pseudo 179 Share Posted May 22, 2020 You'll want to read up on regular expression (regex), it can be used to eliminate certain characters from a character string to parse the data as you so wish. Link to comment Share on other sites More sharing options...
NovaGTX 106 Share Posted May 23, 2020 Integer.ParseInt Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.