How do I get scripts to loop?

All about writing scripts for Celestia in Lua and the .cel system
Topic author
Size_Mick
Posts: 60
Joined: 18.06.2002
With us: 22 years 5 months
Location: United States
Contact:

How do I get scripts to loop?

Post #1by Size_Mick » 30.08.2004, 17:02

I'd like an explanation for both types, if possible.

I searched the forums before asking, and didn't find a satisfactory answer. Is it not possible?

What'd be really boffo is just knowing how to call a script at the end of another, and chain them together, then loop the whole thing again by having the last one call the first one.

Harry
Posts: 559
Joined: 05.09.2003
With us: 21 years 2 months
Location: Germany

Re: How do I get scripts to loop?

Post #2by Harry » 30.08.2004, 18:36

Size_Mick wrote:I'd like an explanation for both types, if possible.

For CEL: not at all (but see below)
For CELX:

Code: Select all

while true do
... script ...
end


Looping a CEL-script embedded in a CELX-script (not testest, just to give you the idea):

Code: Select all

while true do
  celscript = celestia:createcelscript( [[
   ... CEL-script ...
  ]] )
  while celscript:tick() do end
end


What'd be really boffo is just knowing how to call a script at the end of another, and chain them together, then loop the whole thing again by having the last one call the first one.

You can try using "dofile" in CELX, but it's probably better to combine both scripts in one, and then loop that.

Harald

L2Cache
Posts: 25
Joined: 19.01.2004
With us: 20 years 10 months

Post #3by L2Cache » 05.01.2005, 01:31

I've tested this, and it works. Just had to add the wait command.

Code: Select all

while true do
  celscript = celestia:createcelscript( [[
   ... CEL-script ...
  ]] )
  while celscript:tick() do
      wait(0)
    end
  end

L2Cache
Posts: 25
Joined: 19.01.2004
With us: 20 years 10 months

Post #4by L2Cache » 05.01.2005, 01:34

I've tested this, and it works. Just had to add the wait command.

Code: Select all

while true do
  celscript = celestia:createcelscript( [[
   ... CEL-script ...
  ]] )
  while celscript:tick() do
      wait(0)
    end
  end


Return to “Scripting”