Jump to content
⚠ Known Issue: Media on User Profiles ×

Quick Questions, Quick Answers


Mattiewagg

Recommended Posts

  • Replies 2.6k
  • Created
  • Last Reply

Top Posters In This Topic

Would this function work? (Intends to get if the actor is one of the races within the array.)

 

EDIT: Seems to work.

Bool Function IsDogRace(Race[] dogArray, Actor WhichActor)

	;is the actor this function is being called on one of the dog races in the array? Or any race
	Int dIndex = dogArray.Length

	While dIndex

		If WhichActor.GetRace() == dogArray[dIndex]

			;is race
			Return True 

		Else 

			dIndex -= 1

		EndIf 

	EndWhile

	If dIndex == 0

		Return False 

	EndIf 

EndFunction
Edited by Matthiaswagg
Link to comment
Share on other sites

You don't need the global for any other use?

 

It's good that you found a solution, but it bugs me that we don't know why the original script failed.

Yeah, I didn't need the global afterwards... I'm done working on that mod now, but my roommate asked me to make him a mod after I showed what I had done to him :pinch: The mod he asked me to make for him, unfortunately, is a "Gold Converter" mod - Essentially he wants an item added to his inventory that, when activated, will allow you to dump all your unwanted/excess items that you either don't feel like, or are unable to, sell to a merchant. He wants the item to "convert" the items put in it into gold, which can them be taken out of it. I said I would do what I can to make it for him. I built a new room, placed a chest in the middle of the room, and built a script based off the one I made previously, and tested it. It works brilliantly, if you don't mind that it only gives you the base item's value (if you put an enchanted item into it, it only gives you the value of the base un/non-enchanted item). My problem is that, as mentioned, he doesn't want to have to coc to a cell, or go somewhere and use a chest, but just use an item in his inventory to achieve what I have done with the chest.

 

Thus, my question is - How do I link an item to a chest, so that it accesses the chest upon activation, and how do I automatically put that item in the player's inventory?

Link to comment
Share on other sites

The basic process is to add an OnEquipped event to an object that activates a remote container.

 

So something like:

ObjectReference property MyContainer

Event OnEquipped(Actor akActor)

utility.wait(0.1) ;necessary because you can't open a container from inside your inventory.
                  ;If you want to get fancy you can boot the player out of the inventory screen instead.

MyContainer.Activate(akActor)

endEvent

To add the item to the player's inventory, simply use a quest or make it craftable.

Link to comment
Share on other sites

Question: How do you make a container that has an OnClose Event in its script recognize that it has been opened/closed if it is being accessed by an item in the player's inventory?

 

Scripts used:

ScriptName ConverterSkullScript extends ObjectReference  

ObjectReference Property ConversionChestG  Auto  

Event OnEquipped(Actor akActor)
	Utility.Wait(0.1)
	ConversionChestG.Activate(akActor)
EndEvent
ScriptName ConversionChestScript extends ObjectReference

ObjectReference Property ConversionChestG  Auto  
MiscObject Property Gold001  Auto  
Int Property myGoldValue = 0 Auto  
Int Property itemValue  Auto  

Event OnItemAdded(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
	If akSourceContainer == Game.GetPlayer()
		itemValue = akBaseItem.GetGoldValue()
		itemValue = (itemValue * aiItemCount)
		myGoldValue += itemValue
	EndIf
EndEvent

Event OnItemRemoved(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
	If akDestContainer == Game.GetPlayer()
		itemValue = akBaseItem.GetGoldValue()
		itemValue = (itemValue * aiItemCount)
		myGoldValue -= itemValue
	EndIf
EndEvent

Event OnClose(ObjectReference akActionRef)
	Utility.Wait(1.0)
	ConversionChestG.removeAllItems()
	Utility.Wait(1.0)
	ConversionChestG.addItem(Gold001, myGoldValue, true)
	Debug.MessageBox("Items in the chest have been turned into " + myGoldValue + " gold!")
	resetGoldValue()
EndEvent

Function resetGoldValue()
	myGoldValue = 0
	Return
EndFunction
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...