Author Topic: Jens' Script Editor - An on-calc lua editor  (Read 143902 times)

0 Members and 1 Guest are viewing this topic.

Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #225 on: January 08, 2017, 08:17:19 pm »
I just discovered this amazing editor! ;D But on on OS 3.1 pressing an arrow key on the editor page causes it to crash with error, "attempt to call a boolean value." I was able to fix it by deleting this part:
Code: [Select]
--disable specific arrow key events (to trigger the on.arrowKey(direction) event)
on.arrowUp=false
on.arrowDown=false
on.arrowRight=false
on.arrowLeft=false


Hey, thanks for pointing that out!
And that's great timing because I was about to release v2.2.1 this week, which also fixes some problems on the newer OS, so I'll also include a fix for that problem! Seems like the event caller was a bit dumb on OS 3.1  ;D  While your fix may work on OS3.1 (can't test it my self), it doesn't work on OS3.2+, but I found a different solution (make the event distributor (on's metatable) return nil when the event is one of the arrow key events)
But I'm wondering how nobody pointed this out yet; those lines have been there since v2.0A4!

Also: Thanks everyone for voting for POTY 2016! That's my 3rd win in a row, and I'm not even active anymore :w00t: Are there no Lua programmers anymore?! But I'm really glad that this project finally got the POTY, because I didn't make this editor just for fun (well at first I did), but as soon as I noticed that people are actually using it (some even bought a Nspire because of it), I really invested quite some work and time to polish it, so that it becomes a proper, polished on-calc editor as it is today. Sorry for leaving it in this now broken state for so long, I'll fix it soon!
Sorry for nonsense.

Projects:



Offline mdr1

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 303
  • Rating: +21/-2
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #226 on: January 08, 2017, 08:34:30 pm »
But I'm wondering how nobody pointed this out yet; those lines have been there since v2.0A4!
Well, if you look deeper in the topic, you will find that I had already reported such bugs:

Bug report: It is possible to go to the next item on the auto-completion menu with the return key but the arrow keys throw an "attempt to call a boolean value".

EDIT: And [Shift] + [down key] at any time throws the same error.

Thanks again for this editor!

Though, in JSE 2.0, there is no menu and clicking on the right key at the start menu (choose between a touchpad, clickpad or computer) throws the following error:



About the autompletion menu, should it be possible to auto-activate it? And some keywords like "function" or "for" should come with a space.

EDIT: I achieved to show the menu: just go to the home screen and then return to the document.

But I guess that most of Lua programmers use an OS > 3.1.



Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #227 on: January 12, 2017, 11:25:42 am »
Version 2.2.1 is now attached to the first post!

As said, it fixes problems on newer OS versions and a problem with the arrow keys on OS3.1, so you won't miss anything if you don't update if everything still works for you.  ;)
It's built now with the recent version of the student software, which somehow saves ~10KB; I hope OS3.1 still accepts it. Please report if it doesn't, then I'll do it with the student software 3.2 again.




@mdr1: Yes, indeed! Seems like I wasn't able to figure what the problem was, since the error occured outside of my program and no line number was given. Sorry that I forgot about it, it should be fixed now!
Sorry for nonsense.

Projects:



Offline 123outerme

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 458
  • Rating: +23/-0
  • Self-unpaid intern
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #228 on: January 23, 2017, 05:05:45 pm »
Hi Jens_K! You've made a really great script editor! Everything that I needed to know was either in the readme, self-explanatory, or understood through trial-and-error. I just can't figure out one thing; How do you run a script? I get that you have to press MENU > Code > Run, but I switch to the Run page and can't figure out what I'm doing! It says Click to run, but I click the center button, and nothing happens. Sometimes it returns an error that won't solve (even when pressing Menu and trying to let the editor solve the error). I'm on a Clickpad running OS 3.6, if that makes any difference at all.

Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #229 on: January 23, 2017, 06:38:14 pm »
Hi Jens_K! You've made a really great script editor! Everything that I needed to know was either in the readme, self-explanatory, or understood through trial-and-error. I just can't figure out one thing; How do you run a script? I get that you have to press MENU > Code > Run, but I switch to the Run page and can't figure out what I'm doing! It says Click to run, but I click the center button, and nothing happens. Sometimes it returns an error that won't solve (even when pressing Menu and trying to let the editor solve the error). I'm on a Clickpad running OS 3.6, if that makes any difference at all.

Hey, thanks for your feedback!
Seems like on the execution page (usually 1.2), you're focusing the console, but the script executor waits with execution until it has the focus itself. To change focus you can press ctrl + tab. The script executor should then have a black outline instead of a grey one.


I hope that helped. If it didn't, please send me your JSE file and some more infos about those errors! ;)

Sorry for nonsense.

Projects:



Offline 123outerme

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 458
  • Rating: +23/-0
  • Self-unpaid intern
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #230 on: January 23, 2017, 06:48:05 pm »
Hi Jens_K! You've made a really great script editor! Everything that I needed to know was either in the readme, self-explanatory, or understood through trial-and-error. I just can't figure out one thing; How do you run a script? I get that you have to press MENU > Code > Run, but I switch to the Run page and can't figure out what I'm doing! It says Click to run, but I click the center button, and nothing happens. Sometimes it returns an error that won't solve (even when pressing Menu and trying to let the editor solve the error). I'm on a Clickpad running OS 3.6, if that makes any difference at all.

Hey, thanks for your feedback!
Seems like on the execution page (usually 1.2), you're focusing the console, but the script executor waits with execution until it has the focus itself. To change focus you can press ctrl + tab. The script executor should then have a black outline instead of a grey one.


I hope that helped. If it didn't, please send me your JSE file and some more infos about those errors! ;)


Thank you so much Jens! That worked. Like I said, I'm enjoying using the editor! It really has a UI like one of a computer IDE.

Offline 123outerme

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 458
  • Rating: +23/-0
  • Self-unpaid intern
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #231 on: January 24, 2017, 05:46:37 pm »
Hi Jens, another issue I'm having: I'm trying to run a script with several parts. I can't seem to run this code, it always takes extremely long, presumably forever, to load page 1.2:
Code: [Select]
while true do
  function on.paint(gc)
    function textDisp(x,y,str)
      gc:drawString(str,x,y)
    end
  end
  platform.window.invalidate()
end
I've tested that whole code block without the while block, yet it doesn't work with the while. Is there a problem with my code? Or could it be the editor?
« Last Edit: January 24, 2017, 06:06:33 pm by 123outerme »

Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #232 on: January 25, 2017, 10:14:58 am »
Hi Jens, another issue I'm having: I'm trying to run a script with several parts. I can't seem to run this code, it always takes extremely long, presumably forever, to load page 1.2:
Code: [Select]
while true do
  function on.paint(gc)
    function textDisp(x,y,str)
      gc:drawString(str,x,y)
    end
  end
  platform.window.invalidate()
end
I've tested that whole code block without the while block, yet it doesn't work with the while. Is there a problem with my code? Or could it be the editor?
Nspire Lua programs have a different structure, they are event based; code outside of event handlers is usually only executed at the programs start and only for initialisation, which in your case takes an infinite amount of time due to your while loop, which is why your program doesn't respond.
You can see the available events in the Nspire API guide (on page 2.1).
To do what you wanted to do, you could use the timer to refresh the screen repeatingly:
Code: [Select]
x = 0
timer.start(0.01)
function on.timer()
  x = x + 1
  --update screen
  platform.window:invalidate()
end


function on.paint(gc)
  gc:drawString("hi", x % 300, 20)
end
But you don't have to update the screen repeatingly, whenever the Nspire forgets the screens content, it asks for an update by calling on.paint.
If you have further questions, you can ask here: https://www.omnimaga.org/lua-language/ or send me a PM  ;)
Sorry for nonsense.

Projects:



Offline 123outerme

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 458
  • Rating: +23/-0
  • Self-unpaid intern
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #233 on: January 25, 2017, 02:41:43 pm »
Hi Jens, another issue I'm having: I'm trying to run a script with several parts. I can't seem to run this code, it always takes extremely long, presumably forever, to load page 1.2:
Code: [Select]
while true do
  function on.paint(gc)
    function textDisp(x,y,str)
      gc:drawString(str,x,y)
    end
  end
  platform.window.invalidate()
end
I've tested that whole code block without the while block, yet it doesn't work with the while. Is there a problem with my code? Or could it be the editor?
Nspire Lua programs have a different structure, they are event based; code outside of event handlers is usually only executed at the programs start and only for initialisation, which in your case takes an infinite amount of time due to your while loop, which is why your program doesn't respond.
You can see the available events in the Nspire API guide (on page 2.1).
To do what you wanted to do, you could use the timer to refresh the screen repeatingly:
Code: [Select]
x = 0
timer.start(0.01)
function on.timer()
  x = x + 1
  --update screen
  platform.window:invalidate()
end


function on.paint(gc)
  gc:drawString("hi", x % 300, 20)
end
But you don't have to update the screen repeatingly, whenever the Nspire forgets the screens content, it asks for an update by calling on.paint.
If you have further questions, you can ask here: https://www.omnimaga.org/lua-language/ or send me a PM  ;)
Oh, okay, I didn't know they were entirely event-based. Thanks so much for your help, and sorry for the false report. I don't think I'll need any more help, but if I do, I'll ask somewhere; not here. Again, thanks!

Offline Chirlian

  • LV2 Member (Next: 40)
  • **
  • Posts: 22
  • Rating: +0/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #234 on: February 20, 2017, 05:05:39 pm »
Hi Jens,
now I am using your editor some time and I like to work with it very much. Now at this time I have to do with strings that fill the display (text game). Problem: no word wrap by the hard-/software. I found some code for this but like more the simple way: a lineal that shows me the cursor position. So here is my idea, if you like to add something to your editor: a position counter for lines and rows. It would be much easier to enter long strings with it and give a simple way to make word wrap w/o setting separators by hand. What do you think about this? Yes, I know that you closed the editor project. But maybe you like to take your code again in the hand...
cu
klaus

Offline neuronix

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 108
  • Rating: +0/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #235 on: May 11, 2019, 09:45:46 am »
Sorry for this necropost, but a good feature would be to add a list of all user defined variables with var key  ;)

Offline stevepetoskey

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 6
  • Rating: +1/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #236 on: December 07, 2019, 02:26:55 pm »
so It says use nSpaint to use images in the editor but I have no idea how to do that, or at least upload images using the editor in general. I assume that custom images in this editor is a thing, since this editor supports the image library.

Offline Jonson26

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 118
  • Rating: +1/-0
  • Follow cat! Do what cat! Into tree! Now!
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #237 on: December 15, 2019, 09:35:36 pm »
I kinda dabbled into this a while ago, so I think, yoou're supposed to use the clipboard.