Omnimaga

Calculator Community => Casio Calculators => Topic started by: flyingfisch on October 19, 2011, 01:19:09 pm

Title: LuaFX Question
Post by: flyingfisch on October 19, 2011, 01:19:09 pm
Why won't this code work in luaFX? I am trying to make an iPhone type slider.

Code: [Select]
arrow_spr='0x1F, 0xFF, 0xF8, 0x3F, 0xFF, 0xFC, 0x40, 0x00, 0x02, 0xC0, 0x00, 0x03, 0xC0, 0x00, 0x03, 0xC7, 0x80, 0x03, 0xC3, 0xC0, 0x03, 0xC1, 0xE0, 0x03, 0xC0, 0xF0, 0x03, 0xC0, 0x78, 0x03, 0xC0, 0x3C,  0x03, 0xC0, 0x1E, 0x03, 0xC0, 0x3C, 0x03, 0xC0, 0x78, 0x03, 0xC0, 0xF0, 0x03, 0xC1, 0xE0, 0x03, 0xC3, 0xC0, 0x03, 0xC7, 0x80, 0x03, 0xC0, 0x00, 0x03, 0xC0, 0x00, 0x03, 0xC0, 0x00, 0x03, 0x40, 0x00, 0x02, 0x3F, 0xFF, 0xFC, 0x1F, 0xFF, 0xF8'

local line = graydraw.line
local wait = misc.wait

function rectangle (x1, y1, x2, y2) -- rectangle is a function of four parameters lua
line (x1, y1, x1, y2) -- draws the rectangle
line (x1, y1, x1, y2)
line (x1, y1, x1, y2)
line (x1, y1, x1, y2)
end

function slider (x)
rectangle (6, 17, 120, 41) --Draws rectangle
spritexy x+6,30,arrow_spr
end

slider (0)
wait(100)
Title: Re: LuaFX Question
Post by: Jim Bauwens on October 19, 2011, 01:50:52 pm
I don't know LuaFX, but I don't see any Lua mistake in it.
Do you see something on the screen when run? Or do you get an error message?
Title: Re: LuaFX Question
Post by: flyingfisch on October 19, 2011, 01:57:15 pm
I get a string of numbers.... no error message. :(
Title: Re: LuaFX Question
Post by: Eiyeron on October 19, 2011, 02:54:47 pm
Er, yeah, you just mistood into make sprites.
I sugger you make one sprite with SPrite maker from Orwell, then "compile them" with a utility i give you the code. You'll need to give to foo the sprite array, and it will make the string version in a file.

Code: [Select]
foo = { ... le code de ton sprite ... }
out = io.open("Prog.lua", "w") -- l'ancien sera effacé
foo2=string.char(unpack (foo)); -- on remplace foo par le nom du sprite
out:write(("sprite = %q"):format(foo2));
out:close()
io.write(string.byte("n"))

You'll need Lua on your computer

Url for the file:
http://www.planet-casio.com/files/forums/SPrite%20compiler-50456.rar (http://www.planet-casio.com/files/forums/SPrite%20compiler-50456.rar)
Title: Re: LuaFX Question
Post by: flyingfisch on October 19, 2011, 02:57:21 pm
Oh thank you Eiyeron! I was hoping you'd help me out! :)

But now I have another question... how to draw a rectangle with luaFX?
Title: Re: LuaFX Question
Post by: flyingfisch on October 19, 2011, 04:03:46 pm
Er, yeah, you just mistood into make sprites.
I sugger you make one sprite with SPrite maker from Orwell, then "compile them" with a utility i give you the code. You'll need to give to foo the sprite array, and it will make the string version in a file.

Code: [Select]
foo = { ... le code de ton sprite ... }
out = io.open("Prog.lua", "w") -- l'ancien sera effacé
foo2=string.char(unpack (foo)); -- on remplace foo par le nom du sprite
out:write(("sprite = %q"):format(foo2));
out:close()
io.write(string.byte("n"))

You'll need Lua on your computer

Url for the file:
http://www.planet-casio.com/files/forums/SPrite%20compiler-50456.rar (http://www.planet-casio.com/files/forums/SPrite%20compiler-50456.rar)

OK, i just tried that, here is my code:

Code: [Select]
local wait = misc.wait
--Sprite - Name: arrow, Width: 24px, Height: 24px
local arrow_spr="ÿø?ÿü@\000À\000À\000Ç€ÃÀÁàÀðÀxÀ<ÀÀ<ÀxÀðÁàÃÀÇ€À\000À\000À\000@\000?ÿüÿø"

spritexy 57,41,arrow_spr
wait(100)

All I get is "Executing Test!!!" and then the calc restarts. The sprite is not displayed. :(
Title: Re: LuaFX Question
Post by: flyingfisch on October 20, 2011, 12:51:28 pm
bump
Title: Re: LuaFX Question
Post by: Eiyeron on October 21, 2011, 12:34:16 pm
add refresh before wait! :p
Oh, and for the rectangle, li,ne function with two colours instead of one
gray.line(x1,y1,x2,y2,c1,c2) -- If this is the good function to draw a line
Title: Re: LuaFX Question
Post by: flyingfisch on October 21, 2011, 12:39:06 pm
alright, here is my new code:

Code: [Select]
local line = graydraw.line
local wait = misc.wait
local setcolor = graydraw.setcolor
--Sprite - Name: arrow, Width: 24px, Height: 24px
local arrow_spr="ÿø?ÿü@\000À\000À\000Ç€ÃÀÁàÀðÀxÀ<ÀÀ<ÀxÀðÁàÃÀÇ€À\000À\000À\000@\000?ÿüÿø"

setcolor(true)

clear nil
pushxspr 3
drawspr 3,arrow_spr
refresh

repeat
wait(3)
until key(5)

ufortuanately, it seems that my sprite wont work. I tried using that code you gave me. Mario sprite works, but not mine. :(

I used Orwell's sprite maker in black and white mode, is that the problem?
Title: Re: LuaFX Question
Post by: Eiyeron on October 21, 2011, 12:43:51 pm
Yeah, you should use GXlib mode, that is the good method, I forgot...
Title: Re: LuaFX Question
Post by: flyingfisch on October 21, 2011, 01:34:26 pm
Thanks, it works now! here is a screenshot:
(http://img.removedfromgame.com/imgs/12-screenshot.png)
it will be centered in the final version :P

Hey, and is there a built-in text input function or should i make one myself?
Title: Re: LuaFX Question
Post by: Eiyeron on October 21, 2011, 02:40:44 pm
graydraw.text(x,y,char, or num)
Title: Re: LuaFX Question
Post by: flyingfisch on October 28, 2011, 12:27:10 pm
Is there any way to turn off the calculator using LFX? I don't just want to clear the screen, I want to turn it off like when you press Shift + AC/on
Title: Re: LuaFX Question
Post by: bynary_man on October 28, 2011, 02:39:56 pm
I suppose, it's not possible.
Title: Re: LuaFX Question
Post by: Eiyeron on October 29, 2011, 06:17:38 am
No
Title: Re: LuaFX Question
Post by: flyingfisch on October 30, 2011, 01:39:01 pm
is there a way to do that with even C/ASM?
Title: Re: LuaFX Question
Post by: Eiyeron on October 30, 2011, 02:27:55 pm
Yeah there are some good syscalls, but you cannot ( i dunno, but i suppose) run C/ASM in LFX
Title: Re: LuaFX Question
Post by: flyingfisch on October 30, 2011, 02:29:45 pm
Yeah there are some good syscalls, but you cannot ( i dunno, but i suppose) run C/ASM in LFX
yeah, i know. just wanted to know if it was possible to do in any language.
Title: Re: LuaFX Question
Post by: Eiyeron on October 30, 2011, 03:41:43 pm
In theory yes, but as the AFX cannot shutdown with LAFX, Veb said "no shut offs for FX9860G"
Title: Re: LuaFX Question
Post by: flyingfisch on October 30, 2011, 03:46:36 pm
OK