Page 1 of 1

how to use rng?

Posted: Thu Jul 10, 2014 11:02 am
by IvenGray
I was trying to make a randomized chat, but kept failing at it. It seems that rng.table() or rng.percent() just doesn't work in my chat text.
I got "rng.table(greeting)" and "rng.percent(25)" directly printed out in the dialog. I guess the problem is that I haven't required rng, but I don't know how to do it.

This is my source code:

Code: Select all

newChat{ id="Greeting",
    text = [[#light_green# rng.percent(25) .. "my friend."]],
    answers = {
        {[["Greetings. May I ask you something?"]], jump="Question"},
        {[[Greetings.]]},
    },
}

Re: how to use rng?

Posted: Thu Jul 10, 2014 12:05 pm
by HousePet
That is because you are putting the rng functions inside the text string.

What exactly are you trying to randomise?

Re: how to use rng?

Posted: Fri Jul 11, 2014 12:37 am
by IvenGray
I was following the "T4 Modules Howto Guide", trying to make a randomized greeting chat like the guide do. Then since it didn't work out, I switched to another function, the rng.percent(), to see if rng functions work.

And you are right, Housepet. The problem is that the "rng.table()" mistakenly putted in a string, thank you for helping me out. It seems that I need an improved knowledge of lua syntax.

Re: how to use rng?

Posted: Mon Jul 14, 2014 8:43 pm
by Sradac
how to guide? pssshh. Just take something that already exists, break it, then hit it with a hammer a whole bunch of times until it sticks together and "kind of works" like I do.