Jump to content

Quick Question - Quick Answer


Cipscis

Recommended Posts

Yes you can. In fact, GetButtonPressed should just about always be used in a GameMode block. The reason why your script isn't working is probably because you're calling ShowMessage right before GetButtonPressed each time. This means that the script is looking for a button press from the most recent message, but since no time has passed (it's in the same frame) the player can't possibly have pressed a button. You'll want to use a "bDoOnce" variable in order to only call ShowMessage once:
int bDoOnce

Begin Gamemode

if bDoOnce
else;if bDoOnce == 0
	set bDoOnce to 1
	Showmessage SelectAction; 0=one, 1=both, 2=Exit
endif

set Button to getbuttonpressed
IF Button != 2; if exit is selected, skips all the code
	if Button == 1; both selected, so include the second action
		Action on second item

	Endif
	Action on first item

EndIF
END

Cipscis

 

Thanks Cipscis. That makes sense since previously I have used showMessage in an activation block and read the buttonpress from a GameMode block. I will give it a shot.

Link to comment
Share on other sites

  • Replies 804
  • Created
  • Last Reply

Top Posters In This Topic

I'm trying to make a script to activate and deactive a weapon's scope. The problem is, the function 'GetWeaponHasScope' is not working. Everything else, including the key press, is working. I checked the FOSE command docs, and GetWeaponHasScope is indeed a script function. But for some reason, the GECK isn't recognising it. I loaded the GECK with the FOSE loader, by the way.
Link to comment
Share on other sites

scn FG42ScopeSCRIPT

short Switch
short Menu2
short Menu3
short Reload
float  weaponCondition
float  Button
ref	 Weap

Begin GameMode

if Switch
	if IsKeyPressed 36
		if player.IsWeaponInList FG42
		else
			Set Switch to 0
		endif
	else
		Set Switch to 0
	endif
elseif IsKeyPressed 36
	if player.IsWeaponInList FG42
		Set Switch to 1
		set Weap to player.GetEquippedObject 5
		if Weap.GetWeaponHasScope == 1
			Set GetWeaponHasScope to 0
		elseif Weap.GetWeaponHasScope == 0
			Set GetWeaponHasScope to 1
		endif
	endif
endif
End

 

I think that' should toggle the scope on and off. The problem comes in when I try to compile it; it says

 

"SCRIPTS: Script 'FG42ScopeSCRIPT', line 27:

Unknown variable 'GetWeaponHasScope'.

 

 

Context: DEFAULT

 

Now, I think this is because I called the function incorrectly. If that's the case, is there any way to switch a weapon from having a scope to not having one?

Link to comment
Share on other sites

Some FOSE functions, like GetWeaponHasScope, are used on inventory items. These functions can be called in two ways - via reference syntax if being called on a reference, or by passing an EditorID as a parameter when being called on a base object. In this case, you're calling it on a base object, so you should use this syntax:

set Weap to player.GetEquippedObject 5;Weapon
if GetWeaponHasScope Weap

There is no SetWeaponHasScope function, so if you want to change whether or not a weapon uses a scope you'll have to swap between two separate weapons. If there was a function called SetWeaponHasScope, you would call it just like any other function. The only time in which you'd use a "set" command is when you're changing the value of a variable.

 

Cipscis

Link to comment
Share on other sites

@portbash:

I know that you can detect when the player grabs/releases an object via the OnGrab and OnRelease blocks, but I don't know of any way in which you can prevent the player from picking up an object short of either using FOSE's TapControl to force the reference to be instantly released or using FOSE's GetCrosshairRef along with DisableControl/EnableControl in order to prevent the "grab" control from being used while the appropriate object is being targeted.

 

Neither of these are even close to perfect solutions, however, and the both require FOSE. I'm not familiar enough with NIF structure to be able to tell you if there's any way to prevent grabbing on that end, but I wouldn't be surprised if there was.

 

 

thx Cipscis gonna figure something out

Link to comment
Share on other sites

Hi Cipscis! Is there a way to condition perk ability to activate only when actor has equiped armor with less than 15 Armor Rating? Thank you!
Link to comment
Share on other sites

How in the heck do I get the hairpack in with my data so I can make NPCs that use those hairs and require that particular esm/esp? GECK always tells me "Multiple master file DENIED!" when I try to load it. (Yet it doesn't do this when I check FOOK2s to require that...)
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...