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 216 17 18338 339 Nächste Zum Anfang

alt Lua help

KimKat
GAME BANNED Off Offline

Zitieren
Flacko and Blazzingxx.

I've read a tutorial about line replacement and I found this...

Source: http://www.scintilla.org/SciTELua.html
SciTELua hat geschrieben
append(text) - appends text to the end of the document
insert(pos, text) - inserts text at the specified position
remove(startPos, endPos) - removes the text in the range


Most of the functions defined in Scintilla.iface are also be exposed as pane methods. Those functions having simple parameters (string, boolean, and numeric types) are fully supported. For example, editor:InsertText(pos, text) does practically the same thing as editor:insert(pos, text). Functions having a stringresult parameter will include a string in the return value. For both strings and stringresults, if the function is documented as expecting a length as its first parameter, you do not pass the length from Lua. Instead, it is inferred from the context.
These might help a bit.

I think "pos" is what line you're on. For example third row might be number 3, or 2. (not sure if 0 has anything to do with it.)

So I guess it's like this...
editor:insert(3, "put your code here")

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
y = 10

file = io.open("Read.txt","r")

for line in file:lines() do
y = y + 10
screen:print(100,y,line,white)
end

file:close()
Use parameters like that?
2× editiert, zuletzt 18.06.09 15:23:13

alt Re: Lua Scripts/Questions/Help

kikinep
User Off Offline

Zitieren
DC can you make to all this users but more to me a tut of how to do scripts but plz super easy to understand plz thx

PD:DC or anybody who want to do that ill love you xd

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
kikinep hat geschrieben
DC can you make to all this users but more to me a tut of how to do scripts.

PD:DC or anybody who want to do that ill love you xd

He wont.
You can find some tuts in www.lua.org

alt Re: Lua Scripts/Questions/Help

Kaka024
User Off Offline

Zitieren
i have a small request.
If somebody's nick is "Player" then use command "setname <this player's id> [ByKaka] Guest".

And repeat this check-up every 2 minutes.
It should be useful

alt Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Zitieren
guys, noob need help here

my script almost done, all works fine.. but i got this

LUA ERROR: attempt to call a nil value

I dunno where is it @@

alt Re: Lua Scripts/Questions/Help

wups
User Off Offline

Zitieren
Yes of course they can change the nick back, but add the nick hook and it should work fine?

But really annoying :p

NIL = nothing, check at the code if you block nil.

alt Re: Lua Scripts/Questions/Help

Kaka024
User Off Offline

Zitieren
I only want to rename players without nicks (I mean "Player" nick) to guests, because its better than "Player 1, player 2" etc.
So can smbd do it for me? That person can add message "Player has been renamed by ...'s system"

@edit
so... can anybody make that for me?

@edit2
tried this one (remaked script of one user+advertisements - thx for him)
but something wont work :S

addhook("minute","sample.nickchange")
addhook("join","nickjoin")
function nickjoin(p)
n = player(p,"name")
function sample.nickchange()
if (string.find(n,"player") ~= nil) then
parse("setname "..p.." [ByKaka] Guest")
end
end
end

@edit
No way! I've made it! Alone!

A simple script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
addhook("join","nickjoin")
addhook("spawn","pspawn")
a=0

function nickjoin(p)
n = player(p,"name")
 
function pspawn(p)
if n=="Player" then
a=a+1
parse("setname "..p.." [ByKaka] Guest #" ..a)
end
end
end
6× editiert, zuletzt 21.06.09 20:24:05

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
KimKat hat geschrieben
I think "pos" is what line you're on. For example third row might be number 3, or 2. (not sure if 0 has anything to do with it.)

So I guess it's like this...
editor:insert(3, "put your code here")


think about it, why would the SciTE API Documentation supply this function when the actual API for Lua have nothing on this? The 3 functions you've just had on were all "inhouse" functions. Forget about lua for a moment and brush up on streaming objects, view all input objects as streams and you'll figure out how to do it.

Zitat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
addhook("join","nickjoin")
addhook("spawn","pspawn")
a=0

function nickjoin(p)
n = player(p,"name")

function pspawn(p)
if n=="Player" then
a=a+1
parse("setname "..p.." [ByKaka] Guest #" ..a)
end
end
end


If you actually run this on a real server it would always rename the players if the last person who joined is named "Player" and everyone spawned. Also, try putting the different variables in their respective scopes, Lua scoping is very loose, therefore bad programming convention will lead to confusing logic errors (as the one described above), here's some of the fixes:

1) Put global variable outside of the functions. Place them at the top of the script, and always place the keyword "local" inside the function when you are using a variable that you don't want to have recycled outside of that function. Saves memory (basic optimization) and makes your script capable of running parallel with other scripts.

2) Use more meaningful names for your variables.

3) Use the right types of objects. In this case, you should be declaring your ids with a list.

That's all for now.

alt Re: Lua Scripts/Questions/Help

Kaka024
User Off Offline

Zitieren
leggao. It isn't actual. I noticed that so i changed the script for this:
1
2
3
4
5
6
7
8
9
10
11
addhook("join","nickjoin")
addhook("spawn","pspawn")

function nickjoin(p)
function pspawn(p)
n = player(p,"name")
if n=="Player" then
parse("setname "..p.." [ByKaka] Guest")
end
end
end

It works for now

alt Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Zitieren
Kaka024 hat geschrieben
leggao. It isn't actual. I noticed that so i changed the script for this:
1
2
3
4
5
6
7
8
9
10
11
addhook("join","nickjoin")
addhook("spawn","pspawn")

function nickjoin(p)
function pspawn(p)
n = player(p,"name")
if n=="Player" then
parse("setname "..p.." [ByKaka] Guest")
end
end
end

It works for now


what about name change? you could disable it
Zum Anfang Vorherige 1 216 17 18338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht