Jump to content

[EE UI/lua] how to check if container is empty & close loot window?


agris

Recommended Posts

I'm playing BG:EE right now with the excellent Classic BG UI mod, and it includes some handy hotkeys. One of them is "loot entire container" when pressing E. It's great, reminds me of some of the great time-saving sfall tweaks for Fallout 1/2.

It's defined as such in ui.menu

	{
		enabled "containerBigMode == 0"
		on E action
		"
			Infinity_PlaySound('GAM_09')
			worldScreen:TakeAllFromContainer()
		"
	}

Setting aside bigmode, I would like to add onto the end of the on E action macro a line that (1) checks if the container is empty, and (2) if so, closes the container. Something like if getContainerEmpty = 1 then closeContainerWindow else end

Except both those function calls are fake. I made them up! This is where I'm running into my first issue: it seems like there is no good documentation of the functions available for the EE UIs. It's all contained in the black hole that is the Beamdog forums, which don't let you search per-forum and, strangely, are not searchable by google using the classic "TERM site:https://forums.beamdog.com/categories/ui-modding" method.

I've looked through ui.menu and I see a lot of container functions, like getContainerItemProperty([index, 'property']) but I can't find these getContainerX functions documented.

So: what's the "easy" function to check if a container is empty, and what type of function am I looking at to close the loot window? And will the "on E action" macro accept those functions?

Edited by agris
Link to comment

I tried something like this:

if #loot.containerItems == 0 then Infinity_PopMenu('WORLD_CONTAINER') end

But there are two issues:

1) The loot.containerItems variable is updated only after the action ends so you have to press 'E' a second time.

2) This will close the container menu but it will not reopen the action bar.

Link to comment
37 minutes ago, lefreut said:

I tried something like this:

if #loot.containerItems == 0 then Infinity_PopMenu('WORLD_CONTAINER') end

But there are two issues:

1) The loot.containerItems variable is updated only after the action ends so you have to press 'E' a second time.

2) This will close the container menu but it will not reopen the action bar.

Thank you. Excuse my ignorance, but to point 1, would something like this work?

{
	on E action
	"
		count = 0
            	Infinity_PlaySound('GAM_09')
            	worldScreen:TakeAllFromContainer()
            	count = 1
	"
	if count > 0 then
		if #loot.containerItems == 0 then Infinity_PopMenu('WORLD_CONTAINER') end
		count = 0
	end
}

The counter is tracking if we've pressed E or not, so newly opened but empty containers don't close automatically.

To point 2, is there an action bar equivalent of Infinity_PopMenu? like Infinity_PopMenu('ACTION_BAR') that could be invoked together with the closing of the world container?

 

edit: whew, that code view is a finicky beast!

Edited by agris
Link to comment
15 hours ago, agris said:

This is where I'm running into my first issue: it seems like there is no good documentation of the functions available for the EE UIs. It's all contained in the black hole that is the Beamdog forums, which don't let you search per-forum and, strangely, are not searchable by google using the classic "TERM site:https://forums.beamdog.com/categories/ui-modding" method.

I recently found this: https://eeex-docs.readthedocs.io/en/latest/EE Game Lua Functions/index.html

Not much description there, but method names are rather self explanatory.

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...