Omnimaga

Calculator Community => TI Calculators => General Calculator Help => Topic started by: annoyingcalc on September 02, 2012, 05:59:12 pm

Title: ti-nspire student software acting up PLEASE HELP!
Post by: annoyingcalc on September 02, 2012, 05:59:12 pm
My nspire software wont load my program im trying it on the emulator in it and if I drag and drop the program on to the emulator it freezes and so does windows explorer. I try loading it from file>open it still crashes nspire software! HELP
Title: Re: ti-nspire student software acting up
Post by: annoyingcalc on September 02, 2012, 08:07:41 pm
*bump* Id like help! I cant test my programs untill this is fixed!
Title: Re: ti-nspire student software acting up
Post by: DJ Omnimaga on September 02, 2012, 08:28:09 pm
Are those programs written in Lua/BASIC? Because if they're Ndless files (or Lua for an outdated Student Software version), then that might be why. (The software doesn't run Ndless files and even Lua programs will have troubles running sometimes, such as Nyan Cat)
Title: Re: ti-nspire student software acting up
Post by: annoyingcalc on September 02, 2012, 08:36:36 pm
I am using lua for 3.1 with a 3.1 student software
Title: Re: ti-nspire student software acting up
Post by: annoyingcalc on September 02, 2012, 11:52:12 pm
im posting the .lua file to see if anyone else has this problem
Title: Re: ti-nspire student software acting up PLEASE HELP!
Post by: Adriweb on September 03, 2012, 05:21:43 am
Oh wow, do NOT ever do image stuff in a loop, that's what causing your issue ;-)

Here's how you want to do it :
(after the 2 lines of images strings)

Code: [Select]
dx=50
dy=50

function on.paint(gc)
gc:drawImage(background,0,0)
gc:drawImage(duck,dx,dy)
end

function on.arrowKey(arrow)
if arrow == "right" then
dx = dx + 5
elseif arrow == "left" then
dx = dx - 5
elseif arrow == "up" then
dy = dy - 5
elseif arrow == "down" then
dy = dy + 5
end
platform.window:invalidate()
end

I suggest that you read Inspired-Lua's (http://www.inspired-lua.org/2012/01/starting-in-lua/) tutorials and Steve Arnold's (http://www.compasstech.com.au/TNS_Authoring/Scripting/) :)
They really well explain the basic concept of events, the base thing you need to understand first :)

Also, to have a full reference of the Nspire-Lua API, don't forget Inspired-Lua's wiki (http://wiki.inspired-lua.org) (based on (and improving) the official doc)

BTW, Levak and I have created a presentation some weeks ago : "Improving your Nspire-Lua skills" you would be interested in : http://tiplanet.org/forum/archives_voir.php?id=6720 (clic on "Télécharger") - you might prefer the powerpoint version)
Title: Re: ti-nspire student software acting up PLEASE HELP!
Post by: annoyingcalc on September 03, 2012, 12:10:18 pm
Wow! Thanks adriweb,but I want it to be an ai not the character im making duck hunt!
Title: Re: ti-nspire student software acting up PLEASE HELP!
Post by: someone on September 03, 2012, 07:29:57 pm
Then, instead of using the function on.arrowKey(arrow), create one where you calculate the move, e.g:

Code: [Select]
function AI()
    --place your Artificial Intelligence code here

    --if direction==1 then
    --dx=dx-1
    --dy=dy-1
    --else
    --dx=dx+1
    --dy=dy+1
    --end
    --if dx==0 then
    --direction=1
    --end
    --if dy==240 then
    --direction=0
    --end
end

BTW, I see that you use an image from the NES & since the resolution is smaller, it will look awkward, so I would suggest to draw the rest of the background, this code would do:

Code: [Select]
function on.resize(width, height)
    ww = width
    wh = height
end

function on.paint(gc)
    -- Paint background (sky)
    gc:setColorRGB(96, 176, 248)
    gc:fillRect(0, 0, ww, wh)
   
    -- Paint floor (dirt)
    gc:setColorRGB(104, 104, 0)
    gc:fillRect(0, 175, ww, wh-175)
   
    gc:drawImage(background,0,0)
    gc:drawImage(duck,dx,dy)
    AI()
end

Maybe you'll want to place drawing the duck image inside the AI() function, because if you're going to move the image a lot, it will look like it warps. So, you'll need to add the parameter "gc"

Code: [Select]
function on.paint(gc)
    ...
    AI(gc)
end

function AI(gc)
    gc:drawImage(duck,dx,dy)
end
Title: Re: ti-nspire student software acting up PLEASE HELP!
Post by: annoyingcalc on September 03, 2012, 07:36:02 pm
Well, yes thats what im planning on doing with the background well it was >2,500 kb and I edited it wrongly.
Title: Re: ti-nspire student software acting up PLEASE HELP!
Post by: Adriweb on September 04, 2012, 11:59:11 am
Yeah try not to use > 15k :/