Jump to content

How do I do a script that includes adding a item to the activated item


masternetra

Recommended Posts

I assume you're talking about the Pristine Vending Machines placed in the player homes in Megaton and Tenpenny Tower. Actually the script attached to them only needs one minor adjustment to make it work when placed everywhere.

 

This is the script in its full form:

scn HD01NukaVendingMachineScript

;This script is designed to handle the Nuka-Cola Machine that the Player buys for his house
;The Player can add Nuka-Colas to the machine and have them changed to Ice-Cold Nuka-Colas
;He can then dispense them as he wants to take some or drink them

short Button
short NukasOnMe
short GoNuka


begin OnActivate

if ( IsActionRef Player == 1 )
	if ( Player.GetItemCount NukaCola >= 1 )
		ShowMessage HD00NukaMachineWith
		set GoNuka to 2
	elseif ( Player.GetItemCount NukaCola < 1 )
		ShowMessage HD00NukaMachineWithout
		set GoNuka to 1
	endif	
endif

end

begin gamemode

set Button to GetButtonPressed

if ( Button == 0 ) && ( GoNuka >= 1 )
	Activate
	set GoNuka to 0
elseif ( Button == 1 ) && ( GoNuka == 2 )
	set NukasOnMe to ( Player.GetItemCount NukaCola )
	Player.RemoveItem NukaCola NukasOnMe
	HD01NukaMachineRef.AddItem MS05IceNukaCola NukasOnMe
	set NukasOnMe to 0
	set GoNuka to 0
elseif ( Button == 1 ) && ( GoNuka == 1 )
	;Do Nothing
	set GoNuka to 0
elseif ( Button == 2 ) && ( GoNuka == 2 )
	;Do Nothing
	set GoNuka to 0
endif

end

This line:

HD01NukaMachineRef.AddItem MS05IceNukaCola NukasOnMe

Should be changed to this:

AddItem MS05IceNukaCola NukasOnMe

What happens is that AddItem is called on the very object it is attached to, instead of a specific reference (HD01NukaMachineRef) which in this case is placed in the Megaton player home.

 

Now I would create a new container based on one of the existing Pristine Vending Machines to avoid incompatibilities if another mod changes these, make a new script like described above and attach it to the container. And then you have your generic version of it, that you can place anywhere you want.

Link to comment
Share on other sites

The game devs did that a lot. For some reason they didn't like doing the whole "lets write one script and use it in a lot of places" for that kind of thing. There's also a version of that script in my Nuka-Cola Enhanced mod that does the same thing, allowing the machines to be placed in lots of locations.
Link to comment
Share on other sites

  • Recently Browsing   0 members

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