Powered by Invision Power Board

 
    Reply to this topicStart new topicStart Poll

> So I wanna make a variable that goes down gradualy, if a certain object is touching another
United Kingdom
Thingy
Posted: Oct 5 2009, 02:47 PM
Quote Post


So long MFGG 2.0~
[*][*][*][*]

Group Icon
Group: Members
Posts: 1824
Member No.: 4642
Joined: 30-October 07

Status: (0d) [--]


Basically, it's a breath bar for when you are underwater, but you can change between objects and I don't want that to affect it.

Any ideas?


--------------------
user posted image
Old ref, Current ref
Click to see the rest. (opens sig on top post)

user posted image
Hey, MFGG 3.0, it's me from the past.
PMEmail PosterMSN
Top
Netherlands
Captain Flame Guy
Posted: Oct 5 2009, 02:54 PM
Quote Post


a
[*][*]

Group Icon
Group: Members
Posts: 1679
Member No.: 2070
Joined: 6-May 06

Status: (0d) [--]


tried "custom" timers?

something like

timer = 60

if <collision stuff here> {timer -= 1}


--------------------
CAPTAIN FLAME GUY IS HAVING FUN IN THE POST-APOCALYPTIC WORLD
PMEmail PosterYahooMSN
Top
Japan
Soiyeruda
Posted: Oct 5 2009, 03:39 PM
Quote Post


Because retarded looking women is fun. :S
[*][*][*][*][*]
[*][*][*]

Group Icon
Group: Members
Posts: 3589
Member No.: 5004
Joined: 6-March 08

Status: (0d) [--]


I don't quite understand your question.

By change between objects, you mean characters, right?

So basically, you want each character to have their own separate oxygen bars?
PMEmail Poster
Top
United States
YoManRuLz
Posted: Oct 5 2009, 03:56 PM
Quote Post


sit down, it's just me


Group Icon
Group: Members
Posts: 152
Member No.: 6502
Joined: 6-September 09

Status: (0d) [--]


going on with flame guy:
creation event:
//set the alarm, and save what the alarm is
a=100
as=a

step event:
//if he is in water, meter goes down, else it is full
if place_meeting(x,y,obj_water){
a-=1}
else{a=as}

This post has been edited by YoManRuLz on Oct 5 2009, 03:57 PM


--------------------
PMEmail Poster
Top
United Kingdom
Thingy
Posted: Oct 6 2009, 02:20 AM
Quote Post


So long MFGG 2.0~
[*][*][*][*]

Group Icon
Group: Members
Posts: 1824
Member No.: 4642
Joined: 30-October 07

Status: (0d) [--]


QUOTE (YoManRuLz @ Oct 5 2009, 09:56 PM)
going on with flame guy:
creation event:
//set the alarm, and save what the alarm is
a=100
as=a

step event:
//if he is in water, meter goes down, else it is full
if place_meeting(x,y,obj_water){
a-=1}
else{a=as}

This is what I need, but you can switch between characters, which consists of creating the new one at the position and destroying the original.

I don't want any of that to affect the breath bar.

I'm now using this:
CODE
if place_meeting(object0.x,object0.y,water)
{
   breath -= 1
}
else
if place_meeting(object16.x,object16.y,water)
{
   breath -= 1
}
else
if place_meeting(object17.x,object17.y,water)
{
   breath -= 1
}
else
{
breath = breath_full
}

in the alarm event on alarm 0, so it checks every 30 steps.

But it breaks because only one of those objects exists at once (except in the split second whilst switching, when there's two).


--------------------
user posted image
Old ref, Current ref
Click to see the rest. (opens sig on top post)

user posted image
Hey, MFGG 3.0, it's me from the past.
PMEmail PosterMSN
Top
United Kingdom
Thingy
Posted: Oct 6 2009, 07:29 AM
Quote Post


So long MFGG 2.0~
[*][*][*][*]

Group Icon
Group: Members
Posts: 1824
Member No.: 4642
Joined: 30-October 07

Status: (0d) [--]


So I messed with it a bit:
CODE
if object_exists(object0)
{
   if place_meeting(object0.x,object0.y,water)
   {
       breath -= 1
   }
   else
   {
       breath = breath_full
   }
}
else
{
   if object_exists(object16)
   {
       if place_meeting(object16.x,object16.y,water)
       {
           breath -= 1
       }
       else
       {
           breath = breath_full
       }
   }
   else
   {
       if object_exists(object17)
       {
           if place_meeting(object17.x,object17.y,water)
           {
               breath -= 1
           }
           else
           {
               breath = breath_full
           }
       }
   }
}


If my character changes when it checks it breaks and says "Unknown variable x".

Any hints on how to fix?


--------------------
user posted image
Old ref, Current ref
Click to see the rest. (opens sig on top post)

user posted image
Hey, MFGG 3.0, it's me from the past.
PMEmail PosterMSN
Top
Unspecified
Miaxis
Posted: Oct 6 2009, 07:37 AM
Quote Post


hagan bromas
[*]

Group Icon
Group: Members
Posts: 1799
Member No.: 2793
Joined: 12-October 06

Status: (0d) [--]


"Unknown variable x" means you're checking a variable of an instance that doesn't exist.

Your code has a small typo; you're checking if the object exists as in if it exists in the object list. Of course it does, so GM goes on to the next check, but since there isn't an instance for all of the 3 objects, it breaks. You want to check if an instance of the object exists in the room, though, so change the 'if object_exists' to 'if instance_exists'.


--------------------
user posted image

user posted imageuser posted imageuser posted imageuser posted image
PMEmail PosterUsers WebsiteMSN
Top
United States
Tek
Posted: Oct 6 2009, 07:55 AM
Quote Post


no
[*]

Group Icon
Group: Members
Posts: 4393
Member No.: 1734
Joined: 17-December 05

Status: (0d) [--]


Wouldn't it be easier to make breath a global variable?


--------------------
PMEmail PosterUsers Website
Top
United Kingdom
Thingy
Posted: Oct 6 2009, 09:42 AM
Quote Post


So long MFGG 2.0~
[*][*][*][*]

Group Icon
Group: Members
Posts: 1824
Member No.: 4642
Joined: 30-October 07

Status: (0d) [--]


Fixed it now.


--------------------
user posted image
Old ref, Current ref
Click to see the rest. (opens sig on top post)

user posted image
Hey, MFGG 3.0, it's me from the past.
PMEmail PosterMSN
Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:

  Topic Options Topic Options Reply to this topicStart new topicStart Poll

 




[ Script Execution time: 0.0614 ]   [ 14 queries used ]   [ GZIP Enabled ]   [ Server Load: 1.10 ]