Maskar Posted August 8, 2010 Share Posted August 8, 2010 Considering Let is the OBSE version of Set, I was wondering which command is better when using basic statements. For instance: Set i to 1 Let i := 1 I noticed using Let, mod size increases slightly over using the Set command, but haven't discovered any real performance differences. The question is however, is the Set command faster/better in certain circumstances, or is it best to just always use Let? Thanks. Link to comment Share on other sites More sharing options...
Argomirr Posted August 8, 2010 Share Posted August 8, 2010 There's probably a difference, but it's so incredibly tiny that it doesn't really matter which one you use; it will never produce a noticeable difference anyway. Link to comment Share on other sites More sharing options...
Maskar Posted August 8, 2010 Author Share Posted August 8, 2010 I did some further testing, creating a while loop running 100k times, with a number of Set or Let commands and an fQuestDelayTime of 0.01. Although a rather extreme test the Let command dropped FPS a considerable amount more (about 5-10 times i'm guessing). Considering that the Set command takes a few bytes less to store each time it's used and is faster, it's probably best to use the Set command where possible, even though you indeed probably will not see a difference in reallife situations. Link to comment Share on other sites More sharing options...
Tefnacht Posted October 18, 2010 Share Posted October 18, 2010 Whoever programmed the search engine for this bulletin board needs a severe beating with the NERF-bat. I was searching for: “Let vs Set”. ERROR, ERROR! One or more keywords were below 3 characters... bla, bla, bla. Damnit, I put quotation marks around the search term for a reason! I didn't ask you to search for “Let” OR “vs” OR “Set”. I asked you to search for “Let vs Set”. As one term. Bha! Useless! Anyway ... now that I finally found this thread, back to the topic: --- Personally I usually only use the “Let” command. “Let” is so much more powerful than “Set”. Not only does “Let” support arrays and strings, it also supports many more operators than “Set”. “Let” is superior to “Set” in almost any way. It is true that a compiled script using “Let” will sometimes be bigger than the same script using “Set”. “Let foo := 1” results in a longer compiled bytecode than “Set foo To 1”. BUT “Let foo += 1” results in a shorter bytecode than “Set foo To foo + 1”. AND “Let MyQuest.foo += 1” results in a much shorter bytecode than “Set MyQuest.foo To MyQuest.foo + 1”. In the end, “Let” wins. “Set” should be used only to assign a value to a variable. “Set foo To bar” is better than “Let foo := bar”. If you do math, “Let” is almost always the better choice.Because “Let” is so much more powerful than “Set”, it is of course also a little slower if you benchmark it against “Set”. But if your script causes the game to slow down, it is not because you used “Let” instead of “Set”, it is because your script is crap. :) --- However, there is one big difference between “Let” and “Set” that recently caused me quite a headache. If the “Set” command is used to assign a value to a script variable on a persistent remote reference, the script on that reference will be forced into high processing, no matter if the scripted object is in the players cell or not. The script will be executed once during the next frame, and then go back to “sleep”.This is called “heart-beating” a remote reference.The script on this object can in turn write a value to one of its own local variables, thus causing itself to run again during the next frame. It is “heart-beating” itself. This way a script on a remote persistent reference can keep itself running, even if it is in a different cell than the player. But! This only works with the “Set” command. Writing a value to a persistent remote reference with the “Let” command does NOT cause a heartbeat. The value will be written, but the remote script will NOT be executed during the next frame. “Let” does not cause heartbeats, only “Set” does. Many people probably have no idea what I am talking about ... let's just say “Set” is much more aggressive than “Let”. Link to comment Share on other sites More sharing options...
Recommended Posts