English Table in Hudtxt2

13 replies
Goto Page
To the start Previous 1 Next To the start
03.07.12 02:50:19 pm
Up
Sudden Death
User
Offline Off
Like in title, my question is how to show table
More >

in Hudtxt2:
Code:
parse('hudtxt2 '..id..' 6 "questionbox['..math.random(1,15)..']" 120 420')

questionbox is name of table and that math.random is for random question from this table, I hope you understand what I wrote here
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
03.07.12 03:13:01 pm
Up
Alistaire
User
Offline Off
Why did you put quotation marks around that table?

Now it will just create a hudtext saying 'questionbox['..math.random(1,15)..']', not the actual table value.
IMG:http://i.imgur.com/5zhwOTP.png
03.07.12 03:13:55 pm
Up
Sudden Death
User
Offline Off
Becouse I won't get number but txt :l
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
03.07.12 03:14:44 pm
Up
Alistaire
User
Offline Off
So you WANT it to print 'questionbox['..math.random(1,15)..']'?

----

Srsly, remove the quotation marks.

Also, why the fuck did you add '.. and ..' at that value! You HAVE a value in your table which is called ..math.random(1,15).. ?
IMG:http://i.imgur.com/5zhwOTP.png
03.07.12 03:22:42 pm
Up
Sudden Death
User
Offline Off
Ehh, you don't understand
I want to print random question from table called questionbox and I removed quotation marks but it's don't help.
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
03.07.12 03:35:46 pm
Up
Alistaire
User
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
questionbox = {
     [1] = 'Question 1',
     [2] = 'Question 2',
     [3] = 'Question 3',
     [4] = 'Question 4',
     [5] = 'Question 5',
     [6] = 'Question 6',
     [7] = 'Question 7',
     [8] = 'Question 8',
     [9] = 'Question 9',
     [10] = 'Question 10',
     [11] = 'Question 11',
     [12] = 'Question 12',
     [13] = 'Question 13',
     [14] = 'Question 14',
     [15] = 'Question 15'
}

parse('hudtxt2 '..id..' 6 ""..questionbox[math.random(1, 15)].."" 120 420')
IMG:http://i.imgur.com/5zhwOTP.png
03.07.12 04:34:55 pm
Up
Sudden Death
User
Offline Off
Okay, it's work, thanks you
(But I have to change quotation marks from " to ', i don't understand lua >.>)
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
03.07.12 06:20:00 pm
Up
Alistaire
User
Offline Off
Well if the text doesn't need quotation marks just delete the "".. and .."".

Also, you could make the table like;

Code:
1
questionbox = {'Question 1', 'Question 2', etc etc}


But that would create nil values in the table with the NAMES 'Question 1' and so forth. Also, the table you've made is just wrong.

Code:
1
2
3
questionbox = {
     {'s1','s2','s3','s4','s5','s6','s7','s8','s9','s10','s11','s12','s13','s14','s15'}
}


- You made a table inside a table, so it's like questionbox[1]['s1'] etc.

- The table values are nils
IMG:http://i.imgur.com/5zhwOTP.png
03.07.12 09:07:58 pm
Up
EngiN33R
Moderator
Offline Off
user Alistaire has written:
Well if the text doesn't need quotation marks just delete the "".. and .."".

Also, you could make the table like;

Code:
1
questionbox = {'Question 1', 'Question 2', etc etc}


But that would create nil values in the table with the NAMES 'Question 1' and so forth. Also, the table you've made is just wrong.


user Alistaire, you're wrong.
Code:
1
2
3
questionbox = {'Question 1', 'Question 2'}
print(questionbox[1]) -> Question 1
print(questionbox[2]) -> Question 2


@thread:
Code:
1
parse('hudtxt2 '..id..' 6 '..questionbox[math.random(1,15)]..' 120 420')

Should work.
I code, therefore I exist. | Visit my blog for Lua tips and other interesting info
03.07.12 09:42:47 pm
Up
omg
User
Offline Off
lol alistaire...i believe this is the second time u had the same misconception with tables and engineer corrected u both times
will code for food
03.07.12 09:53:29 pm
Up
Infinite Rain
Reviewer
Offline Off
user Yates has written:
@user omg: Tables are so fucking hard man, look at this complicated shit:

IMG:http://media.treehugger.com/assets/images/2011/10/buygreen-bravespace-hollow-dining-table.jpg

Lol'd so hardly
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV
03.07.12 10:02:24 pm
Up
Alistaire
User
Offline Off
user omg has written:
i believe this is the second time u had the same misconception with tables and engineer corrected u both times


Because he likes to correct people.
IMG:http://i.imgur.com/5zhwOTP.png
03.07.12 10:13:47 pm
Up
Avo
User
Offline Off
I can't see what you post here dudes...

@user Sudden Death:

Code:
1
2
3
questionbox={"What's your favourite color?","What do you think about this stupid answers?","Have you got a dog?","How old are you?","Do you want to be DC for a one day?"}
local q=questionbox[math.random(1,#questionbox)]
parse('hudtxt2 '..id..' 6 "'..q..'" 120 420')
03.07.12 10:22:25 pm
Up
EngiN33R
Moderator
Offline Off
@user Alistaire: I endeavour to eliminate ignorance, that's all. Usually it involves correcting others.
@user Avo: That would work, too, although there's an extra line that can be omitted.
I code, therefore I exist. | Visit my blog for Lua tips and other interesting info
To the start Previous 1 Next To the start