Jump to content

Call a Property from an Object - Scripting Help


Recommended Posts

Hi, I'm trying to call a property called Filter_Charge from another script on an object called GasMaskFilter to a GasMask to manipulate a variable. I'm having trouble pulling the variable without errors (I think it's just a lack of syntax knowledge). Any help is welcomed.

 

Gas Masks

Scriptname GasMask:GasMask extends ObjectReference

int TimerID0 = 0
Spell property WastelandRadiation auto
Sound Property VOCPlayerSprintOutOfBreath1st const auto
ObjectReference GasMaskFilter
Keyword GasMask

Function RestartTimer()                
  StartTimer(60, TimerID0) ; 
EndFunction

Event OnEquipped(Actor akActor)
	If (akActor.WornHasKeyword(GasMask) == true) && (akActor == Game.GetPlayer())
		RestartTimer() ;Start the timer to consume filters
	endIf
EndEvent
	
Event OnTimer(int aiTimerID0)		
  If aiTimerID0 == TimerID0 ; The 60 second timer we started just expired
	If  GasMaskFilter.Filter_Charge.Get() == 0;
		Game.GetPlayer().RemoveItem(GasMaskFilter, 1)
		int instance1 = VOCPlayerSprintOutOfBreath1st.play(self); play SFX sound from my self
		Sound.SetInstanceVolume(instance1, 1);    
	else
		GasMaskFilter.Filter_Charge.Set(GasMaskFilter.Filter_Charge.Get() - 10); Remove 10 charge from the item
	endIf
    RestartTimer(); Reset the timer back
  endIf
EndEvent

GasMaskFilter: Property Filter_Charge

Scriptname GasMask_Charge extends ObjectReference

ObjectReference GasMaskFilter
int Charge = 50
int Property Filter_Charge

	int Function Get()
		return Charge
	EndFunction

	Function Set(int i)
		If Charge > 0
			Charge = i
		endIf
	EndFunction

EndProperty
Link to comment
Share on other sites

I have a series of errors that are a little confusing to me. Most of them seem related to the same lines. I've been trying to mimic the examples but I don't think I'm getting the context of the examples.

 

Errors:

 

Compiling "GasMask\GasMask.psc"...
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask.psc(4,13): no viable alternative at input 'GasMaskFilter'
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask.psc(4,26): required (...)+ loop did not match anything at input '.'
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask.psc(4,4): Unknown user flag gasmaskfilter
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask\GasMask.psc(7,8): cannot name a variable or property the same as a known type or script
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask.psc(4,13): no viable alternative at input 'GasMaskFilter'
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask.psc(4,26): required (...)+ loop did not match anything at input '.'
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask.psc(4,4): Unknown user flag gasmaskfilter
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask\GasMask.psc(14,28): GasMask is not a variable
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask.psc(4,13): no viable alternative at input 'GasMaskFilter'
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask.psc(4,26): required (...)+ loop did not match anything at input '.'
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask.psc(4,4): Unknown user flag gasmaskfilter
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask\GasMask.psc(14,28): type mismatch on parameter 1 - cannot pass a gasmask to a keyword
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask\GasMask.psc(14,37): cannot compare a void to a bool (cast missing or types unrelated)
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask\GasMask.psc(21,19): Filter_Charge is not a property on script objectreference or one of its parents
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask\GasMask.psc(21,33): none is not a known user-defined script type
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask\GasMask.psc(21,39): cannot compare a void to a int (cast missing or types unrelated)
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask\GasMask.psc(27,16): Filter_Charge is not a property on script objectreference or one of its parents
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask\GasMask.psc(27,48): Filter_Charge is not a property on script objectreference or one of its parents
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask\GasMask.psc(27,62): none is not a known user-defined script type
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask\GasMask.psc(27,68): cannot subtract a void from a int (cast missing or types unrelated)
E:\SteamLibrarySSD\steamapps\common\Fallout 4\Data\Scripts\Source\User\GasMask\GasMask.psc(27,30): none is not a known user-defined script type
No output generated for GasMask\GasMask.psc, compilation failed.
Link to comment
Share on other sites

Alright. How do I reference to it? I thought ObjectReference GasMaskFilter was the pointer but I'm obviously mistaken. Can you provide an example of pointing to an object and its properties?

 

Right now, GasMask is attached to GasMask Objects and GasMask_Charge is attached to GasMaskFilters.

Edited by D1v1ne122
Link to comment
Share on other sites

Yes. The problem is that you will need to reference more than one gas mask object in order for your script to work properly. I would recommend that you consider rewriting your mod to use a quest script instead of Objectreferences.
Link to comment
Share on other sites

  • Recently Browsing   0 members

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