Jump to content


Photo

code help


  • Please log in to reply
27 replies to this topic

#1 monkeyboy3217

monkeyboy3217

    GMC Member

  • New Member
  • 120 posts

Posted 19 August 2011 - 08:59 PM

So i got this code
if place_meeting(x+15,y+24,lightbeam) with (lightbeam) {instance_destroy()} instance_create (x+15,y+24,lightbeam) 
y.speed= 50
But it doesnt work. What i want it to do is if the object lightbeam is at the pouint 15,24 relative to mirror_up i want it to destroy the lightbeam and create a new light beam moving upwards with a speed of 50
  • 0

#2 ATH Connect

ATH Connect

    GMC Member

  • New Member
  • 20 posts
  • Version:GM8

Posted 19 August 2011 - 09:42 PM

Hmm.
if place_meeting(x+15,y+24,lightbeam) 
{
with (lightbeam) {instance_destroy()} 
with (instance_create(x+15,y+24,lightbeam))
{
speed= 50
direction=90
}
}
Is this what you want?

EDIT: Removed the space.

Edited by ATH Connect, 19 August 2011 - 09:58 PM.

  • 0

#3 monkeyboy3217

monkeyboy3217

    GMC Member

  • New Member
  • 120 posts

Posted 19 August 2011 - 09:44 PM

That doesnt seem to work

Edited by monkeyboy3217, 19 August 2011 - 09:46 PM.

  • 0

#4 C_Pike

C_Pike

    GMC Member

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

Posted 19 August 2011 - 09:44 PM

So i got this code

if place_meeting(x+15,y+24,lightbeam) with (lightbeam) {instance_destroy()} instance_create (x+15,y+24,lightbeam) 
y.speed= 50
But it doesnt work. What i want it to do is if the object lightbeam is at the pouint 15,24 relative to mirror_up i want it to destroy the lightbeam and create a new light beam moving upwards with a speed of 50


if (place_meeting(x+15,y+24,lightbeam)) 
     {  // <- important bracket
     with (lightbeam) {instance_destroy();};
     with (instance_create (x+15,y+24,lightbeam)) {v_speed= -50;}; // <- needs a with statement, imo
     };

Try that... I can only guess that the problem is not bracketing the statements and functions after the if, and not using a 'with instance create'
which would set the speed of object 'y' to 50 continuously

---Edited some errors

Edited by C_Pike, 19 August 2011 - 09:48 PM.

  • 0

#5 SenJe0

SenJe0

    GMC Member

  • GMC Member
  • 733 posts

Posted 19 August 2011 - 09:47 PM

if x=mirror_up.x+15 and y=mirror_up.y+24 
{

with (lightbeam) {instance_destroy()}
instance_create (x+15,y+24,lightbeam) 
y.speed= 50
}
It's off the top of my head...hope it works
  • 0

#6 monkeyboy3217

monkeyboy3217

    GMC Member

  • New Member
  • 120 posts

Posted 19 August 2011 - 09:50 PM

None of these work and i have no idea why.....
  • 0

#7 SenJe0

SenJe0

    GMC Member

  • GMC Member
  • 733 posts

Posted 19 August 2011 - 09:52 PM

None of these work and i have no idea why.....

Are you sure the object names do not conflict the names of the resources...try running the game in debug mode...
  • 0

#8 monkeyboy3217

monkeyboy3217

    GMC Member

  • New Member
  • 120 posts

Posted 19 August 2011 - 09:54 PM


None of these work and i have no idea why.....

Are you sure the object names do not conflict the names of the resources...try running the game in debug mode...

Maybe i have the collision coordinates wrong how would you check that?
  • 0

#9 wadaltmon

wadaltmon

    GMC Member

  • New Member
  • 109 posts

Posted 19 August 2011 - 09:55 PM

You said "y.speed" as a variable... what is "y"?
If it's an instance, then try naming it something else, like "inst_y" or "obj_y", then change it in the code to whatever you renamed it to.
  • 0

#10 monkeyboy3217

monkeyboy3217

    GMC Member

  • New Member
  • 120 posts

Posted 19 August 2011 - 09:58 PM

You said "y.speed" as a variable... what is "y"?
If it's an instance, then try naming it something else, like "inst_y" or "obj_y", then change it in the code to whatever you renamed it to.

Y.speed is the current speed of the object on the y axis
  • 0

#11 ATH Connect

ATH Connect

    GMC Member

  • New Member
  • 20 posts
  • Version:GM8

Posted 19 August 2011 - 09:59 PM

Try my above code again. I removed the space in the instance_create function.

Are you getting an error or just unintended results?

EDIT: Oh. Y? You named an object Y?

Edited by ATH Connect, 19 August 2011 - 10:00 PM.

  • 0

#12 monkeyboy3217

monkeyboy3217

    GMC Member

  • New Member
  • 120 posts

Posted 19 August 2011 - 10:03 PM

Try my above code again. I removed the space in the instance_create function.

Are you getting an error or just unintended results?

EDIT: Oh. Y? You named an object Y?

I did not name an object y but i am not getting an error code absolutely NOTHING happens :\


EDIT: I tried your code again...same results...

Edited by monkeyboy3217, 19 August 2011 - 10:04 PM.

  • 0

#13 wadaltmon

wadaltmon

    GMC Member

  • New Member
  • 109 posts

Posted 19 August 2011 - 10:06 PM

Oh! Then that's not the code you want to use. Use the variable " vspeed " for the movement on the y axis ( upward on the y axis is a negative number, downward is a positive number.
So, here's what your code should be...
if (place_meeting(x+15,y+15,lightbeam)
    {
        with (lightbeam) instance_destroy();        
    obj = instance_create(x+15, y+24, lightbeam)       
    with (obj) vspeed = //whatever value you want here. read above for what value ^^
    }


That should work.



EDIT: Worked out all the mistakes. works now

Edited by wadaltmon, 19 August 2011 - 10:11 PM.

  • 0

#14 monkeyboy3217

monkeyboy3217

    GMC Member

  • New Member
  • 120 posts

Posted 19 August 2011 - 10:08 PM

Oh! Then that's not the code you want to use. Use the variable " hspeed " for the movement on the y axis ( upward on the y axis is a negative number, downward is a positive number.
So, here's what your code should be...

[/b][/size][/color][/font]
[font="monospace"][color="#000088"][size=2][b]if (place_meeting(x+15,y+15,lightbeam)[/b][/size][/color][/font]
[font="monospace"][color="#000088"][size=2][b]	{[/b][/size][/color][/font]
[font="monospace"][color="#000088"][size=2][b]		with (lightbeam) instance_destroy();[/b][/size][/color][/font]
[font="monospace"][color="#000088"][size=2][b]		obj = instance_create(x+15, y+24, lightbeam)[/b][/size][/color][/font]
[font="monospace"][color="#000088"][size=2][b]		with (obj) vspeed = //whatever value you want here. read above for what value ^^[/b][/size][/color][/font]
[font="monospace"][color="#000088"][size=2][b]	}[/b][/size][/color][/font]



[b][font="monospace"][color="#000088"][size=2][b]
[/b]

That should work.


Umm code editor doesnt like it it says unexpected symbol line 1 position 1...i dont even think that GML code

EDIT: That or the website totally screwed up....

Edited by monkeyboy3217, 19 August 2011 - 10:09 PM.

  • 0

#15 wadaltmon

wadaltmon

    GMC Member

  • New Member
  • 109 posts

Posted 19 August 2011 - 10:12 PM


Oh! Then that's not the code you want to use. Use the variable " hspeed " for the movement on the y axis ( upward on the y axis is a negative number, downward is a positive number.
So, here's what your code should be...

[/b][/size][/color][/font]
[font="monospace"][color="#000088"][size=2][b]if (place_meeting(x+15,y+15,lightbeam)[/b][/size][/color][/font]
[font="monospace"][color="#000088"][size=2][b]	{[/b][/size][/color][/font]
[font="monospace"][color="#000088"][size=2][b]		with (lightbeam) instance_destroy();[/b][/size][/color][/font]
[font="monospace"][color="#000088"][size=2][b]		obj = instance_create(x+15, y+24, lightbeam)[/b][/size][/color][/font]
[font="monospace"][color="#000088"][size=2][b]		with (obj) vspeed = //whatever value you want here. read above for what value ^^[/b][/size][/color][/font]
[font="monospace"][color="#000088"][size=2][b]	}[/b][/size][/color][/font]



[b][font="monospace"][color="#000088"][size=2][b]
[/b]

That should work.


Umm code editor doesnt like it it says unexpected symbol line 1 position 1...i dont even think that GML code

EDIT: That or the website totally screwed up....


Website screwed up. Sorry. See my previous post for the real code.
  • 0

#16 monkeyboy3217

monkeyboy3217

    GMC Member

  • New Member
  • 120 posts

Posted 19 August 2011 - 10:14 PM

Oh! Then that's not the code you want to use. Use the variable " vspeed " for the movement on the y axis ( upward on the y axis is a negative number, downward is a positive number.
So, here's what your code should be...

if (place_meeting(x+15,y+15,lightbeam)
    {
        with (lightbeam) instance_destroy();        
    obj = instance_create(x+15, y+24, lightbeam)       
    with (obj) vspeed = //whatever value you want here. read above for what value ^^
    }


That should work.


EDIT: Worked out all the mistakes. works now


It doesnt like the frist french bracket...
  • 0

#17 wadaltmon

wadaltmon

    GMC Member

  • New Member
  • 109 posts

Posted 19 August 2011 - 10:17 PM


Oh! Then that's not the code you want to use. Use the variable " vspeed " for the movement on the y axis ( upward on the y axis is a negative number, downward is a positive number.
So, here's what your code should be...

if (place_meeting(x+15,y+15,lightbeam)
    {
        with (lightbeam) instance_destroy();        
    obj = instance_create(x+15, y+24, lightbeam)   	
    with (obj) vspeed = //whatever value you want here. read above for what value ^^
    }


That should work.


EDIT: Worked out all the mistakes. works now


It doesnt like the frist french bracket...


What? French bracket? (I assume you mean {}...)
Don't copy and paste. Just type in the code manually.
And where I put "//whatever value you want here. read above for what value ^^" I meant replace that with -50 or 50.
  • 0

#18 monkeyboy3217

monkeyboy3217

    GMC Member

  • New Member
  • 120 posts

Posted 19 August 2011 - 10:18 PM



Oh! Then that's not the code you want to use. Use the variable " vspeed " for the movement on the y axis ( upward on the y axis is a negative number, downward is a positive number.
So, here's what your code should be...

if (place_meeting(x+15,y+15,lightbeam)
    {
        with (lightbeam) instance_destroy();        
    obj = instance_create(x+15, y+24, lightbeam)   	
    with (obj) vspeed = //whatever value you want here. read above for what value ^^
    }


That should work.


EDIT: Worked out all the mistakes. works now


It doesnt like the frist french bracket...


What? French bracket? (I assume you mean {}...)
Don't copy and paste. Just type in the code manually.
And where I put "//whatever value you want here. read above for what value ^^" I meant replace that with -50 or 50.


Okay ill let you if it works
  • 0

#19 wadaltmon

wadaltmon

    GMC Member

  • New Member
  • 109 posts

Posted 19 August 2011 - 10:19 PM




Oh! Then that's not the code you want to use. Use the variable " vspeed " for the movement on the y axis ( upward on the y axis is a negative number, downward is a positive number.
So, here's what your code should be...

if (place_meeting(x+15,y+15,lightbeam)
    {
        with (lightbeam) instance_destroy();        
    obj = instance_create(x+15, y+24, lightbeam)   	
    with (obj) vspeed = //whatever value you want here. read above for what value ^^
    }


That should work.


EDIT: Worked out all the mistakes. works now


It doesnt like the frist french bracket...

if it says unknown variable obj, then before the third line, put in "var obj;"

What? French bracket? (I assume you mean {}...)
Don't copy and paste. Just type in the code manually.
And where I put "//whatever value you want here. read above for what value ^^" I meant replace that with -50 or 50.


Okay ill let you if it works




  • 0

#20 wadaltmon

wadaltmon

    GMC Member

  • New Member
  • 109 posts

Posted 19 August 2011 - 10:20 PM





Oh! Then that's not the code you want to use. Use the variable " vspeed " for the movement on the y axis ( upward on the y axis is a negative number, downward is a positive number.
So, here's what your code should be...

if (place_meeting(x+15,y+15,lightbeam)
    {
        with (lightbeam) instance_destroy();        
    obj = instance_create(x+15, y+24, lightbeam)   	
    with (obj) vspeed = //whatever value you want here. read above for what value ^^
    }


That should work.


EDIT: Worked out all the mistakes. works now


It doesnt like the frist french bracket...

if it says unknown variable obj, then before the third line, put in "var obj;"

What? French bracket? (I assume you mean {}...)
Don't copy and paste. Just type in the code manually.
And where I put "//whatever value you want here. read above for what value ^^" I meant replace that with -50 or 50.


Okay ill let you if it works





ok
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users