Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MountRoulette addon #1917

Merged
merged 3 commits into from
Aug 9, 2020
Merged

MountRoulette addon #1917

merged 3 commits into from
Aug 9, 2020

Conversation

xurion
Copy link
Contributor

@xurion xurion commented Aug 9, 2020

Summons a mount at random based on your mount key items.

A function to blacklist certain mounts exists on another branch and isn't included in this PR because of the impact of #1916 (blacklists mounts unexpectedly across multiple characters).

end
end)

windower.register_event('addon command', function(command)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this pattern by itself is nice for more complicated command handlers I feel it's unnecessarily complex here. I'd just make //mr run the roulette and remove the help text and all the boilerplate surrounding it, as well as the help message for it. I don't see a benefit to having this setup,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries - this is the boilerplate left over from removing the blacklist stuff. I'll cut this out as well.

end
end

windower.register_event('load', function()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably forego the load event here and just call the function directly. Its only purpose is if the code should execute after the full file has been loaded, but that does not seem to be necessary here.

end
end
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function needs to clear the allowed_mounts every time it's called. Otherwise if you log into a character that has all mounts, then log out and into a mule that has none, it will still have all mounts unlocked, no? Or am I missing something here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're absolutely right, I'll clear it.

local mount = possible_mounts[mount_index]

-- Add this to allowed mounts if it is not already there
if not allowed_mounts:contains(mount) then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the allowed_mounts are cleared at the top of the function this check could be removed, right? That said, if that was made a set (S{}) you could remove it regardless, which is also what I would do, even if it's temporary and converted to a list later:

allowed_mounts = L(allowed_mounts_set)


windower.register_event('incoming chunk', function(id)
if id == 0x055 then --ki update
update_allowed_mounts()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you verified that this works once you get a new mount? I don't think it should, since the received KI packet will trigger the function, but at that point it hasn't reached the game yet, so windower.ffxi.get_key_items() would not know about it, I think. You may want to run it in a slightly delayed coroutine:

update_allowed_mounts:schedule(0.2)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh I did not know that - I've probably not ran into this issue due to getting new mounts in Upper Jeuno, then needing to go outside to summon a mount. Given this, do still think it's worth the schedule call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about it, EmpyPopTracker has this same pattern and works ok. Is it more of a race condition?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, now that I think about it this should work after all. We store our own copy of the key items, and windower.ffxi.get_key_items returns that, not the game's key item store, so it shouldn't matter. At least I think so...

If you have some mounts left to get you could test it by the function print out the mounts it has found, then you'll see if it's really there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an alt of mine has some mounts to turn in so I'll check that soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thankfully it seems to work fine:

image

Removed unnecessary load event.
Removed unnecessary command complexity.
PR comments.
@xurion
Copy link
Contributor Author

xurion commented Aug 9, 2020

One thing I haven't considered is if someone uses this on a character with zero mounts. You'll get an error when it tries to concat the /mount with the mount name - should I cater for this?

@z16
Copy link
Member

z16 commented Aug 9, 2020

Ah why not, it's good form.

@xurion
Copy link
Contributor Author

xurion commented Aug 9, 2020

Ok cool, I just threw a return statement in there rather than logging something.

@z16 z16 merged commit 596e188 into Windower:dev Aug 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants