Page 1 of 1

Summoning Script

Posted: Fri Dec 24, 2010 1:59 pm
by Theiwar
On to my next project, trying to create a script to automate my summoning. Essentially I've got a simple table with the names of all my ents:
Code: [show] | [select all] lua
summonlist = {"skyrax", "rixil", "eerion", "arctar", "scrag", "pyradius", "dameron", 
"palpatar", "nin'kharsag", "istria", "marduk", "nemesis", "buul", "cadmus", "piridon", "danaeus", "lycantha", "hecate"}
Now what function do I use to go through that list and summon the current entity (i.e. send("summon" ..nextsummon..)) and then wait for balance and then summon the next one. Thanks!

Re: Summoning Script

Posted: Fri Dec 24, 2010 4:00 pm
by Vadi
Um, there are no functions to wait for your MUDs balances.

Re: Summoning Script

Posted: Fri Dec 24, 2010 4:26 pm
by Theiwar
Actually I've worked out most of it, I just need to know how to do it using that table? So to keep things simple how would I summon the first name in the list i.e. send("summon" ..FIRSTnameINtable)

Re: Summoning Script

Posted: Fri Dec 24, 2010 5:52 pm
by Yetzederixx
Need a variable storing the current index, when you hit the end of the list you'll probably want to reset it to 1. Then everytime you regain balance:
Code: [show] | [select all] lua
send("summon " .. summonlist[index])
index = index + 1

Re: Summoning Script

Posted: Sat Dec 25, 2010 4:01 pm
by Theiwar
Ok so this is what I came up with, let me know your thoughts/improvements:
Alias:
Code: [show] | [select all] lua
echo( "-----------BEGIN SUMMONING-----------" )
send("summon skyrax")
sumindex = 1
summongo = 1
Triggers:
Code: [show] | [select all] lua
^You have recovered equilibrium.$
if summongo == 1 
	then
	summonall()
end
Code: [show] | [select all] lua
^The Entity refuses to send another minion to aid you.$
You cannot summon
if summongo == 1 
	then
	sumindex = sumindex + 1
	summonall()
end
Script Function:
Code: [show] | [select all] lua
function summonall()
	if sumindex <= 17 then 
		send("summon " .. summonlist[sumindex])
		sumindex = sumindex + 1
	else
summongo = 0
	end
end

Re: Summoning Script

Posted: Sat Dec 25, 2010 5:56 pm
by tsuujin
if you're using a standard table, you don't have to hard code the length of it in. You can just prefix the table name with a hash (#) to get the number of elements in the table.
Code: [show] | [select all] lua
if sumindex <= #summonlist then