Jump to content


Photo

Problem with unknown variable which does exist


  • Please log in to reply
3 replies to this topic

#1 Maxhelo

Maxhelo

    GMC Member

  • GMC Member
  • 35 posts
  • Version:GM:Studio

Posted 10 July 2015 - 06:26 PM

Hello !

A mystic issue occurs when I try to change the sprite_index of one of my object. The compile fails because it seems the new sprite doesn't exist... but it's wrong !

I don't have any idea why there is a problem. Here is a screen to illustrate my situation : http://image.noelsha...ug-mystique.png

 

Thanks for your help,

@MaxhelOW


  • 0

#2 TsukaYuriko

TsukaYuriko

    #1 of Yal's 25 waifus

  • Global Moderators
  • 9010 posts
  • Version:GM:Studio

Posted 10 July 2015 - 06:28 PM

Please post all relevant code (as code, not as a screenshot) and the full error message.


  • 0

yBGBXQa.pngmWOQbeq.png


#3 NakedPaulToast

NakedPaulToast

    GM Studio/Mac/Win

  • GMC Member
  • 8735 posts
  • Version:GM:Studio

Posted 10 July 2015 - 07:05 PM

This is one of the extremely rare occasions where you need a semi-colon (other than a var statement).
 
Because of the parenthesis around (target), GML is interpretting: 

sprite_index=spr_petiteexplosion

(target).HP-=damage

as
 

sprite_index=spr_petiteexplosion(target).HP-=damage

 

where spr_petiteexplosion(target) is being incorrectly attributed as a function.
 
Your solution is to insert a semi-colon after your sprite_index statement.
 
sprite_index=spr_petiteexplosion ;
 
(target).HP-=damage
 
And like Tsuka said, don't print screen shots and post actual error messages. The error message should not have suggested that the sprite spr_petiteexplosion doesn't exist but rather a function or script spr_petiteexplosion doesn't exist.
 
I would also spend some time learning about proper use of semi-colons as statement separators.


Edited by NakedPaulToast, 10 July 2015 - 07:49 PM.

  • 1

If the Bible truly is inspired by God, you would think that somebody as omnipotent and all-knowing would have known to get his message out using TCP instead of UDP.

 


#4 Maxhelo

Maxhelo

    GMC Member

  • GMC Member
  • 35 posts
  • Version:GM:Studio

Posted 10 July 2015 - 08:51 PM

Wow... I would never have expected that ! Thanks for your quick reply NakedPaulToast and, yes TsukaYuriko, I will do it next time ^ ^


  • 0




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users