Omnimaga

Calculator Community => TI Calculators => Lua => Topic started by: Jim Bauwens on March 15, 2012, 03:51:57 pm

Title: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on March 15, 2012, 03:51:57 pm
Hello :)

Just wanted to show a little project I'm busy on.
As some of you know, I mainly develop on Linux. This means testing Nspire Lua programs is a bit harder.
Nspire_emu works fine, but there is no mouse support.
That is why I set out to create something to run Lua programs natively (meaning without emulation) on my computer.
I started 3 days ago, and here is the result:

Spoiler For screenshots:
(Colors are bad because of screen recorder)


EEPro (under dev) runs pretty good
(http://bwns.be/jim/pcspire1.gif)

Tetris:
(http://bwns.be/jim/pcspire2.gif)

Even different screen sizes if the lua script supports it:
(http://bwns.be/jim/india.gif)

And today I added a debugger:
(http://bwns.be/jim/debug.gif)
( gvars() is a custom function of me that prints classes and/or objects )

I use the Löve Lua framework, since it was also event based and that made stuff a bit easier.

Stuff I still need to do:
If I forgot something I will update the list.
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Levak on March 15, 2012, 03:53:06 pm
awesome =)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: aeTIos on March 15, 2012, 03:55:53 pm
I eat you when this is not for windows. I need this SO bad  if I want to develop nspire lua programs (but I do not have an nspire xD)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on March 15, 2012, 03:59:15 pm
@aeTIos
It's for all os's!
Hey, and you are a big part to blame, since you pointed me to the Love framework!
Guilty I say!
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: aeTIos on March 15, 2012, 04:02:05 pm
Hehe Löve ROCKS.
It makes stuff sooo much easier!
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Juju on March 15, 2012, 04:05:33 pm
That might be pretty useful, you won't need a Nspire or the emulator to run Lua programs.
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on March 15, 2012, 04:06:42 pm
Yeah, true.
Also, with the debugger it becomes a useful programming tool :)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: ruler501 on March 15, 2012, 04:09:46 pm
Can this be set to scale the speed to what a real nspire could do?
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: aeTIos on March 15, 2012, 04:11:03 pm
Could you please spoil the pics in the first post, my browser breaks on them :\
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on March 15, 2012, 04:18:36 pm
Ruler: the timer that most programs use to time stuff is the same.
And keyboard input is set to the same rate. So in theory, all programs should act quite the same.

aeTIos, done
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Lionel Debroux on March 15, 2012, 04:30:26 pm
This is wonderful, and undoubtedly more lightweight (for both size and speed) than the large TINCS bloat :)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on March 15, 2012, 04:48:27 pm
Thanks Lionel :)

Also, cubefield works:
(http://bwns.be/jim/cubefield.gif)

I did have to change a speed variable though. Cubefield detects PCspire as a CX, so it set a variable to make the whole program go faster.
This will probably also be a problem in TINCS, and isn't really fixable (well, cubefield's code needs to be changed).
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: cyanophycean314 on March 15, 2012, 10:06:40 pm
Very nice! May be able to bring me back to Ubuntu for calc development!  :D

Downloads soon?
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: alberthrocks on March 15, 2012, 10:22:59 pm
This is definitely cross-platform, as this itself is also written in Lua! :D Windows, Linux, Mac OS X - you name it :)
(I'm assuming there will be binary distributions: https://love2d.org/wiki/Game_Distribution)

This is some amazing work! :D This will truly unlock the world of Lua for me, and possibly for countless others as well! :D
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on March 16, 2012, 03:53:17 am
@cyanophycean314, I'll shouldn't take too long before a release, as it's already quite progressed.

@alberthrocks, thanks! And yes, I will distribute it in .love files :)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: aeTIos on March 16, 2012, 05:31:53 am
jim: Er, I should maybe mention that you have to include the löve program :)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on March 16, 2012, 06:48:23 am
aeTIos, people just install it on their PC and it will work.
Most linux distributions even have it in their package manager.
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: TIfanx1999 on March 16, 2012, 09:49:08 am
Wow, this looks really nice Jim! =) The fact that it is cross platform is great too!
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Nick on March 16, 2012, 10:30:54 am
this is extremely useful ö nice.. really congratz on this one. but how can it be used under windows? since alberthrocks said it should be possible
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: aeTIos on March 16, 2012, 10:32:22 am
You have to download Löve and drag the .love file over the Löve executable.
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Nick on March 16, 2012, 10:34:03 am
and where can we find the download of the project (not the love files) since i don't see any download...
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: aeTIos on March 16, 2012, 10:35:02 am
Erm, Löve? http://www.love2d.org/
PCspire isnt out yet.
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: alberthrocks on March 16, 2012, 11:03:52 am
aeTIos, people just install it on their PC and it will work.
Most linux distributions even have it in their package manager.
According to the wiki (https://love2d.org/wiki/Game_Distribution), you can also bundle the Love binary and the love file into one executable. It acts like a SFX binary - that is, you can simply concatenate the two together. :)

Code: [Select]
cat /usr/bin/love game.love > game && chmod +x game
So rest assured, you won't have to install Love to use this! :)

EDIT: Also, I've noticed that the screenshot has no blinking cursor when editing the text box. I assume this will be fixed? (Or it could be a crappy screenshot :P)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on March 16, 2012, 11:37:11 am
alberthrocks, that's a lua program. The widgets are lua based (part of EEPro core).
I haven't implemented blinking cursors there yet, and it has nothing to do with PCspire :P

I will see how I'll distribute it in the end, as this isn't hard at all.
Code isn't available yet, but will be soon :)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Chockosta on March 16, 2012, 01:56:36 pm
 O.O I haven't seen that !
This is really awesome, congrats !


I did have to change a speed variable though. Cubefield detects PCspire as a CX, so it set a variable to make the whole program go faster.
This will probably also be a problem in TINCS, and isn't really fixable (well, cubefield's code needs to be changed).

That's really strange, because in cubefield the cubes speed is based on timer.getMilliSecCounter()
So it works nice with TINCLS. Where did you get your version ?
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on March 16, 2012, 02:59:35 pm
ticalc.org IIRC.

On the top of your code you check if it's a CX, and change a speed variable if it is.
I noticed that you use getMilliSecCounter, and my implementation of it should do the same.
Maybe the timer runs a bit slower on calc.

Got to test this ^^
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Chockosta on March 16, 2012, 03:16:56 pm
Please try with this code, it should work...
Code: [Select]
playerImg=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\128\000\128\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128")

cubesX={1,5,7,6,4,6,4,1,3,2,3,7,8,9,1,2,3,4,2,6,7,1,9,1,2,3,4}
cubesY={1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,8,8,8,9,9,9}
lastCube=1
player=0
speed=0.08
moving=false
dir=1
moveStart=0
menu=true
score=0
level=1
color={225,170,0}
rotation=0
lastTick=0
delay=0

function render(gc)
 drawHorizon(gc)
 local size,x,y,i,polygon
 for j=1,27 do
  i=(j+lastCube-2)%27+1
  size=100/(10-cubesY[i])
  x=(cubesX[i]-7-player)/(10-cubesY[i])*150-size/2
  y=5/(10-cubesY[i])*50-180
  polygon=rotate({x,y,x+size,y,x+size,y+size,x,y+size,x,y})
  if cubesY[i]>1 then
   gc:setColorRGB(color[1],color[2],color[3])
   gc:fillPolygon(polygon)
   gc:setColorRGB(0,0,0)
   gc:drawPolyLine(polygon)
  end
  if y+size>3 and y<17 then
   if x<6 and x+size>-6 then
    menu=true
    score=math.floor(score)
   end
  end
 end
end

function rotate(p)
 local s,c=math.sin(rotation),math.cos(rotation)
 return {p[1]*c-p[2]*s+159,p[1]*s+p[2]*c+202,p[3]*c-p[4]*s+159,p[3]*s+p[4]*c+202,p[5]*c-p[6]*s+159,p[5]*s+p[6]*c+202,p[7]*c-p[8]*s+159,p[7]*s+p[8]*c+202,p[9]*c-p[10]*s+159,p[9]*s+p[10]*c+202}
end

function updateCubes()
 local step=menu and 0.06 or speed
 for i=1,27 do
  cubesY[i]=cubesY[i]+step*delay/30
  if cubesY[i]>10 then
   if score%1000<800 then
    cubesX[i]=math.random(0,140)/10+player
   else
    cubesX[i]=math.random(0,140)/200+player+(i-1)%2*5+4.1
   end
   cubesY[i]=cubesY[i]-9
   lastCube=lastCube==1 and 27 or lastCube-1
  end
 end
end

function updateMove()
 if moving then
  player=player+0.07*dir*delay/30
  if math.abs(rotation)<0.15 or dir==rotation/math.abs(rotation) then
   rotation=rotation-0.005*dir*delay/30
  end
  if timer.getMilliSecCounter()-moveStart>=150 then
   moving=false
  end
 else
  if math.abs(rotation)>0.005 then
   rotation=rotation-0.005*rotation/math.abs(rotation)*delay/30
  end
 end
end

function drawPlayer(gc)
 if not menu then
  gc:drawImage(playerImg,149,192)
 end
end

function drawHorizon(gc)
 local s,c=math.sin(rotation),math.cos(rotation)
 gc:setColorRGB(0,0,0)
 gc:drawLine(s*142-c*200+159,202-c*142-s*200,c*200+s*142+159,s*200-c*142+202)
end

function drawMenu(gc)
 if menu then
  gc:setColorRGB(0,0,0)
  gc:setFont("sansserif","r",30)
  gc:drawString("CubeField",80,10,"top")
  gc:setFont("sansserif","b",12)
  gc:drawString("Press Enter",115,150,"top")
  local highscore=var.recall("highscore")
  if not highscore then
   var.store("highscore",0)
   highscore=0
  end
  if score>highscore then
   var.store("highscore",score)
   document.markChanged()
  end
  local str="Score : "..tostring(score).."              Highscore : "..tostring(highscore)
  gc:drawString(str,159-gc:getStringWidth(str)/2,100,"top")
 end
end

function drawScore(gc)
 if not menu then
  gc:setColorRGB(0,0,0)
  gc:setFont("sansserif","r",12)
  gc:drawString(tostring(math.floor(score)),2,0,"top")
  if score%1000>950 then
   gc:setFont("sansserif","r",30)
   gc:drawString("Speed Up !",80,10,"top")
  end
 end
end

function levelUp()
 speed=speed+0.02
 level=level+1
 if (level-1)%5==0 then
  color={225,170,0}
 elseif (level-1)%5==1 then
  color={0,0,255}
 elseif (level-1)%5==2 then
  color={100,100,100}
 elseif (level-1)%5==3 then
  color={90,255,0}
 elseif (level-1)%5==4 then
  color={255,255,255}
 end
end

function on.paint(gc)
 render(gc)
 drawPlayer(gc)
 drawMenu(gc)
 drawScore(gc)
 gc:setColorRGB(0,0,0)
 gc:setFont("sansserif","r",8)
 gc:drawString("Lua CubeField - Par Loic Pujet",10,200,"top")
 updateFPS()
 timer.start(0.01)
end

function on.timer()
 timer.stop()
 updateCubes()
 updateMove()
 if not menu then
  score=score+delay/30
  if score>level*1000 then
   levelUp()
  end
 end
 platform.window:invalidate()
end

function on.enterKey()
 if menu then
  menu=false
  speed=0.08
  moving=false
  score=0
  level=1
  color={225,170,0}
  for i=1,27 do
   cubesY[i]=cubesY[i]-5
  end
 end
end

function on.arrowLeft()
 if not menu then
  dir=-1
  moving=true
  moveStart=timer.getMilliSecCounter()
 end
end

function on.arrowRight()
 if not menu then
  dir=1
  moving=true
  moveStart=timer.getMilliSecCounter()
 end
end

function on.charIn(ch)
 if ch=="6" then
  on.arrowRight()
 elseif ch=="4" then
  on.arrowLeft()
 end
end

function updateFPS()
 delay=timer.getMilliSecCounter()-lastTick
 delay=delay<300 and delay or 0
 lastTick=timer.getMilliSecCounter()
end
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on March 16, 2012, 03:50:19 pm
Looks like it works fine now :)
And even more smooth!
Good job.

Also, maybe you change your image with
Code: [Select]
\20\0\0\0\20\0\0\0\0\0\0\0\40\0\0\0\16\0\1\000alalalalalalalalal\0\128\0\128alalalalalalalalalalalalalalalalal\0\128\0\128\0\128\0\128alalalalalalalalalalalalalalal\0\128\0\128\0\128\0\128\0\128\0\128alalalalalalalalalalalalal\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128alalalalalalalalalalal\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128alalalalalalalalal\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128alalalalalalal\0\128\0\128\0\128\0\128\0\128\0\128alal\0\128\0\128\0\128\0\128\0\128\0\128alalalalal\0\128\0\128\0\128\0\128\0\128alalalalalal\0\128\0\128\0\128\0\128\0\128alalal\0\128\0\128\0\128\0\128\0\128alalalalalalalal\0\128\0\128\0\128\0\128\0\128al\0\128\0\128\0\128\0\128\0\128alalalal\0\128\0\128alalalal\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128alalalalal\0\128\0\128\0\128\0\128alalalalal\0\128\0\128\0\128alalalalalalal\0\128\0\128\0\128\0\128\0\128\0\128alalalalalalalalalalalalal\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128alalalalalalalalalalal\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128alalalalalalalalal\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128alalalalalalal\0\128\0\128\0\128\0\128\0\128\0\128alal\0\128\0\128\0\128\0\128\0\128\0\128alalalalal\0\128\0\128\0\128\0\128\0\128alalalalalal\0\128\0\128\0\128\0\128\0\128alalal\0\128\0\128\0\128\0\128\0\128alalalalalalalal\0\128\0\128\0\128\0\128\0\128al\0\128\0\128\0\128\0\128\0\128alalalalalalalalalal\0\128\0\128\0\128\0\128\0\128\0\128\0\128\0\128alalalalalalalalalalalalalal\0\128\0\128\0\128
It's the same but more compact :D


Edit:

Also, variables and state saving works now. (So high scores too!)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: DJ Omnimaga on March 16, 2012, 04:02:20 pm
Darn that is great jim! Glad to see more Nspire stuff for Linux. Also the great thing is that since it's not by TI, I presume it will actually run everything? :)  (some Lua games won't run correctly in the Student Software)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on March 16, 2012, 04:05:02 pm
Thanks :)

Well, that's what I want.
I'm trying lot's of programs, and when I notice that it error's or acts weird I look for the cause and fix it.
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Scipi on March 17, 2012, 11:43:47 pm
Ironically, I already have Löve for some reason :P

Are programs run with this faster than on calc? If so, is there a way to toggle the speed to that of an Nspire?
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Lionel Debroux on March 18, 2012, 03:04:24 am
Quote
Are programs run with this faster than on calc?
IIUC, they shouldn't - it's one of the points of PCspire :)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on March 18, 2012, 06:45:12 am
Yup, that is correct.
Since Nspire lua is event based, scripts use the timer to trigger updates in a specified interval.
And the timer in PCspire works the same, so the script should seem to run at the same speed.
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: cyanophycean314 on March 18, 2012, 10:55:38 am
This has gotten me interested in the Love framework. It's interesting and I might use it.

For the TI-Image, what are the parts with "alalalalalalala" about?
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on March 18, 2012, 10:59:10 am
"al" represent a color, and in this case the color red, with a alpha bit so that it's invisible.
I replaced the white in his image with it to make it transparent .
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: cyanophycean314 on March 18, 2012, 11:02:38 am
Is there a TI-Image optimizing tool of some sort? Or is there a list of optimizing rules?
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on March 18, 2012, 11:05:41 am
I use my online sprite editor (bwns.be/jim/sprite.html) for that, and/or do some stuff manually :)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Yeong on March 18, 2012, 02:33:23 pm
looks very nice! :D
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: DJ Omnimaga on March 19, 2012, 03:49:57 am
How's the speed by the way? Is it dependent on the computer or will it run at the same speed on every computer? It would be nice if it was the latter, for those who wants to make animated screenshots.
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: aeTIos on March 19, 2012, 05:37:32 am
afaik its same on each computer. (same speed as the nspire)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on March 20, 2012, 12:10:47 pm
People can already check out the code on https://github.com/jimbauwens/PCspire.
However, it's not yet noob proof :P
But it will :)

Currently these things need to be fixed:
- Drawing arcs (draws a full circle now)
- When invalidating specific screen parts, it can skip a couple of pixels. Shouldn't be a problem for most programs, but it needs to be fixed anyway.
- Text offsets need to be improved
- Images need better alpha support

These things need to be added:
- Tool palette (menu system that hardly anybody uses :P)
- Cursor changing. This is more hard because love2d doesn't support this directly

Stuff that I might never implement because they are very hard:
- math.eval (requires CAS engine and TI-Basic interpreter)
- D2Editor (requires rtf interpreter)
- Physics (love2d has physics, but it would be too hard to make it compatible with the chipmunk one on the nspire)


Programs I tested that work fine:
- Updated version of Cubefield
- LogoMagic
- Klondike Lua
- Some programs that use the EEPro widgets (I forgot the names, or maybe I didn't name them yet :P)
- Color Tetris
- BlockBreaker Lua
- Bloxorz
- some other tiny stuff I made :P
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: aeTIos on March 20, 2012, 12:18:30 pm
Jim, love actually does support changing cursors, check out the wiki :)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on March 20, 2012, 12:22:08 pm
Hmm, I don't find it. Mind linking to the page with info?
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on March 21, 2012, 08:11:25 am
Alright, fixed the text offset and the invalidating bug.

DiagramNZ works properly with one little change:
It replaces the Lua function named "type" with a number value, causing some Lua parts of love not to function properly.
So, I just replaced "type" with "Type" (in the DiagramNZ source) and it worked fine :)
Screenshot: http://bwns.be/jim/DiagramNZ.png
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Nick on March 21, 2012, 04:29:03 pm
nice :)

and for that cursor change: here (https://love2d.org/forums/viewtopic.php?f=4&t=4321&p=40527&hilit=cursor#p40559) it says to make the real mouse invisible and place your own sprite on the trackable coordinates of the mouse...
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: apcalc on March 21, 2012, 04:44:01 pm
Wow!  This is great, I don't know how I missed it before now! :)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on March 22, 2012, 07:05:20 am
Nick, I know I can do it that way, but I was looking for a more native approach. But thanks anyway :)

@apcalc, also thanks :)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on April 17, 2012, 02:08:29 pm
Topic split.

Well honestly we should all donate just a bit to pay jim a Prizm.
Seriously, he could make something up :)
:D

(On a little side note: http://bwns.be/jim/WEBspire/JSspire.html . Still many bugs and no user input, but you should get the idea)
(Also, sorry for going off topic :P )
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Adriweb on April 17, 2012, 02:10:24 pm
Also congratz for that JSspire, it's ridiculously awesome o_O
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: DJ Omnimaga on April 17, 2012, 02:46:23 pm
Awesome Jim. And I assume JSpire is for those who wants to try games directly into their browser? I wonder if in the future, an user could just upload a TI-Nspire file in the emulator and emulate it that way? Even better: a script to allow the emu to read Omni archives zip files and play tns files from there. (providing they're in Lua)

How is screen resolution handled by the way? Some Lua games might not look very great at resolutions other than 320x240.
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Adriweb on April 17, 2012, 02:49:43 pm
Yeah we plan to  fully integrate it within TI-Planet when it's done, I guess Omni can do that too !
Also PCSpire handles weel all kind of resolutions so that won't be a problem
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: DJ Omnimaga on April 17, 2012, 02:55:24 pm
Yeah. I assume it would require heavy PHP work from Omni staff part and modifying the download pages, which, sadly, would require a lot of time, which they lack.

Btw I notice the kubefield file is a js file. Does it means the games are ran through a Lua->Javascript converter prior launch?
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Chockosta on April 17, 2012, 03:03:43 pm
Wow, this is just awesome.
It would be also a good idea to add a "menu" key, since a lot of lua programs need it...

Really, congrats!
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: DJ Omnimaga on April 17, 2012, 03:05:54 pm
There's a keypad? ???
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Chockosta on April 17, 2012, 03:08:21 pm
There's no keypad in PCspire/JSspire, it only reacts to mouse/keybord input. (I think)
But there's no "menu" key on a keyboard, so no way to get the menu.

I thought it would be nice to add a "menu" button in the top right corner.
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: DJ Omnimaga on April 17, 2012, 03:09:23 pm
Oh ok, I thought you had a keypad showing up and on my side none did.

But no other key actually works for now anyway, even arrows and enter, so maybe controls are not implemented at all yet.
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on April 17, 2012, 04:19:09 pm
There isn't any key input support here yet.
It's just a PoC, when it's done it will have much more stuff.

The screen resolution will be 212*318 default, with options to change it.
Kubefield is a js file, and indeed I converted it in the beginning. But the end user will not notice anything about it (They will not need to convert lua files).

Currently it's a bit hard to open TNS files (lua files are no problem). This is because of the encryption, legal issues, and other stuff. But I'll look into it.
 
Now, eventually I'm planning to merge WEBspire, PCspire, nCreator and some other stuff together to form openSpire. openSpire will be an open source TI-Nspire software clone with aim on as much compatibility. There will be a PC version and a web version (and possibly mobile).
I have the knowledge to make it, just need the time. But it's a serious plan. 
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: DJ Omnimaga on April 17, 2012, 04:30:11 pm
Nice. I hope there's a Windows version eventually too, or at least a downloadable version of the HTML/JS one, for those with limited internet access or behind filters.
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: ExtendeD on April 17, 2012, 05:07:32 pm
Brilliant, once again :)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on April 17, 2012, 05:30:02 pm
DJ, I will try to make versions for all OS :)
The biggest issue is time :/

Thanks ExtendeD!
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: DJ Omnimaga on April 17, 2012, 05:35:45 pm
Well the thing is if you don't make a PC version but make an browser version like above, then that solves the lack of a PC version problem anyway, saving you time early on :P
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on April 19, 2012, 05:29:39 am
Ah, I see :)

Here is an updated version:
http://bwns.be/jim/WEBspire/JSspire.html

Key inputs work now so you can play the game. However, there is sometimes a little graphical glitch. The cause of this is the HTML5 canvas tag that sometimes glitches when drawing off the screen. Looking into that to fix it.
(Thank you shmibs for finding it)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jonius7 on April 19, 2012, 05:32:01 am
Noice, though I think that is an old version of Chockosta's Cubefield Lua game :D
And interesting developments for a browser version, as I was limited by your Linux scripts (I don't have Ubuntu installed atm as I did in the past)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on April 19, 2012, 05:33:49 am
old version?
It's the latest one IIRC.
The text isn't yet drown properly because I did not implement everything yet.
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jonius7 on April 19, 2012, 05:37:56 am
old version?
It's the latest one IIRC.
The text isn't yet drown properly because I did not implement everything yet.

Sorry I got it partially wrong. It just looked old because an old version I had had the player control as a square sprite whereas on the latest version it is an arrow sprite. I also forgot to account for later features such as Speed up every 1000 points and change it colour.
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on April 19, 2012, 05:40:01 am
Ah yes.
I currently draw a box instead of an image because I did not implement image stuff yet :P
But that shouldn't be too hard since I already made the image lib.

Edit
Should-->Shouldn't
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Adriweb on April 19, 2012, 08:00:25 am
shouldn't *

Also, gg for arrows support :D
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Chockosta on April 19, 2012, 08:08:06 am
This is awesome !
Cubefield is much more fluid with JSspire than with TINCS...
Really, this is amazing.

This will be great when it will be possible to play Lua games trough our browser... No more need to have a TI-Nspire!

And I have an idea to add math.eval()... The open-source CAS giac (AKA Xcas) can be used with the TI-Nspire/TI-68k syntax. Moreover, it is possible to use it through a web browser. (Demo (in french) (http://www.xcasenligne.fr/giac_online/demoGiacPhp.php))
But this would require a lot of work...

Anyway, keep up the great work!
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Adriweb on April 19, 2012, 08:10:53 am
Thanks for that online CAS, it maybe be used indeed, it's a good idea :)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on April 19, 2012, 08:54:57 am
Thanks :)

Chockosta, thanks a lot for that CAS! Was looking for something like that :)
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jonius7 on September 23, 2012, 01:03:57 am
This just doesn't seem to be working in LOVE 0.8. I've tried a lot of stuff, using both the zipped and installer versions of LOVE, and I've dragged the folder of PCSpire (from the zip file) onto Lua to run it.

It shows up with a flashing alternating white and black screen, stops responding and crashes.
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on September 23, 2012, 12:08:45 pm
0.8 wasn't out yet when I made PCspire, I made it for 0.7.2.
Love devs probably broke some compatibility.
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jonius7 on September 24, 2012, 02:21:49 am
Hmm Ok. I'll see if I can make it work in 0.7.2. And see what you can do with the changes in v0.8
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jonius7 on October 13, 2012, 08:30:23 pm
W8 this is still Linux only if I remember correctly? Then I've wasted my time using LOVE 0.7.2 and 0.8 trying to run it as it's still not working for me :(

The best result I can get is a flashing white and black window that's giving me epilepsy (jokes, no offence to anyone). The window is titled PCspire though.
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jim Bauwens on October 14, 2012, 02:34:26 am
PCspire was never Linux-only ;)
Very strange issue, I've tested it in all three major platforms.
Do you get any information if you run it from cmd ?
Title: Re: PCspire, run Nspire lua programs nativly on your pc
Post by: Jonius7 on October 18, 2012, 12:21:30 am
Haven't tried, but I'll see what it says.
Thank goodness it's cross-platform, I though it might not have been from somewhere I read.

EDIT: How can you run it from the commandline? It just runs normally like a normal exe.

Spoiler For Blather:

I eat you when this is not for windows. I need this SO bad  if I want to develop nspire lua programs (but I do not have an nspire xD)

Well I must've of remembered this and it stuck.

Oh there's no .love files it's just a folder with a whole bunch of .lua files and fonts. Should it be compiled I wonder?
@cyanophycean314, I'll shouldn't take too long before a release, as it's already quite progressed.

@alberthrocks, thanks! And yes, I will distribute it in .love files :)

Then again it shouldn't matter

This is definitely cross-platform, as this itself is also written in Lua! :D Windows, Linux, Mac OS X - you name it :)
(I'm assuming there will be binary distributions: https://love2d.org/wiki/Game_Distribution)

This is some amazing work! :D This will truly unlock the world of Lua for me, and possibly for countless others as well! :D


Well I ran from the command line like this "love pcspire" (that's what I named the folder). Exactly the same result.