How to change a template while the game is running?

So I'm running a game where most of it is in first person, but there is this one part that is a different character then the player so I want to be in the third person. I was given this library that does just that, but it makes the game third person from the start and I want it to change from first to third when the player object changes. I know I can do this by changing the templates like "You are in" to he is in" and things like that. But is there away to alter the templates out side of a library while the game is running?


game.pov = object
Then you have to follow a bunch of other set variables stuff.


I don't think you could change a template, but in this case it wouldn't help you anyway. Because the "you are in" prefix can be changed for each room; so it is set to the default YouAreIn template in the editor, when the room is created. So you don't want to change the template, you want to change a string attribute of every room object.

When changing person, you could do something like:

foreach (room, AllRooms()) {
  room.descprefix = Replace (room.descprefix, "You are", "He is")
}

Then you'd have to change a lot of other things, such as the default response for verbs. You would have to change some templates, but the "YouAreIn" template isn't one of them.

Really, it would be better to make the templates work so that they can display the right text either way.

For example, you could replace "You are in" with {=CapFirst(WriteVerb(game.pov, "be")) in. - which would be displayed as "You are in" or "He is in", depending whether the current player object's gender attribute is "you" or "he".

You can change all of the templates in the same way in the editor, using WriteVerb to make the text automatically adjust depending on the player object's gender.


@mrangel
that code for the prefixes worked great, do you have one for other ones like "you can"?


For just about all the templates, you can use WriteVerb.
A while back I searched for "you" in the English language file and changed all of them, I'll see if I can find that thread.

I never got as far as testing this, but here's my attempt at changing all the templates:

	<dynamictemplate name="UnresolvedLocation">CapFirst(game.pov.gender) + " can't go there."</dynamictemplate>
	<dynamictemplate name="TakeSuccessful">WriteVerb(game.pov, "pick") + " " + object.article + " up."</dynamictemplate>
	<dynamictemplate name="TakeUnsuccessful">CapFirst(game.pov.gender) + " can't take " + object.article + "."</dynamictemplate>
	<dynamictemplate name="MaxObjectsInInventory">CapFirst(game.pov.gender) + " can't carry any more items."</dynamictemplate>
	<dynamictemplate name="MaxObjectsInContainer">CapFirst(game.pov.gender) + " can't put more items in " + object.article + "."</dynamictemplate>
	<dynamictemplate name="SeeListHeader">CapFirst(game.pov.gender) + " can see"</dynamictemplate>
	<dynamictemplate name="GoListHeader">CapFirst(game.pov) + " can go"</dynamictemplate>
	<dynamictemplate name="NotCarryingAnything">WriteVerb(game.pov, "be") + " not carrying anything."</dynamictemplate>
	<dynamictemplate name="CarryingListHeader">WriteVerb(game.pov, "be") + " carrying"</dynamictemplate>
	<dynamictemplate name="DropSuccessful">WriteVerb(game.pov, "drop") + " " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DropUnsuccessful">CapFirst(game.pov.gender) + " can't drop " + object.article + "."</dynamictemplate>
	<dynamictemplate name="ObjectCannotBeStored">CapFirst(game.pov.gender) + " can't put " + object.article + " there."</dynamictemplate>
	<dynamictemplate name="AlreadyTaken">"You are already carrying " + object.article + "."</dynamictemplate>
	<dynamictemplate name="NotCarrying">"You are not carrying " + object.article + "."</dynamictemplate>
	<dynamictemplate name="CantUse">CapFirst(game.pov.gender) + " can't use " + object.article + "."</dynamictemplate>
	<dynamictemplate name="CantGive">CapFirst(game.pov.gender) + " can't give " + object.article + "."</dynamictemplate>
	<dynamictemplate name="YouAreIn">WriteVerb(game.pov, "be") + " in"</dynamictemplate>
	<dynamictemplate name="CantOpen">CapFirst(game.pov.gender) + " can't open " + object.article + "."</dynamictemplate>
	<dynamictemplate name="CantClose">CapFirst(game.pov.gender) + " can't close " + object.article + "."</dynamictemplate>
	<dynamictemplate name="OpenSuccessful">WriteVerb(game.pov, "open") + " " + object.article + "."</dynamictemplate>
	<dynamictemplate name="CloseSuccessful">WriteVerb(game.pov, "close") + " " + object.article + "."</dynamictemplate>
	<dynamictemplate name="CannotDoThat">CapFirst(game.pov.gender) + " can't do that."</dynamictemplate>
	<dynamictemplate name="NoKey">WriteVerb(game.pov, "do") + " not have the key."</dynamictemplate>
	<dynamictemplate name="CannotLockOpen">CapFirst(game.pov.gender) + " cannot lock " + object.article + " when " + object.gender + " " + Conjugate(object, "be") + " open."</dynamictemplate>
	<dynamictemplate name="SwitchedOn">WriteVerb(game.pov, "turn") + " " + object.article + " on."</dynamictemplate>
	<dynamictemplate name="SwitchedOff">WriteVerb(game.pov, "turn") + " " + object.article + " off."</dynamictemplate>
	<dynamictemplate name="Eaten">WriteVerb(game.pov, "eat") + " " + object.article + "."</dynamictemplate>
	<dynamictemplate name="YouLooking">WriteVerb(game.pov, "be") + " looking " + text +"."</dynamictemplate>
	<dynamictemplate name="NothingToDrop">WriteVerb(game.pov, "have") + " nothing to drop."</dynamictemplate>
	<dynamictemplate name="NothingToWear">WriteVerb(game.pov, "have") + " nothing to wear."</dynamictemplate>
	<dynamictemplate name="NothingToRemove">WriteVerb(game.pov, "have") + " nothing to take off."</dynamictemplate>
	<dynamictemplate name="WearSuccessful">WriteVerb(game.pov, "put") + " " + object.article + " on."</dynamictemplate>
	<dynamictemplate name="WearUnsuccessful">CapFirst(game.pov.gender) + " can't wear " + object.article + "."</dynamictemplate>
	<dynamictemplate name="CannotWearIfNotHeld">CapFirst(game.pov.gender) + " would need to get " + object.article + " before " + game.pov.article + " can put " + object.article + " on."</dynamictemplate>
	<dynamictemplate name="CannotRemoveIfNotHeld">CapFirst(game.pov.gender) + "would need to get " + object.article + " before " + game.pov.article + " can take " + object.article + " off."</dynamictemplate>
	<dynamictemplate name="AlreadyWearing">WriteVerb(game.pov, "be") + " already wearing " + object.article + "."</dynamictemplate>
	<dynamictemplate name="CannotRemoveIfNotWearing">WriteVerb(game.pov, "be") + " not wearing " + object.article + "."</dynamictemplate>
	<dynamictemplate name="NotRemovable">CapFirst(game.pov.gender) + " cannot remove " + object.article + "!"</dynamictemplate>
	<dynamictemplate name="CannotWearOver">CapFirst(game.pov.gender) + " cannot wear that over " + GetDisplayGarment(object) + "."</dynamictemplate>
	<dynamictemplate name="CannotWearWith">CapFirst(game.pov.gender) + " cannot wear that while wearing " + GetDisplayGarment(object) + "."</dynamictemplate>
	<dynamictemplate name="RemoveSuccessful">WriteVerb(game.pov, "take") + " " + object.article + " off."</dynamictemplate>
	<dynamictemplate name="RemoveFirst">CapFirst(game.pov.gender) + " can't remove that while wearing " + GetDisplayGarment(object) + "."</dynamictemplate>
	<dynamictemplate name="DefaultBuy">CapFirst(game.pov.gender) + " can't buy " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultClimb">CapFirst(game.pov.gender) + " can't climb " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultDrink">CapFirst(game.pov.gender) + " can't drink " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultEat">CapFirst(game.pov.gender) + " can't eat " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultHit">CapFirst(game.pov.gender) + " can't hit " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultKill">CapFirst(game.pov.gender) + " can't kill " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultKiss">CapFirst(game.pov.gender) + " can't kiss " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultKnock">CapFirst(game.pov.gender) + " can't knock " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultLick">CapFirst(game.pov.gender) + " can't lick " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultLie">CapFirst(game.pov.gender) + " can't lie on " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultListenTo">WriteVerb(game.pov, "listen") + ", but " + object.gender + " makes no sound."</dynamictemplate>
	<dynamictemplate name="DefaultLock">CapFirst(game.pov.gender) + " can't lock " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultMove">CapFirst(game.pov.gender) + " can't move " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultPull">CapFirst(game.pov.gender) + " can't pull " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultPush">CapFirst(game.pov.gender) + " can't push " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultRead">CapFirst(game.pov.gender) + " can't read " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultSearch">CapFirst(game.pov.gender) + " can't search " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultShow">CapFirst(game.pov.gender) + " can't show " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultSit">CapFirst(game.pov.gender) + " can't sit on " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultSmell">WriteVerb(game.pov, "sniff") + ", but " + object.gender + " doesn't smell of much."</dynamictemplate>
	<dynamictemplate name="DefaultTaste">CapFirst(game.pov.gender) + " can't taste " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultThrow">CapFirst(game.pov.gender) + " can't throw " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultTie">CapFirst(game.pov.gender) + " can't tie " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultTouch">CapFirst(game.pov.gender) + " can't touch " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultTurnOn">CapFirst(game.pov.gender) + " can't turn " + object.article + " on."</dynamictemplate>
	<dynamictemplate name="DefaultTurnOff">CapFirst(game.pov.gender) + " can't turn " + object.article + " off."</dynamictemplate>
	<dynamictemplate name="DefaultTurn">CapFirst(game.pov.gender) + " can't turn " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultUnlock">CapFirst(game.pov.gender) + " can't unlock " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultUntie">CapFirst(game.pov.gender) + " can't untie " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultUseOn">CapFirst(game.pov.gender) + " can't use " + object2.article + " that way."</dynamictemplate>
	<dynamictemplate name="DefaultWear">CapFirst(game.pov.gender) + " can't wear " + object.article + "."</dynamictemplate>
	<dynamictemplate name="DefaultListen">CapFirst(game.pov.gender) + " can't hear much."</dynamictemplate>
	<dynamictemplate name="DefaultJump">WriteVerb(game.pov, "jump") + ", but nothing happens."</dynamictemplate>
	<dynamictemplate name="EditorVerbDefaultExpression">CapFirst(game.pov.gender) + " can't #verb# " + object.article + "."</dynamictemplate>

(Changing them all to dynamic templates was probably an inefficient way of doing it. I could have used the text processor instead. But I don't think there should be any problem with those)

I was actually doing this originally because I wanted my game to use "I" for the player character, recreating the first computer game I played; but it should all work for "you" or "he" as well. With all these templates in, changing the player pronoun is as simple as changing the player object's gender attribute.


I remember that thread and I tried to use those dynamic teplate code out side a library and I always get this error that's why I started this thread
Error running script: Invalid variable name '<template___SPACE___name' in '<template___SPACE___name = "SeeListHeader">=CapFirst(player.pov_alias)'


That sounds like you're putting the XML in a script.

It doesn't go in a script. You need to either put it in a library, or put it into your game file in full code view, after (and at the same level as) the <include ref="English.aslx" /> directive.

I don't think it's possible to change a template once the game has started; but it should be possible to make a template which will display the right thing in all circumstances.


You mention getting it to do the right thing under the right circumstances before but you were kind of vague can you give me a more detailed explanation?. Like do I use what if sentences in the library or? Like for instance if this object is the current point of view then use he or she rather than you


Actaually, that's what happens when you put spaces in attributes.

If template is an attribute, it would be "template name" which comes out as "template___SPACE___name". Don't ask me why.

Try templatename instead, if you can find it...


@ jmnevil54 tried it no luck
@mrangel So same question to you from my previous post


You mention getting it to do the right thing under the right circumstances before but you were kind of vague can you give me a more detailed explanation?. Like do I use what if sentences in the library or? Like for instance if this object is the current point of view then use he or she rather than you

You use the WriteVerb function.

Taking a random example from the templates I posted above:
<dynamictemplate name="NothingToDrop">WriteVerb(game.pov, "have") + " nothing to drop."</dynamictemplate>

This is the template which is displayed if the player types "drop all" when they're not carrying anything.
The default one in quest just says "You have nothing to drop."

The one I gave you will say "You have nothing to drop" if the POV object's gender is set to "you". If the POV object's gender is "he", it will say "He has nothing to drop." instead.

WriteVerb automatically selects the correct form of a verb to use, depending if the gender is "I", "you", "he", "she", "it", "they", or "we".

The templates I've given you will display the right message for the gender of the current POV object. So you don't need to change the template during the game.
I made that list by taking the entire English language pack, and changing every template that has "you" in it to use the gender of the POV object instead. (Except for some of the help messages, where 'you' seems to mean the actual player rather than their character)


@mrangel
Okay so the code and information you gave me, works on every template I have tried except "Can see," and "Can go" I tired Capfirst, and write verb and nothing changed. I did try the "Drop all" command it did You drop when first person, and She dropped like you said it would in third.
So why does the "Can see" and "Can go" not work?


Ah, my mistake. I was still getting used to the system when I compiled this list originally.

Every room has its own strings for "You can see" and "You can go". These are set based on the template when you create the room in the editor, so making them dynamic templates won't work.

I'm not sure, but I think they should work with the text processor versions:

        <template name="SeeListHeader">{=CapFirst(game.pov.gender)} can see</template>
	<template name="GoListHeader">{=CapFirst(game.pov)} can go</template>

Any rooms you've already created in the game will have these strings already set. So you could either go to each room on the editor, and change You can see to {=CapFirst(game.pov.gender)} can see on the room tab; or you could put some code within your 'start' script to change them all when the game starts:

foreach (room, AllRooms() {
  if (HasString (room, "descprefix")) {
    room.descprefix = Replace (room.descprefix, "You are", "{=CapFirst(WriteVerb(game.pov,\"be\"))}")
  }
  if (HasString (room, "objectslistprefix")) {
    room.objectslistprefix = Replace (room.objectslistprefix, "You ", "{=CapFirst(game.pov.gender)}")
  }
  if (HasString (room, "exitslistprefix")) {
    room.exitslistprefix = Replace (room.exitslistprefix, "You ", "{=CapFirst(game.pov.gender)}")
  }
}

(That will change the "You are in", "You can see", and "You can go" strings for all rooms)


(Unfortunately, there's a problem with using WriteVerb(game.pov, "can") - but it's a problem with the English language, that Quest can't easily fix. Because there's two different verbs "can", that conjugate differently. If a guy works at a canning factory, it's correct to say "He cans peaches" or something. There's no easy way for Quest to guess whether you want "He can" or "He cans" without understanding the sentence; so that's one verb that WriteVerb doesn't work for right now)


@ mrangel, what if instead I use the phrase "is able"? Like is able to see, or is able to go?


Yep. {=WriteVerb(game.pov, "be")} will give you "You are", "I am", "He is", "She is" etc.

Or you can just stick with {=CapFirst(game.pov.gender)} can to have "I can"/"You can"/"He can"/etc, and that will work. It just means that when you're writing these, you have to remember that "can" is different all the other verbs.


Okay one last thing, your {=WriteVerb(game.pov, "be")} or {=CapFirst(game.pov.gender)} , where do I put it? In a library or in a script? and do I added it to more code like
if (HasString (room, "exitslistprefix")) {
room.exitslistprefix = Replace (room.exitslistprefix, "You ", "{=CapFirst(game.pov.gender)}")
}


where do I put it? In a library or in a script?

OK… there's three parts to this.

  1. The templates that I listed above (<template and <dynamictemplate lines) can either go in your game file, or in a library. If you put them into your game file in full code view, they should go after the line <include ref="English.aslx" />.

  2. You'd have to change "You" to {=CapFirst(game.pov.gender)} in the "You can see", "You can go", and "You are in" lines for every room you already created. These are on the room tab in the editor. If you have a lot of rooms already, you can put this script (now with a typo fixed) in your game's "start" script instead:

foreach (room, AllRooms()) {
  if (HasString (room, "descprefix")) {
    room.descprefix = Replace (room.descprefix, "You are", "{=CapFirst(WriteVerb(game.pov,\"be\"))}")
  }
  if (HasString (room, "objectslistprefix")) {
    room.objectslistprefix = Replace (room.objectslistprefix, "You ", "{=CapFirst(game.pov.gender)}")
  }
  if (HasString (room, "exitslistprefix")) {
    room.exitslistprefix = Replace (room.exitslistprefix, "You ", "{=CapFirst(game.pov.gender)}")
  }
}
  1. Anywhere your script includes a message that includes the word 'you', you would replace it with a text processor command. {=game.pov.gender} will give "you", "he", or "she" as appropriate. {=CapFirst(game.pov.gender)} will give "You", "He", or "She" for the start of a sentence. {=WriteVerb(game.pov, "be")} will give "you are" or "he is". Depending how much of your game's text you've already written, finding all of these could be a time-consuming process (though you only need to do it for places and events that could be reached with more than one character).

Log in to post a reply.

Support

Forums