Need example to use defork with printer module (SOLVED)

Hi, i’m new here. So, I would like to know how to use the printer module to get the writter effect with the defork module. I’m trying to get something like that :
text effect on this :
1st paragraph of text -> bla bla bla bla bla…
then the user touch the screen or waits a bit and i goes :
2nd paragraph bla bla bla bla , blabla …
until the text ends and shows the options for switching node.
stop writter effect.

Maybe it’s too complicated to tell me how to do it, but just a hint would be great, cause now i’m stuck.

Thank you so much.

2 Likes

Hello!
Are you trying to use this modules: Defork and Printer?
Yea, defork provides example to work with RichText, but for Printer you should enough to use next functions from Defork:

  • defork.getText()
  • defork.getOptions() / defork.getOptionText(i)

In Printer example you should get text from Defork instead of predefined texts and that’s all.

If you want handle click on options, you should do it by yourself, depends on how you make options visuals (possibly another text nodes)

if you want catch the printer effect ends, you should catch the is_print flag. Sorry, but for now there is no custom callback. I will update module soon for better customization (callbacks, styles and other)

As I know, RichText have the writter effect too. Is it not enough for you?

2 Likes

Thank you for your answer,

I didn’t know that RitchText have that function, I’m gonna check it tomorrow. And as you tell me, for me it would be better to stick with defork and RitchText . I’ll try that as I dig into the code. Not a code guy but I’m trying really hard :slight_smile:
Really glad that I got an answer! ^^

1 Like

If you download the Rich Text project from GitHub and open it in Defold it contains an example program that shows how to achieve the effect you are asking for.

2 Likes

I can’t make richtext.truncate work with Defork, I think it’s because Defork already grabs the text with the options and character name image etc. I tried but the effect occurs everywhere, and when I choose an option to show up other node it does some errors on the console. And I don’t see how to handle only one sentence showing up until user touch to continue reading. I must study more the code and understand what it does, before trying to accomplish what I want, I think. Thank you anyway.

1 Like

Defork already depends on/supports RichText: https://github.com/paweljarosz/defork#richtext-helping-functions

@Pawel can probably explain a bit more how to work with Defork and RichText to achieve what you want.

1 Like

Hey! :wink:

Indeed, Defork was meant to be only for extracting text from json files from Twine, but then I also added RichText support to actually display a text. In the example I provided with Defork, it doesn’t animate a text appearing because I wanted to use RichText hyperlink feature, which allows to easily create “buttons” out of a text.

To avoid that, get rid of
defork.showRichText()
OR modify this function.

For text use only: defork.getText()
and for options: defork.getOptionText()

To understand what do you need from options:
pprint(defork.getOptions()) - this prints the whole table that is returned from getOptions() - this table describes options - each of them has:

  • link (string) string name of the option
  • name (string) - actual text of the option
  • pid (ID) to next node pointed by this option

I’ll try to prepare solution to print it with the Defold-Printer :wink:

1 Like

Wow, thank you for your explanation. It feels good to get some assistance when you.re trying to go all alone into the dev side ^^
I’ll try again tomorrow, sounds good to get the text alone, after that maybe the getOptionText() still work with the part of rich text that is needed to create the text as clickable.
thank you all

Using RichText hyperlink was a shortcut to create that example - you can, and probably would like to, create a gui node representing the button with an option, write a text on top of that button, and instead of detecting clicking on the text - detect clicking on the button gui node :wink:

1 Like

Here is a modified example of Defork that uses Defold-Printer instead:

defork-master-but-with-defold-printer.zip (7.8 MB)

Forgive me, that the result is as is, but I didn’t modified the text provided by defork.createOnePanelText() that is actually suited for RichText with all its <> tags. It is up to you, what informations you want to print :wink:

So - you can modify defork.createOnePanelText() to get a text in a format you want
and you can modify or write new function - something like defork.showPrinterText() that utilizes Defold-Printer :wink:

And of course you can achieve the same with RichText - it’s up to you which one you want :wink:

4 Likes

I’ll try it…made my day! ^^

1 Like

Glad I could help! :wink: Don’t hesitate to ask in any case, not only regarding Defork, but Defold too, you will surely get the answer or hints :wink:

1 Like