Jump to content

Need some tips on making a scripted item display


jtucker40

Recommended Posts

Hi guys,

 

I'm currently working on trying to script a simple modification where if a certain reference container contains a specific item, the script enables a referenced object in-game. Basically, I'm trying to something like the weapon wall from Underground Hideout. The base script I'm using as a reference however is not from UH, but instead the script from the TTW Interiors Rivet City player home that displays toys around your house depending on if they're in a chest or not. Here's what I have:

SCN ItemDisplay Script

SCN ItemDisplay Script

Begin OnClose DisplayBoxREF

    If DisplayBoxREF.GetItemCount WeapLaserRifle >= 1
        LaserRifleREF.Enable
    endif

    If DisplayBoxREF.GetItemCount WeapLaserRifle == 0
        LaserRifleREF.Disable
    endif
endif
end

Here I'm trying to have a laser rifle static on the wall be displayed whenever a Laser Rifle is placed inside the container "DisplayBoxREF." The script saved fine in the GECK, and I have the script selected in the appropriate box for the Display Box base object, however in-game it doesn't appear to be working. The rifle on the wall is enabled initially, even when there is nothing inside the display box. There didn't seem to be much to the original TTW script, and that worked fine, so I'm not sure what I'm doing wrong. I don't know much about scripting so any help would be appreciated.

 

I have made sure that I have "persistent reference" ticked on both references, and "initially disabled" ticked on the laser rifle however it still doesn't work.

Edited by jtucker40
Link to comment
Share on other sites

As Roy noted, it is surprising that you were able to save the script, despite the redundant endif.


Anyhow, AFAIK, OnClose will not fire unless the actual 3D model of the container/door has a closing animation.


Try this, instead:




scn ItemDisplayScript

short bActivated

begin OnActivate

if IsActionRef playerRef
set bActivated to 1
endif

end

begin GameMode

if bActivated
set bActivated to 0
if DisplayBoxREF.GetItemCount WeapLaserRifle
if LaserRifleREF.GetDisabled
LaserRifleREF.Enable
endif
elseif LaserRifleREF.GetDisabled == 0
LaserRifleREF.Disable
endif
endif

end

Link to comment
Share on other sites

 

As Roy noted, it is surprising that you were able to save the script, despite the redundant endif.
Anyhow, AFAIK, OnClose will not fire unless the actual 3D model of the container/door has a closing animation.
Try this, instead:
scn ItemDisplayScript

short	bActivated

begin OnActivate

	if IsActionRef playerRef
		set bActivated to 1
	endif

end

begin GameMode

	if bActivated
		set bActivated to 0
		if DisplayBoxREF.GetItemCount WeapLaserRifle
			if LaserRifleREF.GetDisabled
				LaserRifleREF.Enable
			endif
		elseif LaserRifleREF.GetDisabled == 0
			LaserRifleREF.Disable
		endif
	endif

end

 

 

Ok so JIP I tried using your new script as a substitute for the old faulty one, however now when I activate the container nothing happens. I get the activation sound but I am unable to open it an access the actual container itself for some reason. I'm no script wizard so at a glance I can't look through yours and see what exactly every function does, but are you able to see what might be causing this problem?

Link to comment
Share on other sites

 

Anyhow, AFAIK, OnClose will not fire unless the actual 3D model of the container/door has a closing animation.

 

My original DisplayBoxREF used the metal box as a base object, which didn't have a closing animation. I tried the original script using the blue chest as a base object (since it has an opening and closing animation) and now it works! The script still has a redundant endif though, does it matter which endif I delete?

Link to comment
Share on other sites

 

Ok so JIP I tried using your new script as a substitute for the old faulty one, however now when I activate the container nothing happens. I get the activation sound but I am unable to open it an access the actual container itself for some reason. I'm no script wizard so at a glance I can't look through yours and see what exactly every function does, but are you able to see what might be causing this problem?

 

 

Ah, sorry, I forgot to add Activate:

scn ItemDisplayScript

short	bActivated

begin OnActivate

	if IsActionRef playerRef
		set bActivated to 1
		DisplayBoxREF.Activate playerRef
	endif

end

begin GameMode

	if bActivated
		set bActivated to 0
		if DisplayBoxREF.GetItemCount WeapLaserRifle
			if LaserRifleREF.GetDisabled
				LaserRifleREF.Enable
			endif
		elseif LaserRifleREF.GetDisabled == 0
			LaserRifleREF.Disable
		endif
	endif

end

This script should work regardless of which base object you select for the container, and whether or not it has the required animation sequences.

 

As for the redundant endif in the original script: remove the one just above end (second to last line).

Link to comment
Share on other sites

  • Recently Browsing   0 members

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