Questions about the user database

I have encountered many doubts about the user database function during game development. The main sources are as follows:

  1. Its calling method is GameManager.get_project_database_plain(“database_name”, “record_name”, “column_name”), where “record_name” is of string type. This makes it very difficult and troublesome for me to traverse the database in the script. For example, if I want to have 10 backpack slots, I need to use a very troublesome method to convert between int type and str type. The temporary method used is as follows:
	var backpack_item = []
	var database_name = "背包"
	# 获取背包物品状态
	for i in range(11):
		var database_item_numberName = "背包" + str(i) + "号位"
		var database_item_number = AGMakerManager.get_project_database_plain(database_name, database_item_numberName, "是否有东西")
		# 打印从数据库获取的原始值
		print("从数据库获取第 ", i, " 个位置的原始值: ", database_item_number)
		# 检查获取的值是否为 null
		if database_item_number == null:
			print("警告:第 ", i, " 个位置获取的值为 null,默认设置为 false")
			database_item_number = true
		backpack_item.append(database_item_number)
		print("添加到数组的第 ", i, " 个位置的值: ", database_item_number)

	print(value)

	# 扩展遍历范围到 11 个元素
	for i in range(last_updated_index + 1, min(11, backpack_item.size())):
		if not backpack_item[i]:
			print("更新前第 ", i, " 个位置状态: ", backpack_item[i])
			backpack_item[i] = true
			var database_item_numberName = "背包" + str(i) + "号位"
			# 更新数据库,传入布尔值 true
			AGMakerManager.update_project_database_plain(database_name, database_item_numberName, "是否有东西", true)
			print("已更新第 ", i, " 个位置,更新值为 true")
			# 重新获取更新后的值
			var updated_value = AGMakerManager.get_project_database_plain(database_name, database_item_numberName, "是否有东西")
			print("更新后第 ", i, " 个位置从数据库获取的值: ", updated_value)
			last_updated_index = i
			break
		else:
			print("第 ", i, " 个位置已有物品,继续检查下一个")
	print(backpack_item)

Since all parameters are of string type,,I’m not sure if there’s a better way to handle this, but it has caused me a lot of troubles in terms of code maintenance.
2.The process of calling the user database from VS scripts is also quite cumbersome.
First of all, in the condition checks for switches or variable value comparisons during action transitions, it is impossible to select the user database.


the transition conditions are very odd, which cost me a great deal of effort. I had no choice but to use signals to accomplish this task. I can only send a signal to the script first, then create a new switch variable on the GameObject, and finally modify it in the script to achieve the desired operation.

func _on_test_同步信号测试(signal_name:String, value:Variant) -> void:
	var teststatus = AGMakerManager.get_project_database_plain("背包","背包1号位","是否有东西")
	print("同步信号测试,当前值: ", teststatus)
	$".".set_value("同步开关",teststatus)
	pass # Replace with function body.

Secondly, regarding image display, I’m unsure how to retrieve image data stored in the user database within VS scripts. In the action editor, there doesn’t seem to be an option to directly specify the user database. My previous workaround involved using scripts to fetch data from the database and modify the texture property of a Sprite2D component to achieve the desired effect.


Then there’s the issue with object switches. When selecting “self” (the object itself), I can’t assign values using variables, nor can I directly reference values from the project database to set its state.

When using the user database feature in combination with VS scripts, I often encounter places where variables cannot be specified, which gives me a huge headache. The purpose of using AGM is to reduce the workload of writing code. However, such effects and limitations force me to explore many other solutions. Limited by my coding level, I have encountered numerous troubles and difficulties. I sincerely hope that the interaction logic among variables, user databases, and GameObjects in VS scripts can be optimized. If there are any good solutions, I would be extremely grateful.

「いいね!」 1

This is solid feedback and things we need to hear! I remember the database under went a few expansions during the beta, but now we can look into hooks for using them within Actions and Conditions better. I’ll pass this along!

「いいね!」 1

Thank you. I look forward to an increasingly better user experience.