PDA

View Full Version : Lscript support functions external to main?



TripD
08-02-2010, 09:22 PM
Hi again. So I am working on another script.... I love the pain I guess :).

Anyway, looking at my code, I think it would be better if this bit of code/calculations was external to the main. I can't recall if lscript supports external functions or no? It would be nice for simplifying what I'm working on.

Dodgy
08-03-2010, 12:22 AM
You can use @insert to write a kind of Library for your lscripts. Have a look here for my docs on lscript.

http://www.mikegreen.name/Lscript/Lscript%20Index.html

Look under Pragmas.

TripD
08-03-2010, 06:43 PM
Thanks for the quick reply! I looked there, but was looking for functions :)

Anyway, so it appears I need no variable list to pass for this to work. I assume then I just need to work as though it will be parsed into the lscript, even if it isn't?

evenflcw
08-03-2010, 07:14 PM
Yes. You makebelieve it's inserted at the line you put the insert pragma. There are some gotchas. Like not inserting too many files. Always have an empty line at end of file. Defines/Enums sometimes work sometimes not. Some say declare global variables in all files. The debugger will be offset by a few lines and have trouble picking the right file. Etc. But if you prefer refactoring into functions and separating concerns into different files it's worth it. Obviously it's also good to build reusable libraries.

I would advice you to search the lscript forums for more tips on insert or libraries. You can even compile an lscript library and use it with a non-compiled script, which is quite cool.

TripD
08-03-2010, 08:04 PM
Quite cool... thanx all! I am attempting yet again to create the Dragon Fractal. I think I've finally wrapped my mind around the problem now. Just need to get lighwave to believe me. :D

evenflcw
08-03-2010, 08:12 PM
"Dragon Fractal". Snazzy!

jameswillmott
08-03-2010, 08:26 PM
Quite cool... thanx all! I am attempting yet again to create the Dragon Fractal. I think I've finally wrapped my mind around the problem now. Just need to get lighwave to believe me. :D

If you use recursion to do it be aware that the stack can fill up pretty quickly, I found that was an issue with QuadPanels.

Matt
08-04-2010, 02:34 AM
If you use recursion to do it be aware that the stack can fill up pretty quickly, I found that was an issue with QuadPanels.

What's the stack limit? And how do you get around it in LScript?

TripD
08-05-2010, 02:13 AM
well.... I finally got a working version. Nothing fancey.... but there is brain matter all over the place! :eek: Oh my do i have bad coding habits.

tried it at level 14, got a touch of pause. ~65k polys.

I'm wondering if I should bother prettying up the corners so they don't share the same space. Ended up just plopping it all in the same file, once I realised that I wasn't a million miles from finishing.

Let me know what you think.

TripD
08-09-2010, 05:01 PM
Well, I went ahead and rounded the corners so that the script creates a single path throughout the process.

oh.... now you can select one poly at the start and hit shift 'right bracket' and walk through the whole thing.

On to other things.

TripD
08-28-2010, 04:34 PM
It dawned on me that if you created an image from a given output of this script you could make an infinitely intricate version just by rotating copies of the output at the last point (if that makes any sense) just using clip maps and multiple poly planes.