define selection <selectionname>
info <#variable# | Text>
choice < #variable# |Text> (script)
.
end definedefine selection <Fred_Talk>
info <Talking to Fred...>
choice < What do you know about Porsches?> msg <"Naff all mate.!">
choice <etc>... .
end defineFred_Talk.info = "Talking to Boris..."
Fred_Talk.choice[1] = "Ask him about his tap dancing skills.>"
Fred_Talk.script[1] = do <run_before_he_beats_you_to_a_pulp_procedure>paul_one wrote:Not sure about the solution though, and I can't quite get my mind round to this
define menu <menu>
info <What do you say?>
choice <#one#> stuff..
choice <#two#> stuff..
choice <#three#> stuff..
end definedefine object <menu>
description <what do you want to say?>
action <Oh no - not again!> stuff..
action <*pokie* *pokie* *pokie*> stuff..
end define!library
!asl-version <400>
define type <ConversationNode>
info = UNDEFINED
choice_1 = NULL
lastChoice = NULL
'hook for gatekeeping OnChoosing, may be overwritten
action <BeforeChoosing> {
doaction <$thisobject$; OnChoosing>
}
'internal functionality, should not be overwritten
action <OnChoosing> {
set string <this; $thisobject$>
msg <#(this):info#>
msg <>
set numeric <i; 1>
set string <strChoice; $objectproperty(#this#; choice_%i%)$>
repeat until (#strChoice# = NULL) or (#strChoice# = !) {
msg < %i%. #strChoice#>
inc <i>
if property <#this#; choice_%i%> then {
set <strChoice; $objectproperty(#this#; choice_%i%)$>
}
else {
set <strChoice; NULL>
}
}
msg <>
dec <i>
set string <playerChoice; >
set numeric <n; 0>
repeat until (%n% >= 1) and (%n% <= %i%) {
enter <playerChoice>
set <n; #playerChoice#>
'if (%n% < 1) or (%n% > %i%) then msg < Invalid choice. Choose again.>
}
property <#this#; lastChoice = %n%>
if action <#this#; choice_%n%> then {
doaction <#this#; choice_%n%>
}
else {
if property <#this#; choiceMsg_%n%> then {
msg <$objectproperty(#this#; choiceMsg_%n%)$>
}
else {
debug <Conversation Node "#this#" has no message or state change for choice %n%, which is set to "$objectproperty(#this#; choice_%n%)$".>
}
}
doaction <#this#; AfterChoosing>
}
'hook for additional consequence logic for having made a choice,
'may be overwritten
action <AfterChoosing> {
}
'called when the node is first encountered, add property flag
'"node_initialized" to ensure this only fires once, may be
'overwritten
action <initialize_node> {
}
end define!include <convNode.lib>
define options
debug on
panes disabled
end define
define game <ConversationNodeTypeTest>
asl-version <400>
foreground <white>
background <black>
default fontname <Courier>
default fontsize <12>
startscript {
for each object in game {
if action <#quest.thing#; initialize_node> then doaction <#quest.thing#; initialize_node>
}
}
start room <StartRoom>
command <do conv #cmd1#> {
if real <convNode_#cmd1#> then {
doaction <convNode_#cmd1#; BeforeChoosing>
}
else {
msg <No such conversation node exists.>
}
}
command <jump> {
msg <You jump.>
property <game; jumped>
}
end define
define room <StartRoom>
alias <Start>
look <A very boring location, indeed.>
define object <convNode_1>
type <ConversationNode>
properties <info = Which do |byou|xb like best:>
properties <choice_1 = |crred|cb; choice_2 = |clblue|cb; choice_3 = |cggreen|cb>
action <choice_1> {
set string <this; $thisobject$>
msg <You chose #(this):choice_1#.>
}
properties <choiceMsg_2 = You chose blue.>
action <BeforeChoosing> {
if not property <game; jumped> then {
msg <You must jump first.>
}
else {
doaction <$thisobject$; OnChoosing>
}
}
action <AfterChoosing> {
set string <this; $thisobject$>
msg <Your last choice was #(this):lastChoice#.>
}
action <initialize_node> {
property <game; not jumped>
debug <node $thisobject$ initialized>
}
end define
end defineHaving the menu as more of an (I daresay it) object!