Trying to code something very basic, will appreciate any help

misagh

Active Member
I've decided to try to learn to use LavishScript. I've looked through the Wiki for both Lavish and ISXGames, and have found a lot of helpful information. Currently, I'm trying to make my first, extremely basic script, but I still haven't been able to find a script template to help me with the basic layout and flow.

I'll be using this basic script as my learning experience, so I will state what I'd like the script to do, what I've come up with so far, and what I'm having problems with.

INTENT:

I'd like to make a script which will look at any incoming /tell message, and if the message matchs any of the preset words and phrases in the script, it will take a particular action.

For the purpose of this example lets say that if you sent the script a /tell which said "Hiya, I'm new here", it would reply with "Hey! Welcome <name of person who sent tell>"

WHAT I'VE GOT:

From what I was able to find on the wiki, I should be able to use OnIncomingText (Hiya, I'm new here) to trigger the response, and I can use VGExecute /reply Hey! Welcome.

WHAT I DONT KNOW:

I really have no idea how to lay the script out, I don't know what needs to be definaed, or called... I haven't programmed in forever. I tried opening some of the other.ISS files but a lot of them seemed very cryptic, calling other things that I was pretty clueless about. Also, I have no idea to find out who actually sent the message, and how I could incorporate that in my reply.

I'd really appreciate some help =)
 

Karye

Active Member
Code:
atom(script) VG_OnIncomingText(string Text, string ChannelNumber, string ChannelName)
{
	if ${Text.Find[Hiya, I'm new here]} 
	{
                     VGExecute "/reply Hey! Welcome."
	}
}

;Endless loop to keep the script running
function main()
{
 Event[VG_OnIncomingText]:AttachAtom[VG_OnIncomingText]
 do
    {
      WaitFrame
    }
 while 1
 Event[VG_OnIncomingText]:DetachAtom[VG_OnIncomingText]
}
To find the sender simply parse the variable named "Text" when "ChannelNumber" = 1 (tells as I recall) the senders' name will look something like [<pcname>Sender's Name</link>]
 
Last edited:

don'tdoit

Active Member
for specific example for this type of script, take a look at the code for vgalarm. you'll want to determine what channel the "hey i'm new here" thing comes in on, else you'll be replying with your response to whomever sent you a tell last, even if the "hey i'm new here" came in over a shout. and you don't want to just do a straight reply, as that might backfire too... a bot "mt"ing... heh.

there's another script I wrote for IRC stuff that somebody else released... has some stuff for replying to people (getting incoming name, etc). might help a bit too. this script was all about AI and auto-responding to people (using the ALICE AI). one thing I highly recommend adding to your script is code to delay the response depending on how long your response will be. instantly auto-responding with a paragraph to somebody who just says "hi" would be a huge tipoff that something about you just ain't right.
 

misagh

Active Member
Thank you, this was very helpful =)

Combined with this and thanks to help on IRC (CyberTech, Azeroth, Tenshi) I have been able to construct most of what I need to do now in a small script.

The only issue I've still not tackled, which is my next project, is to allow the script to be run with arguements, like so:

run myscript = any person can send commands to the script
run myscript bob = only commands sent by bob will be recognized
run myscript bob larry mark mike joe = only commands sent by bob, larry, mark, mike and joe will be recognized

Now, while I've managed to extract the name of the person sending the tell in my basic script, it seems to have some issues. Here is the loop that is being used:

Code:
( [COLOR="Red"]Event[VG_OnIncomingText]:AttachAtom[DecideAction] [COLOR="Black"] is sending to atom [/COLOR](global) DecideAction(string Text, string ChannelNumber, string ChannelName)[/COLOR] ) and then the following loop is being used to find the name of the PC who sent the tell:

variable int tagpos
variable int length
variable string tag = "<pcname>"
variable string target

	tagpos:Set[${Text.Find[${tag}]}]
	tagpos:Inc[${tag.Length}]
	
	variable int i=${tagpos}
		do
		{
		length:Inc
		}
	while ${Text.Mid[${i:Inc},1].NotEqual[<]}
	target:Set[${Text.Mid[${tagpos}, ${length}]}]
So what is going into that loop is something like From <pcname>ThePerson</link>: Bla Bla

Now the issue is, when I put a "test Text" in the script, the read out I get is odd. If the persons name is 123456789, I only get 12345 out of it in the console read out. However, if the persons name is 1234 I get a 12345 (it actually gives me part of the closing </link> tag in the console read out). Anyways, I'm hoping its something wrong in the loop, or even better, there is a "What is the name of the person who said the text which triggered you, Mr. VG_OnIncomingText?" type command.

Regardless, for now this works great, and I really appreciate all the help!
 

misagh

Active Member
I still can't figure out why the loop is only giving me a partial readout, any help would be appreciated.
 

Xeon

Active Member
Or you could just use this:
Code:
   variable string aName

    aName:Set[${Text.Token[2,">"].Token[1,"<"]}]

   echo "VGAlarm: aName: ${aName}"
 
Top Bottom