0

i will use images from defined calculator vars in TI nSpire LUA. Code in Script Editor:

platform.apilevel='1.0'
local img=(var.recall("img2"))
local i=image.new(img)

function on.paint(gc)
    gc:drawImage(i,10,10)
end

But Console gave me error in line 3: image must be PIXEL_BIT_SIZE-bits per pixel I have defined the var img2 as a string in Calculator app. When I paste the string in image.new(string) instead of img then it works, so the error is not the string...

Can someone please help me? I looked so many times for this problem, but i can't find any solutions.

  • what is the output if you `print(var.recall("img2"))` or `print(var.recallStr("img2"))` – Piglet Nov 02 '21 at 17:08
  • @Piglet the image string without this symbols at start and end " . But it also won't work if I use var.recallStr(). – TI.Software Nov 02 '21 at 17:46
  • @Piglet I see you are a german and me too. When it's ok for you than you can help me in german. – TI.Software Nov 02 '21 at 18:38
  • check wether the copy/pasted string that works actually equals var.recall("img2"). if that is the case it should work. if it does not work there must be a difference.. – Piglet Nov 02 '21 at 20:21
  • @Piglet But do you know how I can use image strings from calculator to use it in Lua editor? Just like a command? I hear about the commands load and loadstring, but I don't know how to use them. – TI.Software Nov 03 '21 at 15:46
  • if you don't know how to use those commands refer to the manual which explains how to use them. the question remains, why the two strings differ and what the difference is. – Piglet Nov 03 '21 at 17:09
  • @Piglet So do you know I can use image strings from calculator in script or not? I searched very long but don't find an answer... – TI.Software Nov 03 '21 at 18:51
  • if img2 is a string that's the way to get it. is there any particular reason why you refuse to provide the requested information? I'm just trying to ensure you debug your problem properly. if you don't check the difference between those two strings you won't get any further. if it works with the copied string but not with the recalled string there must be a difference between the two strings. – Piglet Nov 03 '21 at 20:23
  • @Piglet So, the output of print(var.recall("img2")) is not a string, only the number. The output of print(var.recallStr("img2")) is the same string that works when i put the string in the script editor. – TI.Software Nov 04 '21 at 15:04
  • so it should work using `var.recallStr`. befor you said it wouldn't work using that function. again, if it is the same string it MUST work. if it does not work it is not the SAME string. – Piglet Nov 04 '21 at 15:44
  • Mmh, this string is very long, eventually recall it not the full string. I'll check it out. – TI.Software Nov 04 '21 at 16:33
  • I told you to check wether they are equal as in use the equality operator `==` and see if it resolves to true. Also that TI stuff is a commercial product. TI has great support and a even greater community forum. so if the strings are not the same you should ask TI what's going on. – Piglet Nov 04 '21 at 16:48
  • @Piglet Yeah, I try it now. I defined v1 to the image string and v2 to var.recall(img_string). In function on.paint(gc) I use the operator == but it shows that the strings aren't the same, also when I tried var.recallStr . If I type in gc:drawString(type(v1),20,20) then it tell me at both vars that there are strings. But if I type in gc:drawString(v1,40,40) then it draw my only the 2nd (the recall) string. For the first it draw only a letter-big rectangle. And from numbers and symbols are both the same, but I don't know why it don't draw the first string from script editor... – TI.Software Nov 05 '21 at 08:09

0 Answers0