Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Stupid problem

Im programing again now and i have a stupid problem:

Code:
  

    p actor_id2

     if actor_id2 != 99 or  $game_actors[actor_id2].bolsa[posicion_objeto(tipo, id, actor_id2)].equipado

 

   else

 

 

 

I KNOW that actor_id2 IS 99. The p says that also. The problem here is that the condition is surpassed and it checks for the other condition wit the or. My problem is that other condition gives a error if it use the id=99... so it dont work.

Maybe i have to sleep or something but... i want that if the id is 99 it goes to the else, wtf, that code is ok ,no?
 

MarkR

Member

Shouldn't you use and instead of or?
Code:
 

if actor_id2 != 99 and $game_actors[actor_id2].bolsa[posicion_objeto(tipo, id, actor_id2)].equipado

  # The actor id is not 99 and $game_actors[actor_id2].bolsa[posicion_objeto(tipo, id, actor_id2)].equipado is true

else

  # The actor id is 99 or $game_actors[actor_id2].bolsa[posicion_objeto(tipo, id, actor_id2)].equipado is false

end

 

If you use an or operator, it will always check both the first and the second statement and that's why you get the error. ;)
 
MarkR":1bsce372 said:
Shouldn't you use and instead of or?
Code:
 

if actor_id2 != 99 and $game_actors[actor_id2].bolsa[posicion_objeto(tipo, id, actor_id2)].equipado

  # The actor id is not 99 and $game_actors[actor_id2].bolsa[posicion_objeto(tipo, id, actor_id2)].equipado is true

else

  # The actor id is 99 or $game_actors[actor_id2].bolsa[posicion_objeto(tipo, id, actor_id2)].equipado is false

end

 

If you use an or operator, it will always check both the first and the second statement and that's why you get the error. ;)

thanks, sometimes the human mind... or my mind,xd. well....
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top