Forum

> > CS2D > Scripts > My Table is Error!?.
Forums overviewCS2D overview Scripts overviewLog in to reply

English My Table is Error!?.

3 replies
To the start Previous 1 Next To the start

old My Table is Error!?.

Rygna
User Off Offline

Quote
Hi.
Please help me with my Table.
1
2
3
4
5
6
7
8
9
10
11
12
13
Messages = {
	[1] = "1",
	[2] = "2",
	[3] = "3",
	[4] = "4",
	[5] = "5";
}

-- Example Function.
addhook("startround","Messages")
function _RandomHUD()
	msg("\169255255255Messages : "..math.random(Messages[1,5]))
end

If you can fix it?, please tell me how to fix it.
#Thanks
***

old Re: My Table is Error!?.

Cure Pikachu
User Off Offline

Quote
1
math.random(Messages[1,5])
Wrong order. Fixed:
1
Messages[math.random(1,5)]
Also
1
2
3
4
5
6
7
Messages = {
	[1] = "1",
	[2] = "2",
	[3] = "3",
	[4] = "4",
	[5] = "5";
}
can be shortened to
1
Messages = {"1","2","3","4","5"}
EDIT: I forgot.
1
addhook("startround","Messages")
Change that to
1
addhook("startround","_RandomHUD")
edited 1×, last 23.01.16 09:07:58 am

old Re: My Table is Error!?.

Gaios
Reviewer Off Offline

Quote
I appreciate that you learn Lua instead of creating new scripts by copying from others.

This one will help you:
> http://cs2d.com/help.php

But keep more care.. I starded learning Lua by creating very simple script like:
• show message "lol" when a player type "123" on a chat
• equip item 83 when I reach tile [5,5]
• and so on...

m8, I can learn you it if you want to
Add me on skype: adrian_gajos

EDIT:
Also first of all I started to learn whole Lua libray of CS2D (and main Lua Scripting Rules of course ). I learned all hooks and many functions. This helped me to create new scripts because of I learned how CS2D's Engine works.
edited 1×, last 23.01.16 12:08:16 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview