Making an Echoable List of Affs from gmcp.Char.Affliction

Post Reply
lussien
Posts: 6
Joined: Wed May 30, 2012 3:07 pm

Making an Echoable List of Affs from gmcp.Char.Affliction

Post by lussien »

Hello, I need help on this mini project.

I have a problem with trying to track in blackout, now in Midkemia blackout lasts for 5 seconds and my opponent can easily disable me during that time frame where I'm unable to do anything except to receive them. I've read somewhere that gmcp.Char.Affliction can help me to track with that said problem.

So,

1. I would like to be able to pull out a list that'll show me what afflictions I've received during the blackout process.

I'm not familiar on how to handle GMCP. Can I ask for some guidance?

Do I set up a script with
Code: [show] | [select all] lua
function show_affs()
if gmcp.Char.Affliction.List != "" then
afflist == gmcp.Char.Affliction.List
echo(afflist)
end
Now I'm not entirely sure but I do understand I have to put the array variables into a table or somesort so I can extract the information in an echo via prompt or some other means of display.

Thanks.

User avatar
kevutian
Posts: 217
Joined: Fri Aug 20, 2010 8:18 pm
Location: United Kingdom
Contact:

Re: Making an Echoable List of Affs from gmcp.Char.Afflictio

Post by kevutian »

I was not even aware MKO gave this information, though regardless, I'd be surprised if that table even got updated whilst in blackout.

lussien
Posts: 6
Joined: Wed May 30, 2012 3:07 pm

Re: Making an Echoable List of Affs from gmcp.Char.Afflictio

Post by lussien »

Asked some players about it and they told me there wasn't such a thing sadly. :(

User avatar
kevutian
Posts: 217
Joined: Fri Aug 20, 2010 8:18 pm
Location: United Kingdom
Contact:

Re: Making an Echoable List of Affs from gmcp.Char.Afflictio

Post by kevutian »

Yeah, the only game I know that supports this is Lithmeria.

Iocun
Posts: 174
Joined: Wed Dec 02, 2009 1:45 am

Re: Making an Echoable List of Affs from gmcp.Char.Afflictio

Post by Iocun »

Regardless, just for the sake of general education and not letting any flawed code remain unchallenged, here some things that are wrong with the code as posted above:

1. In Lua, "not equal" is written as ~= instead of !=.

2. If there's a "list" of sorts, it will probably be a table and not a string. Comparing it to the empty string "" will thus always result in them being considered non-equal. Use if gmcp.Char.Affliction.List ~= {} then to check if a table is not an empty table, or simply if gmcp.Char.Affliction.List then to check whether that table exists at all. In cases like this, you'll probably want the latter.

3. One uses == to compare two values in Lua. In line three however you want to set afflist, for which you use the single equal sign =.

4. You can assign a table to another variable with an equal sign, but it will probably not do what you expect: create a copy of that table. If you actually want the list copied into afflist, you have to do something like:
afflist = {}
for i,v in ipairs(gmcp.Char.Affliction.List) do afflist = v end

5. You cannot use echo to display tables. Use display(afflist) instead.

Post Reply