Exit script problem

Ifrit7th
15 Oct 2011, 21:39
Hello again, feels like I'm asking a hundred questions but hopefully this will be the last for a while. I'm trying to create a starship mechanic where you select your destination from a menu and you fly there, with the hatch on the ship serving as your entrance and exit.

In order to do this, I tried to code it where selecting an option deletes the current exit and creates a brand new one with the same name (since as far as I can tell altering an exit's out point is impossible in script. I tried to do it by changing a variable in the exit itself but it kept giving me a error.) I've used a menu system earlier in the game for character creation with great success, but this part keeps kicking back the same "Unknown object or variable" error every time I try to specify the direction of the script-created exit. It asks for the type of exit but no matter how I express it it still gives me the same problem.

if (not GetBoolean(player, "firstjourney")) {
msg (" Intro message")
SSspacewindow.local = "Starport"
destroy ("hatch")
create exit ("hatch", Helm, Starport, South)
}
else {
msg ("Your ship rumbles as it takes off to the spaceport in a flash. In no time at all, you arrive outside the large, glistening station.")
SSspacewindow.local = "Starport"
destroy ("hatch")
create exit ("hatch", Helm, Starport, South)
}

Alex
16 Oct 2011, 15:33
You can alter an exit's destination via a script. You just need to set the "to" attribute. Make sure you've given the exit a name.

For example,


myexit.to = new_room


The syntax for "create exit" is:


create exit (string name, object from, object to, string type)



The final parameter is a string, so that's why your code is failing, as "South" is not a variable. The correct syntax would be:


create exit ("hatch", Helm, Starport, "southdirection")

Ifrit7th
16 Oct 2011, 15:41
I tried to set the 'to' attribute in a script, but I was using either "Object: Spaceport" or "Object.Spaceport" for the room name. Do I just use the name of the room then or do I need to put it in as a string or some other expression?

Alex
16 Oct 2011, 16:25
Just type in the room name:

changeto.png

Ifrit7th
16 Oct 2011, 16:26
Excellent, thanks again for the quick response.