morogoth35 Posted October 9, 2017 Share Posted October 9, 2017 (edited) Hi guys I have been wondering for a while now what if I wanted a script to check for something if its true and if it is do something else do nothing. So for example this is how I would imagine it being: Event OnActivate(ObjectReference akActionref) If (akActionref == Game.GetPlayer()) Debug.MessageBox("The player activated the activator.") Else ; do nothing? EndIf EndEvent Can I leave it blank or do I need to type something in there? Edited October 9, 2017 by morogoth35 Link to comment Share on other sites More sharing options...
PeterMartyr Posted October 9, 2017 Share Posted October 9, 2017 it all depends on the statement Link to comment Share on other sites More sharing options...
PeterMartyr Posted October 9, 2017 Share Posted October 9, 2017 Event OnActivate(ObjectReference akActionref) If (!akActionref == Game.GetPlayer()) ; do nothing? Else Debug.MessageBox("The player activated the activator.") EndIf EndEvent Link to comment Share on other sites More sharing options...
PeterMartyr Posted October 9, 2017 Share Posted October 9, 2017 Event OnActivate(ObjectReference akActionref) If (akActionref != Game.GetPlayer()) ; do nothing? Else Debug.MessageBox("The player activated the activator.") EndIf EndEvent Link to comment Share on other sites More sharing options...
PeterMartyr Posted October 9, 2017 Share Posted October 9, 2017 Should I continue? I can think more. Nada Event OnActivate(ObjectReference akActionref) If (akActionref != Game.GetPlayer()) return EndIf Debug.MessageBox("The player activated the activator.") EndEvent No more I quit Link to comment Share on other sites More sharing options...
PeterMartyr Posted October 9, 2017 Share Posted October 9, 2017 Serious, it really depends of the entire script, and what your trying to achieve with it, but no you don't need to use ; comment Event OnActivate(ObjectReference akActionref) If (akActionref == Game.GetPlayer()) Debug.MessageBox("The player activated the activator.") Else ; do nothing? EndIf EndEvent Event OnActivate(ObjectReference akActionref) If (akActionref == Game.GetPlayer()) Debug.MessageBox("The player activated the activator.") EndIf EndEvent they are exactly the same. Do the same thing Link to comment Share on other sites More sharing options...
foamyesque Posted October 9, 2017 Share Posted October 9, 2017 (edited) I often write code of this structure: int iSlot = Array.Find(SearchObject) if iSlot < 0 else ;stuff endifIt's equivalent to testing for >=, but I -- and this is a personal preference -- find it easier to parse and to extend. The important point is: if you have no lines of code, the compiler won't care and the script will in fact do nothing. Edited October 9, 2017 by foamyesque Link to comment Share on other sites More sharing options...
Kapteyn Posted October 9, 2017 Share Posted October 9, 2017 Also, the compiler ignores comments - you can have a million lines of comments but it will not be parsed. Link to comment Share on other sites More sharing options...
Recommended Posts