-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_script.gd
More file actions
29 lines (22 loc) · 1.15 KB
/
test_script.gd
File metadata and controls
29 lines (22 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
extends SceneTree
func _init():
print("STARTING SCRIPT")
var db = SQLiteDatabase.new()
var col1 = SQLiteColumnSchema.create("id", TYPE_INT, null, true, true, true, true)
var col2 = SQLiteColumnSchema.create("base", TYPE_INT, null, false, false, true, false)
var col3 = SQLiteColumnSchema.create("mult", TYPE_FLOAT, null, false, false, true, false)
var col4 = SQLiteColumnSchema.create("label", TYPE_STRING, null, false, false, true, false)
db.create_table("scores", [col1, col2, col3, col4]).execute([])
db.insert_row("scores", {"base": 100, "mult": 1.5, "label": "PlayerA"}).execute([])
db.insert_row("scores", {"base": 50, "mult": 2.0, "label": "PlayerB"}).execute([])
db.create_function("calc_complex", 3, Callable(self, "complex_godot_math"))
var q = db.create_query("SELECT id, calc_complex(base, mult, label) AS generated_string FROM scores;")
var res = q.execute([])
print("ERROR CODE: ", res.get_error_code())
var rows = res.get_result()
print("ROWS: ", rows)
db.close()
quit()
func complex_godot_math(base_value: int, multiplier: float, label: String) -> String:
var result = base_value * multiplier
return label + ": " + str(result)