Proximity prompt an image label change visible not working - user-interface

I'm trying to make it so that when you use a proximity prompt an image label becomes visible but it's not working, how do I fix this?
local proximity = workspace.Cardpack.ProximityPrompt
local proximityPromptService = game.GetService("ProximityPromptService")
proximity.Triggered:Connect(function()
_G.visible = not _G.visible game.Workspace.Inventory.Frame.X1.Visble = _G.visible
end)

You don't really need to use _G for this. Instead, we can directly declare it to the X1.
local prompt = workspace.Cardpack.ProximityPrompt
local x1 = workspace.Inventory.Frame.X1
prompt.Triggered:Connect(function()
x1.Visible = not x1.Visible
end)

_G.visible = not _G.visible game.Workspace.Inventory.Frame.X1.Visble = _G.visible
This is where your script goes entirely wrong. This is not LUA syntax and is not how programming works. This is actually what you are currently trying to do.
local value = true = false;
Really what you should be doing is creating a reference to the ImageLabel you are trying to set. Then change it's properties. Setting a variable in the global enviroment won't change the ImageLabel's properties.
local ProximityPromptService = game.GetService("ProximityPromptService");
local ImageLabel = workspace.Inventory.Frame.X1;
local Proximity = workspace.Cardpack.ProximityPrompt;
proximity.Triggered:Connect(function()
ImageLabel.Visible = true;
end)

This seems to be a simple issue which can be solved with a simple solution (granted you know what you're doing). Now here's some things to note:
You don't need to use the ;'s you see on almost every line people make. It's not something mandatory and shouldn't be. Though it's good for when you want to have less lines (if it's your preference).
You wouldn't want to have 2 ='s on the same line as it's not the correct syntax (as #sl0th has stated), you cannot attempt such a task as it wouldn't even work. You want it to not just change it back to false anyways.
As you code this, I don't believe you fully understand how it works, and to make the code you first of all have to understand COMPLETELY or rather fluently how it works. So let's start off with that!
How do we do this? Let's see:
-- Perhaps put the script INSIDE of the Cardpack, and then do it from here.
-- Also, I'm not sure why you've put an "inventory.Frame" here, if it's a screengui then it should go in StarterGui, however if it's a billboardgui then please ignore me.
local Cardpack = script.Parent -- I've added it inside the cardpack as said.
local Prompt = Cardpack.ProximityPrompt
local Label = workspace.Inventory.Frame.X1 -- using the original directory as I don't know how your explorer looks.
local CanBeVisible = false -- if you want to toggle it.
Prompt.Triggered:Connect(function() -- make sure to look up on devforum about this.
if not CanbeVisible then -- "not CanBeVisible" is equivalent to "CanBeVisible==false".
CanBeVisible = true
Label.Visible = true
else -- if it's true and not false:
CanBeVisible = false
Label.Visible = false
end
end)
This is a more..."Acceptable" way of coding. People have their preferences, but this is generally how I'd do it based on how you did it. IF you don't understand much I'm always here to help, of course! :D
FINAL NOTES:
local A,B = "A", "B" -- you can assign multiple variables on a single line!
A,B = "B", "A" -- and you can also change more than one on the same line too.
local A = "A";print(A) -- that's how ; is used if you want to do more than one thing on the same line (but not done at the the same time on the same line!). ; Seperates the code without needing to add spaces, though adding/casting variables you should stick to using the comma(s) to separate them assigning new values and whatnot.
Also, you don't even need that ProximityPromptService variable as you never even use it! And you can't just do game.GetService(..), you IDEALLY do it as game:GetService(..).
I hope this helped you and if it did, mark this as the answer! Though this is my first time trying to help people I tried my best lol.

Related

How to Use a Variable in host[]

I want to achieve this:
*.numPairs = ${N=3}
**.host[0..N].udpApp[0].typename = "UdpBasicApp"
But it does not work. However, if I do like this: **.host[0..3].udpApp[0].typename = "UdpBasicApp", then it works properly.
It means that the problem is that the variable N inside host[] (i.e., host[0..N]) does not work.
Can anyone suggest how to fix this issue (i.e., how to make a variable work inside host[])? Many thanks.
One cannot use a variable as an index of module.

Delete a TestSet in ALM using OTA

So, I'm SLOWLY working my way to having a painful manual process automated in ALM using OTA. My current struggle is deleting a test set. It just doesn't do anything - no error, no deletion, nothing. It's like the line of code isn't even there. Although, it's definitely doing something cause ALM is working funky now.
I've tried different things: Delete, RemoveNode. Any advice is appreciated.
Set qcConnection = QCutil.QCConnection
Set tsFolder = qcconnection.TestSetTreeManager.NodeById(224)
Set tstestList = tsFolder.FindTestSets("", False, "")
If tstestList is Nothing Then
print "No manual tests present", vbOK
Else
For i = 1 to tstestList.Count
Set temp = tstestList.Item(i)
if temp.TestSetFolder.father.name = strMonth then
qcconnection.TSTestFactory.RemoveItem(temp.id)
end if
Next
End If
It seems you use a wrong factory - you need to use TestSetFactory instead of TSTestFactory

VBScript Nothing returns garbage

We have to use VBScript as an embedded script engine in our Hospital Information System.
When we use nothing to set the value of a control (textbox/checkbox/...) it worked always fine. Since somepoint it sets now the textbox to "?>".
item("TEXTBOX").value = nothing ' Leads to -> "?>"
It is not completly clear what causes this, maybe a windows update is responsible, every rollup ~ since KB3212646 Win7 2017-01 seems to cause this error.
My Question is now, has someone else also seem this error, so that it is clear that MS causes this error or is our HIS publisher responsible for not handling nothing correct.
I know setting a textbox to Nothing is not best practice instead "" should be better, but since the item object could be more the just a textbox e.g. a combobox/checkbox this seems, from an objectoriented perpsective, better. Or am I completly wrong?
Following #Ansgar comment, you should apparently change everywhere you have = nothing to = "" in your example
item("TEXTBOX").value = ""
Beware to keep the nothing if you have the Set keyword in left
Set some_object = Nothing

VB6, Adding an integer to a control name in a for loop

I am currently trying you learn VB6 and came across this issue.
I wanted to loop through a for loop and adding a number to a control name.
Dim I As Integer
For I = 1 To 5
S = CStr(I)
If TextS.Text = "" Then
LabelS.ForeColor = &HFF&
Else
LabelS.ForeColor = &H80000012
End If
Next I
This S needs to be added to Text and Label so the colour will be changed without needing to use 5 If Else statements
I hope you can help me with this.
From your comment below:
What i mean is this: If Text1.text = "" Then I need this 1 to be replaced with the variable I, so the for loop can loop through my 5 textboxes and the same for my Labels.
You can't do that (look up a variable using an expression to create its name) in VB6. (Edit: While that statement is true, it's not true that you can't look up form controls using a name from an expression. See "alternative" below.)
What you can do is make an array of your textboxes, and then index into that array. The dev env even helps you do that: Open your form in the dev env and click the first textbox. Change its name to the name you want the array to have (perhaps TextBoxes). Then click the next textbox and change its name to the same thing (TextBoxes). The dev env will ask you:
(Don't ask me why I have a VM lying around with VB6 on it...)
Click Yes, and then you can rename your other textboxes TextBoxes to add them to the array. Then do the same for your labels.
Then your code should look like this:
For I = TextBoxes.LBound To TextBoxes.UBound
If TextBoxes(I).Text = "" Then
Labels(I).ForeColor = &HFF&
Else
Labels(I).ForeColor = &H80000012
End If
Next
LBound is the lowest index of the control array, UBound is the highest. (You can't use the standard LBound and Ubound that take the array as an argument, because control arrays aren't quite normal arrays.) Note also that there's no need to put I on the Next line, that hasn't been required since VB4 or VB5. You can, though, if you like being explicit.
Just make sure that you have exactly the same number of TextBoxes as Labels. Alternately, you could create a user control that consisted of a label and a textbox, and then have a control array of your user control.
Alternative: : You can use the Controls array to look up a control using a name resulting from an expression, like this:
For I = 1 To 5
If Me.Controls("Text" & I).Text = "" Then
Me.Controls("Label" & I).ForeColor = &HFF&
Else
Me.Controls("Label" & I).ForeColor = &H80000012
End If
Next
This has the advantage of mapping over to a very similar construct in VB.Net, should you migrate at some point.
Side note:
I am currently trying you learn VB6...
(tl;dr - I'd recommend learning something else instead, VB6 is outdated and the dev env hasn't been supported in years.)
VB6's development environment has been discontinued and unsupported for years (since 2008). The runtime is still (I believe) supported because of the sheer number of apps that use it, although the most recent patch seems to be from 2012. But FWIW, you'd get a better return on your study time learning VB.net or C#.Net (or any of several non-Microsoft languages), rather than VB6...

Lua - fast changing images

I'm not a programmer, even amateur, I just wanted a program that would change PSP screen (whole) color as fast as possible infinitely. I made something:
rdupa = Image.load("red.png")
gdupa = Image.load("green.png")
bdupa = Image.load("blue.png")
screen:clear()
while true do
screen:blit(0, 0, rdupa, false)
screen:clear()
screen:blit(0, 0, gdupa, false)
screen:clear()
screen:blit(0, 0, bdupa, false)
screen:clear()
end
Using Google, but that doesn't work. What did I do wrong (I have *.png images in the same folder as script)? Ready script would be seen veeeeeeery nicely.
I'm not sure about your environment but I'd guess it's most likely unable to update its main window or whatever as it's essentially stuck executing the Lua code snipped (unless that's executed in a separate thread).
Lua is a small and concise programming language and provides only few core functions (see this list).
Lua does not provide any functions to work with screen and images by default, so without knowing what library/framework are you using, there is little we can do to help.
For this answer, I'm operating under the assumption that you're using Lua Player (consider adding a luaplayer tag?). From what I can see in the documentation, you should be using
screen.flip()
instead of
screen:clear()
whenever you want to update the screen. Unfortunately, I do not have CFW on my PSP, so I cannot test this myself.
To be honest, I wouldn't even consider using images.
something like this would do :)
(This is using PGELua but can easily be adapted for LuaPlayer)
while pge.running() do
color = pge.gfx.createcolor(pge.math.rand(255),pge.math.rand(255),pge.math.rand(255))
pge.gfx.startdrawing()
pge.gfx.drawrect(0,0,480,272,color)
pge.gfx.enddrawing()
pge.gfx.swapbuffers()
end
if you want defined colours, maybe something like.
red = pge.gfx.createcolor(255,0,0)
gre = pge.gfx.createcolor(0,255,0)
blu = pge.gfx.createcolor(0,0,255)
loop = 1
while pge.running() do
pge.gfx.startdrawing()
if loop==1 then
pge.gfx.drawrect(0,0,480,272,red)
elseif loop==2 then
pge.gfx.drawrect(0,0,480,272,gre)
elseif loop==3 then
pge.gfx.drawrect(0,0,480,272,blu)
end
loop=loop+1
if loop>4 then
loop=1
end
pge.gfx.enddrawing()
pge.gfx.swapbuffers()
end

Resources