Zorkaz Posted March 18, 2020 Share Posted March 18, 2020 The setup:Codsworth takes care of prewar sanctuary but runs out of fuel (Dies). When you put fuel in a container(Handybox) he starts working again. The script, which runs on an xmarker Event onload()While self.isenabled()Random = utility.randomint(1,300)Utility.wait(12)if random >1 If DS03HandyBox.GetItemCount(DS03Fuel) >0 DS03HandyBox.RemoveItem(DS03Fuel, 1)DS03Codsworth.Resurrect()EndifElseif random ==1 If DS03HandyBox.GetItemCount(DS03Fuel) >0 DS03HandyBox.RemoveItem(DS03Fuel, 1)DS03Codsworth.Resurrect()Elseif DS03HandyBox.GetItemCount(DS03Fuel) == 0DS03Codsworth.killsilent()endifendifEndwhileEndevent It's the last script piece of 40, would be nice if anyone had a hint where I went wrong. Link to comment Share on other sites More sharing options...
SKKmods Posted March 18, 2020 Share Posted March 18, 2020 The ElseIf logic does not hold as the zero fuel condition will never trigger. Imagine an If evaluation tree is only passed through once and as soon as a match is found processing stops. Your first 2 random number evaluations will always trigger as the cover all of the number cases, so the third no fuel case will never be picked. Try this (which shows your random number thing isn't actually doing anything); If (DS03HandyBox.GetItemCount(DS03Fuel) == 0) ; random number does not matter, there is no fuel DS03Codsworth.killsilent() ElseIf (random == 1) ; we know there is fuel as it passed the first test DS03HandyBox.RemoveItem(DS03Fuel, 1) DS03Codsworth.Resurrect() ;is the actor actually dead here, or does that need a test ? Else ; we know it has fuel and the random number must be more than one DS03HandyBox.RemoveItem(DS03Fuel, 1) ; this case looks the same as = 1, but whatever the designer wants. DS03Codsworth.Resurrect() EndIf Link to comment Share on other sites More sharing options...
Zorkaz Posted March 18, 2020 Author Share Posted March 18, 2020 Makes more sense, thanks Link to comment Share on other sites More sharing options...
Recommended Posts