Data Juggler
|
Data Juggler
Posted 4 Years Ago
|
Group: Forum Members
Last Active: 2 days ago
Posts: 1.7K,
Visits: 5.4K
|
What I came up with works: current_time = RLPy.RGlobal.GetTime() current_frame = RLPy.RTime.GetFrameIndex(current_time, fps) # Position of the playhead RLPy.RGlobal.Play(RLPy.RTime(current_time), RLPy.RTime(delta_time)) RLPy.RGlobal.Stop()Is this the best method to refresh? If there is a simpler way I would like to learn it.I have a second weird issue if anyone knows any tips that might help solve it.I created my first UI widget:Everything works, but the weird thing is I call the same method for Scramble and Unscramble each stack of chips, but I pass in a parameter for Reset = True or False. Here is one method for Red Chips:def ScrambleRedChips(reset = False): # Red Chips # sum = 0 n = 82 propName = "RedChip" chipName = "" for counter in range(2, n+1): if (counter != 51): chipName = propName + str(counter) print ("attempting to rotate " + chipName) RotateChip(chipName, reset) sum += 1 # show a message # if (reset): print("Reset " + str(sum) + " Red Chips."); text_edit.insertPlainText("Red Chips Unscrambled: " + str(sum) + "\r\n") else: print("Rotated " + str(sum) + " Red Chips."); text_edit.insertPlainText("Red Chips Scrambled: " + str(sum) + "\r\n") text_edit.update() # return value # return sumThe only problem is, the progress bar and items refreshed list updates for the reset = true (Unscramble), but for the Scramble it only resets after 25%.The rest wait until everything finishes to refresh. The other weird issue is, if i call Scramble, Unscramble, and then Scramble again, it works the 3rd time.
So something the first time causes it to not update. It's the same code except that scramble creates a random number, so a bit more math is involved, but calling 300 methods shouldn't be that much:
# create a random value - this worked out to be more random than using randint(-30, 30) is why I did it this way # rotationValue = random.randint(101771, 124193) % 59 - 29 Below is the full RotateChip method. def RotateChip(chipName, reset = False): #-- Loop through props --#prop prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, chipName) #-- Get Transform Control and Data --# ts_control = prop.GetControl("Transform") ts_data_block = ts_control.GetDataBlock() rotationValue = 0 if (reset): # set rotation value to 0 # rotationValue = 0 else: # create a random value # rotationValue = random.randint(101771, 124193) % 59 - 29 print(rotationValue) #-- Set Rotation Z = by a random amount ts_data_block.SetData("Rotation/RotationZ", RLPy.RTime(0), RLPy.RVariant(rotationValue * RLPy.RMath.CONST_DEG_TO_RAD)) I am baffled as to what works one way, and doesn't work the other. Your Prime Number progress bar doesn't have this problem, so the calling to IClone must cause the system to be busy. I tried putting some pauses, but from what I read widget.update() only schedules an item to be repainted, it doesn't actually repaint. Calling widget.repaint didn't work either, although not recommended I wanted to rule that out before I posted.Has anyone else had any problems getting a progress bar to refresh? It isn't the end of the world if the user has this problem if not seeing any progress between 25% and done, but I would sure like to fix this if I can before releasing this.In case anyone wants to look at the entire file, here it is:https://github.com/DataJuggler/PythonScripts/blob/main/Poker%20Room%20Python%20Widget.pyThank you for any help on best ways to update.
Creator of the free website: PixelDatabase.Net A Free Online Text Based Image Editor
Edited
4 Years Ago by
Data Juggler
|