Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Scripts/Questions/Help

6.770 Antworten
Seite
Zum Anfang Vorherige 1 2165 166 167338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

Skullz
User Off Offline

Zitieren
hey i need help at making lua scripts. first i have some questions there:
• i need to put all that spaces on the scripts? i mean, like i need to put like 10 (or more) spaces for every action i do?
• how long it takes to make a lua script? (a simple one)
• how can i know ALL these actions? that must take a life to learn that.
• is there any link that answers all my questions? if there is a link, sorry for posting this like a newbie.

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
1-Yes, if you want help from us you have to tab your script (not using the spacebar, just press the tab key)

2-Depends on you

3-There is a reference manual: http://www.lua.org/manual/5.1/

4-Yes
http://www.lua.org/pil/
And you can ask here too, but only if your question is not a stupid one like "why does my script not work" (and you post shitloads of code without telling us what is the error) otherwise, I'll write a post full of flame just for you.

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
Yes, just supply the player id to the image() function, DC forgot to add it in the lua readme, but it appears in the changelog

alt Re: Lua Scripts/Questions/Help

DRoNe
User Off Offline

Zitieren
1
2
3
4
function time_hud(id,slot)
        parse([[hudtxt2 ]]..id..[[ ]]..slot..[[ "©255220000Time: ]]..tc.mins..[[ : ]]..tc.secs..[[ 256 416]])
    end
end

why i don't see my hud?

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
• too many ends
• How are you using this function? Because you have to add id & slot parameters into function.
• Make sure you have declared all variables and you have no nils.
• I suggest you using " " and ' ' quote because you don't know why [[ ]] are used. (I guess so)
In other words, you just copied this hudtext without knowing what you are doing.
In fact, now your hudtext is missing ending quote "

I think that's enough for notes...
1× editiert, zuletzt 17.02.10 21:15:25

alt Re: Lua Scripts/Questions/Help

DRoNe
User Off Offline

Zitieren
Blazzingxx hat geschrieben
• too many ends
• How are you using this function? Because you have to add id & slot parameters into function.
• Make sure you have declared all variables and you have no nils.
• I suggest you using " " and ' ' quote because you don't know why [[ ]] are used. [i](I guess so)[/b]
In other words, you just copied this hudtext without knowing what you are doing.
In fact, now your hudtext is missing ending quote "

I think that's enough for notes...


Yes you right, im copied this hudtext without knowing what i doing ... but where i learn it?

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
I think this string format could be more useful for you:
1
parse('hudtxt2 '..id..' 1 "This is some text" 320 240')

alt Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Zitieren
Alright, I'm trying to make a inventory script, but how do I do it where you can add stuff to a menu and remove stuff from a menu?

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
Actually, there are no CS2D Lua functions to remove buttons from menus.
You can store items in tables and later display them on menu.
Like:
1
item[player][item] = count
1× editiert, zuletzt 17.02.10 23:31:58

alt Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Zitieren
DRoNe hat geschrieben
where are you learn it, this code help's me not if i don't know it...

www.lua.org <- the best place contains all info excluding the CS2D functions
but for someone new to scripting they might need to read/watch a tutorial
there are a lot of users here that have a Lua tutorial

alt Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Zitieren
So I have to make 84 tables? O.o, Also, I mean like, you have a inventoury, and then you put another button on that menu, but thanks for the answer I needed that too lol.
1× editiert, zuletzt 18.02.10 01:14:26

alt Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Zitieren
I was trying to learn about metatables and I used this
1
2
3
4
5
6
7
8
9
10
11
t1 = {a = 1}
t2 = {}

setmetatable(t1, t2)
t3 = {c = 3}

t2.__index = t3

print(t1.a)
print(t1.b)
print(t1.c)
and the output is
1
2
3
1
nil
3
what i need to know is why.

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
@Void:
It's because you've set it like that ?

It printed 1 because t1 has a key named "a" and it has the 1 value assigned to it.

It didn't print t1.b because t1 hasn't got that key, so Lua started looking for that value in t2's index (because it's t1's metatable), but it didn't find it there neither, so it returns nil.

It printed 3 because lua found that value in t2's index (t3) and remember that t2 is the metatable of t1.
1× editiert, zuletzt 18.02.10 07:30:44

alt Re: Lua Scripts/Questions/Help

DRoNe
User Off Offline

Zitieren
Blazzingxx hat geschrieben
I think this string format could be more useful for you:
1
parse('hudtxt2 '..id..' 1 "This is some text" 320 240')


...i still don't see my hud, what is the problem?

alt Re: Lua Scripts/Questions/Help

DRoNe
User Off Offline

Zitieren
ok, but dont smiling im Noobking of scriptz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
if tc==nil then tc={} end
tc={}

function initArray(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end

tc.secs = initArray(32)
tc.mins = initArray(32)

parse ("sv_fow 1")
parse ("sv_gamemode 2")

addhook("usebutton","tcstart")
function tcstart(id,x,y)
if (x==75) and (y==79) then
tc.secs[id]=tc.secs[id]+1
if (tc.secs[id]>=59) then
tc.mins[id]=tc.mins[id]+1
tc.secs[id] = 0
end
end
end

function time_hud(id)
parse('hudtxt2 '..id..' 1 "©255220000Time:'tc.mins' ':' 'tc.secs'" 320 240') 
end
i want to do timecounter ...

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
I found some mistakes with strings:
1
2
3
function time_hud(id)
	parse('hudtxt2 '..id..' 1 "©255220000Time:'..tc.mins..' :'..tc.secs..'" 320 240')
end
You should place your hud function in any hook...
Haven't you noticed that you aren't using your hudtxt function?
Zum Anfang Vorherige 1 2165 166 167338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht