Project: Cplua
#681
Posted 13 September 2006 - 06:37 PM
The biggest difference is that with CPLua each Lua file has its own environment. You cannot share variables between files as easily as with the standard version. If a file A uses a file B, then B may explicitely export some variables to A (so A can use it), but they are completely isolated by default.
There are a lot of changes in the available packages and libraries too. The functions that are available in CPLua are listed in the file "functions.lua" in the ZIP file. You also have access to the standard packages "math", "string", "table", "coroutine" and "debug", with sometimes some differences
The future documentation should explain all of this in detail (but I really need more tiiiiiiiiime to do it )
#682
Posted 14 September 2006 - 03:09 PM
Several small bugs have been fixed.
And there is now a lot more memory available for Lua programs!
Also please don't forget to consider my suggestion about the require() function on the previous page
#683
Posted 14 September 2006 - 09:57 PM
try this code:
require("draw") pic=pict.new(160,240) for i=1,1000 do pic=pict.capture("screen") end --insufficient memory to run!another bug happend by using "math.floor()"
some code like this:
a=3 b=10 c=.3 d=math.floor((a-b)/c) --exception happend ! d=math.floor(math.abs(a-b)/c) --that is O.K !
and please explain me a little about garbage collecting mechanism in CPLua.thanks.
#684
Posted 16 September 2006 - 02:24 AM
When I use this code:
print(type(5e0.5))
lua displays: syntax Error:
')' expected near '.5'
Why?
And this other
e="one string"
b=string.gsub(a,"one","another")
print(a)
print(B)
Lua displays: Runtime error
main: 2 attempt to index global 'string'(a nil value)
As you know Im using The "Programing in Lua" book
#685
Posted 16 September 2006 - 02:55 AM
And this other
e="one string"
b=string.gsub(a,"one","another")
print(a)
print(
Lua displays: Runtime error
main: 2 attempt to index global 'string'(a nil value)
see my half-completed lua tutorial. the dot is used for indexing tables.. you need to call the package string before using any of his functions. type: require("string") at the code beginning. read CPLua examples included on the release, to overview that i mean.
Hi
When I use this code:
print(type(5e0.5))
lua displays: syntax Error:
')' expected near '.5'
Why?
Man, your'e wrong . this is scientific notation (exp on ordinary calcs). the powers are integers. if you need to use EXPONENTIALS use math.exp() function (y=e^x). be care with your maths, it can damage your prog seriously
orwell, really there is a bug with math.floor, i have one some ago . Thanks for 0.9C
#686
Posted 16 September 2006 - 08:42 AM
Wow Nice catch.Orwell i think there is a bug with "pict.capture()" . there is a memory leak!
try this code:require("draw") pic=pict.new(160,240) for i=1,1000 do pic=pict.capture("screen") end --insufficient memory to run!
That's strange, first there shouldn't be any leak and second it shouldn't cause a crash... I'll investigate
That's strange too...another bug happend by using "math.floor()"
In brief:and please explain me a little about garbage collecting mechanism in CPLua.thanks.
Data's (tables, functions, strings, userdata, and threads) are kept in the memory as long as you can access it. While there is somewhere a reference to those data, they won't be deleted.
But if there is no reference to it anymore, the data is marked as "deletable", which means that it will be automatically deleted during the next garbage collection cycle. You don't have to worry about memory usage: data's are automatically deleted when you no longer use it.
An easy example is ...
a = {...} -- create a (big) table, referenced by "a" collectgarbage() -- call the GC print(a, gcinfo()) -- the table is still there b = a -- let "b" reference the same table as "a" a = nil -- now lose the reference "a" to the table collectgarbage() -- call the GC again print(b, gcinfo()) -- and the table is still there, because "b" still points to it b = nil -- now lose the second reference collectgarbage() -- call the GC once again print(gcinfo()) -- now you can see that the table has been deleted, because you had lost all access to it.The GC is perodically called while the interpreter is running, so (except for very large scripts) you shouldn't worry too much about that
#687
Posted 16 September 2006 - 10:22 AM
#688
Posted 16 September 2006 - 09:29 PM
#689
Posted 17 September 2006 - 09:07 AM
#690
Posted 17 September 2006 - 01:49 PM
#691
Posted 19 September 2006 - 12:23 AM
when i was running CPLua the example 2 of ui examples, my classpad crashed and fatal error was displayed in the screen the same problem ocurred in the emulator of CPLua 0.9 C
could you tell me when should i use ":" to dots in CPLua??
#692
Posted 19 September 2006 - 03:42 AM
Orwell, 0.9c is really slower than before!
#693
Posted 20 September 2006 - 11:17 AM
require("draw") fullscreen(1) showgraph() draw.onbuffer() for r=150,0,-2 do draw.circle(80,114,r,3) draw.update() end
Run this code on CPLua 0.8 and CPLua 0.9c and compare....
And i found a bug when writing images to memory:
require("draw","io") f=io.file("test") p=pict.load("pict1") f:create("data","Test") f:open('w') f:write(p) f:close() f:open('r') p2=f:read(1) f:close() showgraph() draw.pict(0,0,p2) waitkey()
This bug doesn't occur when you write p=pict.copy(pict.load("pict1")) instead of p=pict.load("pict1")
And when you create a line edit using ui.lineedit, it's not editable, even if you put edit=true...
I'm programming some Worms game, but I can use neither CPLua 0.8 (memory) nor CPLua 0.9c (drawing functions too slow...)
#694
Posted 21 September 2006 - 01:13 AM
thaaanks
PS: Please.. read the last posts before ask!.. i said:
Vanhoa and Fabri repeated the quote without quoting. Orwell would piss off our complaints . Be patient people, big things will come with luaOrwell... Exeption Error with 0.9C and some examples of the UI. :. The 0.9b3 that you sent me doesn't have these problems. See ya
#695
Posted 21 September 2006 - 07:45 AM
ThanksPeople.. let Orwell to breath a bit .
Don't worry guys, I don't forget these problems and I'm still working on CPLua
Actually I'm currenty rewriting the whole interface (with the editor etc), and I need a little more time... But it will be a lot more flexible than before (for example, the editor will also be able to open a bitmap editor or a help browser without problem ).
#696
Posted 21 September 2006 - 09:44 AM
#697
Posted 21 September 2006 - 11:32 PM
#698
Posted 22 September 2006 - 07:22 AM
#699
Posted 23 September 2006 - 05:35 PM
#700
Posted 23 September 2006 - 06:40 PM
Unfortunately there are a lot chances that OS 3.0 will be a little bigger than OS 2.20, therefore there will be less RAM memory available for CPLua in the future. But don't worry, I think you should have at least 500 Kb of available RAM even with OS 3.0 (in the worst case).
Although 500 Kb is not as huge as the current 1212 Kb, I think it's still comfortable. Please try to allocate memory in a reasonable way (do not allocate several hundreds of Kb memory if there is just a "chance" that the user makes use of it: do it only if he really needs it.) Sparse tables may help too.
PS: I hope that CPLua 0.9D will be ready in a couple of days
#701
Posted 23 September 2006 - 09:05 PM
Ahem... This is true with the current OS version (2.20).
Unfortunately there are a lot chances that OS 3.0 will be a little bigger than OS 2.20, therefore there will be less RAM memory available for CPLua in the future
I know Orwell, you said me... .btw, i will buy a CP300+ with O.$ 3.0 ($$$$$$$$$$$$$$$).. then i will never update my old CP to O$ 3.0 .. then, i'll have the whole piece of cake in my old calc!,
PS: I will write some no the tutorial in some hours, i forgot the tut
#702
Posted 28 September 2006 - 11:12 AM
CPLua 0.9D is ready
At first sight there aren't many new features in this version.
The update 0.9C -> 0.9D has been an heavy refactoring step, making CPLua a lot more flexible and extensible than the previous versions. CPLua now uses a system of plugins, and it is very easy to create some new plugins and make it interact with CPLua's environment (managing windows etc) and the other plugings.
For example, the text editor and the Lua interpreter inside CPLua are simple plugins loaded in the environment. One could imagine sereval new things, like a picture editor, a project manager, a help browser, a "MyPrograms"-like menu, ...
As CPLua's source code should be available soon, different programmers will get able to create these kind of new plugins and extend the functionalities of CPLua
I had to rewrite a lot of things, thus perhaps some minor bugs that I fixed before reappeared in this version. If you see something weird, don't forget to report it here
The biggest visible change concerns CPLua's main menu. I wanted to reorganise it too (and make it accept any number of commands), thus here is what you will now see when starting CPLua:
According to the suggestion I made recently about the default folders, the functions require, dispose, doscript, io.file, pict.save and pict.load have been modified to use the folder of the calling script as default folder. These last 3 functions were also taking 2 arguments for the path (one for the folder name and another for the file name); they now take only one argument with the complete path.
I added a small menu to the Console window too with some useful things
The bug in pict.capture() has been fixed (thanks for having reported it), and you can now specify a region of the screen to capture (it doesn't have to be the whole screen anymore)
There are several small things I'd like to add before CPLua 0.9RC1, but this version is very close to what the final CPLua 0.9 will be.
Have fun
#703
Posted 28 September 2006 - 11:17 AM
#704
Posted 28 September 2006 - 11:33 AM
#705
Posted 28 September 2006 - 04:37 PM
#706
Posted 29 September 2006 - 08:47 AM
#707
Posted 29 September 2006 - 09:32 AM
The new interface is not very appealing, but "Recent Files" is really useful. Unfortunately, LNAtest needs 27 sec (instead of 25 sec in version 0.8), but it seems that larger computation times is the payoff for bigger memory. I'm going to test version 0.9D thoroughly in the next few days, since I will change several things in the upcoming LNA 1.70.New update!
CPLua 0.9D is ready
#708
Posted 29 September 2006 - 11:48 AM
I must say I don't have any skills in graphical design, thus if anyone has a better project for the "Start" page just let me knowThe new interface is not very appealing
It is more convenient however, you don't have to close all files to see the main menu like in the previous versions
#709
Posted 29 September 2006 - 03:59 PM
CPLua now uses a system of plugins, and it is very easy to create some new plugins and make it interact with CPLua's environment (managing windows etc) and the other plugings.
For example, the text editor and the Lua interpreter inside CPLua are simple plugins loaded in the environment. One could imagine sereval new things, like a picture editor, a project manager, a help browser, a "MyPrograms"-like menu, ...
As CPLua's source code should be available soon, different programmers will get able to create these kind of new plugins and extend the functionalities of CPLua
Yay! Let's make some MyLuaPrograms menu and font maker.
The new interface is not very appealing
I find it rather nice although it can be ameliorated.
I'm going to test it right now.
EDIT:
Hehe, I like the console menu That's exactly what I needed. But on the other hand the draw function are still slower than before. And I found a small bug. You told that require("script") was searching first for a Lua script in the current folder, and then in main folder. But I have a "font" script in main, and when I call require("font") in a file in another folder, it raises an error. This doesn't happen when I write require("main/font") |
#710
Posted 30 September 2006 - 01:25 AM
But on the other hand the draw function are still slower than before
Wait for the ASM coded one.. It would be a lot faster
#711
Posted 30 September 2006 - 03:08 AM
#712
Posted 30 September 2006 - 03:15 AM
#713
Posted 30 September 2006 - 07:34 AM
Well it was an idea indeed, but actually this is not the way I implemented it The main folder will only be used if the calling script has no folder (e.g. for new scripts). I'm not really sure what to do. I think it could be confusing to have 2 default folders instead of 1You told that require("script") was searching first for a Lua script in the current folder, and then in main folder. But I have a "font" script in main, and when I call require("font") in a file in another folder, it raises an error. This doesn't happen when I write require("main/font")
#714
Posted 02 October 2006 - 10:19 AM
#715
Posted 02 October 2006 - 12:58 PM
#716
Posted 02 October 2006 - 03:17 PM
#717
Posted 04 October 2006 - 01:11 AM
For example: f=input("f(x):") and you input x^2 then we have a function f(x) x^2 end?
#718
Posted 04 October 2006 - 07:29 AM
f = dostring( "return function(x) return " .. input("f(x)=") .. " end" )Don't forget that in the expression you must use Lua names for math operations (e.g, input "math.cos(x)" instead of "cos(x)" ).
#719
Posted 04 October 2006 - 10:44 AM
#720
Posted 04 October 2006 - 11:02 AM
I forgot to let dostring() return the results of the executed string, thus dostring() will only return nil in the current version. This will be fixed in the next version
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users