I've been doing programming in tkinter for awhile now and I came across a problem...this problem only shows up after a single part but here is the code...kinda lengthy.if you go to the equip menu and equip bare neck you can't change necklaces again. any help in shortening this or fixing the problem let me know

from Tkinter import *
import random
import operator
global armor, sword, game, pots, ether, player, con, mana, magic, fight, melf, text, combattext, letter, available, held, necklace, neck
area = 0
sword = 0
pots = 20
available = {0,1,2}
held = {0,1,2}
armor = 0
first = ""
last = ""
game = "go"
ether = 5
player = 50
con = 0
mana = 10
magic = 0
fight = "menu"
slime = 0
melf = 0
text = 0
combattext = 0
letter = ""
neck = 1
necklace = {1,2,3}

class App:

    def __init__(self, master):

        frame = Frame(master)
        frame.pack()

        def Healthtext():
            global player,mana
            if player > 50+5*con:
                player = 50+5*con
            if mana > 10+magic:
                mana = 10+magic
            health.configure(text = ("hp:",player,"/",50+5*con,",mana:",mana,"/",10+magic), relief=SUNKEN)
            health.after(100, Healthtext)

        def textboxtext():
            global text
            if text == 0:
                if last != "":
                    textbox.configure(text = ("Welcome",first,last,"to","the","world","of","slime","fighter."))
                if last == "":
                    textbox.configure(text = ("Welcome",first,"to","the","world","of","slime","fighter."))
                text = -1
            if text == 1:
                textbox.configure(text = ("You","have",pots,"potions."),fg="black")
                text = -1
            if text == 2:
                textbox.configure(text = ("You","have",ether,"ethers."),fg="black")
                text = -1
            if text == 3:
                textbox.configure(text = "Rested.", fg="blue")
                text = -1
            if text == 4:
                textbox.configure(text = "At least your not naked",fg="black")
                text = -1
            if text == 5:
                textbox.configure(text = "You put on your clothes",fg="black")
                text = -1
            if text == 6:
                textbox.configure(text = "Leather armor gives 1 defence",fg="black")
                text = -1
            if text == 7:
                textbox.configure(text = "You put on your leather armor",fg="black")
                text = -1
            if text == 8:
                textbox.configure(text = "Chainmail gives 2 defence",fg="black")
                text = -1
            if text == 9:
                textbox.configure(text = "You put on some chainmail",fg="black")
                text = -1
            if text == 10:
                textbox.configure(text = "Pointy (1d6)",fg="black")
                text = -1
            if text == 11:
                textbox.configure(text = "You grab your dagger",fg="black")
                text = -1
            if text == 12:
                textbox.configure(text = "This might actually hurt something (1d8)",fg="black")
                text = -1
            if text == 13:
                textbox.configure(text = "You grab your short sword",fg="black")
                text = -1
            if text == 14:
                textbox.configure(text = "Now this is a weapon. (1d10)",fg="black")
                text = -1
            if text == 15:
                textbox.configure(text = "You grab your long sword",fg="black")
                text = -1
            if text == 16:
                textbox.configure(text = "If only you had a necklace",fg="black")
                text = -1
            if text == 17:
                textbox.configure(text = "You take off your necklace",fg="black")
                text = -1
            if text == 18:
                textbox.configure(text = "rejuv necklace gives rejuvination",fg="black")
                text = -1
            if text == 19:
                textbox.configure(text = "You put on your rejuv necklace",fg="black")
                text = -1
            if text == 20:
                textbox.configure(text = "regen necklace gives regeneration",fg="black")
                text = -1
            if text == 21:
                textbox.configure(text = "You put on your regen necklace",fg="black")
                text = -1
            if text == 22:
                textbox.configure(text = ("Welcome","back",first,last),fg="black")
                text = -1
            textbox.after(100, textboxtext)

        health = Label(master, text="")
        health.configure(text = ("hp:",player,"/",50+5*con,",mana:",mana,"/",10+magic), relief=SUNKEN)
        health.pack()
        health.after(100, Healthtext)

        textbox = Label(master, text="")
        textbox.pack()
        textbox.after(100, textboxtext)

        self.North = Button(frame, text="North",bg="red",fg="white", command=self.north)
        self.North.pack(side=TOP)
        self.North.configure(cursor="sb_up_arrow")

        self.South = Button(frame, text="South",bg="yellow", command=self.south)
        self.South.pack(side=BOTTOM)
        self.South.configure(cursor="sb_down_arrow")

        self.West = Button(frame, text="West",bg="blue",fg="white", command=self.west)
        self.West.pack(side=LEFT)
        self.West.configure(cursor="sb_left_arrow")

        self.Quit = Button(frame, text="Quit",bg="black",fg="white",command=quit)
        self.Quit.pack(side=LEFT)
        self.Quit.configure(cursor="pirate")

        self.East = Button(frame, text="East",bg="green", command=self.east)
        self.East.pack(side=LEFT)
        self.East.configure(cursor="sb_right_arrow")

    def north(self):
        global fight
        fight = "1"
        root.destroy()

    def west(self):
        global fight
        fight = "2"
        root.destroy()
        
    def east(self):
        global fight
        fight = "4"
        root.destroy()

    def south(self):
        global fight
        fight = "3"
        root.destroy()

def potions():
    global text
    text = 1

def ethers():
    global text
    text = 2

def rest():
    global player,mana,text
    player = 50+con*5
    mana = 10+magic
    text = 3

def clothes():
    global text
    text = 4

def wearclothes():
    global text
    text = 5
    global armor
    armor = 0
    equip.delete(0,10)
    for x in available:
        if armor == 0 and x == 0:
            equip.add_command(label="clothes*", command=clothes)
        if armor != 0 and x == 0:
            equip.add_command(label="clothes", command=wearclothes)
        if armor == 1 and x == 1:
            equip.add_command(label="leather armor*", command=leather)
        if armor != 1 and x == 1:
            equip.add_command(label="leather armor", command=wearleather)
        if armor == 2 and x == 2:
            equip.add_command(label="chainmail*", command=chain)
        if armor != 2 and x == 2:
            equip.add_command(label="chainmail", command=wearchain)
    equip.add_separator()
    for x in held:
        if sword == 0 and x == 0:
            equip.add_command(label="dagger*", command=dagger)
        if sword != 0 and x == 0:
            equip.add_command(label="dagger", command=wielddagger)
        if sword == 1 and x == 1:
            equip.add_command(label="short sword*", command=short)
        if sword != 1 and x == 1:
            equip.add_command(label="short sword", command=wieldshort)
        if sword == 2 and x == 2:
            equip.add_command(label="long sword*", command=long)
        if sword != 2 and x == 2:
            equip.add_command(label="long sword", command=wieldlong)
    equip.add_separator()
    for x in necklace:
        if neck == 1 and x == 1:
            equip.add_command(label="bare neck*", command=neck)
        if neck != 1 and x == 1:
            equip.add_command(label="bare neck", command=wearneck)
        if neck == 2 and x == 2:
            equip.add_command(label="rejuv necklace*", command=rejuv)
        if neck != 2 and x == 2:
            equip.add_command(label="rejuv necklace", command=wearrejuv)
        if neck == 3 and x == 3:
            equip.add_command(label="regen necklace*", command=regen)
        if neck != 3 and x == 3:
            equip.add_command(label="regen necklace", command=wearregen)
    
def leather():
    global text
    text = 6

def wearleather():
    global text
    text = 7
    global armor
    armor = 1
    equip.delete(0,10)
    for x in available:
        if armor == 0 and x == 0:
            equip.add_command(label="clothes*", command=clothes)
        if armor != 0 and x == 0:
            equip.add_command(label="clothes", command=wearclothes)
        if armor == 1 and x == 1:
            equip.add_command(label="leather armor*", command=leather)
        if armor != 1 and x == 1:
            equip.add_command(label="leather armor", command=wearleather)
        if armor == 2 and x == 2:
            equip.add_command(label="chainmail*", command=chain)
        if armor != 2 and x == 2:
            equip.add_command(label="chainmail", command=wearchain)
    equip.add_separator()
    for x in held:
        if sword == 0 and x == 0:
            equip.add_command(label="dagger*", command=dagger)
        if sword != 0 and x == 0:
            equip.add_command(label="dagger", command=wielddagger)
        if sword == 1 and x == 1:
            equip.add_command(label="short sword*", command=short)
        if sword != 1 and x == 1:
            equip.add_command(label="short sword", command=wieldshort)
        if sword == 2 and x == 2:
            equip.add_command(label="long sword*", command=long)
        if sword != 2 and x == 2:
            equip.add_command(label="long sword", command=wieldlong)
    equip.add_separator()
    for x in necklace:
        if neck == 1 and x == 1:
            equip.add_command(label="bare neck*", command=neck)
        if neck != 1 and x == 1:
            equip.add_command(label="bare neck", command=wearneck)
        if neck == 2 and x == 2:
            equip.add_command(label="rejuv necklace*", command=rejuv)
        if neck != 2 and x == 2:
            equip.add_command(label="rejuv necklace", command=wearrejuv)
        if neck == 3 and x == 3:
            equip.add_command(label="regen necklace*", command=regen)
        if neck != 3 and x == 3:
            equip.add_command(label="regen necklace", command=wearregen)

def chain():
    global text
    text = 8

def wearchain():
    global text
    text = 9
    global armor
    armor = 2
    equip.delete(0,10)
    for x in available:
        if armor == 0 and x == 0:
            equip.add_command(label="clothes*", command=clothes)
        if armor != 0 and x == 0:
            equip.add_command(label="clothes", command=wearclothes)
        if armor == 1 and x == 1:
            equip.add_command(label="leather armor*", command=leather)
        if armor != 1 and x == 1:
            equip.add_command(label="leather armor", command=wearleather)
        if armor == 2 and x == 2:
            equip.add_command(label="chainmail*", command=chain)
        if armor != 2 and x == 2:
            equip.add_command(label="chainmail", command=wearchain)
    equip.add_separator()
    for x in held:
        if sword == 0 and x == 0:
            equip.add_command(label="dagger*", command=dagger)
        if sword != 0 and x == 0:
            equip.add_command(label="dagger", command=wielddagger)
        if sword == 1 and x == 1:
            equip.add_command(label="short sword*", command=short)
        if sword != 1 and x == 1:
            equip.add_command(label="short sword", command=wieldshort)
        if sword == 2 and x == 2:
            equip.add_command(label="long sword*", command=long)
        if sword != 2 and x == 2:
            equip.add_command(label="long sword", command=wieldlong)
    equip.add_separator()
    for x in necklace:
        if neck == 1 and x == 1:
            equip.add_command(label="bare neck*", command=neck)
        if neck != 1 and x == 1:
            equip.add_command(label="bare neck", command=wearneck)
        if neck == 2 and x == 2:
            equip.add_command(label="rejuv necklace*", command=rejuv)
        if neck != 2 and x == 2:
            equip.add_command(label="rejuv necklace", command=wearrejuv)
        if neck == 3 and x == 3:
            equip.add_command(label="regen necklace*", command=regen)
        if neck != 3 and x == 3:
            equip.add_command(label="regen necklace", command=wearregen)

def dagger():
    global text
    text = 10

def wielddagger():
    global text
    text = 11
    global sword
    sword = 0
    equip.delete(0,10)
    for x in available:
        if armor == 0 and x == 0:
            equip.add_command(label="clothes*", command=clothes)
        if armor != 0 and x == 0:
            equip.add_command(label="clothes", command=wearclothes)
        if armor == 1 and x == 1:
            equip.add_command(label="leather armor*", command=leather)
        if armor != 1 and x == 1:
            equip.add_command(label="leather armor", command=wearleather)
        if armor == 2 and x == 2:
            equip.add_command(label="chainmail*", command=chain)
        if armor != 2 and x == 2:
            equip.add_command(label="chainmail", command=wearchain)
    equip.add_separator()
    for x in held:
        if sword == 0 and x == 0:
            equip.add_command(label="dagger*", command=dagger)
        if sword != 0 and x == 0:
            equip.add_command(label="dagger", command=wielddagger)
        if sword == 1 and x == 1:
            equip.add_command(label="short sword*", command=short)
        if sword != 1 and x == 1:
            equip.add_command(label="short sword", command=wieldshort)
        if sword == 2 and x == 2:
            equip.add_command(label="long sword*", command=long)
        if sword != 2 and x == 2:
            equip.add_command(label="long sword", command=wieldlong)
    equip.add_separator()
    for x in necklace:
        if neck == 1 and x == 1:
            equip.add_command(label="bare neck*", command=neck)
        if neck != 1 and x == 1:
            equip.add_command(label="bare neck", command=wearneck)
        if neck == 2 and x == 2:
            equip.add_command(label="rejuv necklace*", command=rejuv)
        if neck != 2 and x == 2:
            equip.add_command(label="rejuv necklace", command=wearrejuv)
        if neck == 3 and x == 3:
            equip.add_command(label="regen necklace*", command=regen)
        if neck != 3 and x == 3:
            equip.add_command(label="regen necklace", command=wearregen)

def short():
    global text
    text = 12

def wieldshort():
    global text
    text = 13
    global sword
    sword = 1
    equip.delete(0,10)
    for x in available:
        if armor == 0 and x == 0:
            equip.add_command(label="clothes*", command=clothes)
        if armor != 0 and x == 0:
            equip.add_command(label="clothes", command=wearclothes)
        if armor == 1 and x == 1:
            equip.add_command(label="leather armor*", command=leather)
        if armor != 1 and x == 1:
            equip.add_command(label="leather armor", command=wearleather)
        if armor == 2 and x == 2:
            equip.add_command(label="chainmail*", command=chain)
        if armor != 2 and x == 2:
            equip.add_command(label="chainmail", command=wearchain)
    equip.add_separator()
    for x in held:
        if sword == 0 and x == 0:
            equip.add_command(label="dagger*", command=dagger)
        if sword != 0 and x == 0:
            equip.add_command(label="dagger", command=wielddagger)
        if sword == 1 and x == 1:
            equip.add_command(label="short sword*", command=short)
        if sword != 1 and x == 1:
            equip.add_command(label="short sword", command=wieldshort)
        if sword == 2 and x == 2:
            equip.add_command(label="long sword*", command=long)
        if sword != 2 and x == 2:
            equip.add_command(label="long sword", command=wieldlong)
    equip.add_separator()
    for x in necklace:
        if neck == 1 and x == 1:
            equip.add_command(label="bare neck*", command=neck)
        if neck != 1 and x == 1:
            equip.add_command(label="bare neck", command=wearneck)
        if neck == 2 and x == 2:
            equip.add_command(label="rejuv necklace*", command=rejuv)
        if neck != 2 and x == 2:
            equip.add_command(label="rejuv necklace", command=wearrejuv)
        if neck == 3 and x == 3:
            equip.add_command(label="regen necklace*", command=regen)
        if neck != 3 and x == 3:
            equip.add_command(label="regen necklace", command=wearregen)

def long():
    global text
    text = 14

def wieldlong():
    global text
    text = 15
    global sword
    sword = 2
    equip.delete(0,10)
    for x in available:
        if armor == 0 and x == 0:
            equip.add_command(label="clothes*", command=clothes)
        if armor != 0 and x == 0:
            equip.add_command(label="clothes", command=wearclothes)
        if armor == 1 and x == 1:
            equip.add_command(label="leather armor*", command=leather)
        if armor != 1 and x == 1:
            equip.add_command(label="leather armor", command=wearleather)
        if armor == 2 and x == 2:
            equip.add_command(label="chainmail*", command=chain)
        if armor != 2 and x == 2:
            equip.add_command(label="chainmail", command=wearchain)
    equip.add_separator()
    for x in held:
        if sword == 0 and x == 0:
            equip.add_command(label="dagger*", command=dagger)
        if sword != 0 and x == 0:
            equip.add_command(label="dagger", command=wielddagger)
        if sword == 1 and x == 1:
            equip.add_command(label="short sword*", command=short)
        if sword != 1 and x == 1:
            equip.add_command(label="short sword", command=wieldshort)
        if sword == 2 and x == 2:
            equip.add_command(label="long sword*", command=long)
        if sword != 2 and x == 2:
            equip.add_command(label="long sword", command=wieldlong)
    equip.add_separator()
    for x in necklace:
        if neck == 1 and x == 1:
            equip.add_command(label="bare neck*", command=neck)
        if neck != 1 and x == 1:
            equip.add_command(label="bare neck", command=wearneck)
        if neck == 2 and x == 2:
            equip.add_command(label="rejuv necklace*", command=rejuv)
        if neck != 2 and x == 2:
            equip.add_command(label="rejuv necklace", command=wearrejuv)
        if neck == 3 and x == 3:
            equip.add_command(label="regen necklace*", command=regen)
        if neck != 3 and x == 3:
            equip.add_command(label="regen necklace", command=wearregen)

def neck():
    global text
    text = 16

def wearneck():
    global neck,text
    text = 17
    neck = 1
    equip.delete(0,9)
    for x in available:
        if armor == 0 and x == 0:
            equip.add_command(label="clothes*", command=clothes)
        if armor != 0 and x == 0:
            equip.add_command(label="clothes", command=wearclothes)
        if armor == 1 and x == 1:
            equip.add_command(label="leather armor*", command=leather)
        if armor != 1 and x == 1:
            equip.add_command(label="leather armor", command=wearleather)
        if armor == 2 and x == 2:
            equip.add_command(label="chainmail*", command=chain)
        if armor != 2 and x == 2:
            equip.add_command(label="chainmail", command=wearchain)
    equip.add_separator()
    for x in held:
        if sword == 0 and x == 0:
            equip.add_command(label="dagger*", command=dagger)
        if sword != 0 and x == 0:
            equip.add_command(label="dagger", command=wielddagger)
        if sword == 1 and x == 1:
            equip.add_command(label="short sword*", command=short)
        if sword != 1 and x == 1:
            equip.add_command(label="short sword", command=wieldshort)
        if sword == 2 and x == 2:
            equip.add_command(label="long sword*", command=long)
        if sword != 2 and x == 2:
            equip.add_command(label="long sword", command=wieldlong)
    equip.add_separator()
    for x in necklace:
        if neck == 1 and x == 1:
            equip.add_command(label="bare neck*", command=neck)
        if neck != 1 and x == 1:
            equip.add_command(label="bare neck", command=wearneck)
        if neck == 2 and x == 2:
            equip.add_command(label="rejuv necklace*", command=rejuv)
        if neck != 2 and x == 2:
            equip.add_command(label="rejuv necklace", command=wearrejuv)
        if neck == 3 and x == 3:
            equip.add_command(label="regen necklace*", command=regen)
        if neck != 3 and x == 3:
            equip.add_command(label="regen necklace", command=wearregen)

def rejuv():
    global text
    text = 18

def wearrejuv():
    global neck,text
    text = 19
    neck = 2
    equip.delete(0,9)
    for x in available:
        if armor == 0 and x == 0:
            equip.add_command(label="clothes*", command=clothes)
        if armor != 0 and x == 0:
            equip.add_command(label="clothes", command=wearclothes)
        if armor == 1 and x == 1:
            equip.add_command(label="leather armor*", command=leather)
        if armor != 1 and x == 1:
            equip.add_command(label="leather armor", command=wearleather)
        if armor == 2 and x == 2:
            equip.add_command(label="chainmail*", command=chain)
        if armor != 2 and x == 2:
            equip.add_command(label="chainmail", command=wearchain)
    equip.add_separator()
    for x in held:
        if sword == 0 and x == 0:
            equip.add_command(label="dagger*", command=dagger)
        if sword != 0 and x == 0:
            equip.add_command(label="dagger", command=wielddagger)
        if sword == 1 and x == 1:
            equip.add_command(label="short sword*", command=short)
        if sword != 1 and x == 1:
            equip.add_command(label="short sword", command=wieldshort)
        if sword == 2 and x == 2:
            equip.add_command(label="long sword*", command=long)
        if sword != 2 and x == 2:
            equip.add_command(label="long sword", command=wieldlong)
    equip.add_separator()
    for x in necklace:
        if neck == 1 and x == 1:
            equip.add_command(label="bare neck*", command=neck)
        if neck != 1 and x == 1:
            equip.add_command(label="bare neck", command=wearneck)
        if neck == 2 and x == 2:
            equip.add_command(label="rejuv necklace*", command=rejuv)
        if neck != 2 and x == 2:
            equip.add_command(label="rejuv necklace", command=wearrejuv)
        if neck == 3 and x == 3:
            equip.add_command(label="regen necklace*", command=regen)
        if neck != 3 and x == 3:
            equip.add_command(label="regen necklace", command=wearregen)

def regen():
    global text
    text = 20
    
def wearregen():
    global neck,text
    text = 21
    neck = 3
    equip.delete(0,9)
    for x in available:
        if armor == 0 and x == 0:
            equip.add_command(label="clothes*", command=clothes)
        if armor != 0 and x == 0:
            equip.add_command(label="clothes", command=wearclothes)
        if armor == 1 and x == 1:
            equip.add_command(label="leather armor*", command=leather)
        if armor != 1 and x == 1:
            equip.add_command(label="leather armor", command=wearleather)
        if armor == 2 and x == 2:
            equip.add_command(label="chainmail*", command=chain)
        if armor != 2 and x == 2:
            equip.add_command(label="chainmail", command=wearchain)
    equip.add_separator()
    for x in held:
        if sword == 0 and x == 0:
            equip.add_command(label="dagger*", command=dagger)
        if sword != 0 and x == 0:
            equip.add_command(label="dagger", command=wielddagger)
        if sword == 1 and x == 1:
            equip.add_command(label="short sword*", command=short)
        if sword != 1 and x == 1:
            equip.add_command(label="short sword", command=wieldshort)
        if sword == 2 and x == 2:
            equip.add_command(label="long sword*", command=long)
        if sword != 2 and x == 2:
            equip.add_command(label="long sword", command=wieldlong)
    equip.add_separator()
    for x in necklace:
        if neck == 1 and x == 1:
            equip.add_command(label="bare neck*", command=neck)
        if neck != 1 and x == 1:
            equip.add_command(label="bare neck", command=wearneck)
        if neck == 2 and x == 2:
            equip.add_command(label="rejuv necklace*", command=rejuv)
        if neck != 2 and x == 2:
            equip.add_command(label="rejuv necklace", command=wearrejuv)
        if neck == 3 and x == 3:
            equip.add_command(label="regen necklace*", command=regen)
        if neck != 3 and x == 3:
            equip.add_command(label="regen necklace", command=wearregen)

def Save():
    global fight
    fight = "save"
    root.destroy()

def Load():
    global fight
    fight = "load"
    root.destroy()

root = Tk()

menu = Menu(root)
root.config(menu=menu)

File = Menu(menu, tearoff=0)
menu.add_cascade(label="File", menu=File)
File.add_command(label="save", command=Save)
File.add_command(label="load", command=Load)
File.add_separator()
File.add_command(label="exit", command=quit)

inv = Menu(menu, tearoff=0)
menu.add_cascade(label="Inv", menu=inv)
inv.add_command(label="Potions", command=potions)
inv.add_command(label="Ethers", command=ethers)
inv.add_separator()
inv.add_command(label="rest", command=rest)


equip = Menu(menu, tearoff=0)
menu.add_cascade(label="equip", menu=equip)
for x in available:
    if armor == 0 and x == 0:
        equip.add_command(label="clothes*", command=clothes)
    if armor != 0 and x == 0:
        equip.add_command(label="clothes", command=wearclothes)
    if armor == 1 and x == 1:
        equip.add_command(label="leather armor*", command=leather)
    if armor != 1 and x == 1:
        equip.add_command(label="leather armor", command=wearleather)
    if armor == 2 and x == 2:
        equip.add_command(label="chainmail*", command=chain)
    if armor != 2 and x == 2:
        equip.add_command(label="chainmail", command=wearchain)
equip.add_separator()
for x in held:
    if sword == 0 and x == 0:
        equip.add_command(label="dagger*", command=dagger)
    if sword != 0 and x == 0:
        equip.add_command(label="dagger", command=wielddagger)
    if sword == 1 and x == 1:
        equip.add_command(label="short sword*", command=short)
    if sword != 1 and x == 1:
        equip.add_command(label="short sword", command=wieldshort)
    if sword == 2 and x == 2:
        equip.add_command(label="long sword*", command=long)
    if sword != 2 and x == 2:
        equip.add_command(label="long sword", command=wieldlong)
equip.add_separator()
for x in necklace:
    if neck == 1 and x == 1:
        equip.add_command(label="bare neck*", command=neck)
    if neck != 1 and x == 1:
        equip.add_command(label="bare neck", command=wearneck)
    if neck == 2 and x == 2:
        equip.add_command(label="rejuv necklace*", command=rejuv)
    if neck != 2 and x == 2:
        equip.add_command(label="rejuv necklace", command=wearrejuv)
    if neck == 3 and x == 3:
        equip.add_command(label="regen necklace*", command=regen)
    if neck != 3 and x == 3:
        equip.add_command(label="regen necklace", command=wearregen)

app = App(root)

root.title ("movement")
root.geometry('300x200+50+50')
root.mainloop()

Recommended Answers

All 4 Replies

I don't see "equip" declared anywhere so there is no way to tell what equip.delete() is trying to do, but there is too much code=too much wasted time, to sort through. Also, a dictionary container is your friend here. Pretty much all of the if statements can be replaced with a dictionary, and all of the variables at the beginning should be a dictionary or list so you only pass around one container. A simple example for setting the textbox using one function and a dictionary that is much more readable IMHO. The same can be done for armor, sword, etc.

game_dict = {}
game_dict['area'] = 0
game_dict['sword'] = 0
game_dict['pots'] = 20

text_dict = {}
text_dict[1] = ["You have", "pots" ,"potions."]
text_dict[3] = ["Rested"]
text_dict[4] = ["At least you're not naked"]  ## spelling corrected

def textbox_conf(text):
    print "\ntext is always set to -1 and fg is always 'black'"
    list_to_print = text_dict[text] 
    print "textbox.configure test =", list_to_print[0],
    next_el = 1
    if len(list_to_print) > 2:    ## we have a member of game_dict to print
        game_dict_index = list_to_print[1]
        print game_dict[game_dict_index],
        next_el = 2
    for x in range(next_el, len(list_to_print)):
        print list_to_print[x],
    print

text = 1
textbox_conf(text)

text = 3
textbox_conf(text)

text = 1
game_dict['pots'] = 30
textbox_conf(text)

I've never seen the dictionary container so I'm going to research that a bit, that might help but near the very bottom I created the menu,

equip = Menu(menu, tearoff=0)
menu.add_cascade(label="equip", menu=equip)

and everything worked but the necklaces.
Thanks for the tip on dictionary containers.

Cleaned up the code for my own satisfaction so that all dictionary entries are of the same format, i.e. a list as the second element that can contain zero or more indexes to the game_dict.

regen() is defined on line 597, wearregen() on line 601. Both are used above that so should yield some kind of undefined error message.

game_dict = {}
game_dict['area'] = 0
game_dict['sword'] = 0
game_dict['pots'] = 20
game_dict['first'] = 'Harry'
game_dict['last'] = 'Palms'
 
text_dict = {}
text_dict[0] = ["Welcome ", ['first','last'], "to the world of slime fighter."]
text_dict[1] = ["You have ", ["pots"] ,"potions."]
text_dict[3] = ["Rested", []]
text_dict[4] = ["At least you're not naked", []]  ## spelling corrected
 
def textbox_conf(text):
    print "\ntext is always set to -1 and fg is always 'black'"
    list_to_print = text_dict[text] 
    text_string = list_to_print[0]
    for index in list_to_print[1]:     ## members of game_dict to print
       text_string += str(game_dict[index]) + " "
    for x in range(2, len(list_to_print)):
        text_string += list_to_print[x]
    print "textbox.configure test =", text_string
 
text = 1
textbox_conf(text)
 
text = 3
textbox_conf(text)
 
text = 1
game_dict['pots'] = 30
textbox_conf(text)

text = 0
textbox_conf(text)

OK well thanks for the dictionary thing I've started using that and the necklace issue is resolved I don't know how but no complaints.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.