Jump to content

Short Scripting Question: If-Else Evaluations


Xaranth

Recommended Posts

All right, I've learned not to take ANYTHING for granted with this atrocious mockery of a programming language.

 

Basically, I want to know if comparisons work like every other language on earth.

 

Assuming rDummy is disabled:

 

if rDummy.getDisabled
DoStuff
endIf

 

and:

 

if (rDummy.getDisabled == 1)
DoStuff
endIf

 

are the exact same thing, right?

Link to comment
Share on other sites

0 = null/false

 

1 = 1/true

 

Yes, but the lack of a real Boolean type had me mistrusting it. Also a number of other things that I would expect in any language simply aren't here in FNVScript.

 

And the script in question wasn't working either way. >.> Got it sorted though.

 

-X

Link to comment
Share on other sites

0 = null/false

 

1 = 1/true

 

Yes, but the lack of a real Boolean type had me mistrusting it. Also a number of other things that I would expect in any language simply aren't here in FNVScript.

 

And the script in question wasn't working either way. >.> Got it sorted though.

 

-X

 

can i see the script.

Link to comment
Share on other sites

can i see the script.

 

No need. The issue was that I forgot that I needed reset my time float in the GameMode bock. Dumb*** mistake.

 

...Actually, I could tighten it up some more by eliminating the time variable completely. It's not used for anything but a comparison anyway...

 

But for your edification, here's the final, WORKING script.

 

scn DARC02scptGHLtDayNt

ref rLtParent ;Diabled == Day, Enabled == Night

begin onLoad

Set rLtParent to GetLinkedRef	

if ((GetCurrentTime > 5) && (GetCurrentTime <= 19))
	if rLtParent.GetDisabled == 0
		rLtParent.Disable
	endif
else 
	if rLtParent.GetDisabled
		rLtParent.Enable
	endif
endif

end

begin GameMode

if ((GetCurrentTime > 5) && (GetCurrentTime <= 19))
	if rLtParent.GetDisabled == 0
		rLtParent.Disable
	endif
else 
	if rLtParent.GetDisabled
		rLtParent.Enable
	endif
endif

end

Edited by Xaranth
Link to comment
Share on other sites

The begin OnLoad i think is redundant seeing as you have the Begin Gamemode does the same thing but in each frame.

 



begin GameMode

Set rLtParent to GetLinkedRef 

       if (GetCurrentTime > 5 && GetCurrentTime <= 19)
               if rLtParent.GetDisabled == 0
                       rLtParent.Disable
               endif
       else 
               if rLtParent.GetDisabled
                       rLtParent.Enable
               endif
       endif

end

 

 

This should be more then enough.

Edited by Capt Mitch
Link to comment
Share on other sites

The begin OnLoad i think is redundant seeing as you have the Begin Gamemode does the same thing but in each frame.

 

This should be more then enough.

 

Actually, it is. But given that I'm resource mad to the point of being truly irritating, I'll tweak it this way:

 

scn DARC02scptGHLtDayNt

ref rLtParent ;Diabled == Day, Enabled == Night

begin onLoad

       Set rLtParent to GetLinkedRef   

end

begin GameMode

       if ((GetCurrentTime > 5) && (GetCurrentTime <= 19))
               if rLtParent.GetDisabled == 0
                       rLtParent.Disable
               endif
       else 
               if rLtParent.GetDisabled
                       rLtParent.Enable
               endif
       endif

end

 

Saves a memory IOp every frame.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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