I added a new part to my script however i cant figure out how to integrate it and make it work, i am trying to add a Damage int to the weapon that i will later use in conjunction with attack modifiers and such but however ive fiddled around with it a while and i cant seem to figure out how to get it to be a column in the ItemList or how to get the Damage Ints for each weapon to show up
extends ItemList
var buystuff = load ("res://Charatabs.gd")
var SHOP_ITEMS = {
#Swords
"LongSword":{"sold":false,"Damage":4, "type":"Sword", "cost":10},
"Rapier":{"sold":false, "Damage":7, "type":"Sword", "cost":25},
"Scimitar":{"sold":false, "Damage":12, "type":"Sword", "cost":40},
"BroadSword":{"sold":false, "Damage":20, "type":"Sword", "cost":60},
"BastardSword":{"sold":false, "Damage":35, "type":"Sword", "cost":100},
"Excalibur":{"sold":false, "Damage":150, "type":"Sword", "cost":500},
#Daggers
"RogueDagger":{"sold":false, "Damage":3, "type":"Dagger", "cost":10},
"Shank":{"sold":false, "Damage":10, "type":"Dagger", "cost":20},
"LongKnife":{"sold":false, "Damage":18, "type":"Dagger", "cost":30},
"AssassinBlade":{"sold":false, "Damage":30, "type":"Dagger", "cost":50},
"MurderWeapon":{"sold":false, "Damage":60, "type":"Dagger", "cost":80},
}
var selected_item_name = null;
func _ready():
add_item("Weapon Name", null, false);
add_item("Damage", null, false);
add_item("Weapon Type", null, false);
add_item("Cost", null, false);
# Add each item.
for item_name in SHOP_ITEMS:
add_item(item_name, null, SHOP_ITEMS[item_name]["sold"]);
add_item(SHOP_ITEMS[item_name]["type"], null, false);
add_item(str(SHOP_ITEMS[item_name]["cost"]), null, false);
# Connect the item_selected signal so we know when a item in the list is selected.
connect("item_selected", self, "shop_item_selected");
func shop_item_selected(index):
# Get the name of the selected item
selected_item_name = get_item_text(index);
# Check if name is a name of a item in the shop (and the type/cost of a item)
if (SHOP_ITEMS.has(selected_item_name) == true):
print ("Item selected: ", selected_item_name, " | Cost: ", SHOP_ITEMS[selected_item_name]["cost"]);
func _on_Button_pressed():
get_node("/root/global").goto_scene("res://TownMap.tscn")
func _on_Buy_pressed():
if (buystuff.current_tab() == 0) && Coins.warrior_coins >= SHOP_ITEMS[selected_item_name]["cost"]:
Coins.warrior_coins -= SHOP_ITEMS[selected_item_name]["cost"]
print (Coins.warrior_coins)
Also this part at the bottom here is me trying to set it up so that when an item is selected and a characters tab is the current tab then it will deduct money from the particular characters coins however i cant get it to see which tab is the current tab as i just get an error that says Invalid Function