Jump to content

FOSE Based Sorter Scripting Issue


vforvic

Recommended Posts

I am trying to get a dynamic sorter working that allows the Player to add and remove custom weapons from a formlist that allows sorting to occur to custom containers. So any weapon added by a custom mod can be sorted to the container of the Players choosing...based on options given.

For example, I have a container that says Sniper Rifles. A Player could take a custom weapon of any type, equip the weapon and using the menu options at a Activator sort that weapon to the Sniper Rifles container. Essentially any weapon added by any mod could be custom sorted to custom containers I set up.

 

The problem is my poor scripting skills especially with FOSE involved. The code more or less works, but somewhere the getbuttonpressed is messing with me...I think. The script below is used for adding weapons to a formlist on the fly. Another script I have, which works, uses the various formlist's to sort into containers.

I have If you look down where it says "showmessage Merc00AddWeapon" this is where the Message pops up asking where you want your equipped weapon to start being sorted. The problem is that the script is not going beyond the "if sort == 1" line. No matter what button I press on the Message it always sorts to the 1 formlist as if I were pressing the 1st button on the message.

 

I do know that through testing it appears to only be getting the getbuttonPressed from the 1st Message at "ShowMessage Merc00ASKADD" (this message asks where to look for the weapon to scan...equipped, hotkey, etc...) and using it throughout the script no matter what buttons I press on the next popup message at "Merc00AddWeapon" which is supposed to be the message where you pick which formlist to add the weapon to. Do I have to reset the getbuttonpressed or maybe a endif is set in the wrong place?

int Sort		
int i		
int endlist
ref curRef	
ref testRef
int inlist
int equip
int active
ref list
int button
int valid

Begin OnActivate
	ShowMessage Merc00ASKADD
	Set Active To 1
	Set List To 0
End

Begin Gamemode
if active == 1
	set Sort to getbuttonPressed + 1	
	endif

	if sort == 4	
		set active to 0	
		set Sort to 0	
	elseIf Sort == 1	
		showmessage Merc00MSGSCAN	
		Set curRef to player.GetEquippedObject  5
		if curRef != 0												
			Set i to 0
			Set inlist to 0
			set endlist to ListGetFormIndex Merc00WeaponsList Merc00Endlist

			Label 1
			set testRef to ListGetNthForm Merc00WeaponsList i		
			if testRef == curRef						
				set inlist to 1					
				set i to endlist - 1				
			endif
			If i == (endlist - 1)	
			else
				set i to i + 1	
				Goto 1		
			Endif
 
			showmessage Merc00MSGCOMPLETE	
			if inlist == 1			
				showmessage Merc00MSGINLIST
			else

			showmessage Merc00AddWeapon
			if sort == 1
				Set curRef to player.GetEquippedObject  5
				ListAddForm Merc00WeaponsList curRef 0
				showmessage Merc00FinishAdded
				set active to 0
			elseif sort == 2
				Set curRef to player.GetEquippedObject  5
				ListAddForm Merc00WeaponLaserPistolList curRef 0
				showmessage Merc00FinishAdded
				set active to 0
			elseif sort == 3
				showmessage Merc00FinishNotAdded
				set active to 0
				set active to 0										
				Set button to 0
			endif
		endif
		else
			showmessage Merc00FinishNOWP
		set active to 0
		Set Sort to 0	
endif
endif
End
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...