Strange boolean problem with while

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
User avatar
Mirrodin
Regular
Posts: 114
Joined: Sun Mar 19, 2017 2:56 pm
Contact:

Strange boolean problem with while

#1 Post by Mirrodin »

Hello

I build a battle rpg and i want the player choose a spell between different in a screen overlay.

i have this is my battle rpg

Code: Select all

                while selectionattaque == 0:
                    n_fr "your turn, choose attack"
i do this for dont go until the player choose a spell on the interface

in my overlay i have this :

Code: Select all

screen gold_overlay():
     if selectionattaque == 0:
     imagebutton idle "rpg/boule_de_feu.png" hover "rpg/boule_de_feu_hover.png" action AddToSet(attaque_standart1,attaque_selectionne),  AddToSet(1,selectionattaque) align (0.80, 0)
and i have this error :

I dont understand, i iterate on a bool before but i replace by integer, can u help me ?

Code: Select all

[code]
I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/rpg.rpy", line 240, in script
    n_fr "your turn, choose attack"
  File "renpy/common/00action_data.rpy", line 325, in get_sensitive
    return self.value not in self.set
TypeError: argument of type 'bool' is not iterable

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

Full traceback:
  File "game/rpg.rpy", line 240, in script
    n_fr "Votre tour, selectionnez une attaque"
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\ast.py", line 613, in execute
    renpy.exports.say(who, what, interact=self.interact)
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\exports.py", line 1147, in say
    who(what, interact=interact)
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\character.py", line 877, in __call__
    self.do_display(who, what, cb_args=self.cb_args, **display_args)
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\character.py", line 716, in do_display
    **display_args)
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\character.py", line 508, in display_say
    rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\ui.py", line 285, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2526, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2793, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 495, in visit_all
    d.visit_all(callback)
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 495, in visit_all
    d.visit_all(callback)
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 495, in visit_all
    d.visit_all(callback)
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\display\screen.py", line 403, in visit_all
    self.child.visit_all(callback)
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 495, in visit_all
    d.visit_all(callback)
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 497, in visit_all
    callback(self)
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2793, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\display\behavior.py", line 793, in per_interact
    if self.is_sensitive():
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\display\behavior.py", line 783, in is_sensitive
    return is_sensitive(self.action)
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\display\behavior.py", line 375, in is_sensitive
    return all(is_sensitive(i) for i in action)
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\display\behavior.py", line 375, in <genexpr>
    return all(is_sensitive(i) for i in action)
  File "E:\RenPy\renpy-6.99.12.4-sdk\renpy\display\behavior.py", line 378, in is_sensitive
    return action.get_sensitive()
  File "renpy/common/00action_data.rpy", line 325, in get_sensitive
    return self.value not in self.set
TypeError: argument of type 'bool' is not iterable

Windows-8-6.2.9200
Ren'Py 6.99.12.4.2187
0.108

[/code]

terrordoll
Regular
Posts: 46
Joined: Tue Apr 11, 2017 11:57 am
Contact:

Re: Strange boolean problem with while

#2 Post by terrordoll »

This may sound stupid, but did you make sure to save your file after switching your while loop to an int from a bool? I've made the mistake myself several times, thinking the changes were made when I had forgotten to hit save, or I saved a different file.

terrordoll
Regular
Posts: 46
Joined: Tue Apr 11, 2017 11:57 am
Contact:

Re: Strange boolean problem with while

#3 Post by terrordoll »

Mind you, I'm pretty new to this, but isn't AddToSet() supposed to be for lists and collections?

If you are just looking to increment an int, would it make more sense to use SetVariable()?

User avatar
Mirrodin
Regular
Posts: 114
Joined: Sun Mar 19, 2017 2:56 pm
Contact:

Re: Strange boolean problem with while

#4 Post by Mirrodin »

Ok thanks for the info.

For the record it was an other error :
SetVariable is indeed what i need to use.
when i correct this : no error !

Renpy mastermind me ^^

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot], snotwurm