Author Topic: PCspire, run Nspire lua programs nativly on your pc  (Read 31892 times)

0 Members and 1 Guest are viewing this topic.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: PCspire, run Nspire lua programs nativly on your pc
« Reply #15 on: March 16, 2012, 05:31:53 am »
jim: Er, I should maybe mention that you have to include the löve program :)
I'm not a nerd but I pretend:

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: PCspire, run Nspire lua programs nativly on your pc
« Reply #16 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.

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: PCspire, run Nspire lua programs nativly on your pc
« Reply #17 on: March 16, 2012, 09:49:08 am »
Wow, this looks really nice Jim! =) The fact that it is cross platform is great too!
« Last Edit: March 16, 2012, 09:49:46 am by Art_of_camelot »

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: PCspire, run Nspire lua programs nativly on your pc
« Reply #18 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

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: PCspire, run Nspire lua programs nativly on your pc
« Reply #19 on: March 16, 2012, 10:32:22 am »
You have to download Löve and drag the .love file over the Löve executable.
I'm not a nerd but I pretend:

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: PCspire, run Nspire lua programs nativly on your pc
« Reply #20 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...

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: PCspire, run Nspire lua programs nativly on your pc
« Reply #21 on: March 16, 2012, 10:35:02 am »
Erm, Löve? http://www.love2d.org/
PCspire isnt out yet.
I'm not a nerd but I pretend:

Offline alberthrocks

  • Moderator
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 876
  • Rating: +103/-10
    • View Profile
Re: PCspire, run Nspire lua programs nativly on your pc
« Reply #22 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, 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)
« Last Edit: March 16, 2012, 11:07:57 am by alberthrocks »
Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/


Proud member of ClrHome!

Miss my old signature? Here it is!
Spoiler For Signature:
Alternate "New" IRC post notification bot (Newy) down? Go here to reset it! http://withg.org/albert/cpuhero/

Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/

Activity remains limited due to busyness from school et al. Sorry! :( Feel free to PM, email, or if you know me well enough, FB me if you have a question/concern. :)

Don't expect me to be online 24/7 until summer. Contact me via FB if you feel it's urgent.


Proud member of ClrHome!

Spoiler For "My Projects! :D":
Projects:

Computer/Web/IRC Projects:
C______c: 0% done (Doing planning and trying to not forget it :P)
A_____m: 40% done (Need to develop a sophisticated process queue, and a pretty web GUI)
AtomBot v3.0: 0% done (Planning stage, may do a litmus test of developer wants in the future)
IdeaFrenzy: 0% done (Planning and trying to not forget it :P)
wxWabbitemu: 40% done (NEED MOAR FEATURES :P)

Calculator Projects:
M__ C_____ (an A____ _____ clone): 0% done (Need to figure out physics and Axe)
C2I: 0% done (planning, checking the demand for it, and dreaming :P)

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: PCspire, run Nspire lua programs nativly on your pc
« Reply #23 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 :)

Offline Chockosta

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 447
  • Rating: +169/-6
    • View Profile
Re: PCspire, run Nspire lua programs nativly on your pc
« Reply #24 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 ?

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: PCspire, run Nspire lua programs nativly on your pc
« Reply #25 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 ^^

Offline Chockosta

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 447
  • Rating: +169/-6
    • View Profile
Re: PCspire, run Nspire lua programs nativly on your pc
« Reply #26 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

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: PCspire, run Nspire lua programs nativly on your pc
« Reply #27 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!)
« Last Edit: March 16, 2012, 04:03:16 pm by jimbauwens »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: PCspire, run Nspire lua programs nativly on your pc
« Reply #28 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)

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: PCspire, run Nspire lua programs nativly on your pc
« Reply #29 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.
« Last Edit: March 16, 2012, 04:05:21 pm by jimbauwens »