Dial
var/npct = ""
var/responses = list()
Resp
var/respt
var/Dial/next
mob/var/talktarget
mob/proc
ShowDial()
winshow(usr,"dial",1)
GetDial(mob/M,var/Dial/D)
var/Resp/R
src.talktarget = M
winset(src,"npctalk",{"\
<title>[M.name]</title>
<br>
<br>
<style>
body{
background: black;
color: white;
}
</style>
<body>
<b>
[D.npct]
</b>
</body>"})
winset(src,"playerchoice",{"cells="1x""})
for(R in D.responses)
src<<output("<a href=?src=\ref[src];action=[R]>[R.respt]</a>","playerchoice:1,++")
mob
Topic(href,href_list[])
switch(href_list["action"])
if(Resp) //undefined var
GetDial(src.talktarget,Resp.next)
Problem description:
It calls Resp an undefined var, therefore calling Resp.next an undefined var. However, I'm not sure how to make it recognize a datum as a defined var. I tried putting var/ BEFORE resp in the if() statement, but that only gave me more errors.
What the code does:
The code is supposed to create a dialogue system similar to The Elder Scrolls games, where each line of dialogue and each player response are recognized as their own object. The dialogue text is output to a browser in a window, and then the possible responses are listed in a grid, with all of the actions being listed as the datums, creating the potential for infinite responses, if I wanted it that way.
EDIT:
I just fixed a few things in the code, because quite a few of these lines were causing compiler and runtime errors, and even glitches. Here's an updated version:
Dial
var/npct = ""
var/responses = list()
Resp
var/respt
var/Dial/next
mob/var/talktarget
Dial/TestDial
npct = "Hello, I'm Santa Clause. You are a worthless piece of crap."
responses = list(/Resp/TestDialRA,/Resp/TestDialRB,/Resp/TestDialRC)
Resp
TestDialRA
respt = "No, you!"
TestDialRB
respt = "Okay. :("
TestDialRC
respt = "How dare you!"
mob/proc
ShowDial()
winshow(src,"dial",1)
GetDial(mob/M,Dial/D)
var/Resp/R
var/i=1
src.talktarget = M
src << browse("[M.name]","window=dial")
winset(src,"playerchoice",{"cells="1x1"})
for(R in D.responses)
src<<output("<a href=?src=\ref[src];action=[R]>[R.respt]</a>","[i++],[i++]")
/*mob
Topic(href,href_list[])
switch(href_list["action"])
if(Resp) //undefined var
GetDial(src.talktarget,Resp.next)
*/
The problem I have here is listing the responses, I'm not sure why, but none of them are showing up in my Dial window.
Well, onto the problems I noticed...
You are attempting to loop through /Resp datums but are scripting to where there aren't actually any inside your responses list, only the paths. To fix that simply add new in front of each path.
Im not entirely sure, but I do believe you are using winset() incorrectly as well. It should be winset(src,"parentWindow.gridName","cells=1x1").
Also, the way you've set the grid, I believe you aren't using output correctly, and it would display output in a diagonal slash downwards. That can easily be fixed though.
Now, I could be wrong on some of my points, because I'm not sure if setting a grid to default will cause it to react differently to commands (I prefer on-screen interaction opposed to the use of grids). However, my suggestions should help you tremendously.