Exit script problem
Ifrit7th
15 Oct 2011, 21:39Hello 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)
}
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:33You 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,
The syntax for "create exit" is:
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:
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:41I 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:25Just type in the room name:


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