antstubell Posted October 29, 2019 Share Posted October 29, 2019 Have a long OnActivate script which calls a function. Within the function I need to have a timer. Script compiles but timer never... times. I can't call an event within the function - can I? - Wiki example always shows OnUpdateGameTime() being called as an event but this function is within an event.Help please. Function SentFromWithinAnEvent(); show msg water heating, register for time to boil, enable valveIf IsBoilingWater == 1WaterIsHeating.Show();----------Timer-------------------------------------RegisterForUpdateGameTime(TimeToPass)OnUpdateGameTime()ValveObj.enable()WaterIsBoiling.show()UnregisterForUpdateGameTime()EndifEndFunction Link to comment Share on other sites More sharing options...
cumbrianlad Posted October 29, 2019 Share Posted October 29, 2019 I wrote this script to disable a magic barrier on a timer. The script should be fairly easy to modify for your purpose. It definitely works. If you want to have different times for other parts of your mod, you could just add an integer property for the timer state. Scriptname MBEJbarrierDispelScript extends ObjectReference ;This is the trigger box in front of Dwethand main entrance door ;It needs an xMarker to toggle objects between enabled and disabled states ;It disables and then enabes the marker after a time Spell Property MBEJdisableSpell auto {BASEOBJECT PROPERTY} ObjectReference Property ObjectToToggle auto Message Property MessageToShow auto Auto State WaitingForHit Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) if akSource == MBEJdisableSpell ObjectToToggle.Disable(true) GoToState("Activated") Endif If akSource!=MBEJdisableSpell GoToState("Reset") endif EndEvent EndState State Activated Event OnBeginState() Utility.Wait(20) ObjectToToggle.Enable(true) GoToState("WaitingForHit") EndEvent EndState State Reset Event OnBeginState() Utility.Wait(0.5) MessageToShow.Show() Utility.Wait(3) GoToState("WaitingForHit") EndEvent EndState Edit: Maybe using the wait utility in a state is not the best, say if you wanted it to be a very long time, I'm not sure if it's a good thing, but for seconds it certainly causes no issue. Link to comment Share on other sites More sharing options...
ReDragon2013 Posted October 30, 2019 Share Posted October 30, 2019 (edited) Skyrim wiki is a good data base, but antstubell your code is only a snippet of a script. It could be impemented as follow: Message PROPERTY WaterIsHeating auto Message PROPERTY WaterIsBoiling auto ObjectReference PROPERTY ValveObj auto ; [default=None] Float PROPERTY TimeToPass auto ; [default=0.0] Int PROPERTY IsBoilingWater auto ; [default=0] ; -- EVENTs -- EVENT OnActivate(ObjectReference akActionRef) ; .. SentFromWithinAnEvent() ENDEVENT EVENT OnUpdateGameTime() ;;; UnRegisterForUpdateGameTime() ValveObj.Enable() ; enable valve after gametime waiting WaterIsBoiling.show() ENDEVENT ; -- FUNCTIONs -- ;------------------------------- FUNCTION SentFromWithinAnEvent() ;------------------------------- IF (IsBoilingWater == 1) WaterIsHeating.show() ; show msg water is heating, RegisterForSingleUpdateGameTime(TimeToPass) ; register for time to boil ELSE UnRegisterForUpdateGameTime() ENDIF ENDFUNCTION cumbrianlad you should avoid using of OnBeginState() events, this is not good like you wrote: "using the wait utility in a state is not the best", but imho it depends on code implementation. Scriptname MBEJbarrierDispelScript extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/8104613-registerforupdategametime-without-an-event/ ; This object is a triggerbox in front of Dwethand main entrance door. ; It needs an xMarker to toggle objects between enabled and disabled states. Message PROPERTY myMsg auto ; MessageToShow Spell PROPERTY mySpell auto ; MBEJdisableSpell ObjectReference PROPERTY ObjectToToggle auto ; {BASEOBJECT PROPERTY} ; -- EVENTs -- ;======================================== auto state Waiting ;================= EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool b1, Bool b2, Bool b3, Bool b4) gotoState("Busy") ; ### STATE ### IF (akSource == mySpell as Form) ObjectToToggle.Disable(TRUE) ; switch off Utility.Wait(20) IF ( ObjectToToggle ) ObjectToToggle.Enable(TRUE) ; switch on after 20 sec ENDIF ELSE Utility.Wait(0.5) myMsg.Show() Utility.Wait(3.0) ; delay of 3 sec after message ENDIF gotoState("Waiting") ; ### STATE ### ENDEVENT ;======= endState ;======================================== state Busy ; prevent calling of OnHit() event during wait ;========= ;EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool b1, Bool b2, Bool b3, Bool b4) ;ENDEVENT endState Edited October 30, 2019 by ReDragon2013 Link to comment Share on other sites More sharing options...
cumbrianlad Posted October 30, 2019 Share Posted October 30, 2019 Thanks for that, RedDragon. I'm no guru with scripts. When I get one that works I'm always delighted. I'll amend my script and test it. I've done a similar script to open a distant door with a timer so that the player has to run a gauntlet of traps Tomb Rader style before it closes on them again. I'll neaten that one up too. Thanks again. Link to comment Share on other sites More sharing options...
antstubell Posted October 30, 2019 Author Share Posted October 30, 2019 Greatly helpful.Got another issue but first let me explain what the script is intending to do.Idea is the script has a universal 'light a fire' wherever. The 2 possibilities of player encountering a situation where a fire being lit would help or be necessary are when player discovers for example a fireplace without any firewood. In this case firewood needs to be in player inventory as well as an ignition source and a necessary accelerant or kindling misc. object. The second case is where player discovers a 'set fire' (firewood is in place already) and this does not require the player to have any firewood in inventory just an ignition source and a necessary accelerant or kindling misc. item. This option is set locally by the input...Int Property IsFirewoodReq = 0 Auto; does starting this fire require firewood 0-no 1-yesI did and you guys helped, the same thing with boiling the water as in the previous post. Int Property IsBoilingWater = 0 Auto; does starting this fire boil water 0-no 1-yes The issue I have now is that the script, when IsFirewoodReq = 1 does check for firewood, finds none but continues anyway - proceeding to next menu/options/lighting fire and ending.I've tried many different approaches and I am sure the solution is right in front of me but I can't see it.It is a long script but I want it to cover a few scenarios. The script compiles and saves but obviously not doing what I want.Thanks for your patience and help.Float Property TimeToPass Auto; time for timerInt Property IsBoilingWater = 0 Auto; does starting this fire boil water 0-no 1-yesInt Property IsFirewoodReq = 0 Auto; does starting this fire require firewood 0-no 1-yesGlobalVariable Property FlintUseCount AutoGlobalVariable Property FlintInUse AutoLight Property MyTorch AutoSound Property MySFX AutoMiscObject Property FWood AutoMiscObject Property Paper AutoMiscObject Property Oil AutoMiscObject Property EmptyBottle AutoMiscObject Property Rag AutoMiscObject Property Bristle AutoMiscObject Property Flint AutoMessage Property Need3Fwood AutoMessage Property FlintBroke AutoMessage Property EquipTorch AutoMessage Property CombustMenu AutoMessage Property NeedKindAcc AutoMessage Property NeedIgnite AutoMessage Property FlintOrTorch AutoMessage Property ReqItemsMsg AutoMessage Property NoReqIgniteItems AutoMessage Property WaterIsHeating AutoMessage Property WaterIsBoiling AutoObjectReference Property MyMarker AutoObjectReference Property ValveObj AutoAuto State WaitingEvent OnActivate(ObjectReference akActionRef)if (akActionRef == Game.GetPlayer())If (IsFirewoodReq == 1)NeedFirewood()EndifIf (Game.GetPlayer().GetItemCount(MyTorch) > 0) || (Game.GetPlayer().GetItemCount(Flint) > 0)MyIgnitesItem() ; If player has ignition source and firewood will go to "MyIgnitesItem()"ElseNoReqIgniteItems.Show(); no ignition sourceGoToState("Waiting")EndifEndifEndEventEndStateState BusyEvent OnActivate(ObjectReference akActionRef);Do nothing.EndEventEndState;---------------------------------------------------------------EVENT OnUpdateGameTime()UnRegisterForUpdateGameTime()ValveObj.Enable() ; enable valve after gametime waitingWaterIsBoiling.show()ENDEVENT;--------------------------------------------------------------Function MyIgnitesItem()GoToState("Busy")Int iButtonA = FlintOrTorch.Show()If iButtonA == 0If Game.GetPlayer().GetEquippedItemType(0) == 11MyCombustibleMenu() ; Goes to the choose combustion items MENU if TORCH is equipped "MyCombustibleMenu()"elseEquipTorch.Show(); If Torch is NOT EQUIPED, Player should "Equip the Torch" Message will showGoToState("Waiting"); After the Message Above will EXIT to be activated againEndIfEndIfIf iButtonA == 1If Game.GetPlayer().GetItemCount(Flint) > 0FlintInUse.SetValue(1); sets variable for Flint sfx to play IF lighting fire succeedsDebug.Notification ("Using Flint To Light Fire")MyCombustibleMenu() ; player chose flint and has flint so goes to combustible items menuEndIfEndIfEndFunction;------------------------------------------------------------------------------------------------------------Function MyCombustibleMenu()Int iButtonB = CombustMenu.Show()If iButtonB == 0Game.GetPlayer().RemoveItem(Rag, 1, TRUE)debug.notification("Rag Used As Kindling")LightFire() ; If this option is choose will go to "Function LightFire()"EndIfIf iButtonB == 1Game.GetPlayer().RemoveItem(Oil, 1, TRUE)Game.GetPlayer().AddItem(EmptyBottle, 1, TRUE)debug.notification("Paraffin used as accelerant")LightFire() ; If this option is choose will go to "Function LightFire()"EndIfIf iButtonB == 2Game.GetPlayer().RemoveItem(Bristle, 1, TRUE)debug.notification("Bristles Used As Kindling")LightFire() ; If this option is choose will go to "Function LightFire()"EndIfIf iButtonB == 3Game.GetPlayer().RemoveItem(Paper, 1, TRUE)debug.notification("Paper Used As Kindling")LightFire() ; If this option is choose will go to "Function LightFire()"EndIfif (Game.GetPlayer().GetItemCount(Rag) < 1) && (Game.GetPlayer().GetItemCount(Oil) < 1) &&(Game.GetPlayer().GetItemCount(Bristle) < 1) && (Game.GetPlayer().GetItemCount(Paper) < 1); add if fire is not litFlintInUse.SetValue(0); resets variable for Flint sfx to play because lighting fire was unsuccessfulNeedKindAcc.show()EndifGoToState("Waiting")EndFunction;--------------------------------------------------------------------------------------------------Function LightFire(); Light the fireIf FlintInUse.GetValue() == 1MySFX.Play(Self) ; if player chose flint then play flint ignition soundFlintInUse.SetValue(0); resets variable for future useFlintUseCount.Mod(1) ; counting how many times this piece of flint has been usedEndifIf FlintUseCount.GetValue() == 5Game.GetPlayer().RemoveItem(Flint, 1, TRUE)FlintBroke.Show(); flint used 5 times so breaksEndIfUtility.Wait(1.5); allow time for flintsfx to finishMyMarker.Disable(); actually show fire lightBoilWater()Self.disable()EndFunction;-------------------------------------------------------------------------------------------------------Function BoilWater()If (IsBoilingWater == 1)WaterIsHeating.show(); show msg water is heatingRegisterForSingleUpdateGameTime(TimeToPass) ; register for time to boilElseUnRegisterForUpdateGameTime()EndIfEndFunction;--------------------------------------------------------------------------------------------------------Function NeedFirewood()if (Game.GetPlayer().GetItemCount(FWood) >= 3); if player has at least 3 firewoodReturnElseif (Game.GetPlayer().GetItemCount(FWood) < 3); if player has less than 3 firewoodNeed3FWood.Show(); do thisEndifGoToState("Waiting")EndFunction Link to comment Share on other sites More sharing options...
cumbrianlad Posted November 1, 2019 Share Posted November 1, 2019 Sorry, mate, I'm often on this forum looking for help with scripts. I really struggle with states. What we need here, methinks, is one of those mage types from Winterhold to step in. There are a few on this forum. (Pretty sure of that) They may have no business poking their noses around Saarthal, a place for Nord dead, but they certainly know their way around the wizardry of papyrus. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 1, 2019 Share Posted November 1, 2019 Greatly helpful.Got another issue but first let me explain what the script is intending to do.Idea is the script has a universal 'light a fire' wherever. The 2 possibilities of player encountering a situation where a fire being lit would help or be necessary are when player discovers for example a fireplace without any firewood. In this case firewood needs to be in player inventory as well as an ignition source and a necessary accelerant or kindling misc. object. The second case is where player discovers a 'set fire' (firewood is in place already) and this does not require the player to have any firewood in inventory just an ignition source and a necessary accelerant or kindling misc. item. This option is set locally by the input...Int Property IsFirewoodReq = 0 Auto; does starting this fire require firewood 0-no 1-yesI did and you guys helped, the same thing with boiling the water as in the previous post. Int Property IsBoilingWater = 0 Auto; does starting this fire boil water 0-no 1-yes The issue I have now is that the script, when IsFirewoodReq = 1 does check for firewood, finds none but continues anyway - proceeding to next menu/options/lighting fire and ending.I've tried many different approaches and I am sure the solution is right in front of me but I can't see it.It is a long script but I want it to cover a few scenarios. The script compiles and saves but obviously not doing what I want.Thanks for your patience and help.Float Property TimeToPass Auto; time for timerInt Property IsBoilingWater = 0 Auto; does starting this fire boil water 0-no 1-yesInt Property IsFirewoodReq = 0 Auto; does starting this fire require firewood 0-no 1-yesGlobalVariable Property FlintUseCount AutoGlobalVariable Property FlintInUse AutoLight Property MyTorch AutoSound Property MySFX AutoMiscObject Property FWood AutoMiscObject Property Paper AutoMiscObject Property Oil AutoMiscObject Property EmptyBottle AutoMiscObject Property Rag AutoMiscObject Property Bristle AutoMiscObject Property Flint AutoMessage Property Need3Fwood AutoMessage Property FlintBroke AutoMessage Property EquipTorch AutoMessage Property CombustMenu AutoMessage Property NeedKindAcc AutoMessage Property NeedIgnite AutoMessage Property FlintOrTorch AutoMessage Property ReqItemsMsg AutoMessage Property NoReqIgniteItems AutoMessage Property WaterIsHeating AutoMessage Property WaterIsBoiling AutoObjectReference Property MyMarker AutoObjectReference Property ValveObj AutoAuto State WaitingEvent OnActivate(ObjectReference akActionRef)if (akActionRef == Game.GetPlayer())If (IsFirewoodReq == 1)NeedFirewood()EndifIf (Game.GetPlayer().GetItemCount(MyTorch) > 0) || (Game.GetPlayer().GetItemCount(Flint) > 0)MyIgnitesItem() ; If player has ignition source and firewood will go to "MyIgnitesItem()"ElseNoReqIgniteItems.Show(); no ignition sourceGoToState("Waiting")EndifEndifEndEventEndStateState BusyEvent OnActivate(ObjectReference akActionRef);Do nothing.EndEventEndState;---------------------------------------------------------------EVENT OnUpdateGameTime()UnRegisterForUpdateGameTime()ValveObj.Enable() ; enable valve after gametime waitingWaterIsBoiling.show()ENDEVENT;--------------------------------------------------------------Function MyIgnitesItem()GoToState("Busy")Int iButtonA = FlintOrTorch.Show()If iButtonA == 0If Game.GetPlayer().GetEquippedItemType(0) == 11MyCombustibleMenu() ; Goes to the choose combustion items MENU if TORCH is equipped "MyCombustibleMenu()"elseEquipTorch.Show(); If Torch is NOT EQUIPED, Player should "Equip the Torch" Message will showGoToState("Waiting"); After the Message Above will EXIT to be activated againEndIfEndIfIf iButtonA == 1If Game.GetPlayer().GetItemCount(Flint) > 0FlintInUse.SetValue(1); sets variable for Flint sfx to play IF lighting fire succeedsDebug.Notification ("Using Flint To Light Fire")MyCombustibleMenu() ; player chose flint and has flint so goes to combustible items menuEndIfEndIfEndFunction;------------------------------------------------------------------------------------------------------------Function MyCombustibleMenu()Int iButtonB = CombustMenu.Show()If iButtonB == 0Game.GetPlayer().RemoveItem(Rag, 1, TRUE)debug.notification("Rag Used As Kindling")LightFire() ; If this option is choose will go to "Function LightFire()"EndIfIf iButtonB == 1Game.GetPlayer().RemoveItem(Oil, 1, TRUE)Game.GetPlayer().AddItem(EmptyBottle, 1, TRUE)debug.notification("Paraffin used as accelerant")LightFire() ; If this option is choose will go to "Function LightFire()"EndIfIf iButtonB == 2Game.GetPlayer().RemoveItem(Bristle, 1, TRUE)debug.notification("Bristles Used As Kindling")LightFire() ; If this option is choose will go to "Function LightFire()"EndIfIf iButtonB == 3Game.GetPlayer().RemoveItem(Paper, 1, TRUE)debug.notification("Paper Used As Kindling")LightFire() ; If this option is choose will go to "Function LightFire()"EndIfif (Game.GetPlayer().GetItemCount(Rag) < 1) && (Game.GetPlayer().GetItemCount(Oil) < 1) &&(Game.GetPlayer().GetItemCount(Bristle) < 1) && (Game.GetPlayer().GetItemCount(Paper) < 1); add if fire is not litFlintInUse.SetValue(0); resets variable for Flint sfx to play because lighting fire was unsuccessfulNeedKindAcc.show()EndifGoToState("Waiting")EndFunction;--------------------------------------------------------------------------------------------------Function LightFire(); Light the fireIf FlintInUse.GetValue() == 1MySFX.Play(Self) ; if player chose flint then play flint ignition soundFlintInUse.SetValue(0); resets variable for future useFlintUseCount.Mod(1) ; counting how many times this piece of flint has been usedEndifIf FlintUseCount.GetValue() == 5Game.GetPlayer().RemoveItem(Flint, 1, TRUE)FlintBroke.Show(); flint used 5 times so breaksEndIfUtility.Wait(1.5); allow time for flintsfx to finishMyMarker.Disable(); actually show fire lightBoilWater()Self.disable()EndFunction;-------------------------------------------------------------------------------------------------------Function BoilWater()If (IsBoilingWater == 1)WaterIsHeating.show(); show msg water is heatingRegisterForSingleUpdateGameTime(TimeToPass) ; register for time to boilElseUnRegisterForUpdateGameTime()EndIfEndFunction;--------------------------------------------------------------------------------------------------------Function NeedFirewood()if (Game.GetPlayer().GetItemCount(FWood) >= 3); if player has at least 3 firewoodReturnElseif (Game.GetPlayer().GetItemCount(FWood) < 3); if player has less than 3 firewoodNeed3FWood.Show(); do thisEndifGoToState("Waiting")EndFunction In your OnActivate event in the Waiting state, you have an IF block that checks firewood and if there is not enough goes to a function to tell the player. But immediately after is another IF block that checks for ignition sources and if there is enough also assumes there is firewood and continues on. As the OnActivate event stands now as long as there is an ignition source the menu will start regardless of the firewood quantity. A solution is as follows: Add a bool variable with a default of true for the locations that do not need firewood and change its value as needed within the NeedFirewood function locations that do need firewood. Then check it for a true value along with the ignition source checks. Changes to code follow Bool HasWood = true ; true-firewood not required false-firewood required Auto State Waiting Event OnActivate(ObjectReference akActionRef) if (akActionRef == Game.GetPlayer()) If (IsFirewoodReq == 1) NeedFirewood() Endif If HasWood == True && (Game.GetPlayer().GetItemCount(MyTorch) > 0) || (Game.GetPlayer().GetItemCount(Flint) > 0) MyIgnitesItem() ; If player has ignition source and firewood will go to "MyIgnitesItem()" Else NoReqIgniteItems.Show(); no ignition source GoToState("Waiting") Endif Endif EndEvent EndState ;-------------------------------------------------------------------------------------------------------- Function NeedFirewood() if (Game.GetPlayer().GetItemCount(FWood) >= 3); if player has at least 3 firewood HasWood = True Return Elseif (Game.GetPlayer().GetItemCount(FWood) < 3); if player has less than 3 firewood HasWood = False Need3FWood.Show(); do this Endif GoToState("Waiting") EndFunction Link to comment Share on other sites More sharing options...
ReDragon2013 Posted November 1, 2019 Share Posted November 1, 2019 (edited) my solution as follow, no idea it is working for you.. I am a bit confused with enable() and disable() in your code and "RETURN" only finished the function or event where it is, not the caller antFirewoodMenuScript Scriptname antFirewoodMenuScript extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/8104613-registerforupdategametime-without-an-event/ GlobalVariable PROPERTY FlintUseCount auto GlobalVariable PROPERTY FlintInUse auto Light PROPERTY MyTorch auto Sound PROPERTY MySFX auto MiscObject PROPERTY FWood auto MiscObject PROPERTY Paper auto MiscObject PROPERTY Oil auto MiscObject PROPERTY EmptyBottle auto MiscObject PROPERTY Rag auto MiscObject PROPERTY Bristle auto MiscObject PROPERTY Flint auto Message PROPERTY Need3Fwood auto Message PROPERTY FlintBroke auto Message PROPERTY EquipTorch auto Message PROPERTY CombustMenu auto Message PROPERTY NeedKindAcc auto Message PROPERTY NeedIgnite auto Message PROPERTY FlintOrTorch auto Message PROPERTY ReqItemsMsg auto Message PROPERTY NoReqIgniteItems auto Message PROPERTY WaterIsHeating auto Message PROPERTY WaterIsBoiling auto ObjectReference PROPERTY MyMarker auto ObjectReference PROPERTY ValveObj auto Float PROPERTY TimeToPass auto ; [default=0.0] wattime for timer Int PROPERTY IsFirewoodReq auto ; = 0, does starting this, fire requires firewood [0-no 1-yes] {set to 1 when firewood is required} Int PROPERTY IsBoilingWater auto ; = 0, does starting this, fire boils water [0-no, 1-yes, 2-waitForReset] ; -- EVENTs -- 3 + "Busy" EVENT OnReset() IF (IsBoilingWater == 2) IsBoilingWater = 0 ; reset all for next heating MyMarker.Enable() self.Enable() ENDIF ENDEVENT EVENT OnUpdateGameTime() UnRegisterForUpdateGameTime() ; just in case IF (IsBoilingWater == 1) IsBoilingWater = 2 ValveObj.Enable() ; enable valve after gametime waiting WaterIsBoiling.show() ENDIF ENDEVENT EVENT OnActivate(ObjectReference akActionRef) IF (akActionRef == Game.GetPlayer() as ObjectReference) ELSE RETURN ; - STOP - not player activated, end this event immediately ENDIF ;--------------------- from here akActionRef is the player IF (IsBoilingWater == 1) WaterIsHeating.show() RETURN ; - STOP - water is still heating ENDIF ;--------------------- IF (IsFirewoodReq == 1) IF (akActionRef.GetItemCount(FWood) >= 3) ; player has at least 3x firewoods, all fine! ELSE Need3FWood.show() RETURN ; - STOP - player has less than three firewood items ENDIF ENDIF IF (akActionRef.GetItemCount(MyTorch) > 0) || (akActionRef.GetItemCount(Flint) > 0) ; player has source for ignition (and firewood if required) gotoState("Busy") ; ### STATE ### MyIgnitesItem(akActionRef as Actor) gotoState("") ; ### STATE ### ELSE NoReqIgniteItems.show() ENDIF ENDEVENT ;================================= State Busy ; do not track activation ;========= EVENT OnActivate(ObjectReference akActionRef) ENDEVENT ;======= endState ; -- FUNCTIONs -- 3 ;----------------------------------- FUNCTION MyIgnitesItem(Actor player) ;----------------------------------- int i = FlintOrTorch.show() IF (i == 0) IF (player.GetEquippedItemType(0) == 11) ; Torch check MyCombustibleMenu(1, player) ELSE EquipTorch.show() ; If Torch is NOT EQUIPED, Player should "Equip the Torch" Message will show ENDIF ELSE ;IF (i == 1) IF (player.GetItemCount(Flint) > 0) ; Flint check FlintInUse.setValue(1) ;*1* sets globalvariable for Flint sfx to play, IF lighting fire succeeds MyCombustibleMenu(2, player) ENDIF ENDIF ENDFUNCTION ;---------------------------------------------- FUNCTION MyCombustibleMenu(Int n, Actor player) ;---------------------------------------------- ; n = 1 -> Torch ; n = 2 -> Flint Debug.Notification ("Using Flint To Light Fire") bool bOK = False int i = CombustMenu.show() IF (i == 0) bOK = (player.GetItemCount(Rag) > 0) IF ( bOK ) player.RemoveItem(Rag, 1, TRUE) Debug.Notification("Rag Used As Kindling") ENDIF ELSEIF (i == 1) bOK = (player.GetItemCount(Oil) > 0) IF ( bOK ) player.RemoveItem(Oil, 1, TRUE) player.AddItem(EmptyBottle, 1, TRUE) Debug.Notification("Paraffin used as accelerant") ENDIF ELSEIF (i == 2) bOK = (player.GetItemCount(Bristle) > 0) IF ( bOK ) player.RemoveItem(Bristle, 1, TRUE) Debug.Notification("Bristles Used As Kindling") ENDIF ELSEIF (i == 3) bOK = (player.GetItemCount(Paper) > 0) IF ( bOK ) player.RemoveItem(Paper, 1, TRUE) Debug.Notification("Paper Used As Kindling") ENDIF ENDIF ; ------------ IF ( bOK ) LightFire() Utility.Wait(1.5) ; allow time for flintsfx to finish MyMarker.Disable() ; actually show fire light self.Disable() IsBoilingWater = 1 ; set TRUE RegisterForSingleUpdateGameTime(TimeToPass) ; register for time to boil ; ------------ ELSE ; fire is not lit FlintInUse.setValue(0) ;*0* resets variable for Flint sfx to play because lighting fire was unsuccessful NeedKindAcc.show() ENDIF ENDFUNCTION ;------------------- FUNCTION LightFire() ;------------------- IF (FlintInUse.GetValue() == 1) MySFX.Play(self) ; if player chose flint then play flint ignition sound FlintInUse.SetValue(0) ;*0* resets variable for future use FlintUseCount.Mod(1) ; counting how many times this piece of flint has been used ENDIF IF (FlintUseCount.GetValue() == 5) Game.GetPlayer().RemoveItem(Flint, 1, TRUE) FlintBroke.show() ; flint has been used for 5 times, so let them breaking FlintUseCount.setValue(0) ENDIF ENDFUNCTION Edited November 1, 2019 by ReDragon2013 Link to comment Share on other sites More sharing options...
antstubell Posted November 4, 2019 Author Share Posted November 4, 2019 Thank you both. I just copied and pasted what you posted, I don't have time to go in-depth of what I did wrong, on my head be it. I will study it when I have time.Oh yeah - works. Link to comment Share on other sites More sharing options...
Recommended Posts