New cookbook candidate- need experienced coders' opinions

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
ParsonSyunOwen
Regular
Posts: 27
Joined: Sun Jun 08, 2008 6:01 pm
Contact:

New cookbook candidate- need experienced coders' opinions

#1 Post by ParsonSyunOwen » Tue Jul 15, 2008 2:54 pm

For the past while, I've been working on some code designed to help reproduce a Fighting Fantasy gamebook using Ren'Py. You've helped me with some of the more difficult bits. Now I've finally got it to the point where it does everything I want, and does it correctly. I'd like to share it with the community, but I'm not a terribly experienced coder, and I'd like to make sure I haven't made any mistakes that will bite future developers in the butt. I've composed a brief demo that shows off the new features, and attached the source code to this post. Give it a look and let me know how it could be improved.

[EDIT: Corrected version posted]
Attachments
GCDemo.zip
(715.01 KiB) Downloaded 1796 times
Last edited by ParsonSyunOwen on Wed Jul 16, 2008 6:38 pm, edited 2 times in total.

User avatar
Subarashi
Newbie
Posts: 11
Joined: Mon Jul 31, 2006 2:08 am
Projects: House MD visual novel (Nearing end of script writing)
Contact:

Re: New cookbook candidate- need experienced coders' opinions

#2 Post by Subarashi » Tue Jul 15, 2008 11:30 pm

Ah, Fighting Fantasy. I've never read any of those, but I read a bunch of the Lone Wolf series when I was younger, so I hope your code works out.
"That thing you burnt up isn't important to me. It's the fluid catalytic
cracking unit. It made shoes for orphans. Nice job breaking it, hero."

"There really was a cake."
http://subarashiproductions.deviantart.com/
http://subarashi-productions.blogspot.com/
http://otakuencyclopedia.pbwiki.com/

maselphie
Regular
Posts: 71
Joined: Fri May 23, 2008 2:12 pm
Projects: By The Lake, Seraphine
Location: USA
Contact:

Re: New cookbook candidate- need experienced coders' opinions

#3 Post by maselphie » Wed Jul 16, 2008 5:51 pm

Wow, I'm impressed. I like this script/framework very much. I would happily play a game in this way. ^_^
However, I did stumble upon 2 errors, once while right clicking (accidentally, mind you):

Code: Select all

 File "C:\Documents and Settings\HP_Administrator\Desktop\visual novel\renpy-6.6.2-full\renpy-6.6.2\renpy\loader.py", line 274, in load
Exception: Couldn't find file 'covertemp.jpg'.
And once while drinking a potion:

Code: Select all

File "C:\Documents and Settings\HP_Administrator\Desktop\visual novel\renpy-6.6.2-full\renpy-6.6.2\renpy\script.py", line 464, in lookup
ScriptError: could not find label 'CheckHP'.
Other than that, I'll be waiting eagerly for the finished version, because I just might find a use for it!
I have switched accounts to Aleema.

User avatar
x__sinister
Regular
Posts: 153
Joined: Thu Aug 23, 2007 5:34 pm
Projects: Modus Operandi, Grim
Contact:

Re: New cookbook candidate- need experienced coders' opinions

#4 Post by x__sinister » Wed Jul 16, 2008 6:12 pm

This is what I got. I didn't go far into the demo; just until I equipped the sword. I'm not sure if it makes a difference, but I am on windows vista. That might cause problems, or whatever. [shrug]

Code: Select all

I'm sorry, but an exception occured while executing your Ren'Py
script.

Exception: Couldn't find file 'covertemp.jpg'.

While running game code:
 - script at line 41 of C:\Documents and Settings\Steven\My Documents\muriamisc\vn\dreams\renpy-6.6.2\GCDemo/game/script.rpy
 - python at line 177 of renpy-6.6.2/common/00nvl_mode.rpy.
 - script at line 31 of renpy-6.6.2/common/00menus.rpy
 - python at line 31 of renpy-6.6.2/common/00menus.rpy.

-- Full Traceback ------------------------------------------------------------

  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\bootstrap.py", line 210, in bootstrap
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\main.py", line 303, in main
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\main.py", line 92, in run
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\execution.py", line 199, in run
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\ast.py", line 343, in execute
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\exports.py", line 469, in say
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\character.py", line 535, in __call__
  File "renpy-6.6.2/common/00nvl_mode.rpy", line 177, in do_display
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\character.py", line 308, in display_say
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\ui.py", line 58, in interact
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\display\core.py", line 1274, in interact
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\display\core.py", line 1709, in interact_core
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\game.py", line 272, in call_in_new_context
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\execution.py", line 199, in run
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\ast.py", line 1211, in execute
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\python.py", line 909, in py_eval
  File "renpy-6.6.2/common/00menus.rpy", line 31, in <expression>
  File "renpy-6.6.2/common/_layout/classic_yesno_prompt.rpym", line 52, in yesno_prompt
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\ui.py", line 58, in interact
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\display\core.py", line 1274, in interact
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\display\core.py", line 1410, in interact_core
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\display\core.py", line 241, in predict
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\display\core.py", line 215, in visit_all
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\display\core.py", line 241, in <lambda>
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\display\im.py", line 343, in predict_one
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\display\im.py", line 133, in get
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\display\im.py", line 372, in load
  File "C:\Users\Alicia\Downloads\renpy-6.6.2\renpy\loader.py", line 274, in load
Exception: Couldn't find file 'covertemp.jpg'.

While running game code:

Ren'Py Version: Ren'Py 6.6.2b
Image
A literate roleplaying community.

ParsonSyunOwen
Regular
Posts: 27
Joined: Sun Jun 08, 2008 6:01 pm
Contact:

Re: New cookbook candidate- need experienced coders' opinions

#5 Post by ParsonSyunOwen » Wed Jul 16, 2008 6:37 pm

Argh, that was dumb of me. covertemp is a file that was suppossed to be in the .zip, but wasn't. The other problem is a function that I changed the name of midway through production and forgot to check. Sorry. Updated to correct those two.

User avatar
Serkai
Regular
Posts: 58
Joined: Fri Jan 18, 2008 9:35 am
Projects: Teo the Deciever, Shades of Grey and Junk Story(SoG and JS are fanworks)
Contact:

Re: New cookbook candidate- need experienced coders' opinions

#6 Post by Serkai » Tue Dec 16, 2008 9:03 am

Don't know if this is still active or what, but while looking for someway to make the battles more random in my game, I stumbled across this topic, which was more or less what I was looking for. Now, the reason I'm typing this is because while playing around with it trying to get it to fit my needs alittle better, I ran upon an error (that only appears when I try to get the game to run using my own version of the script, so there's nothing wrong with the original) that when, during combat, instantly kills the 'hero' no matter what I do >_<;

How, here's the code, and if anyone can help me figure out what's wrong, I'd be happy.

Code: Select all

init:
    python hide:
        def CombatIn():
            if CombatStatus== 'starting':
                ui.fixed()
                ui.at(Move((-0.3, 0.1), (0.14, 0.1), 0.5))
                ui.image(HeroPortrait)
                ui.at(Move((1.0, 0.1), (0.60, 0.1), 0.5))
                ui.image(FoePortrait)
                ui.at(FactorZoom(0.0, 1.0, 0.5, xpos=0.43, ypos=0.3, opaque=False))
                ui.image(CombatVS)
                ui.close()
            elif CombatStatus== 'starting2':
                ui.fixed()
                ui.at(Move((-0.3, 0.1), (0.14, 0.1), 0.5))
                ui.image(HeroPortrait2)
                ui.at(Move((1.0, 0.1), (0.60, 0.1), 0.5))
                ui.image(FoePortrait)
                ui.at(FactorZoom(0.0, 1.0, 0.5, xpos=0.43, ypos=0.3, opaque=False))
                ui.image(CombatVS)
                ui.close()
        config.overlay_functions.append(CombatIn)
        def CombatOn():
            if CombatStatus== 'on':
                ui.fixed()
                ui.at(Position(xpos=0.14, ypos=0.1, xanchor=0.0, yanchor=0.0))
                ui.image(HeroPortrait)
                ui.at(Position(xpos=0.60, ypos=0.1, xanchor=0.0, yanchor=0.0))
                ui.image(FoePortrait)
                ui.at(Position(xpos=0.43, ypos=0.3, xanchor=0.0, yanchor=0.0))
                ui.image(CombatVS)
                ui.close()
            elif CombatStatus== 'on2':
                ui.fixed()
                ui.at(Position(xpos=0.14, ypos=0.1, xanchor=0.0, yanchor=0.0))
                ui.image(HeroPortrait2)
                ui.at(Position(xpos=0.60, ypos=0.1, xanchor=0.0, yanchor=0.0))
                ui.image(FoePortrait)
                ui.at(Position(xpos=0.43, ypos=0.3, xanchor=0.0, yanchor=0.0))
                ui.image(CombatVS)
                ui.close()
        config.overlay_functions.append(CombatOn)
        def CombatOut():
            if CombatStatus== 'ending':
                ui.fixed()
                ui.at(Move((0.14, 0.1), (-0.3, 0.1), 0.5))
                ui.image(HeroPortrait)
                ui.at(Move((0.60, 0.1), (1.0, 0.1), 0.5))
                ui.image(FoePortrait)
                ui.at(FactorZoom(1.0, 0.0, 0.5, xpos=0.43, ypos=0.3, opaque=False))
                ui.image(CombatVS)
                ui.close()
            elif CombatStatus== 'ending2':
                ui.fixed()
                ui.at(Move((0.14, 0.1), (-0.3, 0.1), 0.5))
                ui.image(HeroPortrait)
                ui.at(Move((0.60, 0.1), (1.0, 0.1), 0.5))
                ui.image(FoePortrait)
                ui.at(FactorZoom(1.0, 0.0, 0.5, xpos=0.43, ypos=0.3, opaque=False))
                ui.image(CombatVS)
                ui.close()
        config.overlay_functions.append(CombatOut)

label BasicFight:
    python:
        display_charsheet = True
        CombatStatus = 'starting'
        FoePortrait= FoeData.pop(0)
        renpy.restart_interaction()
        renpy.pause(1.4)
        CombatStatus = 'on'
        renpy.restart_interaction()
        FoeName = FoeData.pop(0)
        FoeSkill = FoeData.pop(0)
        FoeCurrentHP = FoeData.pop(0)
        special_rules = FoeData
        HeroCombatSkill = HeroSkill
        CombatResolved = False
        while CombatResolved == False:
            CombatRatio = HeroCombatSkill - FoeSkill
            if CombatRatio > 0:
                CombatRatioDisplay= '+'+str(CombatRatio)
            else:
                CombatRatioDisplay= str(CombatRatio)
            ui.fixed()
            ui.vbox(xpos=0.27, ypos=0.65, xanchor=0.5, yanchor=0.0)
            ui.text(HeroName)
            ui.hbox()
            ui.text("Power: ", size=14)
            ui.text(str(HeroCombatSkill), size=14)
            ui.close() ### HeroCombatSkill Line
            ui.hbox()
            ui.text("Stamina: ", size=14)
            ui.text(str(HeroCurrentHP), size=14)
            ui.close() ###HeroStamina Line
            ui.close() ###Hero Column
            ui.text("Advantage", size=27, xpos=0.5, ypos=0.63, xanchor=0.5, yanchor=0.0)
            ui.text(CombatRatioDisplay, size=27, xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
            ui.vbox(xpos=0.73, ypos=0.65, xanchor=0.5, yanchor=0.0)
            ui.text(FoeName)
            ui.hbox()
            ui.text("Power: ", size=14)
            ui.text(str(FoeSkill), size=14)
            ui.close() ###FoeSkill Line
            ui.hbox()
            ui.text("Stamina: ", size=14)
            ui.text(str(FoeCurrentHP), size=14)
            ui.close() ###FoeStam Line
            ui.close() ###Foe Column
            ui.close() ###Stats area
            ui.vbox(xpos=0.5, ypos=0.75, xanchor=0.5, yanchor=0.0)
            ui.textbutton("Attack", clicked=ui.returns('attack'))
            ui.textbutton("Defend", clicked=ui.returns('defend')) #added
            if 'escapable' in special_rules:
                ui.textbutton("Escape!", clicked=ui.returns('escape'))
            if 'Strength Potion' in inven:
                ui.textbutton("Drink a Strength Potion", clicked=ui.returns('SPotion'))
            ui.close()
            ChosenAction=ui.interact()
            if ChosenAction == 'attack':
                DiceInGroups= [3] #altered from 2
                AttackRoll=reduce(add, rolld6(DiceInGroups, ' ', 'combat', 0.425, 0.5)) + CombatRatio
                HeroHits = False
                FoeHits = False
                if AttackRoll <= 7: #altered from 7
                    FoeHits = True
                if AttackRoll >= 7: #altered from 7
                    HeroHits= True
                if HeroHits== True:
                    ui.text("%(HeroName)s hits %(FoeName)s for 5 damage!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                else:
                    ui.text("%(HeroName)s misses!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                renpy.pause(0.8)
                if FoeHits == True:
                    ui.text("%(FoeName)s hits %(HeroName)s for 5 damage!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                else:
                    ui.text("%(FoeName)s misses!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                renpy.pause(0.8)
                if HeroHits== True:
                    FoeCurrentHP -= 5
                if FoeHits== True:
                    HeroCurrentHP -= 5
            elif ChosenAction == 'defend':
                FoeHits = True
                ui.text("%(HeroName)s defends." % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                renpy.pause(0.8)
                ui.text("%(FoeName)s hits %(HeroName)s for 1 damage!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                renpy.pause(0.8)
                if FoeHits== True:
                    HeroCurrentHP -=1
            elif ChosenAction == 'escape':
                CombatResult= 'escaped'
                CombatResolved= True
                HeroCurrentHP -= 4
                ui.text("%(HeroName)s escapes the fight!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                renpy.pause(0.8)
                ui.text("But %(FoeName)s hits with a parting shot for 4 damage!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                renpy.pause(0.8)
            elif ChosenAction == 'SPotion':
                inven.remove('Strength Potion')
                HeroCombatSkill += 2
                ui.text("%(HeroName)s ducks back out of combat and quickly gulps a Strength Potion!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                renpy.pause(0.8)
                ui.text("%(HeroName)s's Skill is temporarily increased by 2!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                renpy.pause(0.8)
            if HeroCurrentHP <= 0:
                CombatResolved= True
                CombatResult = 'lose'
                ui.text("%(HeroName)s is defeated!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                renpy.pause(0.5)
            elif FoeCurrentHP <= 0:
                CombatResolved= True
                CombatResult= 'win'
                ui.text("%(FoeName)s is defeated!" %globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                renpy.pause(0.8)
        CombatStatus = 'ending'
        renpy.restart_interaction()
        renpy.pause(0.8)
        CombatStatus = 'off'
        display_charsheet = False
        renpy.restart_interaction()
    return

 

label BasicFight2:
    python:
        display_charsheet = True
        CombatStatus = 'starting2'
        FoePortrait= FoeData.pop(0)
        renpy.restart_interaction()
        renpy.pause(1.4)
        CombatStatus = 'on2'
        renpy.restart_interaction()
        FoeName = FoeData.pop(0)
        FoeSkill = FoeData.pop(0)
        FoeCurrentHP = FoeData.pop(0)
        special_rules = FoeData
        HeroCombatSkill = HeroSkill # allows the Strength Potion to work as designed.
        CombatResolved = False
        while CombatResolved == False:
            CombatRatio = HeroCombatSkill - FoeSkill
            if CombatRatio > 0:
                CombatRatioDisplay= '+'+str(CombatRatio)
            else:
                CombatRatioDisplay= str(CombatRatio)
            ui.fixed()
            ui.vbox(xpos=0.27, ypos=0.65, xanchor=0.5, yanchor=0.0)
            ui.text(HeroName)
            ui.hbox()
            ui.text("Power: ", size=14)
            ui.text(str(HeroCombatSkill), size=14)
            ui.close() ### HeroCombatSkill Line
            ui.hbox()
            ui.text("Stamina: ", size=14)
            ui.text(str(HeroCurrentHP), size=14)
            ui.close() ###HeroStamina Line
            ui.close() ###Hero Column
            ui.text("Advantage", size=27, xpos=0.5, ypos=0.63, xanchor=0.5, yanchor=0.0)
            ui.text(CombatRatioDisplay, size=27, xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
            ui.vbox(xpos=0.73, ypos=0.65, xanchor=0.5, yanchor=0.0)
            ui.text(FoeName)
            ui.hbox()
            ui.text("Power: ", size=14)
            ui.text(str(FoeSkill), size=14)
            ui.close() ###FoeSkill Line
            ui.hbox()
            ui.text("Stamina: ", size=14)
            ui.text(str(FoeCurrentHP), size=14)
            ui.close() ###FoeStam Line
            ui.close() ###Foe Column
            ui.close() ###Stats area
            ui.vbox(xpos=0.5, ypos=0.75, xanchor=0.5, yanchor=0.0)
            ui.textbutton("Attack", clicked=ui.returns('attack'))
            ui.textbutton("Defend", clicked=ui.returns('defend')) #added
            ui.textbutton("Combo", clicked=ui.returns('combo')) #added
            if 'escapable' in special_rules:
                ui.textbutton("Escape!", clicked=ui.returns('escape'))
            if 'Strength Potion' in inven:
                ui.textbutton("Drink a Strength Potion", clicked=ui.returns('SPotion'))
            ui.close()
            ChosenAction=ui.interact()
            if ChosenAction == 'attack':
                DiceInGroups= [3] #altered from 2
                AttackRoll=reduce(add, rolld6(DiceInGroups, ' ', 'combat', 0.425, 0.5)) + CombatRatio
                HeroHits = False
                FoeHits = False
                if AttackRoll <= 7: #altered from 7
                    FoeHits = True
                if AttackRoll >= 7: #altered from 7
                    HeroHits= True
                if HeroHits== True:
                    ui.text("%(HeroName)s hits %(FoeName)s for 5 damage!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                else:
                    ui.text("%(HeroName)s misses!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                renpy.pause(0.8)
                if FoeHits == True:
                    ui.text("%(FoeName)s hits %(HeroName)s for 5 damage!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                else:
                    ui.text("%(FoeName)s misses!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                renpy.pause(0.8)
                if HeroHits== True:
                    FoeCurrentHP -= 5
                if FoeHits== True:
                    HeroCurrentHP -= 5
            elif ChosenAction == 'defend':
                FoeHits = True
                ui.text("%(HeroName)s defends." % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                renpy.pause(0.8)
                ui.text("%(FoeName)s hits %(HeroName)s for 1 damage!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                renpy.pause(0.8)
                if FoeHits== True:
                    HeroCurrentHP -=1
            elif ChosenAction == 'combo':
                DiceInGroups= [3] #altered from 2
                AttackRoll=reduce(add, rolld6(DiceInGroups, ' ', 'combat', 0.425, 0.5)) + CombatRatio
                HeroHits = False
                FoeHits = False
                if AttackRoll <= 11: #altered from 7
                    FoeHits = True
                if AttackRoll >= 11: #altered from 7
                    HeroHits= True
                if HeroHits== True:
                    ui.text("%(HeroName)s hits %(FoeName)s twice, for a total of 10 damage!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                else:
                    ui.text("%(HeroName)s misses!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                renpy.pause(0.8)
                if FoeHits == True:
                    ui.text("%(FoeName)s hits %(HeroName)s for 5 damage!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                else:
                    ui.text("%(FoeName)s misses!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                renpy.pause(0.8)
                if HeroHits== True:
                    FoeCurrentHP -= 10
                if FoeHits== True:
                    HeroCurrentHP -= 5
            if HeroCurrentHP <= 0:
                CombatResolved= True
                CombatResult = 'lose'
                ui.text("%(HeroName)s is defeated!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                renpy.pause(0.5)
            elif FoeCurrentHP <= 0:
                CombatResolved= True
                CombatResult= 'win'
                ui.text("%(FoeName)s is defeated!" %globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
                renpy.pause(0.8)
        CombatStatus = 'ending2'
        renpy.restart_interaction()
        renpy.pause(0.8)
        CombatStatus = 'off'
        display_charsheet = False
        renpy.restart_interaction()
    return
Me, I can make no sense of it. I created this code simply by looking at the original and copying and then testing, and this error that kills the player, I can't figure out how to solve >_<; Help me, please.

User avatar
Serkai
Regular
Posts: 58
Joined: Fri Jan 18, 2008 9:35 am
Projects: Teo the Deciever, Shades of Grey and Junk Story(SoG and JS are fanworks)
Contact:

Re: New cookbook candidate- need experienced coders' opinions

#7 Post by Serkai » Tue Dec 16, 2008 9:05 am

And yeah, I know it's shitloads of text, but for some reason, the attachment thing didn't work for me, so I had no choice but to do this ;_;

User avatar
Corylea
Newbie
Posts: 3
Joined: Mon Jun 06, 2011 11:21 pm
Completed: Medical Problems 1, Medical Problems 2 -- adventures for The Witcher
Location: Boston area, USA
Contact:

Re: New cookbook candidate- need experienced coders' opinion

#8 Post by Corylea » Tue Jul 03, 2012 12:26 am

I wanted to try this out, but the demo wouldn't even launch for me; when I tried to start it, I got this:

Image

Is there a more recent version somewhere?

Thanks!
Middle-aged woman learns to make computer games. Film at 11.

Descant-Air
Newbie
Posts: 1
Joined: Sat Feb 02, 2013 11:57 pm
Location: Canada
Contact:

Re: New cookbook candidate- need experienced coders' opinion

#9 Post by Descant-Air » Sun Feb 03, 2013 12:10 am

I got the demo to sort of work, but when I say sort of I mean I got rid of the "jump equipsword" from script.rpy as well as removing this part of the code from inventory.rpy:

Code: Select all

        for key, item in enumerate(inven):
            ui.button(clicked=ui.returns(key))
            ui.text(item)
        ui.textbutton("Return to game", clicked=ui.returns('exit'))
        ui.close()
        ui.close()
        selectedItem = ui.interact()
        if selectedItem == 'exit':
            return
        # selectedItem is now set to the list index of the item the
        # user has clicked on. We can now search for it in the master 
        # item list, below. 
        elif inven[selectedItem] == 'Healing Potion':
            renpy.call_in_new_context('UsedHealingPotion')
        elif inven[selectedItem] == 'Sword':
            renpy.call_in_new_context('UsedSword')
        elif inven[selectedItem] == 'Strength Potion':
            renpy.call_in_new_context('ExamStrengthPotion')
        else:
            renpy.call_in_new_context('InventoryError')
Something is wrong with those "return" and "elif" statements, but I haven't a clue as to what *is not good at coding* ^^"

User avatar
PyTom
Ren'Py Creator
Posts: 15165
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: New cookbook candidate- need experienced coders' opinion

#10 Post by PyTom » Sun Feb 03, 2013 12:47 am

I don't think cookbook code should be using ui functions in 2013.

Screens are more readable and generally better, and over the next year or so I plan to accelerate screens in ways that will be hard to do for ui functions.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

thishumblemosquito
Newbie
Posts: 18
Joined: Mon Feb 04, 2013 10:01 am
Contact:

Re: New cookbook candidate- need experienced coders' opinion

#11 Post by thishumblemosquito » Mon Feb 04, 2013 10:08 am

It seems to be a matter of the python code. I out-dented the code 1 level after the UI.Close and replaced it with following code (Native Ren'py?) and it now works for me. (Renpy 6.14.1, Windows 7 64bit). I only edit the Inventory.rpy code.

I was very glad to get it to work. It helps me look at inventory, randomisation and combat.

Code: Select all

 $ selectedItem = ui.interact()
    if selectedItem == 'exit':
        return
        # selectedItem is now set to the list index of the item the
        # user has clicked on. We can now search for it in the master 
        # item list, below. 
    elif inven[selectedItem] == 'Healing Potion':
        jump UsedHealingPotion
    elif inven[selectedItem] == 'Sword':
        jump UsedSword
    elif inven[selectedItem] == 'Strength Potion':
        jump ExamStrengthPotion
    else:
        jump InventoryError
    return

u10
Newbie
Posts: 1
Joined: Mon Jun 09, 2008 9:07 am
Contact:

Re: New cookbook candidate- need experienced coders' opinion

#12 Post by u10 » Wed Mar 20, 2013 9:41 am

/game/inventory.rpy, line 39
replace return with pass

Post Reply

Who is online

Users browsing this forum: Kia, MaydohMaydoh