Problem with LuaGlobal

Post Reply
chalraes
Posts: 10
Joined: Mon Jun 14, 2010 10:48 pm

Problem with LuaGlobal

Post by chalraes » Mon Jun 14, 2010 10:53 pm

Hello,

It seem I have come across a problem that I cannot seem to solve. I have completely rewritten the function which triggers it twice, and I have had this problem persist across three different installations.

I recieve this error every time my prompt should fire:
[ERROR:] object:<Prompt> function:<Trigger1>
<...ents and Settings/Owner/.config/mudlet/LuaGlobal.lua:1058: bad argument #1 to 'split' (string expected, got nil)>
Now, my current code in that function is:
Code: [show] | [select all] lua
if matches[2] then
	if affs.blackout == 1 then
		affs:remove("blackout")
	end
	stats.lasthealth = stats.health
	stats.lastmana = stats.mana
	stats.lastego = stats.ego

	stats.health = tonumber(matches[3])
	stats.mana = tonumber(matches[4])
	stats.ego = tonumber(matches[5])
	stats.power = tonumber(matches[6])
	if matches[7] then
		stats.momentum = tonumber(matches[8])
	else
		stats.momentum = 0
	end

	local str = matches[9]
else
	if affs.blackout == 0 then
		affs.blackout = 1
	end
end
selectString(matches[1], "1")
replace("")
local promptecho = prompt:decorate()
cecho(promptecho)

I am unsure how to deal with this issue. If anybody knows what the problem might be, a point in the right direction would really help right now.

Thank you.

naftali
Posts: 138
Joined: Wed Jan 20, 2010 8:42 pm

Re: Problem with LuaGlobal

Post by naftali » Tue Jun 15, 2010 5:33 am

do you call string:split() in any of the functions within this script? Like prompt:decorate() perhaps?

chalraes
Posts: 10
Joined: Mon Jun 14, 2010 10:48 pm

Re: Problem with LuaGlobal

Post by chalraes » Tue Jun 15, 2010 6:13 am

naftali wrote:do you call string:split() in any of the functions within this script? Like prompt:decorate() perhaps?
Not once. Here is the code for prompt:decorate()
Code: [show] | [select all] lua
function prompt:decorate()
	if affs.blackout == 0 then
		stats:getmax()
		stats:getpercentage()

		local echostring = ""

		--health
		if stats.healthpercentage > prompt.medhealth then
			echostring = echostring .. "<green>"
		elseif stats.healthpercentage <= prompt.lowhealth then
			echostring = echostring .. "<red>"
		else
			echostring = echostring .. "<yellow>"
		end
		echostring = echostring .. stats.health .. "/" .. stats.maxhealth .. " "
		--mana
		if stats.manapercentage > prompt.medmana then
			echostring = echostring .. "<green>"
		elseif stats.manapercentage <= prompt.lowmana then
			echostring = echostring .. "<red>"
		else
			echostring = echostring .. "<yellow>"
		end
		echostring = echostring .. stats.mana .. "/" .. stats.maxmana .. " "
		--ego
		if stats.egopercentage > prompt.medego then
			echostring = echostring .. "<green>"
		elseif stats.egopercentage <= prompt.lowego then
			echostring = echostring .. "<red>"
		else
			echostring = echostring .. "<yellow>"
		end
		echostring = echostring .. stats.ego .. "/" .. stats.maxego .. " "
		--power
		if stats.power > prompt.medpower then
			echostring = echostring .. "<DarkOrchid>"
		elseif stats.power <= prompt.lowpower then
			echostring = echostring .. "<orchid>"
		else
			echostring = echostring .. "<MediumOrchid>"
		end
		echostring = echostring .. stats.power ..  " "
		
		return echostring
	end
end
And the two it calls...
Code: [show] | [select all] lua
function stats:getmax()
	local regex = rex.new( "NL:(\\d+)/100 H:\\d+/(\\d+) M:\\d+/(\\d+) E:\\d+/(\\d+) P:\\d+/10 N:\\d+/\\d+ W:\\d+/\\d+" )
	if regex:match(atcp.CharVitals) then
		stats.newlevel, stats.maxhealth, stats.maxmana, stats.maxego = regex:match(atcp.CharVitals)
	else
		display:fatal("Cannot get max stat values.")
	end
end

function stats:getpercentage()
	stats.healthpercentage = stats.health / stats.maxhealth
	stats.manapercentage = stats.mana / stats.maxmana
	stats.egopercentage = stats.ego / stats.maxego
end
EDIT: Probably should have mentioned. It did work until I restarted the client.

naftali
Posts: 138
Joined: Wed Jan 20, 2010 8:42 pm

Re: Problem with LuaGlobal

Post by naftali » Tue Jun 15, 2010 8:45 am

restarting again solves some periodic problems with luaGlobal for me, particularly if Mudlet had previously crashed.

chalraes
Posts: 10
Joined: Mon Jun 14, 2010 10:48 pm

Re: Problem with LuaGlobal

Post by chalraes » Tue Jun 15, 2010 9:14 am

It seems after some tracing, I found the problem to be not in LuaGlobal, but in my blackout checking... :?
Thank you for your help

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests