CEMETECH
Leading The Way To The Future
Login [Register]
Username:
Password:
Autologin:

Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 92 users online: 1 member, 66 guests and 25 bots.
Members: None.
Bots: Alexa (1), Spinn3r (1), MSN/Bing (2), Magpie Crawler (3), Googlebot (2), Googlebot (16).
RSS & Social Media
SAX
You must log in to view the SAX chat widget
    » Goto page 1, 2, 3, 4, 5, 6  Next
» View previous topic :: View next topic  
Author Message
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55759
Location: Earth, Sol, Milky Way

Posted: 08 Sep 2012 12:23:04 am    Post subject: LuaZM v0.1 Beta: Lua for the Casio Prizm
08 Sep 2012

The programming language Lua has been around for fifteen years, and has recently gained significant traction as an introductory scripting language. As I mentioned when I first announced the LuaZM project, the TI-Nspire CX has had Lua for about a year now, Texas Instruments' uneasy relationship with hobbyist programmers notwithstanding. I'm proud to release the first beta of LuaZM to the public, along with documentation on the current features of the core program and its included libraries. Create your own .lua programs, then use LuaZM's handy graphical file browser to select a program and run it. LuaZM also includes a command line where you can test out commands and functions. LuaZM is a semi-port of Lua 5.2.1. Please try out this beta, give me feedback, and start publishing your own Prizm Lua programs! Compatibility layers for Nspire and LuaFX programs may be coming soon. Special thanks go to Juju and AHelper for the PrizmIO console library and the File Browser GUI respectively.

Download & Read More
LuaZM v0.1 - Casio Prizm Lua Interpreter
LuaZM reference documentation


_________________




Last edited by KermMartian on 09 Sep 2012 01:58:12 pm; edited 1 time in total
Back to top
vebveb


Newbie


Joined: 02 Jul 2012
Posts: 24

Posted: 08 Sep 2012 04:41:08 am    Post subject:

You should add functions to scroll the screen of your clipping rectangle and to save it and restore it later (as in luaFX).

I think a compatibility layer for luaFX programs is possible, but some functionnalities will be difficult to make it compatible (I mean the file library and the module system). For the other functions, it is not quite difficult: add '(' and ')' to the .lua where it is needed, load a different library.
Back to top
gbl08ma


Power User


Joined: 26 Nov 2011
Posts: 475
Location: Portugal

Posted: 08 Sep 2012 06:46:34 am    Post subject:

Yet another promising project from the guys at Cemetech. I'm specially excited for the (both standard and Prizm/Nspire-specific) libraries that hopefully are coming...

Also, I miss a cursor in the console... not being able to go back and insert text is a pain.

I figured out a clean screenshot not taken with a camera on an actual Prizm would be nice, so here it is...
Unfortunately your method for capturing keyboard keys doesn't work on the emulator, so I couldn't open the About screen or print an epic "Hello Moon" message Wink




gbl08ma gets more and more annoyed that people don't use standard GetKey syscalls when possible...
_________________
My blog, where I write about random things... | tiny URL shortener
View JPEG images on your Prizm | Utilities for the Casio Prizm - clock, stopwatch, calendar/agenda, add-in manager and more!
Back to top
flyingfisch


Super-Expert


Joined: 02 Feb 2012
Posts: 895
Location: Akron, OH

Posted: 08 Sep 2012 07:25:56 am    Post subject:

Wow, this is awesome. Smile

Is it possible to write in lowercase in the command line?

EDIT:

My program I made will not run.

Code:

local clear = zmg.clear
local drawCircle = zmg.drawCircle
local drawRect = zmg.drawRect
local keyMenu = zmg.keyMenu

clear()
drawCircle(50,50,25,0xFFFF)
drawRect(100,100,100,100, 0xFFFF)

keyMenu()




Here is the file: https://dl.dropbox.com/u/63621708/calcs/progs/luaZM/test.lua
_________________



Back to top
gbl08ma


Power User


Joined: 26 Nov 2011
Posts: 475
Location: Portugal

Posted: 08 Sep 2012 08:26:07 am    Post subject:

Writing in lowercase is a bit cumbersome/buggy but I think the idea is to switch between caps and lowercase with the OPTN key.
_________________
My blog, where I write about random things... | tiny URL shortener
View JPEG images on your Prizm | Utilities for the Casio Prizm - clock, stopwatch, calendar/agenda, add-in manager and more!
Back to top
flyingfisch


Super-Expert


Joined: 02 Feb 2012
Posts: 895
Location: Akron, OH

Posted: 08 Sep 2012 09:20:20 am    Post subject:

Ah, OK.

Does anyone know why my program will not work though? It says there is a problem near <eof>.
_________________



Back to top
Ashbad


... I think redheaded girls are kind of cool


Joined: 01 Dec 2010
Posts: 2418
Location: Stomp Stomp Stomp, The Idiot Convention

Posted: 08 Sep 2012 09:51:40 am    Post subject:

gbl08ma wrote:
gbl08ma gets more and more annoyed that people don't use standard GetKey syscalls when possible...


To be fair, it's not very game-friendly to use the syscalls, as they're a lot slower, can't detect more than one key at once, etc. I found a nice solution is to build two versions of the addin in question: one for hardware, and one that's (mostly) emulator friendly. Perhaps Kerm should consider the same Smile And to Kerm specifically, I'm totally trying this out today.
_________________
-Ashbad
Back to top
gbl08ma


Power User


Joined: 26 Nov 2011
Posts: 475
Location: Portugal

Posted: 08 Sep 2012 10:10:07 am    Post subject:

The problem with not using GetKey in hardware is that you are unable to take screenshots and do things like turning off the calculator (without adding additional code for it like Kerm did in Graph3DP).

I personally like the suggestion Ashbad used in his Pong and Raptor games: when the custom keyboard routines detect the Menu key, Shift+AC or Shift+7, they do a standard GetKey syscall so that the special events are handled.
_________________
My blog, where I write about random things... | tiny URL shortener
View JPEG images on your Prizm | Utilities for the Casio Prizm - clock, stopwatch, calendar/agenda, add-in manager and more!
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55759
Location: Earth, Sol, Milky Way

Posted: 08 Sep 2012 10:17:08 am    Post subject:

Yes, PrizmIO needs the modifier keys changed up; they're currently nonsensical. I have made suggestions to Juju about it, and since he's planning to make a lot of changes to PrizmIO based on my suggestions, I didn't bother making the changes myself yet. Smile No sense doing it twice if he's going to get to it soon. If he's not, though, I'll just do it myself. Here were my suggestions:
http://www.cemetech.net/forum/viewtopic.php?p=188440#188440
Oh, and for what it's worth, PrizmIO currently uses Ashbad's system to check if keys are currently pressed or held.

Flyingfisch: Although that should work, what do you have against calling the functions directly? Is it faster that way? I'll try your code on my Prizm and see how it runs.

Edit: As requested, here is a list of planned features for LuaZM before 1.0:
:: Either get a fixed PrizmIO or fix PrizmIO
:: Finish overhauling IO library and include it. Add serial port support.
:: Finish overhauling OS library and include it.
:: Decide whether to include the Coroutines library
:: Decide whether to make a LuaFX compatibility layer or just port over (some or all) of the ten existing LuaFX programs.
_________________


Back to top
flyingfisch


Super-Expert


Joined: 02 Feb 2012
Posts: 895
Location: Akron, OH

Posted: 08 Sep 2012 11:08:26 am    Post subject:

KermMartian wrote:

Flyingfisch: Although that should work, what do you have against calling the functions directly? Is it faster that way? I'll try your code on my Prizm and see how it runs.


I guess I don't call functions directly because it seems like just about all LuaFX programs call them like that. I don't know if that is just veb's preference or not, but I have been doing it that way for quite a while.

So, while it may be faster (I don't know), I do it because I always have. Should I call them directly instead?
_________________



Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55759
Location: Earth, Sol, Milky Way

Posted: 08 Sep 2012 11:09:38 am    Post subject:

I suspect it might be slightly faster to do it that way. Can you use the zmg.ticks() function wrapped around 1000 calls of some function written both ways to see what the relative speeds are?
_________________


Back to top
vebveb


Newbie


Joined: 02 Jul 2012
Posts: 24

Posted: 08 Sep 2012 11:12:12 am    Post subject:

Yes, it faster:

local clear = zmg.clear
clear ()

first part : local clear = zmg.clear
search the global zmg
find the index clear
put the result in an upvalue

second part : clear()
load the upvalue
call it

and the other way: zmg.clear()
search the global zmg
find the index clear
call it


Then if we call a function multiple times, the first way is faster.
Back to top
flyingfisch


Super-Expert


Joined: 02 Feb 2012
Posts: 895
Location: Akron, OH

Posted: 08 Sep 2012 11:13:04 am    Post subject:

KermMartian wrote:
I suspect it might be slightly faster to do it that way. Can you use the zmg.ticks() function wrapped around 1000 calls of some function written both ways to see what the relative speeds are?


well, sure, but could I can't get any lua progs to work for me. Maybe it has something to do with me using linux line breaks or me using linux formats? I think mine is in UTF-8...
_________________



Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55759
Location: Earth, Sol, Milky Way

Posted: 08 Sep 2012 11:33:04 am    Post subject:

Ah, UTF-8 is encoding, it doesn't understand UTF-8. Try ANSI encoding.
_________________


Back to top
flyingfisch


Super-Expert


Joined: 02 Feb 2012
Posts: 895
Location: Akron, OH

Posted: 08 Sep 2012 11:40:59 am    Post subject:

Oh, ok.
_________________



Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55759
Location: Earth, Sol, Milky Way

Posted: 08 Sep 2012 11:49:06 am    Post subject:

vebveb wrote:
Yes, it faster:
[...]Then if we call a function multiple times, the first way is faster.
I just tried an experiment with the following code:

Code:
local point = zmg.drawPoint
local start = zmg.ticks()
for j=1,1000,1 do
   point(64,64,0x6421)
end
print((zmg.ticks()-start)/(64*1000))
start = zmg.ticks()
for j=1,1000,1 do
   zmg.drawPoint(64,64,0x6421)
end
print((zmg.ticks()-start)/(64*1000))


The former method averaged 0.000125 seconds (125 microseconds) per call, while the latter method averaged 0.000141 seconds (141 microseconds) per call. A small but measurable difference, which would be amortized for more complex calls than drawPoint.
_________________


Back to top
flyingfisch


Super-Expert


Joined: 02 Feb 2012
Posts: 895
Location: Akron, OH

Posted: 08 Sep 2012 12:09:35 pm    Post subject:

Is there an implemented text input routine for LuaZM?
_________________



Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55759
Location: Earth, Sol, Milky Way

Posted: 08 Sep 2012 12:11:18 pm    Post subject:

flyingfisch wrote:
Is there an implemented text input routine for LuaZM?
Yes, there is; it was one of the last ZMG routines that I added:

http://prizm.cemetech.net/index.php?title=LuaZM_Reference#zmg.drawText.28.29
_________________


Back to top
flyingfisch


Super-Expert


Joined: 02 Feb 2012
Posts: 895
Location: Akron, OH

Posted: 08 Sep 2012 12:13:57 pm    Post subject:

Oh, cool.

Why don't you import the io standard library instead of adding it to zmg?

EDIT:
Just looked at the docs. I didn't mean to draw text, i meant to get user input from the command line.
_________________



Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55759
Location: Earth, Sol, Milky Way

Posted: 08 Sep 2012 12:21:05 pm    Post subject:

flyingfisch wrote:
Oh, cool.

Why don't you import the io standard library instead of adding it to zmg?

EDIT:
Just looked at the docs. I didn't mean to draw text, i meant to get user input from the command line.
Those are going to be part of the io library. print() prints to the command line for now, but there's no read() or readline() function yet.
_________________


Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    » Goto page 1, 2, 3, 4, 5, 6  Next
» View previous topic :: View next topic  
Page 1 of 6 » All times are GMT - 5 Hours

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.043067 seconds.