Jump to content


Photo

Can Anybody Help Me With My Script


  • Please log in to reply
4 replies to this topic

#1 @rpp3

@rpp3

    GMC Member

  • New Member
  • 112 posts

Posted 27 March 2010 - 05:27 PM

This is my first time writing a script, and generally it helps with room transition
here it is

scr_room

//argument 0 = players x in new room
//argument 1 = players x in new room
//argument 2 = new room
//argument 3 = transition_kind
//argument 4 = players direction to face
xx = argument0
yy = argument1
room_goto = argument2
transition_kind = argument3
facing = argument4

and an example of when I executed it ( collision with a non-visible door object )

if room = roomlinkhouse
{
script_execute(scr_room,368,528,roomlinkyard,21,0)
}

Why does this not work?
thanks to anyone who posts
  • 0

#2 GameGeisha

GameGeisha

    GameGeisha

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

Posted 27 March 2010 - 05:44 PM

Remember that scripts can be treated like functions, so do this instead.
if (room==roomlinkhouse) {
  scr_room(368,528,roomlinkyard,21,0);
}

GameGeisha
  • 0

#3 GameRoom

GameRoom

    GMC Member

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

Posted 28 March 2010 - 12:38 AM

room_goto is a function, not a script. Use room_goto(argument2).
  • 0

#4 Davido01

Davido01

    GMC Member

  • New Member
  • 905 posts

Posted 28 March 2010 - 01:32 AM

I know this is completely irrelevant and doesnt affect your actual code, but in your comment you put player x in new room when you meant to put y.
  • 0

#5 hotshotscott

hotshotscott

    GMC Member

  • New Member
  • 3483 posts

Posted 28 March 2010 - 04:17 AM

The problem is in the script. You're changing the room before the room transition code is used, and before the variable 'facing' is set. SO firstly, you need to put the room_goto() part at the end like this;

//argument 0 = players x in new room
//argument 1 = players y in new room
//argument 2 = new room
//argument 3 = transition_kind
//argument 4 = players direction to face
xx = argument0
yy = argument1

transition_kind = argument3
facing = argument4

room_goto = argument2

The next problem is that all of the variables you just set (xx, yy, facing) are local variables, which cannot be used in another room. I'm assuming that when you go to the new room, you want to place the character at xx, yy so that he's facing the 'facing' variable? Well to do this, all you'll have to do is make them into global variables, both in the script and the that's used in the new room.

//argument 0 = players x in new room
//argument 1 = players y in new room
//argument 2 = new room
//argument 3 = transition_kind
//argument 4 = players direction to face
global.xx = argument0
global.yy = argument1

transition_kind = argument3
global.facing = argument4

room_goto = argument2

Then, when you get inside the room, do something like this;
Character=instance_create(global.xx, global.yy, Character)
Character.facing=global.gacing

Hope it helps,

Scotty

Edited by hotshotscott, 28 March 2010 - 04:18 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users