Author Topic: LuaFX Question  (Read 8047 times)

0 Members and 1 Guest are viewing this topic.

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
LuaFX Question
« 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)



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: LuaFX Question
« Reply #1 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?

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: LuaFX Question
« Reply #2 on: October 19, 2011, 01:57:15 pm »
I get a string of numbers.... no error message. :(



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: LuaFX Question
« Reply #3 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
« Last Edit: October 19, 2011, 02:55:47 pm by Eiyeron »

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: LuaFX Question
« Reply #4 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?
« Last Edit: October 19, 2011, 03:00:52 pm by flyingfisch »



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: LuaFX Question
« Reply #5 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

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. :(



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: LuaFX Question
« Reply #6 on: October 20, 2011, 12:51:28 pm »
bump



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: LuaFX Question
« Reply #7 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
« Last Edit: October 21, 2011, 12:39:41 pm by Eiyeron »

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: LuaFX Question
« Reply #8 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?



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: LuaFX Question
« Reply #9 on: October 21, 2011, 12:43:51 pm »
Yeah, you should use GXlib mode, that is the good method, I forgot...

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: LuaFX Question
« Reply #10 on: October 21, 2011, 01:34:26 pm »
Thanks, it works now! here is a screenshot:

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?



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: LuaFX Question
« Reply #11 on: October 21, 2011, 02:40:44 pm »
graydraw.text(x,y,char, or num)

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: LuaFX Question
« Reply #12 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



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline bynary_man

  • LV2 Member (Next: 40)
  • **
  • Posts: 24
  • Rating: +1/-0
    • View Profile
Re: LuaFX Question
« Reply #13 on: October 28, 2011, 02:39:56 pm »
I suppose, it's not possible.

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: LuaFX Question
« Reply #14 on: October 29, 2011, 06:17:38 am »
No