←  Ask a Pro

ComputerCraft | Programmable Computers for Minecraft

»

Problem printing strings

DarkEyeDragon's Photo DarkEyeDragon 28 Jun 2016

Hello! I'm not sure if this should be posted in the bug section, since there's nothing wrong with my code.

I got this weird issue where my computer won't let me print a string. at all.

Posted Image

NOTE: I put everything in comments to make sure that is the issue.
and get this: magreader:2: attempt to call string.
Well obviously its trying to call a string...
and when i tried to put this code on pastebin to show you guys, i got this error:

Posted Image

I made a new program and tried the same. Same error.


this is computercraft 1.74 in the Tekkit Legends modpack.
It worked fine before. Just now started acting up.


Edit: Its only that one computer. I'm very confused on this xD

Edit 2: Anything related to strings in that computer is messed up.
Posted Image

Yet another edit: I was just reading trough the forums and saw this: "string.format is broken in LuaJ, which CC uses. Instead, use string.match, or string.sub." -KingofGamesYami
original post: http://www.computerc...27024-decimals/

And i did try to use the string.format as i couldn't get my other part of code to work since it said it wasn't a string. Might that be the issue here?

Seems like the code i'm using to figure out how to use string.len is causing it to break here.
Edited by DarkEyeDragon, 28 June 2016 - 01:43 PM.
Quote

Lupus590's Photo Lupus590 28 Jun 2016

I have a suspicion that something in a startup file has broken something. Try your code on a fresh computer, if that doesn't work then disable your resource pack and see if that works. Otherwise, have you edited your computercraft.jar?

Edit: Good spot Selim (see below)
Edited by Lupus590, 28 June 2016 - 02:38 PM.
Quote

Selim's Photo Selim 28 Jun 2016

I see the problem already. In the first screenshot, you are setting the value of print to "String length ok!". Due to this, whenever a script attempts to call print, it is calling a string, hence the "attempt to call string" error. Changing the value once changed the global variable and then requires a reboot to fix. If the script was run once, it will not fix until said reboot.
Edited by Selim, 28 June 2016 - 02:22 PM.
Quote

DarkEyeDragon's Photo DarkEyeDragon 28 Jun 2016

View PostSelim, on 28 June 2016 - 02:20 PM, said:

I see the problem already. In the first screenshot, you are setting the value of print to "String length ok!". Due to this, whenever a script attempts to call print, it is calling a string, hence the "attempt to call string" error. Changing the value once changed the global variable and then requires a reboot to fix. If the script was run once, it will not fix until said reboot.
omg wow.... i never noticed the = there... xD Thanks for the heads up. The fail is big in this one. very odd non the less xD
Quote