Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+3)

Well, if a dialog tree is complicated and contains many unique behaviors, the code may tend to be complicated. I do have a few suggestions that might help:

One thing I notice is that you're writing alternate conditional cases as "else if" instead of using the "elseif" keyword; the former nests conditionals (and requires a stack of matching "end"s) and the latter allows you to write a flatter sequence:

# nested:
if C1 B1 else if C2 B2 else if C3 B3 else B4 end end end
# flat:
if C1 B1 elseif C2 B2 elseif C3 B3 else B4 end

I don't recommend using eval[] on the text of fields to structure reusable pieces of code when you can help; it's usually clearer (and less surprising) to define functions and call them. Instead of:

eval[field2.text () 1]

You could consider

asklove[]

With a definition further down in your script:

on asklove do
 # ...
end

Instead of dispatching like so:

r:dd.ask[ ... ]
if r~0
 dd.say[ask0.value]
elseif r~1
 dd.say[ask1.value]
else
 dd.say[ask2.value]
end

It may be easier to index into a list of widgets:

dd.say[(ask0,ask1,ask2)[r].value]

This doesn't necessarily work when, as in your case, each response has somewhat different logic behind it, but it might be possible to abstract some of those differences into custom dialogizer commands, like the "!light" and "!dark" commands you're using to adjust dialog box styles. Even better might be to use semantically relevant widget names so it's easier to remember what's happening where:

dd.say[(askAboutLove,askAboutYou,askAboutReading,iHaveToGo)[r].value]

I took a crack at reworking the script in the "button1" widget in your example deck, applying some of the above ideas:

on click do
 o.size:180,0
 o.pos:"pos2"
 o.osound:"click"
 o.asound:"click"
 o.tsound:("talk1","moan2","talk3")
 o.speed:3
 dd.style[o]
 dd.open[deck o]
 dd.say[script.value]
 r:dd.ask["What were you looking for?"
  ("You.","Love","What are you reading?","Nevermind...")
 ]
 dd.say[(ask,ask3,ask4,ask5)[r].value]
 if r~0 askyou[] end
 dd.close[]
 pt.clear[]
end
on askyou do
 r:dd.ask["Sarah: and now the site doesn't get much traffic."
  ("Why did it go down?","You do seem like you'd have a low satisfaction score","*say nothing*")
 ]
 dd.say[(ask6,ask2,ask5)[r].value]
 if r~0
  trigger.value:1
  alert["SARAH gave you 'archive artifact'"]
 end
end

You could consider further simplifying the askyou[] function here by making the "give artifact" bit into a custom command, and just having something like

!giveartifact

In the text of the "ask6" field. With askyou[] simplified further, you might just inline it:

on click do
 o.size:180,0
 o.pos:"pos2"
 o.osound:"click"
 o.asound:"click"
 o.tsound:("talk1","moan2","talk3")
 o.speed:3
 dd.style[o]
 dd.open[deck o]
 dd.say[script.value]
 r:dd.ask["What were you looking for?"
  ("You.","Love","What are you reading?","Nevermind...")
 ]
 dd.say[((ask,ask3,ask4,ask5)[r]).value]
 if r~0
  r:dd.ask["Sarah: and now the site doesn't get much traffic."
   ("Why did it go down?","You do seem like you'd have a low satisfaction score","*say nothing*")
  ]
  dd.say[((ask6,ask2,ask5)[r]).value]
 end
 dd.close[]
 pt.clear[]
end

Make sense? Does that help at all?