Using text from elsewhere

Dogz
31 Dec 2013, 07:55
Hello!
This is probably a stupid question, but please answer it as simply as possible. I'm a bit new to this sort of thing.
Anyways, I want to use text I already typed without typing it again (or copy and paste).
Basically, here's what I'm going for.

Player enters a room.
"You're in a room. There's a bed."

player types "look at room"
"you're in a room. There's a bed."

Basically, if player says "look at room", I want it to give the same message as when you walk in.
Is there a way to get multiple things to use text from a single place?

I hope my question makes sense. Thanks for any help!

By the way, I'm using the online version.

jaynabonne
31 Dec 2013, 09:02
Your question does make sense. It's about not duplicating things all over the place. Generally, the answer is that it depends on what you're doing. For example, the case you gave is *almost* handled already. When you enter a room, it dumps out the room description. If you type "l" or "look", it uses the same description. So that's done. You just need to make the specific phrase "look at room" also map to the same call: ShowRoomDescription.

For other situations, the pattern is similar. You either need to have the text in a common place that can be accessed from multiple places of script, or you need to have a common function you can call from those places.

Not sure if that helped, but...

Pertex
31 Dec 2013, 11:23
Just a way to do it: First create a function where you add variables like game.xxx where you can save your texts.
t1.png


Then call this function in the startscript of your game
t2.png


Now you can call your text by printing your variables
(in code view:
msg(game.xxx)