Page 1 of 2

Gray Out / Disable User Interface?

Posted: Fri Nov 11, 2016 6:47 am
by Lark
When the party climbs a ladder, the party's hands are grayed out and the keyboard movement keys don't work until you reach the top. I wish to reproduce this effect from a script: The script will be triggered, the interface disabled, the script does its thing, and enables the interface just before it exits.

Does anyone know how to do enable/disable this user interface? I've searched for days and not found anything.

Thank you, -Lark

Re: Gray Out / Disable User Interface?

Posted: Fri Nov 11, 2016 6:55 am
by Isaac

Code: Select all

GameMode.setGameFlag("HideGui", true)
GameMode.setGameFlag("DisableMovement", true)
GameMode.setGameFlag("DisableMouseLook", true)
Also:

Code: Select all

GameMode.setEnableControls(false)
edit:
*"HideGUI" may be overkill... That hides everything, including the portraits.

To disable just the attack panel, [afaik*] requires a party hook, if you are interested.
*(I would love to learn otherwise. :) )

Lark, there is another (more up to date) scripting reference for LoG2; maintained by JKos & minmay.
https://github.com/JKos/log2doc/wiki

Re: Gray Out / Disable User Interface?

Posted: Fri Nov 11, 2016 7:21 am
by minmay
"Maintained" isn't the word I'd use

Re: Gray Out / Disable User Interface?

Posted: Fri Nov 11, 2016 7:33 am
by Isaac
minmay wrote:"Maintained" isn't the word I'd use
Embellished then. ;)

[But they are welcome updates.]

Re: Gray Out / Disable User Interface?

Posted: Fri Nov 11, 2016 6:53 pm
by Lark
Isaac, This is fantastic! Thank you! This fixed my problem! And the new wiki is great! Thank you JKos and minmay!!

I have a ladder script that automatically deploys itself on all ladders defined in the game that gives the party an actual descent to the floor instead of just falling. Just back onto a ladder and you descend it. It's working really well, but if the party moved forward while descending, they wound back up at the top of the ladder on the landing and the script got "confused". Disabling movement takes care of that and it's better than spawning a temporary block in the square!

I've still to handle stacked ladders and I'd like to disable the sound of the party falling, but I added some relatively hefty sounds of the party stepping down the ladder rungs, so the falling sound isn't so bad. I have a few leads on that, but the stacked ladder support is more fun right now.

I'd also like to add clicking on the top or bottom of the ladder while on a multi-ladder segment to go up or down, but I don't even know where to begin with that yet. Regardless, I hope to have at least a single ladder script uploaded soon.

Thank you again for your help! -Lark

Re: Gray Out / Disable User Interface?

Posted: Fri Nov 11, 2016 7:32 pm
by minmay
The party_land sound only plays upon the party hitting the ground from their GravityComponent. If you disable the party's GravityComponent before they touch the ground, you should be able to prevent the sound from playing.

Re: Gray Out / Disable User Interface?

Posted: Fri Nov 11, 2016 8:42 pm
by Isaac
Lark wrote:I have a ladder script that automatically deploys itself on all ladders defined in the game that gives the party an actual descent to the floor instead of just falling. Just back onto a ladder and you descend it.
That sounds really cool. 8-)

I have a different kind of ladder script; one that spawns additional ladders as needed [upwards or down], resulting in a multi-story ladder object... but there was no safe descent. :shock:

Re: Gray Out / Disable User Interface?

Posted: Fri Nov 11, 2016 9:39 pm
by Lark
minmay: Thanks for the gravity idea, but the party is actually "falling" a short distance on a moving, invisible platform. So when I turn off gravity, the party doesn't, uh, fall! :D I tried using party.party:move() but found through trial and error that it only allows you to move N, E, S, and W (0, 1, 2, 3 respectively). It's a great idea, but alas...

Can/should others update the wiki? I had to experiment with :move(), but I could document what I just found if that is allowed/desired.

Isaac: I'll post the script soon, but now I really want to get it working on multi-level ladders! I'll share what I have at anytime if anyone wants it in alpha state.

Thank you both, -Lark

Re: Gray Out / Disable User Interface?

Posted: Sat Nov 12, 2016 2:48 am
by minmay
Lark wrote:minmay: Thanks for the gravity idea, but the party is actually "falling" a short distance on a moving, invisible platform. So when I turn off gravity, the party doesn't, uh, fall! :D I tried using party.party:move() but found through trial and error that it only allows you to move N, E, S, and W (0, 1, 2, 3 respectively). It's a great idea, but alas...
party.party:move() and party.party:turn() are for changing the movement state of the party as if the player sent an input (except it ignores the input queue and overwrites any current action). If your intent is to translate the party along a path, party.party:move() is not what you want. Instead, use GameObject:setWorldPosition() called every frame - like you are presumably doing for your moving platform.

Re: Gray Out / Disable User Interface?

Posted: Sat Nov 12, 2016 6:59 pm
by akroma222
Sorry if Im late to the party Lark,
to replicate the disabled attack panel (for a custom Frozen condition) I use:

Code: Select all

GameMode.setGameFlag("DisableMovement", true)
GameMode.setGameFlag("DisableMouseLook", true)
GameMode.setGameFlag("DisableKeyboardShortcuts", true)
then for the onDrawAttackPanel partyhook:

Code: Select all

if champion:hasCondition("frozen") and (not champion:hasCondition("petrified") and not champion:hasCondition("paralyzed")) then
	g.color(30,100,300)
	champion:showAttackResult("", "ChampionConditionOverlay")  -- I think this is what you may be looking for
	champion:showAttackResult("Frozen", "SpellNoEnergy")           --extra stuff you prob dont need
and then for the other appropriate party hooks (onAttack, onMove etc):

Code: Select all

if champion:hasCondition("frozen") then                                --add your checks in here then return false
		return false
	end
Importantly, is the onClickItemSlot hook though, as you may want different mouse clicks to be allowed or not (??):

Code: Select all

               onClickItemSlot = function(self, champion, container, slot, button)
			------------------------------------------
			local m = getMouseItem()
			--------------------------------------------FROZEN
			if champion:hasCondition("frozen") 
			or champion:hasCondition("paralyzed") 
			or champion:hasCondition("petrified") then
				if (slot == 1 or slot == 2) 
				and (button == 0 or button == 1 or button == 2) then
					return false
				elseif slot 
				and (button == 1 or button == 2) then
					return false
				end
			end
             end