Lemma Soft Forums

Supporting creators of visual novels and story-based games since 2003.


Visit our new games list, blog aggregator, IRC, and wiki.
Activation problem? Email [email protected]
It is currently Thu May 23, 2013 4:55 am

All times are UTC - 5 hours [ DST ]


Forum rules


Ask questions about one topic per thread, and use a descriptive subject. "NotImplemented error in script.rpy" is a good subject, "Tom's problems" is not. Remember to include all of traceback.txt or error.txt when reporting a problem, as well as the relevant lines of script. Use the [code] tag to format scripts.



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sat Jan 14, 2012 1:44 am 
Newbie

Joined: Sun Jan 16, 2011 5:43 pm
Posts: 15
Basically, I need to set a variable for time. A number. That I can decrease by one, and then test to see if it equals zero to see if a day ends, based on what choices a person makes during the day.

I've tried simply making it somthing like....

Code:
    $ test = "0"


Followed by....

Code:
   $ test += 1


When applicable... but unlike in the inventory and money page of the wiki (http://www.renpy.org/wiki/renpy/doc/coo ... ney_System), it had issues with the second line of code there, and refused to add the one to the value. Can anyone explain to me a way to do this? If possible, one that could be easily repeatable?

This is the full error code I got, for the record:
Quote:
I'm sorry, but an uncaught exception occurred.

TypeError: cannot concatenate 'str' and 'int' objects

While running game code:
- script at line 25 of C:\Users\ProxyPawaa\Desktop\Folders\Game Development\Apples and Oranges; Dawn/game/script.rpy
- python at line 25 of C:\Users\ProxyPawaa\Desktop\Folders\Game Development\Apples and Oranges; Dawn/game/script.rpy.

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

File "C:\Users\ProxyPawaa\Desktop\Folders\renpy-6.11.2\renpy\bootstrap.py", line 270, in bootstrap
File "C:\Users\ProxyPawaa\Desktop\Folders\renpy-6.11.2\renpy\main.py", line 310, in main
File "C:\Users\ProxyPawaa\Desktop\Folders\renpy-6.11.2\renpy\main.py", line 93, in run
File "C:\Users\ProxyPawaa\Desktop\Folders\renpy-6.11.2\renpy\execution.py", line 259, in run
File "C:\Users\ProxyPawaa\Desktop\Folders\renpy-6.11.2\renpy\ast.py", line 574, in execute
File "C:\Users\ProxyPawaa\Desktop\Folders\renpy-6.11.2\renpy\python.py", line 957, in py_exec_bytecode
File "C:\Users\ProxyPawaa\Desktop\Folders\Game Development\Apples and Oranges; Dawn/game/script.rpy", line 25, in <module>
TypeError: cannot concatenate 'str' and 'int' objects

While running game code:
- script at line 25 of C:\Users\ProxyPawaa\Desktop\Folders\Game Development\Apples and Oranges; Dawn/game/script.rpy
- python at line 25 of C:\Users\ProxyPawaa\Desktop\Folders\Game Development\Apples and Oranges; Dawn/game/script.rpy.

Ren'Py Version: Ren'Py 6.11.2b


Something where I could add a minimum and maximum the number can go to as well would be just peachy. >.< I've been messing with this for about an hour now.... Thanks to anyone who helps!


Top
 Profile Send private message  
 
PostPosted: Sat Jan 14, 2012 1:57 am 
Eileen-Class Veteran
User avatar

Joined: Sat Apr 23, 2011 2:43 pm
Posts: 1086
Completed: Ristorante Amore, The Elevator, SPLENDIDEST OTOGE
Projects: Break Chance Memento, Swan Grimoire
Organization: Cyanide Tea
It's because you're putting quotes around the 0 in the first line, so you're making the variable a string. So then when you try to add to it, it won't let you because you can't add strings and integers like that. (which is exactly what the error message is telling you) Remove the quotations and it should work.

_________________
1/2 of Cyanide Tea | BCM | Ristorante Amore | The Elevator | @Twitter


Top
 Profile Send private message  
 
PostPosted: Sat Jan 14, 2012 2:01 am 
Newbie

Joined: Sun Jan 16, 2011 5:43 pm
Posts: 15
Thank you Camille!!! That explains everything, and helped me fix all the issues.

The only thing now I'd like to do in top of this, is make a maximum for the number, and a minimum. Is that at all possible without some long python code at the start?


Top
 Profile Send private message  
 
PostPosted: Sat Feb 11, 2012 1:48 pm 
Miko-Class Veteran
User avatar

Joined: Sun Dec 20, 2009 10:15 am
Posts: 608
Completed: The Loop
Projects: The Madness, In Orbit
Organization: Gliese Productions
Long python code? No. But this reasonably short one should solve your problem.
Code:
python:
    test = 0
    def addtest():
        if test < max:
            test += 1
    def subtracttest():
        if 0 < test:
            test -= 1

label scene:
    "Eileen" "I'm going to add one point."
    $ addtest()
    "Eileen" "I'm going to remove one point."
    $ subtracttest()

Been a while since I did python, someone correct me if I'm wrong. -_-''

_________________
"Why would you even need so many characters?!!"
~Me. Just now. At you.
Gliese Productions
If anybody is interested in writing blog posts for Gliese, drop me a line. Website needs more traffic/content.
Bloggers will get free copies of Gliese VNs once we go commercial.


Top
 Profile Send private message  
 
PostPosted: Sun Feb 12, 2012 1:07 pm 
Miko-Class Veteran
User avatar

Joined: Thu May 14, 2009 8:15 pm
Posts: 585
Projects: Castle of Arhannia
the code greeny posted works if you just want to set a limit to what values a variable can have.

however, you said in your first post you wanted to check if it had reached the limit right?

that would be more like this:
Code:
$ test += 1
if test >= 3:
    jump end_day


if you wanted to make a python function to do this for you it'd be something like this
Code:
python:
    test = 0
    def addtest():
        test += 1
        if test > 3:
            return True
        return False

label scene:
    Eileen "now let's see if we have any time left"
    if addtest():
        Eileen "nope, where out of time"
    else:
        Eileen "Yep, we still have some left"

I would suggest avoiding that unless you have to though, as it's not that much effort to just copy and paste the simpler code where ever you need it.


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Protected by Anti-Spam ACP
Powered by phpBB® Forum Software © phpBB Group