how to use rng?

Moderator: Moderator

Post Reply
Message
Author
IvenGray
Higher
Posts: 69
Joined: Mon Aug 20, 2012 5:58 am

how to use rng?

#1 Post 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.]]},
    },
}

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: how to use rng?

#2 Post by HousePet »

That is because you are putting the rng functions inside the text string.

What exactly are you trying to randomise?
My feedback meter decays into coding. Give me feedback and I make mods.

IvenGray
Higher
Posts: 69
Joined: Mon Aug 20, 2012 5:58 am

Re: how to use rng?

#3 Post 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.

Sradac
Sher'Tul
Posts: 1081
Joined: Fri Sep 21, 2007 3:18 am
Location: Angolwen

Re: how to use rng?

#4 Post 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.

Post Reply