Author Topic: What Numbers shall i use, is there a list or a document?  (Read 3612 times)

0 Members and 1 Guest are viewing this topic.

Offline kepp

  • Scripter
  • King
  • ******
  • Posts: 790
  • Karma: +2/-0
What Numbers shall i use, is there a list or a document?
« on: 07 December, 2003, 22:33:57 »
Code: [Select]
if strsub(data, 1, 3) == "$SR" or strsub(data, 1, 7) == "$Search" then
Ok, The ones above seems to work...

But what number should $ConnectToMe for instance have?
Is there a list or a document that will show what number for what...?

This is a big issue for me, and no doubt for others aswell..

i have 3 scripts that does the same from diferent authors,
they have different numbers after "data,"

Thanks
« Last Edit: 07 December, 2003, 22:34:45 by kepp »
Guarding    

PtokaX forum

What Numbers shall i use, is there a list or a document?
« on: 07 December, 2003, 22:33:57 »

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #1 on: 07 December, 2003, 23:02:42 »
strsub(s, i [, j])

returns another string, wich is a substring of s, starting @ 1 and running untill j: i and j may be negative, If j is absent, then it is assumed to be equal to -1 (wich is the same as the strings length).
In particular, the call strsub(s,1,j) returns a prefix of s with the length j, and the call strsub(s, -i) returns a suffix of s with length i.

(source: refman-4.0.pdf taken from http://www.lua.org)

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Offline Snoris

  • Double Ace
  • *
  • Posts: 122
  • Karma: +3/-0
(No subject)
« Reply #2 on: 07 December, 2003, 23:44:52 »
Quote
Originally posted by plop
strsub(s, i [, j])

returns another string, wich is a substring of s, starting @ 1 and running untill j: i and j may be negative, If j is absent, then it is assumed to be equal to -1 (wich is the same as the strings length).
In particular, the call strsub(s,1,j) returns a prefix of s with the length j, and the call strsub(s, -i) returns a suffix of s with length i.

(source: refman-4.0.pdf taken from http://www.lua.org)

plop

Nice...Now I've even learned how to speak spanish :]

That is just letters for me...In a strange way =))

But...I probably will learn SOMETHING this lifetime ;)

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #3 on: 08 December, 2003, 00:00:32 »
The strsub(s,i,j) function extracts a piece of the string s, from the i-th to the j-th character inclusive. In Lua, the first character of a string has index 1.
You can use also negative indices, which count from the end of the string: The index −1 refers to the last character in a string, −2 to the previous one, and so on. Therefore, the call strsub(s, 1, j) gets a prefix of the string s with length j; strsub(s, j, -1) gets a suffix of the string, starting at the j-th character (if you do not provide a third argument, it defaults to −1, so the last call could be written as strsub(s, j)); and strsub(s, 2, -2) removes the first and last characters of a string: If s is "[in brackets]", strsub(s, 2, -2) will be "in brackets".

maby this is more clear, luabook1.pdf  also from the same site.

plop
« Last Edit: 08 December, 2003, 00:00:43 by plop »
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Offline kepp

  • Scripter
  • King
  • ******
  • Posts: 790
  • Karma: +2/-0
(No subject)
« Reply #4 on: 08 December, 2003, 00:08:58 »
Ah well :D
I guess i need to spend some hours reading this :) Thanks though
Guarding    

Offline Snoris

  • Double Ace
  • *
  • Posts: 122
  • Karma: +3/-0
(No subject)
« Reply #5 on: 08 December, 2003, 00:10:08 »
*if Brain says ("Syntax error" or "blackout") then :]

Shit I must have this in swedish....If Im not tired Im getting blackout about this ;)

Offline kepp

  • Scripter
  • King
  • ******
  • Posts: 790
  • Karma: +2/-0
(No subject)
« Reply #6 on: 08 December, 2003, 00:14:04 »
Sorry snoris, Det l?r ta hundra ?r och ?vers?tta det....

In english =

Sorry snoris, That will take about 100 years to translate!!
Guarding    

Offline Snoris

  • Double Ace
  • *
  • Posts: 122
  • Karma: +3/-0
(No subject)
« Reply #7 on: 08 December, 2003, 00:16:53 »
Quote
Originally posted by kepp
Sorry snoris, Det l?r ta hundra ?r och ?vers?tta det....

In english =

Sorry snoris, That will take about 100 years to translate!!
'
FFS lamer come ooooon :]

Give me a hand :D

Offline kepp

  • Scripter
  • King
  • ******
  • Posts: 790
  • Karma: +2/-0
(No subject)
« Reply #8 on: 08 December, 2003, 00:24:39 »
The strsub(s,i,j) function extracts a piece of the string s, from the i-th to the j-th character inclusive. In Lua, the first character of a string has index 1.
You can use also negative indices, which count from the end of the string: The index −1 refers to the last character in a string, −2 to the previous one, and so on. Therefore, the call strsub(s, 1, j) gets a prefix of the string s with length j; strsub(s, j, -1) gets a suffix of the string, starting at the j-th character (if you do not provide a third argument, it defaults to −1, so the last call could be written as strsub(s, j)); and strsub(s, 2, -2) removes the first and last characters of a string: If s is "[in brackets]", strsub(s, 2, -2) will be "in brackets".


SWEDISH :

strsub funktionen extracts en del av tjejernas string s,
fr?n i:et till j:et. I LUA, har den f?rsta bokstaven i tjejernas string index 1 (ett).
du kan ?ven anv?nda negativa idikationer, vilket r?knas fr?n slutet av tjejernas string: Indikationen −1


Sen orkar jag inte mer :)
Guarding    

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #9 on: 08 December, 2003, 01:06:05 »
start the next script with the command line lua.exe.
it gives a simple example of what strsub does.
Code: [Select]
text = "test string"
start = 1
End = 1

for i=1,strlen(text) do
   string2 = strsub(text, start, End)
   print(string2)
   End = End +1
end
for i=1,strlen(text) do
   string2 = strsub(text, start, End)
   print(string2)
   start = start + 1
end
this is the result.
Code: [Select]
t
te
tes
test
test
test s
test st
test str
test stri
test strin
test string
test string
est string
st string
t string
 string
string
tring
ring
ing
ng
g
plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Offline kepp

  • Scripter
  • King
  • ******
  • Posts: 790
  • Karma: +2/-0
(No subject)
« Reply #10 on: 08 December, 2003, 06:35:13 »
$ConnectToMe

so... $ConnectToMe will have 1,12 ?

If i try 1,11 in Lua.exe it won't give me the whole thing...


$  C  o  n   n  e   c   t   T   o  M  e
^ ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^
1  2  3   4   5  6   7  8   9  10  11  12


As there are 12 Characters...
that's how i get it
« Last Edit: 08 December, 2003, 06:35:40 by kepp »
Guarding    

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #11 on: 08 December, 2003, 11:08:52 »
Quote
Originally posted by kepp
$ConnectToMe

so... $ConnectToMe will have 1,12 ?

If i try 1,11 in Lua.exe it won't give me the whole thing...


$  C  o  n   n  e   c   t   T   o  M  e
^ ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^
1  2  3   4   5  6   7  8   9  10  11  12


As there are 12 Characters...
that's how i get it
yep, if you wanne find a string wich is always in the same place this is the best way 2 find it.
strfind(data, "%$ConnectToMe") can even get the wrong result if you for example say $ConnectToMe in mainchat.
if data = <[TGA-OP]plop> $ConnectToMe then strfind(data, "%$ConnectToMe") whill give a match.
but strsub(data, 1,12) whill return <[TGA-OP]plo, wich is ~= 2 $ConnectToMe.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

PtokaX forum

(No subject)
« Reply #11 on: 08 December, 2003, 11:08:52 »