[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Using a table index as a boolean

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Using a table index as a boolean
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Kevnuke   USA  (83 posts)  [Biography] bio
Date Mon 30 Apr 2012 12:07 AM (UTC)  quote  ]

Amended on Sun 06 May 2012 04:30 AM (UTC) by Kevnuke

Message
This is supposed to be a list of skill groups that the script does NOT pass to the SendGMCP function since these groups don't have any abilities. They are all passive.

Jonathan, you should recognize SendGMCP..you wrote it lol



function OnPluginTelnetSubnegotiation (opt, data)

	if opt ~= 201 then

		return

	end

	local msg, content = unpack(utils.split(data, " ", 1))

	print (msg, content)

	if not content or content:len() == 0 then

		_G[msg:gsub("%.", "")]()

	else

		_G[msg:gsub("%.", "")](content)

	end

end

function SendGMCP(message, content)
	if type(message) ~= "string" then
		return nil, "Message name must be a string."
	end
  
	if content ~= nil then
		content = json.encode({content})
		if content == nil then
			return nil, "Invalid input."
		end
		message = ("%s %s"):format(message, content:sub(2, #content-1))
	end
  
	SendPkt(SB_GMCP:format(message))
	return true
end

function CharSkillsGroups (content)

	local EXCLUDED_GROUPS	=	{

		"Antidotes",
		"Avoidance",
		"Constitution",
		"Fitness",
		"Frost",
		"Galvanism",
		"Philosophy",
		"Thermology",

	}

	for k,v in ipairs (JSON.decode("[" .. content .. "]")[1]) do

		system[system.char]	=	{

			skills	=	{

				[v.name]	=	{

					rank		=	v.rank,

				},
			},
	
		}

		if not EXCLUDED_GROUPS [v.name] then

			system[system.char]["skills"][v.name]["abilities"]	=	{}

			local GROUP	=	{group = v.name}

			SendGMCP ("Char.Skills.Get ", GROUP)

		end

	end

end

Run-time error
Plugin: The_System (called from world: Achaea)
Function/Sub: OnPluginTelnetSubnegotiation called by Plugin The_System
Reason: Executing plugin The_System sub OnPluginTelnetSubnegotiation
[string "Plugin"]:223: attempt to call local 'EXCLUDED_GROUPS' (a table value)
stack traceback:
        [string "Plugin"]:223: in function '?'
        [string "Plugin"]:560: in function <[string "Plugin"]:548>
Error context in script:
 219 :    },
 220 :  
 221 :   }
 222 : 
 223*:   if not EXCLUDED_GROUPS {v.name} then
 224 : 
 225 :    system[system.char]["skills"][v.name]["abilities"] = {}
 226 : 
 227 :    local GROUP = {group = v.name}


See my problem?
EDIT: Wow if that wasn't a rookie mistake. See if the top half works now

..also, while I'm on the subject. I don't remember having to do anything special to get the contents of the items field last time I used print to see the Char.Items.List data. All I'm getting now is..

Char.Items.List { "location": "inv", "items": [ ] }

using this


function CharItemsList (content)

	print ("CharItemsList ", content)

end


EDIT: I think it was because I had Twisol's GMCP plugin running at the same time. Lemme check.

..I'll find out as soon as I stop getting Runtime errors in my plugin -sigh-

"x" variable does not exist because you are a retard and have not declared it yet LOL
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


408 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]