Alright, sorry it took me so long to get back on this.
This behavior makes some sense, at least for the example shown in the first post (thanks Kevin!). The code looks as follows (I edited it slightly, still produces the crash though):
[code]
local CAS = game.ContextActionService
function f1()
print(“f1”)
CAS:BindAction(“f2”, f2, false, Enum.KeyCode.K)
end
function f2()
print(“f2”)
–
end
CAS:BindAction(“f1”, f1, false, Enum.KeyCode.K)[/Code]
This essentially results in a stack overflow. This is because when you press down on K it immediately binds K to f2, which causes f1 to receive a cancel event, which then binds to f2, which sends a cancel event to f1, and so on and so forth. We have updated the wiki with better documentation on ContextActionService, and essentially you should pay attention to the parameters being passed into both f1 and f2. Here is a code example that does not crash and probably does what you want.
[Code]
local CAS = game.ContextActionService
function f1(name, state, inputObject)
if state == Enum.UserInputState.Begin then
print(“f1”)
CAS:BindAction(“f2”, f2, false, Enum.KeyCode.K)
elseif state == Enum.UserInputState.Cancel then
print(“f1 has been cancelled”)
end
end
function f2(name, state, inputObject)
print(“f2”, name, state, inputObject)
–
end
CAS:BindAction(“f1”, f1, false, Enum.KeyCode.K)[/Code]
If you press K in this example, the output will be:
f1
f1 has been cancelled
f2 f2 Enum.UserInputState.End InputObject
Hopefully that clears some stuff up, if not please feel free to ask.