I have the following code that I am not able to test very well due to the testing window being so short. It is for an iPhone autotouch script that will scan a coordinate for a color and tap when the color changes to black. I added a second component to the script which functions similarly, it detects a color on the screen then taps on a specified coordinate. Is the code formatted in a way where when the first color is detected and the tap occurs, the code advances to the second portion of the code?
colorone is the variable for the first page, and colortwo is the variable for the second page (the page displayed after the first colorone button is tapped).
Thank you in advance
local colorone = getColor(165, 1566)
local colortwo = getColor(652, 2301)
repeat
colortwo = getColor(652, 2301)
until( colortwo == 0 )
tap(652, 2301);
repeat
colorone = getColor(165, 1566)
until( colorone == 0 )
tap(920, 1688);
Related
I'm a scripting newbie and I'm trying to make a button that when you click it disappears I have a local script as the child of a text button, this is the code I'm using.
local button = script.Parent
local function onButtonActivated()
print("Button activated!")
game.StarterGui.ScreenGui.TextButton.Transparency = 1
end
How do I make it so that the computer does the function when the button is clicked?
Check out the docs for TextButtons.
You simply need to connect your code to the Activated signal of the button.
button.Activated:Connect(onButtonActivated)
On a separate note, there's an issue with your function as well. You are modifying the button template that is in StarterGui, not the one that the player sees. UI elements are copied from StarterGui into each player's PlayerGui when the Player spawns.
To access the actual button you are trying to turn invisible, you can use relative paths, like how you defined the button variable, or give the full path to the button.
local button = script.Parent
local function onButtonActivated()
button.Transparency = 1
-- or
local player = game.Players.LocalPlayer
local btn = player.PlayerGui.ScreenGui.TextButton
btn.Transparency = 1
end
button.Activated:Connect(onButtonActivated)
There are a few ways to check if a button is clicked.
The main way is UIButton.Activated. It works the exact same as MouseButton1Click.
Something around the lines of:
button.Activated:Connect(onButtonActivated);
If this helped, you should accept either my answer or Kylaaa's answer.
try this
first make all the onButtonActivated
then instead of transperency use:
button.Visible = false
it works for me
Working on a desktop application and having a probably silly problem that's still managing to driving me mad.
I have a listbox that gets its rows from a dynamic source.
I'm trying to change the forecolor of specific cells in the control if the underlying data for that cell changes to specific conditions.
The control also gets drawn once before the condition starts being checked,meaning every cells starts painted with the same (white) forecolor.
Also, this listbox sits inside a Canvas, and that Canvas is in turn inside a Window control.
This code checks for the condition vs. all the rows in the listbox:
for each dict as Dictionary in WidgetsDictionary
Dim site as String = dict.Value("Site").StringValue
Dim device as String = dict.Value("Device").StringValue
Dim sensor as String = dict.Value("Sensor").StringValue
for intC as integer = 0 to actualLstBox.ListCount
Dim siteComp as String = actualLstBox.Cell(intC,4)
Dim deviceComp as String = actualLstBox.Cell(intC,0)
Dim sensorComp as String = actualLstBox.Cell(intC,1)
if actualLstBox.Cell(intC,4) = site AND
actualLstBox.Cell(intC,1) = sensor AND
actualLstBox.Cell(intC,0) = device then
actualLstBox.CellTag(intC,2) = RGB(255, 192, 203)
exit For
end
next
next
Where WidgetsDictionary contains the conditions I need to check against.
And that works,if i check the CellTags after it runs I find them set correctly where they are supposed to be.
Now,if after that code i call
actualLstBox.Refresh()
Note: I know Refresh isn't optimal but I need it to fire as soon as possible
I see the code jumping to the CellBackgroundPaint event of the ListBox
There I have this
If (row<me.ListCount ) then
If Me.CellTag(row, column ) <>nil Then
g.ForeColor = me.CellTag(row,column)
g.FillRect(0, 0, g.Width, g.Height)
End If
end
And again, I see this code executing correctly.
So, I'd expect the list to be redrawn with the correct cells in the new color.
But nothing changes, I see the CellBackgroundPaint event fire after every refresh but the end result shown is always the default (white) colored cells.
I've tried calling, in order
InvalidateCell on the specific cell
Invalidate on the whole Listbox instead of Refresh (since you never know)
Refresh on the containing Canvas
After the first block of code,to no avail.
So now I'm at a loss on what to try next.
Edit
If i replace the event handler with
If (row mod 2) = 0 Then
g.ForeColor = RGB(232,235,255)
g.FillRect 0, 0, g.Width, g.Height
End If
if column = 2 then
g.ForeColor = RGB(255,253,208)
g.FillRect 0, 0, g.Width, g.Height
end
I get alternating colors for the rows and the whole 3rd column of a different colour.
So I guess the fact that I'm trying to repaint it after the first time it's shown is where the problem lies.
You need to return true from the handler in order to tell Xojo that you already have do e the painting. Otherwise Xojo will do its own FillRect after yours.
Keep in mind that this will also override the selection coloring. Meaning that if the row is selected, your cell won't show that unless you either return false in that case or draw your own special bg color for that case.
Also, what you are talking about is the background color, not foreground color, it seems to me. You could perhaps update your question title accordingly.
My App Basically has a start screen where the user enters how many exercise reps they want to do. I use this as my max variable, and then I have a button which activates a counter mechanism which adds up to max value. When it equals max value, the UI resets and I am meant to get back to Screen 1.
I have been working this problem for over an hour and I can't figure out why my button doesn't reappear when the clicker value = user input(max value).
I have coded it to do so in
ButtonScreen1.hidden = false
UserInputScreen1.hidden = false
LabelScreen1.hidden = false
But the Button won't reappear. But it appears at the start, so it's not a view controller issue to my knowledge.
Images (Top One Is Without Button which Should be Present at the End of the Application) (Bottom One is What It Looks like as it Starts which I am trying to replicate at the End)
For Full Code
I have a simple custom cursor code that loads a cursor from my Content folder to a Texutre2D, and then simply draws it on Draw. How can I program the image to change when I hold right click and then switch back to default when I release right click?
You have to load both your textures in two Texture2D variables, then simply check in your Update the state of the right button.
if (mouse.RightButton == ButtonState.Pressed)
cursorTexture = pressedTexture;
else
cursorTexture = releasedTexture;
Of course, cursorTexture is the one you have to draw.
I have a flash file where the first frame contains two buttons, one of which takes the user to the second frame, and the other takes them to the third frame. At each of those frames, various text fields and variables can be manipulated via SimpleButtons. Both Frame 2 and Frame 3 have "back" buttons to take them back to Frame 1.
Currently when the user navigates back to Frame 1 for the second time (thus playing it for a third time), my second button appears to no longer exist, and I receive an error. Both buttons on Frame 1 were placed via the Flash IDE. Why is my button popping out of existence, when it did perfectly fine the previous two times? Below is my code for Frame 1. The "back" buttons simple remove event listeners and then call gotoAndStop(1)
var inited:Boolean;
var cache:SharedObject;
var libsans:Font = new libsansreg();
this.addEventListener(Event.ENTER_FRAME, frameEnter);
stats.addEventListener(MouseEvent.CLICK, statsclicked);
modules.addEventListener(MouseEvent.CLICK, modsclicked);
function initcache():void
{
this.cache = SharedObject.getLocal("RPG_Shooter")
}
function frameEnter(e:Event):void
{
if (!inited)
{
inited = true
initcache()
this.gotoAndStop(1)
}
}
function statsclicked(e:MouseEvent):void
{
this.removeEventListener(Event.ENTER_FRAME, frameEnter)
stats.removeEventListener(MouseEvent.CLICK, statsclicked)
modules.removeEventListener(MouseEvent.CLICK, modsclicked)
this.gotoAndStop(2)
}
function modsclicked(e:MouseEvent):void
{
this.removeEventListener(Event.ENTER_FRAME, frameEnter)
stats.removeEventListener(MouseEvent.CLICK, statsclicked)
modules.removeEventListener(MouseEvent.CLICK, modsclicked)
this.gotoAndStop(3)
}
I actually had similar problem at one point. It has to do with garbage collection which is not the best in Flash to begin with, but the IDE's compiler settings make it so much more insane. There are a couple of tricks you can try which might help.
Make sure you remove all listeners before leaving the frame.
Go to a "blank" frame (something which still has a background and styling, but no interact-able components) for even a 5/1000 of a second
Set the variable names to "null" on frame one (so if your component on frame 3 is named "foo" put foo = null on frame one)
put var foo:MovieClip on frame 1. repeat for all MovieClips which you might be using that are named ahead of time.