def test(self): floatnode = Node(None, None) floatnode.set_type("number") floatnode.set_invokable("config") floatnode.set_value(0.0) self.assertEqual(floatnode.get_type(), "number") self.assertEqual(floatnode.get_value(), 0.0) self.assertEqual(floatnode.get_config("$invokable"), "config") intnode = Node(None, None) intnode.set_type("int") intnode.set_value(1) self.assertEqual(intnode.get_type(), "int") self.assertEqual(intnode.get_value(), 1) enumnode = Node(None, None) enumnode.set_type("enum") enumnode.set_value(["test", "hi"]) self.assertEqual(enumnode.get_type(), "enum") self.assertEqual(enumnode.get_value(), "enum[test,hi]")
def get_default_nodes(self): root = self.get_root_node() play_sound = Node("playSound", root) play_sound.set_name("Play Sound") play_sound.set_config("$is", "playSound") play_sound.set_invokable("write") root.add_child(play_sound) pause_sound = Node("pauseSound", root) pause_sound.set_name("Pause Sound") pause_sound.set_config("$is", "pauseSound") pause_sound.set_invokable("write") root.add_child(pause_sound) queue_sound = Node("queueSound", root) queue_sound.set_name("Queue Sound") queue_sound.set_config("$is", "queueSound") queue_sound.set_invokable("write") queue_sound.set_parameters([ { "name": "Sound Path", "type": "string" } ]) root.add_child(queue_sound) return root
def get_default_nodes(self, super_root): create_rng = Node("create_rng", super_root) create_rng.set_display_name("Create RNG") create_rng.set_config("$is", "create_rng") create_rng.set_invokable("config") create_rng.set_parameters([ { "name": "Name", "type": "string" } ]) create_rng.set_columns([ { "name": "Success", "type": "bool" } ]) set_speed = Node("set_speed", super_root) set_speed.set_display_name("Set Speed") set_speed.set_config("$is", "set_speed") set_speed.set_invokable("config") set_speed.set_parameters([ { "name": "Speed", "type": "number" } ]) set_speed.set_columns([ { "name": "Success", "type": "bool" } ]) super_root.add_child(create_rng) super_root.add_child(set_speed) return super_root
def create_rng(self, data): name = data[1]["Name"] if self.responder.get_super_root().get("/%s" % name) is None: rng = Node(name, self.responder.get_super_root()) rng.set_config("$is", "rng") rng.set_type("number") rng.set_value(0) self.responder.get_super_root().add_child(rng) delete = Node("delete", rng) delete.set_config("$is", "delete_rng") delete.set_invokable("config") rng.add_child(delete) self.rngs[name] = rng return [ [ True ] ] return [ [ False ] ]