Author Topic: Scripting Help  (Read 13171 times)

0 Members and 1 Guest are viewing this topic.

Offline Yahoo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +32/-14
  • People Say "I Dont Know English"
    • Yahoo
Scripting Help
« on: 01 May, 2007, 14:07:38 »
i had join this forum long back for requesting script and now i want to try scripting which can be possible only with the help of all members and scripters of this forum.So i will like to have support of all the members of this forum and this can also help new scripter who have started there scripting recently or want to start with it and it can also reduce the pressure on most of the scripter
I WILL LIKE TO KNOW
1)how can i learn LUA language, which stuff to read or refer to learn this language.
2)i would also like to know the difference between lua 4, 5, 5.1


P.S  i dont know anything about programing or scripting

thanks in advance
"BoRN FIGhTEr"

PtokaX forum

Scripting Help
« on: 01 May, 2007, 14:07:38 »

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 730
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: Scripting Help
« Reply #1 on: 01 May, 2007, 14:16:31 »
So, you'd like to start programming in Lua. Your holy bible should be:
- Lua book
- 5.1 reference manual
- PtokaX Wiki
Everything could have been anything else and it would have just as much meaning.

Offline 6Marilyn6Manson6

  • Scripter
  • King
  • ******
  • Posts: 869
  • Karma: +47/-35
    • http://www.marilynmanson986.altervista.org
Re: Scripting Help
« Reply #2 on: 01 May, 2007, 14:18:11 »
www.lua.org

You find all answers to your questions :D

Offline achiever

  • Lord
  • ***
  • Posts: 260
  • Karma: +25/-22
Re: Scripting Help
« Reply #3 on: 01 May, 2007, 16:10:55 »
if i may suggest its also good to look into others script and modify things and c how they work.
still i m no one to even suggest u this, but can be helpful ;)
thks,
achiever.

Offline Yahoo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +32/-14
  • People Say "I Dont Know English"
    • Yahoo
Re: Scripting Help
« Reply #4 on: 01 May, 2007, 16:54:51 »
thanks all members for u reply on my post
Quote
if i may suggest its also good to look into others script and modify things and c how they work.
still i m no one to even suggest u this, but can be helpful Wink
i have tried modifying and i can do it upto a extent by then also i am not able to write a script . i just dont qwanna modify scripts i want to create scripts
"BoRN FIGhTEr"

Offline achiever

  • Lord
  • ***
  • Posts: 260
  • Karma: +25/-22
Re: Scripting Help
« Reply #5 on: 01 May, 2007, 16:58:12 »
i just dont qwanna modify scripts i want to create scripts
u r not alone in this.
thks,
achiever.

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 730
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: Scripting Help
« Reply #6 on: 02 May, 2007, 01:20:33 »
And also we encourage lua-related discussion here, it's kinda boring to code 'can I have this in PM' issues all the time.
Everything could have been anything else and it would have just as much meaning.

Offline Yahoo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +32/-14
  • People Say "I Dont Know English"
    • Yahoo
Re: Scripting Help
« Reply #7 on: 02 May, 2007, 14:26:20 »
thanks you all the member for your support. the site and the reference manual suggested by the scripter and members are very helpful but the prob is tht they are to big and vast (boaring also) to read with my speed i will require atleast 2 months to read tht whole thing i cant manage tht much time. so can u suggest me any other way through which i can learn the language in small,simple and easy way


thanks in advance
"BoRN FIGhTEr"

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 730
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: Scripting Help
« Reply #8 on: 02 May, 2007, 14:29:04 »
I started with creating a simple bot. You should create one too:
  • register at startup
  • when a new user connects, greet her
  • when a user disconnects, say goodbye
Everything could have been anything else and it would have just as much meaning.

Offline speedX

  • Lord
  • ***
  • Posts: 437
  • Karma: +59/-19
Re: Scripting Help
« Reply #9 on: 03 May, 2007, 07:54:01 »
I started with creating a simple bot. You should create one too:
  • register at startup
  • when a new user connects, greet her
  • when a user disconnects, say goodbye

Done :D
Thanking You,

speedX

Offline achiever

  • Lord
  • ***
  • Posts: 260
  • Karma: +25/-22
Re: Scripting Help
« Reply #10 on: 03 May, 2007, 18:50:10 »
I started with creating a simple bot. You should create one too:
  • register at startup
  • when a new user connects, greet her
  • when a user disconnects, say goodbye

here is my try
Code: [Select]
sBot ="Fusion"
mesg ="this hub welcomes all regs. Hope u enjoy ur stay"
mesg1 ="Good bye!! c u soon"
function NewUserConnected(user)
user:SendData(sBot, mesg)
end
OpConnected = NewUserConnected

function UserDisconnected(user)
SendToAll(sBot, mesg1)
end
OpDisconnected = UserDisconnected

how is it, i will like to here all suggestions but plzz be abit explainatory ;)
how do u register a bot?

i even tried to do this profile specific
Code: [Select]
sBot ="Fusion"
mesg ="this hub welcomes all regs. Hope u enjoy ur stay"
mesg1 ="Good bye!! c u soon"
mesg2 ="welcome home"
function NewUserConnected(user)
if user.iProfile ==0 or user.iProfile ==1 then
user:SendData(sBot, mesg2)
else
user:SendData(sBot, mesg)
end
end

function UserDisconnected(user)
SendToAll(sBot, mesg1)
end
OpDisconnected = UserDisconnected

it doesnt work :( what is the change needed.

thks,
thks,
achiever.

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 730
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: Scripting Help
« Reply #11 on: 03 May, 2007, 19:28:01 »
If you check whether a user is registered, bRegistered would be a better choice. Registering a bot: hmm, documented.
http://wiki.ptokax.ath.cx/doku.php?id=scriptinghelp:ptokaxapi#the_frmhub_object
Everything could have been anything else and it would have just as much meaning.

Offline Naithif

  • Triple Ace
  • **
  • Posts: 199
  • Karma: +32/-13
Re: Scripting Help
« Reply #12 on: 03 May, 2007, 19:28:46 »
Code: [Select]
function NewUserConnected(user)
if user.iProfile ==0 or user.iProfile ==1 then


Hint (SPOILER WARNING!!!)  :)
This'll never be true in itself, you need to do is similarly to disconnection

Code: [Select]
OpDisconnected = UserDisconnected
« Last Edit: 03 May, 2007, 19:30:51 by Naithif »

Offline CrazyGuy

  • Viking
  • ****
  • Posts: 506
  • Karma: +83/-20
    • ?????=-_The NightHawk_-=?????
Re: Scripting Help
« Reply #13 on: 03 May, 2007, 22:43:40 »
here is my try
Code: [Select]
sBot ="Fusion"
mesg ="this hub welcomes all regs. Hope u enjoy ur stay"
mesg1 ="Good bye!! c u soon"
function NewUserConnected(user)
user:SendData(sBot, mesg)
end
OpConnected = NewUserConnected

function UserDisconnected(user)
SendToAll(sBot, mesg1)
end
OpDisconnected = UserDisconnected

This code is actually quite close. It doesn't work because the bot isn't registered, and most clients ignore messages from offline users.

To register your bot:

Code: [Select]
Main = function()
      frmHub:RegBot(sBot)
end

that should do it :)

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 730
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: Scripting Help
« Reply #14 on: 03 May, 2007, 23:05:01 »
I think they don't benefit from directly telling them the solution, we should rather give them hnts.
Everything could have been anything else and it would have just as much meaning.

Offline 6Marilyn6Manson6

  • Scripter
  • King
  • ******
  • Posts: 869
  • Karma: +47/-35
    • http://www.marilynmanson986.altervista.org
Re: Scripting Help
« Reply #15 on: 03 May, 2007, 23:23:21 »
This code is actually quite close. It doesn't work because the bot isn't registered, and most clients ignore messages from offline users.

To register your bot:

Code: [Select]
Main = function()
      frmHub:RegBot(sBot)
end

that should do it :)

For speedX example:

Code: [Select]
function Main()
      frmHub:RegBot(sBot)
end

This version is most good :p

Offline Naithif

  • Triple Ace
  • **
  • Posts: 199
  • Karma: +32/-13
Re: Scripting Help
« Reply #16 on: 03 May, 2007, 23:37:14 »
If only the second version is the one that's not working (as I've suspected), then see my post. The second version misses a line...

Offline 6Marilyn6Manson6

  • Scripter
  • King
  • ******
  • Posts: 869
  • Karma: +47/-35
    • http://www.marilynmanson986.altervista.org
Re: Scripting Help
« Reply #17 on: 03 May, 2007, 23:38:51 »
There is no functional difference here.

Sure? but speedX has been only used  mode  funtion name()   only for this my version would be more homogenous ^^

Offline speedX

  • Lord
  • ***
  • Posts: 437
  • Karma: +59/-19
Re: Scripting Help
« Reply #18 on: 04 May, 2007, 10:43:20 »
Code: [Select]
Bot = frmHub:GetHubBotName()


function Main()
frmHub:RegBot(Bot)
end

function NewUserConnected(user)
  if user.bOperator then
    user:SendData(Bot, "Welcome home "..user.sName)
  else
    user:SendData(Bot, "Welcome "..user.sName.." to "..frmHub:GetHubName())
  end
end
OpConnected = NewUserConnected

function UserDisconnected(user)
  SendToAll(Bot, "Goodbye "..user.sName)
end
OpDisconnected = UserDisconnected
Thanking You,

speedX

Offline achiever

  • Lord
  • ***
  • Posts: 260
  • Karma: +25/-22
Re: Scripting Help
« Reply #19 on: 04 May, 2007, 11:41:54 »
Hint (SPOILER WARNING!!!)  :)
This'll never be true in itself, you need to do is similarly to disconnection

naithif i did not understand this plzz explain it.

Registering a bot: hmm, documented.
http://wiki.ptokax.ath.cx/doku.php?id=scriptinghelp:ptokaxapi#the_frmhub_object
thks bastya this was really a good 1 :)
thks,
achiever.

Offline speedX

  • Lord
  • ***
  • Posts: 437
  • Karma: +59/-19
Re: Scripting Help
« Reply #20 on: 04 May, 2007, 12:12:34 »
I started with creating a simple bot. You should create one too:
  • register at startup
  • when a new user connects, greet her
  • when a user disconnects, say goodbye

Next ??
Thanking You,

speedX

Offline achiever

  • Lord
  • ***
  • Posts: 260
  • Karma: +25/-22
Re: Scripting Help
« Reply #21 on: 04 May, 2007, 12:33:10 »
well i m trying to add some more messages and it should send random message
thks,
achiever.

Offline Naithif

  • Triple Ace
  • **
  • Posts: 199
  • Karma: +32/-13
Re: Scripting Help
« Reply #22 on: 05 May, 2007, 01:16:03 »

i even tried to do this profile specific
Code: [Select]
sBot ="Fusion"
mesg ="this hub welcomes all regs. Hope u enjoy ur stay"
mesg1 ="Good bye!! c u soon"
mesg2 ="welcome home"
function NewUserConnected(user)
if user.iProfile ==0 or user.iProfile ==1 then
user:SendData(sBot, mesg2)
else
user:SendData(sBot, mesg)
end
end

function UserDisconnected(user)
SendToAll(sBot, mesg1)
end
OpDisconnected = UserDisconnected

Here's your post.
You got a NewUserConnected function that's targets are users. (user, reg, vip)
You got a profile check that's targets are masters, and ops

Hint 1
NewUserConnected takes all users, regs, and vips, and the if statement filters everyone of them except ops and masters.  ::)


Hint 2
You are missing a line that was present in version 1...

« Last Edit: 05 May, 2007, 01:23:51 by Naithif »

Offline achiever

  • Lord
  • ***
  • Posts: 260
  • Karma: +25/-22
Re: Scripting Help
« Reply #23 on: 05 May, 2007, 10:21:35 »
well yes got it
i had missed OpConnected = NewUserConnected

thks
thks,
achiever.

Offline CrazyGuy

  • Viking
  • ****
  • Posts: 506
  • Karma: +83/-20
    • ?????=-_The NightHawk_-=?????
Re: Scripting Help
« Reply #24 on: 05 May, 2007, 13:12:59 »

Hint 1
NewUserConnected takes all users, regs, and vips, and the if statement filters everyone of them except ops and masters.  ::)


This is not exactly true.
NewUserConnected handles all users with a profile with bIsOP = 0 , and unregistered users.
Subtle, yet important difference if you use custom profile permissions  ::)

PtokaX forum

Re: Scripting Help
« Reply #24 on: 05 May, 2007, 13:12:59 »