xboxscene.org forums

Author Topic: Help Me Do Minor Mod To This Script?  (Read 42 times)

timdog82001

  • Archived User
  • Sr. Member
  • *
  • Posts: 446
Help Me Do Minor Mod To This Script?
« on: February 01, 2007, 08:37:00 PM »

I'm trying to modify the Kaleidascrape script to work for some new trivia slides I got.  I know almost nothing about python, I basically just tried to figure it out by looking through the script and seeing what was doing what.   Anyway, part of the script starts a slideshow, and some slides are supposed to be grouped together, in groups of two for the original script, because with the trivia questions, there's a question, and then an answer.  In a new trivia slide pack I got, there is still a question and answer, but also a CLUE inbetween.  So, I'm trying to make it so it will group these new ones together as well.  The old slides use an A, B system, where like 101a.jpg would be the question and 101b.jpg would be the answer, a would show first and then b.  I want to continue to use this, but also add the ability to do the three slide thing.  The way the 3 slide groups are labels is q for question, c for clue, and r for response, so it would go, for example, 101q.jpg, then 101c.jpg, then 101r.jpg (the 101 is just filling the place for any arbitrary file name, by the way).  Anyway, below you can see my efforts to achieve this, however it doesn't like it.  I get a "TypeError: an integer is required" message for the line that says randInfo3 = re.sub(r'([^-]+)q.jpg', r'\1r.jpg', r'\1c.jpg', str(randInfo3))

I'm sure its a simple fix, but if somebody could help me out it would be great.  By the way, the lines I added are all the lines referring to randInfo3, 4 and 5, and match3, 4 and 5

#Function to grab Trivia#

trivialist = index(triviaDir);

count = (len(trivialist))
queuecount = 0
mytrivia = Trivia()

xbmc.Player().play(mlist)
time.sleep(1)
mytrivia.show()
while queuecount < trivia_num:
    randtriv = random.randint(1, count)
    randInfo = trivialist[randtriv]
    randInfo1 = trivialist[randtriv]
    randInfo2 = trivialist[randtriv]
    randInfo3 = trivialist[randtriv]
    randInfo4 = trivialist[randtriv]
    randInfo5 = trivialist[randtriv]
    randInfo1 = re.sub(r'([^-]+)b.jpg', r'\1a.jpg', str(randInfo1))
    randInfo2 = re.sub(r'([^-]+)a.jpg', r'\1b.jpg', str(randInfo2))
    randInfo3 = re.sub(r'([^-]+)q.jpg', r'\1r.jpg', r'\1c.jpg', str(randInfo3))
    randInfo4 = re.sub(r'([^-]+)r.jpg', r'\1q.jpg', r'\1c.jpg', str(randInfo4))
    randInfo5 = re.sub(r'([^-]+)c.jpg', r'\1q.jpg', r'\1r.jpg', str(randInfo5))
    match = re.match('.*?b.jpg', randInfo)
    match2 = re.match('.*?a.jpg', randInfo)
    match3 = re.match('.*?q.jpg', randInfo)
    match4 = re.match('.*?r.jpg', randInfo)
    match5 = re.match('.*?c.jpg', randInfo)
    if match:
        mytrivia.display(randInfo1)
        mytrivia.display(randInfo2)
    elif match2:
        mytrivia.display(randInfo1)
        mytrivia.display(randInfo2)
    elif match3:
        mytrivia.display(randInfo3)
        mytrivia.display(randInfo4)
        mytrivia.display(randInfo5)
    elif match4:
        mytrivia.display(randInfo3)
        mytrivia.display(randInfo4)
        mytrivia.display(randInfo5)
    elif match5:
        mytrivia.display(randInfo3)
        mytrivia.display(randInfo4)
        mytrivia.display(randInfo5)
    else:
        mytrivia.display(randInfo1)
    queuecount = queuecount + 1
mytrivia.close()
xbmc.Player().stop(mlist)
del mytrivia
Logged