RevertableList Object?

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
DesertFox
Regular
Posts: 196
Joined: Sun Jul 28, 2013 1:29 pm
Completed: Over The Hills And Far Away
Projects: My Little Dictator
Organization: WarGirl Games
Contact:

RevertableList Object?

#1 Post by DesertFox »

What is a revertable list?

I'm trying to create an image that links to a map in the UnitEngine and got the following error

Code: Select all

AttributeError: 'RevertableList' object has no attribute 'label'
What are the possible attributes of a RevertableList object?

Here's the full coding that led to that:

Code: Select all

def ActionSquareClicked(self, pos):
      thisItem = self.selected_unit.selected_weapon
      if thisItem.type in [self.RANGEDWEAPON, self.MELEEWEAPON]:
        thisSquare = self.map[pos[0]][pos[1]]
        if thisSquare.unit:
          self.selected_unit.TurnToFace(pos)
          self.Show()
          ui.image("%s_fight.png" % self.map.label, xalign=.5)
          ui.image("%s_hit.png" % self.selected_unit.controller.name, xalign=.1)
          ui.image("%s_anger.png" % self.selected_unit.character.name, xalign=.9)
          #self.selected_unit.character.object("Hit them!")
          self.DamageUnit(self.selected_unit.selected_weapon.damage, thisSquare.unit)
          self.Hide()
          self.FinishAction()
        else:
          self.selected_unit.character.object("Nothing found at %d,%d" % pos)

Timberduck
Regular
Posts: 60
Joined: Sat Jan 04, 2014 12:52 am
Location: Canada
Contact:

Re: RevertableList Object?

#2 Post by Timberduck »

it says its missing label function.

label:

Tsapas
Regular
Posts: 69
Joined: Mon Oct 14, 2013 8:18 am
Contact:

Re: RevertableList Object?

#3 Post by Tsapas »

In this line:

Code: Select all

ui.image("%s_fight.png" % self.map.label, xalign=.5)
What exactly are you referring to with self.map.label here? The map's name?
By default the map is a list so it does not have any "label" attribute (and I didn't see it be defined in another way in your files on the other thread).

DesertFox
Regular
Posts: 196
Joined: Sun Jul 28, 2013 1:29 pm
Completed: Over The Hills And Far Away
Projects: My Little Dictator
Organization: WarGirl Games
Contact:

Re: RevertableList Object?

#4 Post by DesertFox »

Tsapas wrote: What exactly are you referring to with self.map.label here? The map's name?
By default the map is a list so it does not have any "label" attribute (and I didn't see it be defined in another way in your files on the other thread).
Hi. I was experimenting, trying out .name and .label. The label used for the map in this particular run was the default CombatMap from the UnitEngine demo. I'm hoping I can link a specific image to each different map through the "%s_fight.png" or similar.

Code: Select all

label CombatMap:
python:
  map = [
     [c(grass), c(grass), c(grass ), c(grass), c(grass ), c(grass), c(grass ), c(tile ), c(tile ), c(wall ), c(tile ), c(tile ), c(grass), c(grass )],
     [c(grass), c(grass ), c(grass), c(grass), c(grass ), c(grass ), c(grass), c(grass), c(tile ), c(wall ), c(tile ), c(tile ), c(grass), c(grass )],
     [c(grass), c(grass), c(grass ), c(grass), c(grass ), c(grass), c(grass ), c(tile ), c(tile ), c(wall ), c(tile ), c(tile ), c(grass), c(grass )],
     [c(grass ), c(grass), c(grass ), c(grass), c(grass ), c(grass), c(grass ), c(grass), c(tile ), c(wall ), c(tile ), c(tile ), c(grass), c(grass )],
     [c(grass), c(grass), c(grass ), c(grass), c(grass), c(grass ), c(grass), c(tile ), c(tile ), c(wall ), c(tile ), c(tile ), c(grass), c(grass )],
     [c(grass), c(grass), c(grass), c(grass), c(grass ), c(grass ), c(grass), c(tile ), c(tile ), c(wall ), c(tile ), c(tile ), c(grass), c(grass )],
     [c(grass), c(grass), c(grass), c(grass ), c(grass), c(grass ), c(grass), c(tile ), c(tile ), c(wall ), c(tile ), c(tile ), c(grass), c(grass )],
     [c(grass), c(grass), c(grass), c(grass ), c(grass), c(grass ), c(grass), c(tile ), c(tile ), c(wall ), c(tile ), c(tile ), c(grass), c(grass )],
     [c(grass), c(grass), c(grass), c(grass ), c(grass), c(grass ), c(grass), c(tile ), c(tile ), c(wall ), c(tile ), c(tile ), c(grass), c(grass )],
     [c(grass), c(grass), c(grass ), c(grass), c(grass), c(grass ), c(grass), c(tile ), c(tile ), c(wall ), c(tile ), c(tile ), c(grass), c(grass )],
     [c(grass), c(grass), c(grass), c(grass), c(grass ), c(grass ), c(grass), c(tile ), c(tile ), c(wall ), c(tile ), c(tile ), c(grass), c(grass )],
     [c(grass), c(grass), c(grass), c(grass ), c(grass), c(grass ), c(grass), c(tile ), c(tile ), c(wall ), c(tile ), c(tile ), c(grass), c(grass )],

     [c(grass), c(gtree), c(gtree), c(gtree), c(grass ), c(grass), c(grass ), c(tile ), c(tile ), c(wall ), c(tile ), c(tile ), c(grass), c(grass )],
     [c(grass ), c(grass), c(grass), c(grass), c(grass ), c(grass), c(grass ), c(tile ), c(tile ), c(wall ), c(tile ), c(tile ), c(grass), c(grass )],
     [c(grass ), c(grass ), c(grass ), c(grass), c(grass ), c(grass), c(grass ), c(tile ), c(tile ), c(wall ), c(tile ), c(tile ), c(grass), c(grass )],
     [c(tile ), c(grass), c(tile ), c(grass), c(tile ), c(grass), c(grass), c(grass ), c(tile ), c(tile ), c(tile ), c(tile ), c(grass), c(grass )],
     [c(grass), c(grass ), c(tile ), c(tile ), c(tile ), c(tile ), c(tile ), c(tile ), c(tile ), c(wall ), c(tile ), c(tile ), c(grass), c(grass )],

     [c(wall ), c(wall ), c(wall ), c(grass), c(grass ), c(wall ), c(wall ), c(tile ), c(wall ), c(wall ), c(tile ), c(tile ), c(grass), c(grass )],
     [c(tile ), c(tile ), c(tile ), c(tile ), c(tile ), c(grass), c(grass ), c(tile ), c(tile ), c(tile ), c(tile ), c(tile ), c(grass), c(grass )],
     [c(tile ), c(tile ), c(tile ), c(tile ), c(tile ), c(tile ), c(grass), c(grass ), c(grass), c(grass ), c(grass), c(grass ), c(tile ), c(tile ), c(tile ), c(tile )]
    ]
return
So if I could link to the map above by it having a specific name of sorts. So it would come up with CombatMap_fight.png and display it as it does with the other images.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
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: RevertableList Object?

#5 Post by PyTom »

RevertableList is the object that Ren'Py replaces the standard Python list type with, so that Rollback can occur. When you run the code:

Code: Select all

l = [ 1, 2, 3 ]
l refers to an object of type RevertableList. RevertableLists have the same methods as normal lists. They do not have any attributes.

In this case, you're using self.map, a list, and accessing the label field on it. That's not going to work.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: No registered users