Fixing a someone else game I am playing and learning

slik4x4

New Member
Nov 3, 2019
14
5
Good day all.

I am playing the game Harem Camp for the first time, and well, it is full of bugs and typo's. I have been enjoying trying to tackle the bugs and have fixed quite a few. I an enjoying learning about the code side, since with an exception of a website I coded in html back in the 90's, I don't know anything about code. No plans of creating a game or anything, but maybe my own mods or something, or just fixing games I have fun playing.

Anyway, there is a error I can not seem to find a fix for. I will attach traceback of the error, but essentially it is a code info. It is having problem with no int. I don't see the problem, how ever the question is, should a randint work as an int?

Thanks for the help.
 

slik4x4

New Member
Nov 3, 2019
14
5

I'm sorry, but an uncaught exception occurred.

While running game code:
File "game/rpg.rpy", line 1634, in script
$ player.money+=option
File "game/rpg.rpy", line 1634, in <module>
$ player.money+=option
TypeError: unsupported operand type(s) for +=: 'int' and 'unicode'

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

Full traceback:
File "game/rpg.rpy", line 1634, in script
$ player.money+=option
File "renpy/ast.py", line 923, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "renpy/python.py", line 2235, in py_exec_bytecode
exec(bytecode, globals, locals)
File "game/rpg.rpy", line 1634, in <module>
$ player.money+=option
TypeError: unsupported operand type(s) for +=: 'int' and 'unicode'

Windows-10-10.0.19041
Ren'Py 7.4.8.1895
Harem Camp 0.10.1
Fri Sep 3 10:24:34 2021

 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,959
16,195
Anyway, there is a error I can not seem to find a fix for. I will attach traceback of the error, but essentially it is a code info.
The default of Ren'py's traceback is that they are mostly oriented to help Ren'py author, more than game authors. Therefore they generally flood you under tons of reference to the internal code, and sometimes don't even tell you where in the game code the error is happening.
But in this particular case, it's a relatively explicit error. It tell you exactly where the error happen (line 1634 of the "rpg.rpy" file), give you the full line in error ($ player.money+=option), and tell you precisely what is wrong (player.money is an integer number, while option is an Unicode string). Said otherwise, you're trying to proceed something like x = 42 + "forty two", what will not works.
Therefore, either option is not the variable to use in this addition, or the value that was assigned to it isn't correct.


[...] should a randint work as an int?
It return an int, yes.


This being said, the forum have a whole section dedicated to development, what include modding and this kind of questions.
 

slik4x4

New Member
Nov 3, 2019
14
5
Thank you for the reply. I will definitely check out that forum.

So here is the option code.

$ option=renpy.random.randint(43,126)

I will do a search and try to fix it, but any help here would be great.

Thanks again.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,959
16,195
So here is the option code.

$ option=renpy.random.randint(43,126)
No, this isn't the "option code".

Here's the code of the game:
Python:
label rpg_battle_victory:
    "The enemies have been defeated!"
    $ option=renpy.random.randint(43,126)  # <- the 'option code' you talk about
    if rpg_mode==1:
[...]
    if rpg_mode==3:
        $ option1=renpy.random.choice([item_hard_wood,item_iron_ore,item_bronze_ore,item_cards_gnk,item_stone,item_silver_ore,item_gold_ore])
        "You found some [option1.name]"
        $ player.inventory.add_item(option1)
        $ option=villains[0].name   # <- The source of the error.
        if option=="Slasher":
            show slasher_defeated as monster at left
            monster "You fucking kids! God damn it!"
        if option=="Goalie":
            show goalie_defeated as monster at left
            monster "Hurrrffff.....!"
        if option=="Faker":
            show faker_defeated as monster at left
            monster "Stop stealing {i}my{/i} life!"
        if option=="Skeleton":
            # award random item
            pass
        elif option=="Stuffie":
            pass
        else:
            $ player.earned_upgrade+=.5
            $ player.money+=option       # <- Here is the line 1634
            "You dial Kit's number and soon the fox girl shows up to take the monster home."
            show kit_sad as kit at right with pixellate
            kit "Thank you for incapacitating him. We'll get him out of here. {w}Sorry!"
            monster "Awww."
Unless there's a villain named with an integer, what would throw another error somewhere else, there's just no way this code could works.
 

slik4x4

New Member
Nov 3, 2019
14
5
Ahhh, I get it. So with out some coding, it just won't work.

Thanks again for your time and patience.