Forum

> > CS2D > Scripts > Table in Hudtxt2
Forums overviewCS2D overview Scripts overviewLog in to reply

English Table in Hudtxt2

13 replies
To the start Previous 1 Next To the start

old Table in Hudtxt2

Sudden Death
User Off Offline

Quote
Like in title, my question is how to show table
More >

in Hudtxt2:
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

old Re: Table in Hudtxt2

Alistaire
User Off Offline

Quote
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.

old Re: Table in Hudtxt2

Alistaire
User Off Offline

Quote
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).. ?

old Re: Table in Hudtxt2

Sudden Death
User Off Offline

Quote
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.

old Re: Table in Hudtxt2

Alistaire
User Off Offline

Quote
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')

old Re: Table in Hudtxt2

Sudden Death
User Off Offline

Quote
Okay, it's work, thanks you
(But I have to change quotation marks from " to ', i don't understand lua >.>)

old Re: Table in Hudtxt2

Alistaire
User Off Offline

Quote
Well if the text doesn't need quotation marks just delete the "".. and .."".

Also, you could make the table like;

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.

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

old Re: Table in Hudtxt2

EngiN33R
Moderator Off Offline

Quote
user Alistaire has written
Well if the text doesn't need quotation marks just delete the "".. and .."".

Also, you could make the table like;

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.
1
2
3
questionbox = {'Question 1', 'Question 2'}
print(questionbox[1]) -> Question 1
print(questionbox[2]) -> Question 2

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

old Re: Table in Hudtxt2

omg
User Off Offline

Quote
lol alistaire...i believe this is the second time u had the same misconception with tables and engineer corrected u both times

old Re: Table in Hudtxt2

Alistaire
User Off Offline

Quote
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.

old Re: Table in Hudtxt2

Avo
User Off Offline

Quote
I can't see what you post here dudes...

@user Sudden Death:

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')

old Re: Table in Hudtxt2

EngiN33R
Moderator Off Offline

Quote
@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.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview