Templates in web editor?

Disturbed666
16 May 2014, 14:18
I am forced to use the web editor (running linux) and am writing a game based on a ship. I've read the how to on the wiki on using templates to change the compass directions and tried inserting the code in a few places, and only get errors probably because I'm trying to insert xml data where it doesn't belong. Is using templates even possible in the web editor

PS. I'm more then comfortable editing code by hand if there's some way to edit the code locally and then re-upload and continue using the web editor afterward

jaynabonne
16 May 2014, 15:47
I don't see any way to use templates in the web editor. However, if you're trying to change the compass, there may be another way to do it. Can you explain what you'd like to change?

Disturbed666
16 May 2014, 15:58
well essentially exactly what's in the tutorial: change North/N to Forward/F. South/S to Aft/A etc.

jaynabonne
16 May 2014, 22:37
In the Script for your "game" object (the start script), go to Code View and add this code:

game.compassdirections = NewStringList()
list add (game.compassdirections, "[CompassNW]")
list add (game.compassdirections, "fore")
list add (game.compassdirections, "[CompassNE]")
list add (game.compassdirections, "port")
list add (game.compassdirections, "starboard")
list add (game.compassdirections, "[CompassSW]")
list add (game.compassdirections, "aft")
list add (game.compassdirections, "[CompassSE]")
list add (game.compassdirections, "[CompassUp]")
list add (game.compassdirections, "[CompassDown]")
list add (game.compassdirections, "[CompassIn]")
list add (game.compassdirections, "[CompassOut]")
request (SetCompassDirections, Join(game.compassdirections, ";"))
foreach (exit, AllExits()) {
if (DoesInherit(exit, "northdirection")) {
exit.alias = "fore"
exit.alt = NewStringList()
list add (exit.alt, "f")
}
else if (DoesInherit(exit, "southdirection")) {
exit.alias = "aft"
exit.alt = NewStringList()
list add (exit.alt, "a")
}
else if (DoesInherit(exit, "westdirection")) {
exit.alias = "port"
exit.alt = NewStringList()
list add (exit.alt, "p")
}
else if (DoesInherit(exit, "eastdirection")) {
exit.alias = "starboard"
exit.alt = NewStringList()
list add (exit.alt, "s")
}
}
go.pattern = "^go to (?<exit>.*)$|^go (?<exit>.*)$|^(?<exit>fore|starboard|aft|port|northeast|northwest|southeast|southwest|in|out|up|down|f|s|a|p|ne|nw|se|sw|o|u|d)$"


It works for me with a test program. I did not update the look direction, but that would be an easy addition.

Disturbed666
17 May 2014, 03:19
throws an internal error :(

jaynabonne
17 May 2014, 05:29
Ok, do it in two phases. First, add this code in Code View:

game.compassdirections = NewStringList()
list add (game.compassdirections, "[CompassNW]")
list add (game.compassdirections, "fore")
list add (game.compassdirections, "[CompassNE]")
list add (game.compassdirections, "port")
list add (game.compassdirections, "starboard")
list add (game.compassdirections, "[CompassSW]")
list add (game.compassdirections, "aft")
list add (game.compassdirections, "[CompassSE]")
list add (game.compassdirections, "[CompassUp]")
list add (game.compassdirections, "[CompassDown]")
list add (game.compassdirections, "[CompassIn]")
list add (game.compassdirections, "[CompassOut]")
request (SetCompassDirections, Join(game.compassdirections, ";"))
foreach (exit, AllExits()) {
if (DoesInherit(exit, "northdirection")) {
exit.alias = "fore"
exit.alt = NewStringList()
list add (exit.alt, "f")
}
else if (DoesInherit(exit, "southdirection")) {
exit.alias = "aft"
exit.alt = NewStringList()
list add (exit.alt, "a")
}
else if (DoesInherit(exit, "westdirection")) {
exit.alias = "port"
exit.alt = NewStringList()
list add (exit.alt, "p")
}
else if (DoesInherit(exit, "eastdirection")) {
exit.alias = "starboard"
exit.alt = NewStringList()
list add (exit.alt, "s")
}
}
go.pattern = ""

Then when it settles, go to the very bottom outside of Code View. It will have:

Set variable [go.pattern] = [expression]
[""]


Change the bottom "" to:

"^go to (?<exit>.*)$|^go (?<exit>.*)$|^(?<exit>fore|starboard|aft|port|northeast|northwest|southeast|southwest|in|out|up|down|f|s|a|p|ne|nw|se|sw|o|u|d)$"

That should do it!

Disturbed666
17 May 2014, 16:12
nope, still getting an internal error when i paste that first block of code, I have a simple intro script there already consisting simply of clear the screen (to get rid of title), print centered message, wait, print centered message, wait. Would that have anything to do with it? I'll try dropping the code after the intro script for the hell of it.

Edit: nope didn't think so. reading your code I understand what it's supposed to do, just don't understand quests code handling capabilities enough to figure it out (there should really be a debug option, "Error line 2 char 6" always helps lol)

Edit: I GOT IT, dropped all the code in a new function and called the function from the game/script page, thanks SOO much for your help XD

jaynabonne
17 May 2014, 16:17
You could try what I tried initially - add it in logical chunks. Maybe it will work better with smaller bites. :)

Disturbed666
17 May 2014, 16:20
Disturbed666 wrote:Edit: I GOT IT, dropped all the code in a new function and called the function from the game/script page, thanks SOO much for your help XD

jaynabonne
17 May 2014, 16:29
Cool! Glad it worked. :)