Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ideas - What are your opinions?
#5
(02-22-2012, 02:03 PM)Qwertygiy Wrote:
(02-22-2012, 04:24 AM)Jacob_ Wrote: [*]No more script objects. Instead, all scripting is done through events (like the current events menu that you get when you right click something.) The only way to run event scripts is to test the game, but they will be checked for syntax errors as you type.

I like the checking for syntax errors part a lot; however, making them only use events would make having indefinitely looping scripts slightly more difficult.

Infinite loops are almost always bad design anyway, so I'll probably make "while true do" a syntax error. In java, a while loop with a sleep() in it causes a compiler warning.

sleep() will be also be done away with, since it causes more bugs than it's worth. To replace sleeping and using infinite loops, I'll add something like the setTimeout() function in JavaScript, so you could do this:

[lua]function doSomething()
print("something")
setTimeout(doSomething, 0.5) --call the function again after 5 seconds
end
doSomething()
[/lua]
All of that code would go in the game.Started event that will be added.

You could also do this put this in a Clicked event limit the firing rate of weapons: (object will be the object that the event goes with, to replace "script")
[lua]
if not object.Enabled.Value then return end
--...
object.Enabled.Value = false
setTimeout(function() object.Enabled.Value = true end, 5)
[/lua]
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)