[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: New to lua... few questions
- From: Asko Kauppi <askok@...>
- Date: Tue, 31 Oct 2006 21:13:49 +0200
Your message may well be left with only a few -if any- replies, due
to too scarce details, and lazy use of language. You are a native
English writer and addressing thousands of people, don't you think
you should brush up? :)
Now, to the point (below).
Kevin Vandenborne kirjoitti 31.10.2006 kello 19.50:
Hello all, for an application i'm writting i want to use lua as the
script language.
I want to be able to load and unload scripts. lets say i have a
window form with a editbox and the user can type SCRIPTLOAD
<scriptName> and SCRIPTEND <scriptName> and have multieple scripts
running at once. Would this be possible? anyone have a example howto?
What exactly do you mean by "multiple scripts running at once"? You
can use either multiple lua_States (and OS-level threading) or Lua's
coroutine approach, which shares a state and is kind of like old non-
preemptive multitasking. The reference manual tells the details of
the latter.
Ask first, should the multiple scripts have how much to do with each
other. If none, use separate states. If they do, you need to make a
choice. The whole problem area remains fuzzy to me from your
description. Sorry. :)
Normally, people don't "unload" scripts. It's easy to start with a
completely clean lua_State if needed. Why exactly would you unload,
and what exactly do you mean by it?
Second question what does happen if ya reload a script? Does it
update the functions if its allready in the memmory? I really only
have experience with PHP. and in PHP it would prompt a error if the
function allready exists.
Functions are just names in Lua. Of the little I know it, I place
PHP closer to C and not as a real real scripting language. Avoid
making too much parallels between the two.
print(print) -> function
print=1
print(print) -> will fail, since 'print' is now 1 and you cannot call 1
Functions are there, but they are not bound with a fixed name. In a
way, all functions in Lua are anonymous.
Welcome to the world of Lua; I wish you get the help and notice the
language serving you tremendously. :)
-asko
I'm using c# with Tao.Lua to get full access to the API
Regards...