GetMarkedReachedSignal isn't a valid member of AnimationTrack? - scripting

So I’m trying to make two functions happen upon a marker being reached in an animation, however it says:
“GetMarkedReachedSignal is not a valid member of AnimationTrack” I’m really confused.
Heres my code:
`
script.Parent.OnServerEvent:Connect(function(plr)
print("Started")
local on = true
local char = plr.Character
local fist = game.Lighting.DivergentFists:Clone()
local leftfist = game.Lighting.DivergentFists2:Clone()
local anim = script.Parent.Parent.DiverGentAnim
local weld = Instance.new("ManualWeld")
local leftweld = Instance.new("ManualWeld")
local function RightHandEmit()
fist.Parent = char.RightHand
fist.CFrame = char.RightHand.CFrame
weld.Parent = char.RightHand
weld.Part0 = char.RightHand
weld.Part1 = fist
weld.C0 = CFrame.new(0,-1,0)
local function FlameEmit()
while on == true do
fist.Attachment.BlackFlames:Emit(10)
fist.Attachment.Flames:Emit(10)
wait(.1)
end
end
local function SparksEmit()
while on == true do
fist.Attachment.Aura:Emit(10)
fist.Attachment.Main:Emit(10)
wait(.1)
end
end
spawn(SparksEmit)
spawn(FlameEmit)
end
local function LeftHandEmit()
leftfist.Parent = char.LeftHand
leftfist.CFrame = char.LeftHand.CFrame
leftweld.Parent = char.LeftHand
leftweld.Part0 = char.LeftHand
leftweld.Part1 = leftfist
leftweld.C0 = CFrame.new(0,-1,0)
local function LeftFlameEmit()
while on == true do
leftfist.Attachment.BlackFlames:Emit(10)
leftfist.Attachment.Flames:Emit(10)
wait(.1)
end
end
local function LeftSparksEmit()
while on == true do
leftfist.Attachment.Aura:Emit(10)
leftfist.Attachment.Main:Emit(10)
wait(.1)
end
end
spawn(LeftFlameEmit)
spawn(LeftSparksEmit)
end
local load = char.Humanoid.Animator:LoadAnimation(anim)
load:Play()
load:GetMarkerReachedSignal("ReachedStart"):Connect(function()
print("Reached")
spawn(LeftHandEmit)
spawn(RightHandEmit)
end)
end)
`
Any help is appreciated, thanks! (This is all on the server by the way)
I tried doing it on the client but nothing happened

Related

In Lua, How do I call a variable using index?

local index = 1
Defining Function
local function PickGlass()
local RandomNum = math.random(0,1)
local Platform1 = game.Workspace.Tester.Platform(index)
local Platform2 = game.Workspace.Tester.Platform(index + 1)
local function Falling()
Platform1.Anchored = false
end
local function OtherFalling()
Platform2.Anchored = false
end
if RandomNum == 1 then
Platform1.Touched:Connect(Falling)
end
if RandomNum == 0 then
Platform2.Touched:Connect(OtherFalling)
end
index = index + 1
end
Running Function
while index < 4 do
PickGlass()
index += 2
end
It wont let me use index when defining Platform 1 and 2. How do I use it?
If you’re trying to index an instance using a variable, you can do either:
game.Workspace.Tester.Platform[tostring(index)]
-- or
game.Workspace.Tester.Platform:FindFirstChild(tostring(index))
You can’t do:
game.Workspace.Tester.Platform(index)
Because that is indicating that you want to call the Platform method which doesn’t exist on Tester. (Plus you’d need : to pass self first on any function call)

Expanding a SAP Tree

I'm using UFT (vbscript) to automate a process between SAP and a Web page. Using SAP transaction S_ALR_87013534, I have a piece of code in UFT that will expand the tree completely and extract the value associated with one of the order numbers:
set tree = SAPGuiSession("Session").SAPGuiWindow("Execute Drilldown Report").SAPGuiTree("TableTreeControl")
tree.OpenItemContextMenu "PRJ "&projNum,"PRJ "&projNum
tree.SelectMenuItemById "&EXPAND"
tree.SelectNode "PRJ "&projNum
colKey_plan1 = getColNameFromTitle(tree, "Plan 2--Overall")
rowContainingOrdNum = findBudget(tree, ordNum)
plannedProjectBudget = tree.Object.GetItemText(tree.Object.GetAllNodeKeys(rowContainingOrdNum(0)), colKey_plan1)
Function getColNameFromTitle(tree, title)
set colNames = tree.Object.GetColumnNames
For i = 1 To (colNames.length-1)
selectedColTitle = tree.Object.GetColumnTitleFromName(colNames(i))
If selectedColTitle = title Then
getColNameFromTitle = colNames(i)
Exit For
End If
Next
End Function
Function findBudget(tree, ordNum)
rowContainingOrdNum = Array()
Set columnNames = tree.Object.GetColumnNames()
set columnKeys = tree.Object.GetColumnCol(columnNames(0))
For i = 1 To (columnKeys.length-1)
If InStr(columnKeys(i), ordNum)>0 Then
AddItem rowContainingOrdNum, i
Exit For
End If
Next
findBudget = rowContainingOrdNum
End Function
Function AddItem(arr, val)
ReDim Preserve arr(UBound(arr) + 1)
arr(UBound(arr)) = val
AddItem = arr
End Function
This works perfectly, but when I use a different report, S_ALR_87013543, it's still recognised as a tree but the above code doesn't work as there is no EXPAND option at the Object heading. I'm not very familiar with SAP and all their trees and how to use automation with it, so any guidance or tips are appreciated.
Left is the report I need to expand, and right is the report the code works with:
Solution:
Set TreeObj = SAPGuiSession("Session").SAPGuiWindow("Actual/Plan/Variance").SAPGuiTree("TableTreeControl").Object
Set AllValues = TreeObj.GetAllNodeKeys
Count = AllValues.Count
Found = 0
For i = 0 to Count-1
NodeText = TreeObj.GetNodeTextByKey(AllValues(i))
If NodeText = WBSelement Then
Found = 1
Exit For
End if
Next
If Found = 1 Then
SAPGuiSession("Session").SAPGuiWindow("Actual/Plan/Variance").SAPGuiTree("TableTreeControl").SelectNode WBS
End If

How can I improve this iterative function?

I am trying to simplify this function which is similar from
Function Snake_makestep()
maincar.Location = locate(xpos, ypos)
car0.Location = locate(posx(0), posy(0))
car1.Location = locate(posx(1), posy(1))
If car2.Visible = True Then
car2.Location = locate(posx(2), posy(2))
End If
If car3.Visible = True Then
car3.Location = locate(posx(3), posy(3))
End If
If car4.Visible = True Then
car4.Location = locate(posx(4), posy(4))
End If
To
If car30.Visible = True Then
car30.Location = locate(posx(30), posy(30))
End If
End Function
I'm not sure If I can/how to use Controls.Find solution within this function. Any help?
To answer the question as asked:
For i = 2 To 30
Dim car = Controls("car" & i)
If car.Visible Then
car.Location = locate(posx(i), posy(i))
End If
Next
Visible and Location are both members of the Control class so it doesn't matter what type of control those car variables are.
Note that this assumes that all controls are on the form itself. If they are in a different parent container, you'd need to use the Controls collection of that container.
Also, I have started i at 2 there, so you'd still need the explicit code for car0 and car1. If they are always visible then you could start the loop at 0 and it would still work, saving you those two lines of code as well.

How can I use iteration to make this vbnet code more efficient?

Function set_bar_positions()
bar_x(0) = delocateX(bar1.Left)
bar_y(0) = delocateY(bar1.Top)
bar_x(1) = delocateX(bar2.Left)
bar_y(1) = delocateY(bar2.Top)
bar_x(2) = delocateX(bar3.Left)
bar_y(2) = delocateY(bar3.Top)
This snippet from one of my functions show what I'm trying to do. These lines repeat almost identical until the end of the function where this is called:
bar_x(29) = delocateX(bar30.Left)
bar_y(29) = delocateY(bar30.Top)
I have tried iterating this functions by doing stuff like this, but now I know I can't:
Dim num As Integer = 0
bar_x(num) = delocateX(bar(num)).Left)
I am trying to make this code more efficient and have less lines. Anyone have an idea I can implement?
You can use Controls.Find
For i = 0 To 29
Dim cs = Me.Controls.Find("bar" & i.ToString(), True)
If cs.Any() Then
Dim c = cs.First()
bar_x(i) = delocateX(c.Left)
bar_y(i) = delocateY(c.Top)
End If
Next

How to port this Linq to VS 2005

I have following code in VS2008
If Linq.Enumerable.Contains(Of String)(selectedUsersRoles, RoleCheckBox.Text) Then
RoleCheckBox.Checked = True
Else
RoleCheckBox.Checked = False
End If
I need the above code in VS2005
What can i do instead of linq in above code? Can anybody help?
RoleCheckBox.Checked = False
For Each str As String in selectedUsersRoles
If str = RoleCheckBox.Text Then
RoleCheckBox.Checked = True
Exit For
End If
Next
If you don't wish to alter the RoleCheckBox.Checked twice (when str is actually found) then declare a boolean flag (i.e. boolFound) with an initial False value, change it to true when found, and asign RoleCheckBox.Checked = boolFound after the "for each" loop....
bool containsRole = false;
foreach(string entry in selectedUsersRoles)
{
if(entry == RoleCheckBox.Text)
{
containsRole = true;
break;
}
}
RoleCheckBox.Checked = containsRole;
The code is C# but i guess u'll get the idea.
This is for IEnumerable. If you have a list try Binary Worrier's sollution.