Hi, apologize for being back to the forum again so soon, but I can't seem to figure out how to, in the game, have a script or function that generates numbered objects. I'm trying to create a device in game that records notes typed by the player and stores them to be recalled later named chronologically (i.e. Memo 1,Memo 2, Memo 3...). I've got the use of getimput down to put the message typed by the player into an attribute value spot on a Memo object generated by the device using the create an object function. The trouble is I can only make the one. I've tried various ways to do it, including not having Memos be objects at all but nothing has worked. I'm thinking making them objects is simpler because objects can be recalled through object lists and I'd like there to be a Memo Book function which lists all the Memos taken so far, before letting the player select them as links to read back. I feel like this is either really simple and I'm missing something or what I'm asking is kind of complex. Haven't been able to find a similar question/solution. Thanks in advance.
Well, my main language is not english, I possibly do not know what you need,
but you can give this a try
Nemos swimming around daeun's head
Sample play
https://textadventures.co.uk/games/view/57zl3sqjdeoeuqwqok9r5q/test
Sample code (Customize according to what you need)
To paste the code
<!--Saved by Quest 5.8.6836.13983-->
<asl version="580">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="test6">
<gameid>a9c3bcd5-e10a-411c-968c-59b1e0857889</gameid>
<version>1.0</version>
<firstpublished>2024</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<isroom />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="memo">
<inherit name="editor_object" />
<record type="script">
get input {
this.note = result
this.number = this.number+1
this.alias = this.name+" "+this.number
CloneObject (this)
this.alias = "memo"
}
</record>
<playback type="script">
msg (""+this.note)
</playback>
<note type="string"></note>
<number type="int">0</number>
</object>
</object>
<verb>
<property>record</property>
<pattern>record</pattern>
<defaultexpression>"You can't record " + object.article + "."</defaultexpression>
</verb>
<verb>
<property>playback</property>
<pattern>playback</pattern>
<defaultexpression>"You can't playback " + object.article + "."</defaultexpression>
</verb>
</asl>
That's an interesting way to do it… although I think you can get some odd behaviour if the player tries to use the "record" verb on a memo that's already been recorded. (You could end up with an object whose alias is something like "memo16 17")
I'm sure you can figure out how to deal with this. But I think I'd probably do it by using a command. Off the top of my head, something like:
<command name="makememo">
<pattern>record memo #text#</pattern>
<script>
number = this.next_number
this.next_number = number + 1
create ("memo" + number, "memo")
newmemo = GetObject ("memo" + number)
newmemo.alias = "Memo " + number
newmemo.text = text
newmemo.number = number
AddToInventory (newmemo)
msg ("You recorded {object:memo"+ number +"}.")
</script>
<attr name="next_number" type="int">1</attr>
</command>
<type name="memo">
<read type="script">
msg ("This is memo number " + this.number)
if (HasString (this, "text")) {
msg ("It says " + this.text + ".")
}
</read>
<look type="script">
msg ("It's a memo. If you want to know what it says, you can {command:read "+ this.alias +":read it}")
</look>
</type>
(Note: This is just a command and a type. Unlike the previous example, they need to be inserted into an existing game)
The AI says, your line 21 should be
msg ("It says " + this.text + ".")
For people whom dun understand parser commands, you simply type in "record memo Idrina is the murderer"
Then type "read Memo 1"
According to mrangel's feedback, I have changed my code
Code 2
<!--Saved by Quest 5.8.6836.13983-->
<asl version="580">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="test6">
<gameid>a9c3bcd5-e10a-411c-968c-59b1e0857889</gameid>
<version>1.0</version>
<firstpublished>2024</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<isroom />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="memo">
<inherit name="editor_object" />
<note type="string"></note>
<number type="int">0</number>
<record type="script">
get input {
if (this.prototype=memo) {
msg ("This page has already been written")
}
else {
this.note = result
this.number = this.number+1
this.alias = this.name+" "+this.number
CloneObject (this)
this.alias = "memo"
}
}
</record>
<playback type="script">
msg (""+this.note)
</playback>
</object>
</object>
<verb>
<property>record</property>
<pattern>record</pattern>
<defaultexpression>"You can't record " + object.article + "."</defaultexpression>
</verb>
<verb>
<property>playback</property>
<pattern>playback</pattern>
<defaultexpression>"You can't playback " + object.article + "."</defaultexpression>
</verb>
</asl>