Help a noob coder out, please!

Post Reply
Ishin
Posts: 4
Joined: Sun Oct 19, 2014 5:26 am

Help a noob coder out, please!

Post by Ishin »

I've been working a lot on making my own offenses lately in Aetolia, and been having a whole lot of fun doing it. One of the most frustrating things for me is when I get an error back and it's not really very...specific, lol. I did a little bit of reading before posting here, and it looks like my error -might- be a GMCP thing? I do use a GMCP check to determine my class, like so:
Code: [show] | [select all] lua
if gmcp.Char.Vitals.class == "syssin" then
	if not soffense.auto_kill then
		soffense.auto_kill = true
		set.killing = true
		SyssinAI()
		ui:combat_echo("Auto Kill - ON", "green")
	elseif soffense.auto_kill then
		soffense.auto_kill = false
		set.killing = false
		ui:combat_echo("Auto Kill - OFF", "red")
		soffense.auto_kill_limiter = false
	end
end
	
if gmcp.Char.Vitals.class == "indorani" then
	if not ioffense.auto_kill then
		ioffense.auto_kill = true
		set.killing = true
		ui:combat_echo("Auto Kill - ON", "green")
		IndoAI()
	elseif ioffense.auto_kill then
		ioffense.auto_kill = false
		set.killing = false
		ui:combat_echo("Auto Kill - OFF", "red")
		ioffense.auto_kill_limiter = false
		send("qeb order entourage passive")
	end
end
This is the error I'm getting, though:

[ERROR:] object:<prompt calls> function:<Trigger52>
<[string "function selectVenom(aff)..."]:4: bad argument #1 to 'ipairs' (table expected, got nil)>

It says selectVenom(aff) is the issue, but I didn't start having that issue until today, when I started trying to do offenses for multiple classes I have. Should I just disable the folders the other offenses are in when I'm not in that class or is there an easier/proper way to check? For reference, here's the actual selectVenom function:
Code: [show] | [select all] lua
function selectVenom(aff)
soffense.to_envenom = {}

for i, v in ipairs(aff) do
	if not t.affs[v] then
		table.insert(soffense.to_envenom, soffense.to_venom[v])
	end
	if #soffense.to_envenom == 2 then return soffense.to_envenom end
		end
end
For reference, to_venom is a table that has the affliction name and the venom, so that my offense knows what venom corresponds to what affliction.

User avatar
Zaphob
Posts: 180
Joined: Wed May 09, 2012 8:07 am
Location: mg.mud.de

Re: Help a noob coder out, please!

Post by Zaphob »

Welcome Ishin, maybe let the noob read this: http://sscce.org/

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: Help a noob coder out, please!

Post by Akaya »

From the error you're getting, selectVenom requires a table as an argument. So aff must be a table to loop through it with ipairs.

Post Reply