Jump to content


Photo

Lives


  • Please log in to reply
5 replies to this topic

#1 _242000

_242000

    GMC Member

  • New Member
  • 3 posts

Posted 30 November 2011 - 05:07 PM

I have built my game so that its a asteroids like game, the player shoots from the ship and can turn by using the arrow keys, i shoot at asteroids by using the can_shoot variable. i try to add lives to make the game more challenging by following tutorials online, but when i enter the game with the lives set up it comes up with the error
___________________________________________
ERROR in
action number 1
of Step Event
for object obj_ship_parent:

Error in code at line 1:
can_shoot += 1
^
at position 1: Unknown variable can_shoot

why is it giving me this? before i add the lives its fine, then after, its gives me this.
this is the tutorial http://www.youtube.c...h?v=qDrariGknIg
if one of you can explain, or maybe fix this problem, i welcome it, i don't mind D&D or script, but i just want it to work right
  • 0

#2 Noele

Noele

    GMC Mentor

  • GMC Member
  • 2352 posts
  • Version:GM8.1

Posted 30 November 2011 - 05:16 PM

In the Create Event for object obj_ship_parent you need to give the variable can_shoot a starting value.

The clue is in the error message.
The Step Event does not know what can_shoot is so cannot add 1 to it.
  • 0

#3 _242000

_242000

    GMC Member

  • New Member
  • 3 posts

Posted 30 November 2011 - 06:14 PM

In the Create Event for object obj_ship_parent you need to give the variable can_shoot a starting value.

The clue is in the error message.
The Step Event does not know what can_shoot is so cannot add 1 to it.


so what do i need to do? make a create event with the can_shoot with the starting value of 0? :S
  • 0

#4 Noele

Noele

    GMC Mentor

  • GMC Member
  • 2352 posts
  • Version:GM8.1

Posted 30 November 2011 - 06:24 PM

In the Create Event for object obj_ship_parent you need to give the variable can_shoot a starting value.


That should do quite nicely.
  • 0

#5 MudbudGoldfish

MudbudGoldfish

    Indie Game Dev Team

  • New Member
  • 494 posts
  • Version:GM8

Posted 30 November 2011 - 06:36 PM

Assuming that "can_shoot" is either a 1 for shooting and a 0 for not shooting, it would be easier to set it as a Boolean variable (true/false).

In the create event of your parent object , set 'can_shoot' to be true (so you can shoot). It's pretty much the same as Noele posted but I don't know why you have can_shoot += 1

OR
Why not just set it to can_shoot = 1; ?
  • 0

#6 _242000

_242000

    GMC Member

  • New Member
  • 3 posts

Posted 30 November 2011 - 06:50 PM

Assuming that "can_shoot" is either a 1 for shooting and a 0 for not shooting, it would be easier to set it as a Boolean variable (true/false).

In the create event of your parent object , set 'can_shoot' to be true (so you can shoot). It's pretty much the same as Noele posted but I don't know why you have can_shoot += 1

OR
Why not just set it to can_shoot = 1; ?


i have done it with a = 1, i dont actually know where the + has come from. cus without the lives system in there the game works perfectly fine, then i add the lives and it comes up with this error. now i've tried 4 different tutorials and it happens everytime. then i exit game maker and return to the previous save and it works. :@ how is the lives making it f***ed up??
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users