- Edited
Raptorkillz Use a trivial test example.
- use actions you know 100% are defined and map 1:1 to physical input, because you might have messed up something with your action definitions
- use trivial sequence to speed up your testing, because you're testing how the parts of your code are communicating so the actual sequence is not important
- print immediately at the start of the signal handler
- print the sequence as it builds up
- double check your signal connections
- be sure to catch and understand all error messages the engine might be reporting
- If you can't use
print()
on your dev platform - use a different platform or set things up in a way so you can see your prints. Developing without printing is not a very wise thing to do. It just makes tracking the flow of your code needlessly more difficult.
class_name CheatCodeCapture extends Node
signal cheat_code_entered(name: String)
var s: String
var cheats: Dictionary = {"ui_left ui_right" : "cheat1"}
func _input(e):
for a in InputMap.get_actions().filter(func(aa): return e.is_action_pressed(aa)).slice(0,1):
s += a if not s else " " + a
print("current sequence: ", s) # debug
for k in cheats.keys(): if s.contains(k): cheat_code_entered.emit(cheats[k]); s = ""
func _ready():
cheat_code_entered.connect(on_cheat)
func on_cheat(name):
print(name) # debug