Menu

#55 Conditional links

open
nobody
None
5
2010-01-27
2010-01-27
snaga
No

Chris Klimas at gimcrackd.com has developed a very good set of conditional links (CYOA) for TiddlyWiki. His original syntax (he's added to it) was just <<set somevar=somevalue>>, <<if somevar [= somevalue]>>, and <<else>>. He also had a <<choice>> syntax where elements in a bulleted list would be removed from the list one by one as they were selected (and the user returned to the page) but he later said that same thing could be easily done with the IF-THEN-ELSE tags.

Could we please have conditional link syntax, even as a plugin, that is exactly that simple? I'm sure we could use [[SET::Wiki Link|Link]] or something that is more like our existing markup, but I'm looking for that WoaS brilliant simplicity in the final product. :) Thanks

Discussion

  • FutureBoyNil

    FutureBoyNil - 2010-01-30

    That is already possible in the enhancement branch. The syntax is <<<>>> and the command is print(), so
    <<<A=6>>> <<<if(A==6) print('[[link1]]') else print('[[link2]]')>>>
    Of course, you need a bit more code to save the variable to a page so its not volatile. There was a small game I made where you could grab items and the text changed accordingly. And also some math stuff.

    for the visited thing, on the visited page put <<<VISITED[pagename]=true>>>
    and in the parent page:
    <<< if(!VISITED[pagename]) print("* this is a listitem") >>>

    FBnil

     
  • snaga

    snaga - 2010-01-30

    I need to elaborate on the specifications I'm requesting. I'm aware of the backend that already exists in the development branch, but it uses syntax that is not valid Wiki markup. It borrows from programming languages, which is scary to non-technical end-users.

    My suggestion is to use square brackets and the words [[If::, [[Then::, [[Else:: to identify these links, exactly the way we do [[Include:: or [[Special:: . I want to make it crystal clear that my preference is to not add any new characters to our Wiki markup if possible. I'm also thinking of the kids who I hope will use this.

    The rest of the syntax could be the right side of any valid WoaS link, such as [[If::somevar!="value"|Special::Edit Bootscript|Surprise!]]. I am puzzled by the problem of having anything but a link or included page after the IF-syntax. I guess you could accomplish that by going [[If:somevar]] ...A few paragraphs of text... [[EndIf]] That's pretty unambiguous and still simple...

    Basically, I'm asking if you could make the "print()"" syntax parse into a pipe character. The [[EndIf]] stuff would be extra, later...

     

Log in to post a comment.