Jump to content

Please help me get this simple script working


irswat

Recommended Posts

  • Replies 135
  • Created
  • Last Reply

Top Posters In This Topic

when is a script initialized? Just once per load?

I threw this in OnInit()

 

;revoke tempered blade timer with help from IsharaMeriden
StartTime = Utility.GetCurrentGameTime()
EndTime = StartTime + 1 

 



This in Main()

 

if (TimeofDay>=6.0 && TimeofDay<18.0)
		DayTime=1
		if DuskfangUpgraded==true && DuskfangSated==false && RevokeTemperedBladeCheck==0 
			RevokeTemperedBladeCheck=1
			RevokeTemperedBlade()
		endif
		ItsDayTime()
	elseif ((TimeofDay>=18.0 && TimeofDay<=24.0)||(TimeofDay<6.0))
		DayTime=0
		if DawnfangUpgraded==true && DawnfangSated==false && RevokeTemperedBladeCheck==0 
			RevokeTemperedBladeCheck=1
			RevokeTemperedBlade()
		endif
		ItsNightTime()
	endif 

				
	GetUpdateTime() 

 



and this in GetUpdateTime()

 

	;sub-routine with help from IsharaMeradin
	if Utility.GetCurrentGameTime() >= EndTime
		RevokeTemperedBladeCheck==0
		StartTime = Utility.GetCurrentGameTime()
		EndTime = StartTime + 1
		RegisterForSingleUpdate(1)
	endif 

 



How to limit the player to one upgrade per day, and to check whether a blade was sated took some time to figure out how to accomplish efficiently, but here it is:

 

;KillCount function with help from FamilyFrank
;includes check and Notification if fangblade is sated
Function IncrementKillCount(Bool bIdentity)
		
	If bIdentity ; its dawnfang
		DawnfangFragCount.Mod(1)
		if DaytimeFragCount.GetValue()<12
			DaytimeFragCount.Mod(1)		
		endif
		if DaytimeFragCount.GetValue()==12.0	
			if DawnfangUpgraded==true
				Debug.Notification("Dawnfang blood lust sated.")
				DawnfangSated=true
			elseif DawnfangUpgraded==false
				DawnfangSated=false
				DawnfangUpgraded=true
			endif
		endif
		GetKillLevel(bIdentity)
	Else ; its duskfang
		if NighttimeFragCount.GetValue()<12
			NighttimeFragCount.Mod(1)
		endif
		DuskfangFragCount.Mod(1)
		if DaytimeFragCount.GetValue()==12.0	
			if DuskfangUpgraded==true
				Debug.Notification("Duskfang blood lust sated.")
				DuskfangSated=true
			elseif DuskfangUpgraded==false
				DuskfangSated=false
			endif
		endif
		GetKillLevel(bIdentity)
	Endif
EndFunction 

 



the idea is in any 12 hour period the first 12 kills will upgrade a blade, and the next 12 with satiate the upgraded blade. In effect you need 24 kills per 12 hours to keep the tempered fang blades.

here is the other function:

 

Function RevokeTemperedBlade()
			
	if Daytime==1 && DuskfangSated==false && DuskfangUpgraded==true
		Debug.Notification("Revoke blade triggered: Duskfang was not sated. Revoking tempered blade")
		DuskFangLevel.SetValue(1.0)
		DuskfangFragCount.SetValue(0.0)
		NighttimeFragCount.SetValue(0.0)
		DuskfangTemperFormList.Revert()
		DuskfangSated==false
		DuskfangUpgraded==false
	elseif Daytime==0 && DawnfangSated==false && DawnfangUpgraded==true
		Debug.Notification("Revoke blade triggered: Dawnfang was not sated. Revoking tempered blade")
		DawnFangLevel.SetValue(1.0)
		DawnFangFragCount.SetValue(0.0)
		DaytimeFragCount.SetValue(0.0)
		DawnfangTemperFormList.Revert()
		DawnfangSated==false
		DawnfangUpgraded==false
	endif
	
endFunction 

 

 

Edited by irswat
Link to comment
Share on other sites

RE: OnInit()

Scripts are initialized when the object they are attached to is first loaded. I really only know what the wiki says on the matter. I've not delved into testing specific scenarios to see if OnInit() could run more than once.

 

RE: waiting at night

It depends upon how your function is called and written as to whether or not it will be skipped or processed after the player has finished waiting. This is something where in-game testing might yield more information than asking others. At least, I know that I can't give any specifics in the matter.

Link to comment
Share on other sites

the mod should be pretty darn close to fully functional. I know I've said that before, but well, here I have pictures to prove it.

http://i63.tinypic.com/34pjfvo.jpg

DISCLAIMER: Countless mud crabs were slaughtered indiscriminately in the making of this mod.

Edited by irswat
Link to comment
Share on other sites

I had once a script on a item that was crafted for testing purposes and if i remember right this was the oninit/onload behavior:

 

As soon as it's crafted the item begins to exist, but as a "item x on container Y reference" invalid object reference => OnInit

Drop the item => the reference becomes a proper object reference => OnInit again and OnLoad

 

My item became persistent the moment it was loaded so OnInit never run again but i guess if its not persistent it will eventually unload from memory and this behaviour would repeat. But not once per load.

If the item is persistent and placed on the world from the beginning (not in a container) then OnInit would only run once i think.

 

EDIT: I was curious and checked the wiki, the relevant part for when OnInit runs:

 

For persistent refs: At game start the first time this script is loaded

For non-persistent refs: When the ref is loaded the first time [and] when the cell resets.

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...