Here is how I define the class.
The view is True if the item is available in stores, while if the bought one is True, then the item is bought and no longer available in stores. However, the item can be worn inside the wardrobe.
Code: Select all
class Top(store.object):
def __init__(self, name, style, image="", imagehover="", bigimage="", view=True, bought=False, cost=0):
self.name = name
self.style = style
self.image=image # image file to use for this item
self.imagehover=imagehover
self.bigimage=bigimage
self.view=view
self.bought=bought
self.cost=cost # how much does it cost in shops?
This below is the top screen part.
Code: Select all
screen topinventoryscreen:
tag menu
use dressupcommand
# default selected_top = 0
$ x = 627 # coordinates of the top left item position
$ y = -26
$ i = 0
$ next_top_inv_page = top_inv_page + 1
$ before_top_inv_page = top_inv_page - 1
$ maximum_top_inv_page = int(len(wardrobetop.tops)/12)
if next_top_inv_page > maximum_top_inv_page:
$ top_inv_page = maximum_top_inv_page
if before_top_inv_page < 0:
$ top_inv_page = 0
$ sorted_tops = sorted([top for top in wardrobetop.tops if top.bought])
for top in sorted_tops:
if i+1 <= (top_inv_page+1)*12 and i+1>top_inv_page*12:
$ x += 128
if i%4==0: ## PENGGANTIAN BARIS
$ y += 145
$ x = 627
$ pic = top.image
$ pichover = top.imagehover
imagebutton idle pic hover pichover xpos x ypos y action [SetVariable("top", top), top_addstyle, SetVariable("selected_top",1), SetVariable("showtopbigimage", top.bigimage), Show("displayclothes")]
$ i += 1
if len(wardrobetop.tops)>12: ## berarti lebih dari 1 page pasti!
imagebutton:
xpos 994
ypos 599
idle "pref/afteridle.png"
hover "pref/afterhover.png"
action [SetVariable('top_inv_page', next_top_inv_page), Show("topinventoryscreen")]
if len(wardrobetop.tops)>24: ## berarti lebih dari 2 page pasti! => tambahan "before page"
imagebutton:
xpos 694
ypos 599
idle "pref/beforeidle.png"
hover "pref/beforehover.png"
action [SetVariable('top_inv_page', before_top_inv_page), Show("topinventoryscreen")]
Code: Select all
$ sorted_tops = sorted([top for top in wardrobetop.tops if top.bought])
for top in sorted_tops:
if i+1 <= (top_inv_page+1)*12 and i+1>top_inv_page*12:
$ x += 128
if i%4==0: ## PENGGANTIAN BARIS
$ y += 145
$ x = 627
$ pic = top.image
$ pichover = top.imagehover
imagebutton idle pic hover pichover xpos x ypos y action [SetVariable("top", top), top_addstyle, SetVariable("selected_top",1), SetVariable("showtopbigimage", top.bigimage), Show("displayclothes")]
$ i += 1
However, the problem persists in the next lines:
Code: Select all
if len(wardrobetop.tops)>12: ## berarti lebih dari 1 page pasti!
imagebutton:
xpos 994
ypos 599
idle "pref/afteridle.png"
hover "pref/afterhover.png"
action [SetVariable('top_inv_page', next_top_inv_page), Show("topinventoryscreen")]
if len(wardrobetop.tops)>24: ## berarti lebih dari 2 page pasti! => tambahan "before page"
imagebutton:
xpos 694
ypos 599
idle "pref/beforeidle.png"
hover "pref/beforehover.png"
action [SetVariable('top_inv_page', before_top_inv_page), Show("topinventoryscreen")]
Is there something I can do to fix this problem?
Or is this code so messy that it's beyond help?
Thank you!
I appreciate any kind of help!
Also, I'm sorry if I can't explain it well ><