"Paint"-command that changes "look at"-descriptions

chellkafka
So, I want to put something like "paint" into my game. So when the player has it in its inventory, the player can type "paint #text# on *object*" (I thought I would put 4 walls, a floor and a ceiling as objects in the rooms, but any other object should be "paintable"). The text is some message or a description of a picture, or just any bullshit the player types in. And after that is done, if the player looks at the object, the text should be displayed.

I guess, changing the "look"-attribute does the trick, but I don't know how to change the value to the text the player types in. Any suggestions?

Liam315
How you do this depends on a few things:
1. Does painting an object a second time replace the first paint job or would it be in addition to it?
2. Do you want to trigger certain events after something specific is painted and/or after an object gets painted?
3. Will you need to allow for the player's input to contain sentences longer than 1 or 2 words?
4. How exactly do you want the painting to be displayed within the object description?

For the "look at" descriptions it would probably be easiest to redefine the default "look at" command to add the additional detail at the end of a description.

A string list attribute would be appropriate for cumulative painting; every time the player paints something, you can make the paint command add the player's input to the string list of the object that got painted. If each object can only hold 1 type of painting, then modifying the look attribute might be sufficient,

If everything should be paintable then you should also be looking at creating a new object type or remodeling the existing default object type to include new attributes that hold the values pertaining to painting.

jaynabonne
Here's one way to do it. (Seems I was thinking along the same lines as Liam. :) )

There is a Paintable base type for objects that implements "look". You need to add a "description" attribute to the objects to hold the normal description. It only remembers the most recent painting.

jaynabonne
Here is another approach, which might be simpler. No base type, no need to define common text. It uses the text processor.

<!--Saved by Quest 5.5.5173.27901-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="PaintText2">
<version>1.0</version>
<firstpublished>2014</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="book">
<inherit name="editor_object" />
<look>It looks like an old textbook. {if book.painted: It is defaced with paint spelling out "{book.paintedtext}".}</look>
</object>
<object name="desk">
<inherit name="editor_object" />
<look></look>
<look>It's an old-fashioned hardwood desk {if desk.painted: with "{desk.paintedtext}" painted on it.}</look>
</object>
<object name="wall">
<inherit name="editor_object" />
<scenery />
<look>The wall is covered in gaudy wallpaper. {if wall.painted: You see something paint on it: "{wall.paintedtext}".}</look>
</object>
</object>
<command name="PaintText">
<pattern>paint #text# on #object#</pattern>
<script>
msg ("You spray the words '" + text + "' onto the " + GetDisplayAlias(object))
object.paintedtext = text
object.painted = true
</script>
</command>
</asl>

The paint command adds the painted text and sets the "painted" attribute on the object. The description checks the painted state and adds the painted text if it's true. You need to add the description and logic to each object but... you get to customize the text for each object...

You can also do this entirely in the editor, in the standard description section.

chellkafka
Ok, so, Jay, thanks for the code, works pretty good, though, some text won't work. I typed in paint "Read after nuclear war." on book, but the command wasn't understood. There shouldn't be any restrictions for the player what to type in, is that possible?

Addressing the questions of Liam, a second time should not replace the first painting. I thought that with big objects like walls etc the paintings should be additive, but with small objects like notes the paintings should get blurred like if the player paints the second time on the note the description should say something like "It is pretty blured, but you can decipher #text1# and #text2#." and the third time it shouldn't be readable anymore.
The painting shouldn't trigger any events, they are just a means of providing the player artistic expression. So no restrictions would be the optimal.
the painting should be displayed immediately when there's no significant description for the object, replacing the original description. when there's a significant description, as in it contains a vital information for gameplay, the painting should be displayed in hindsight. maybe even only when looked at twice.

jaynabonne

I typed in paint "Read after nuclear war." on book, but the command wasn't understood.


That's caused by the fact that Quest uses a period to separate commands. It seems it doesn't even ignore periods inside quotes. So it splits it into

paint "Read after nuclear war

and

" on book

as separate commands. I don't know how many people actually know you can type multiple commands that way - like "x book. take book." - and it just seems to cause problems. I've never seen anything good come from it. (Turnscripts don't execute per command, etc. It's just a mess.) The first thing I do in my games is disable that. But to do it, you have to copy the massive HandleCommand function into your game and modify it. I can let you know how if you want to do that.

chellkafka
Yes, please. The less restrictions, the better.

jaynabonne
  <function name="HandleCommand" parameters="command, metadata">
<![CDATA[
handled = false
if (game.menucallback <> null) {
if (HandleMenuTextResponse(command)) {
handled = true
}
else {
if (game.menuallowcancel) {
ClearMenu
}
else {
handled = true
}
}
}
if (not handled) {
StartTurnOutputSection
if (StartsWith (command, "*")) {
msg ("")
msg (SafeXML (command))
}
else {
shownlink = false
if (game.echocommand) {
if (metadata <> null and game.enablehyperlinks and game.echohyperlinks) {
foreach (key, metadata) {
if (EndsWith(command, key)) {
objectname = StringDictionaryItem(metadata, key)
object = GetObject(objectname)
if (object <> null) {
msg ("")
msg ("&gt; " + Left(command, LengthOf(command) - LengthOf(key)) + "{object:" + object.name + "}" )
shownlink = true
}
}
}
}
if (not shownlink) {
msg ("")
OutputTextRaw ("&gt; " + SafeXML(command))
}
}
if (game.command_newline) {
msg ("")
}
commands = Split(command, "")
game.pov.commandmetadata = metadata
if (ListCount(commands) = 1) {
game.pov.commandqueue = null
HandleSingleCommand (Trim(command))
}
else {
game.pov.commandqueue = commands
HandleNextCommandQueueItem
}
}
}
]]>
</function>

I just changed the "." to a "" in the Split for the command, so it won't split at all.

chellkafka
So, I copied the function and replaced it with your code, but the game fails to load because
Error: Error adding script attribute 'script' to element 'HandleCommand': Invalid variable name ''

jaynabonne
I might need to see your file. I pulled this straight out of a test I had, so I know it works there. It might be a simple problem.

chellkafka
alright

jaynabonne
I don't see the HandleCommand in that file. :)

jaynabonne
Regardless, here it is with HandleCommand put in. I wasn't able to figure out where the paint stuff happens, so I'll leave that to you.

chellkafka
Alright, thanks a lot. Sorry, I deleted it before uploading, wasn't thinking, sorry.
Thanks a lot, man, again. Again you helped me, provided me code. I'm not sure what to say or what to do, so I'm gonna let it be, but if this game is ever gonna make it, you'll get support and programming credits. If you want to. So, yeah, thanks.

jaynabonne
No problem. That's what we're here for. :)

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums