Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Hi!

I'm trying to set up a script to make an entity change its frame each time the player clicks it. I've come up with this:

if self.property["state"] == 0 then
  play_animation(self, "frame1");
  set_entity_property(self, "state", self.property["state"] + 1)
else
  if self.property["state"] == 1 then
    play_animation(self, "frame2");
    set_entity_property(self, "state", self.property["state"] + 1)
  else
    if self.property["state"] == 2 then
      play_animation(self, "frame3");
      set_entity_property(self, "state", self.property["state"] + 1)
    else
      if self.property["state"] == 3 then
        play_animation(self, "frame4");
        set_entity_property(self, "state", self.property["state"] + 1)
      end
    end
  end
end

And I get this error:

SCRIPT ERROR: eval Invalid operands 'String' and 'int' in operator '=='.
    At: res://parser/relop_bexp.gd:34

However, if I use global properties, like below, everything works as expected.

if global.property["state"] == 0 then
  play_animation(self, "frame1");
  set_global_property("state", global.property["state"] + 1)
else
  if global.property["state"] == 1 then
    play_animation(self, "frame2");
    set_global_property("state", global.property["state"] + 1)
  else
    if global.property["state"] == 2 then
      play_animation(self, "frame3");
      set_global_property("state", global.property["state"] + 1)
    else
      if global.property["state"] == 3 then
        play_animation(self, "frame4");
        set_global_property("state", global.property["state"] + 1)
      end
    end
  end
end

Am I missing something, or is there a problem with local properties integers?