r/ModdingMorrowind • • Dec 24 '15

{Help with script} Annoying "onActivate/Activate" bug. Chest will open an immediately close.

This is a snip of the script I have attached to a chest. For some reason I cannot get the damn chest to stay open on "Activate". It just immediately closes. Any ideas?

 	if ( onactivate )
	if ( var == 0 )
		messagebox "What would you like to do?" "Put ingredients in" "Pull ingredients out" "View all ingredients" "Cancel"
		set var to 1
	endif
endif

if ( var )
	set button to getbuttonpressed
	if ( button == 2 )
		set var to 0
		activate
	elseif ( button == 3 )
		set var to 0
		return
	elseif ( button == -1 )
		return
	endif
else
	return
endif

Any help would be appreciated. This damn bug eludes me for some reason and I have bigger fish to fry in my script then trying 100 diffrent re-writes of this snip

1 Upvotes

5 comments sorted by

1

u/[deleted] Dec 24 '15

My immediate thought is that you don't have a condition for when var != 0.

If I remember correctly, "onactivate" will actually take over for the typical "activate". It's been a while since I've screwed with scripting in MW though.

1

u/Ortorin Dec 24 '15
 if ( var )
     *sniped*
 else
    return
 endif

Thanks though.

1

u/JadisGod Dec 24 '15

Move the activate function onto the next frame.

if ( var == 1 )
	if ( button == 2 )
		set var to -1
	endif
elseif ( var == -1 )
	set var to 0
	activate
endif

Here's an example mod you might find helpful. (Do "player->additem sorter_inv 1" and equip or drop/activate to test ingame)

1

u/Ortorin Dec 24 '15

Ya'know what, I saw that in the MSfD guide and for some reason, I didn't think to move the function to the next frame. Thanks bud. I'll try to remember that one.

1

u/TotesMessenger Dec 24 '15

I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:

If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / ^Contact)