how should i set my var, if i have many var but need to choose one?
for example:
when i use item(exmple potion with stats str and con),
i want to increase B_STR["BUFF"]
and B_CON["BUFF"]
there any other way to do it? the simple way .
for now i just do like this:
it become so long
inv script
var stats = preload(stats script resource path)
var itemData : Dictionary ={ all data of item}
func _on_invSlot_gui_input(event:InputEvent,invSlot :slotClass):
if event is InputEventMouseButton:
if event.button_index == BUTTON_LEFT and event.pressed:
stats.update_stats(itemData[statsName], itemData[statsType],itemData[[amount)
stats script resource
var B_STR :Dictionary = {"BASE":0,"EQ":0,"BUFF":0,"DEBUFF":0}
var B_CON :Dictionary = {"BASE":0,"EQ":0,"BUFF":0,"DEBUFF":0}
var B_DEX :Dictionary = {"BASE":0,"EQ":0,"BUFF":0,"DEBUFF":0}
var B_INT :Dictionary = {"BASE":0,"EQ":0,"BUFF":0,"DEBUFF":0}
var B_WIS :Dictionary = {"BASE":0,"EQ":0,"BUFF":0,"DEBUFF":0}
var B_LUK :Dictionary = {"BASE":0,"EQ":0,"BUFF":0,"DEBUFF":0}
func update_stats(statsName,statType,amount):
match statsName:
"STR":
if statType == "BUFF":
B_STR["BUFF"] += amount
if statType == "EQ":
B_STR["EQ"]+= amount
if statType == "BASE":
B_STR["BASE"] += amount
if statType == "DEBUFF":
B_STR["DEBUFF"] += amount
"CON":
if statType == "BUFF":
B_CON["BUFF"] += amount
if statType == "EQ":
B_CON["EQ"]+= amount
if statType == "BASE":
B_CON["BASE"] += amount
if statType == "DEBUFF":
B_CON["DEBUFF"] += amount
"DEX":
if statType == "BUFF":
B_DEX["BUFF"] += amount
if statType == "EQ":
B_DEX["EQ"]+= amount
if statType == "BASE":
B_DEX["BASE"] += amount
if statType == "DEBUFF":
B_DEX["DEBUFF"] += amount
and so on>>>>