Jump to content


electrodude512's Content

There have been 60 items by electrodude512 (Search limited from 10-February 22)


By content type

See this member's


Sort by                Order  

#195302 Lua

Posted by electrodude512 on 05 October 2014 - 10:41 PM in General

View Postmistertimn, on 05 October 2014 - 07:14 PM, said:

I write Lua scripts in Sublime Text 2 on my Mac, and you can just execute the scripts in Terminal. Just navigate to the directory where you have your script with 'cd <directory>' and run it with 'lua <filename>'.

But you have to install lua before that will work. Also, you might want lua 5.1 and not 5.2, because that's what CC uses.



#193557 Turtle additions

Posted by electrodude512 on 14 September 2014 - 06:50 PM in Suggestions

View PostBomb Bloke, on 09 September 2014 - 12:09 PM, said:

That has less to do with the turtle's functions as it does with funkiness in how the Lua interpreter handles functions when using that sort of syntax within certain code block structures. Or ComputerCraft's Lua interpretor, anyways - that being an outdated version of LuaJ. Whatever repl.it uses has the same issue.

I've been pretty annoyed by this before as well. But, for once, it's not LuaJ's fault.

$ lua
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> print('a') and print('b')
stdin:1: unexpected symbol near 'and'
>

The standard Lua 5.2.3 interpreter doesn't even support it. Just do what Lyqyd says with the local _ = stuff



#192847 Out of Bounds

Posted by electrodude512 on 02 September 2014 - 05:21 PM in Ask a Pro

I've gotten this error many times. It means stack overflow, right? Then why the 32? The maximum stack depth is surely greater than 32?



#192846 Define custom characters

Posted by electrodude512 on 02 September 2014 - 05:18 PM in Suggestions

View PostSebra, on 01 September 2014 - 08:09 PM, said:

This would not work in multitasking environment, where you can switch between different font changing programs and even have them run in windows.
But why not to add such fun bugs? ;)
Yes it would work. The window API would just have to add a virtualization layer to worry about it and translate custom character IDs. For non-overlapping windows, there might be a problem when there are more than a total of 256 characters.

And some people seemed they wanted these functions in textutils. They would have to go in term so they could be independent per terminal (and window).



#192789 CC + OpenCCSensors Space Station with Oxygen Network

Posted by electrodude512 on 01 September 2014 - 06:15 PM in Media

Oh dear. Now I'll have to add Galacticraft to my server.



#192741 Run code "in background"

Posted by electrodude512 on 01 September 2014 - 02:44 AM in Tutorials

You might want to put your function in a pcall so you can restore the real coroutine.yield in case the function dies, so the whole computer doesn't crash.



#192738 Define custom characters

Posted by electrodude512 on 01 September 2014 - 01:54 AM in Suggestions

Or you could pass it a character and use string.byte if you wanted a number. It doesn't really matter, and if it gets done and you think it's done the wrong way you can make your own function that calls the real one with string.byte or string.char
function textutils.setPixelNum(charMap, num)
  return textutils.setPixelChar(charMap, string.char(num))
end
or
function textutils.setPixelChar(charMap, char)
  return textutils.setPixelNum(charMap, string.byte(char))
end


Custom characters should be per-computer (and per-monitor) but should only work on advanced computers. Global custom characters wouldn't make any sense at all. I think you should be able to redefine any character, even normal characters, but that there should be a function to reset all normally printable characters (or all characters, for that matter). In the case of texturepacks, they should be normally be ignored (i.e. assume the default one is in use), but there should probably be a function to get the name of the current texture pack. For HD texturepacks, there could be a function to get the resolution of the texturepack, which would influence the maximum resolution of a custom character. But HD texturepack support would probably overcomplicate everything.



#187352 [1.63] string.format("a%-2sc", "b") doesn't pad spaces

Posted by electrodude512 on 10 July 2014 - 12:16 AM in Bugs

View PostLyqyd, on 09 July 2014 - 11:56 PM, said:

Adding a differently broken string.format wouldn't help anything.
OK, then I'll add a fully standards-compliant implementation instead of one that only adds padding. I might not be able to add it any time soon though, because I'll be busy with real life and I'll want to debug it before posting it. However, I can write that padding doesn't work without posting a fixed version as soon as I get wiki edit privileges.



#187330 [1.63] string.format("a%-2sc", "b") doesn't pad spaces

Posted by electrodude512 on 09 July 2014 - 10:02 PM in Bugs

I requested wiki edit priveleges on the wiki edit privileges page. In case a moderator sees this post before my post on that page, my wiki username is Electrodude512. I'll add how padding is broken and I'll put my above example and probably also a fully functional (or closer to fully functional) string.format (but in lua so slower) because I'm about to write one anyway.



#187298 [1.63] string.format("a%-2sc", "b") doesn't pad spaces

Posted by electrodude512 on 09 July 2014 - 06:52 PM in Bugs

Version:
ComputerCraft 1.63 on Minecraft 1.6.4

Description:
string.format("a%-2sc", "b") returns "abc"

This is probably a LuaJ bug. Is it fixable, or should it be added to the list of broken string functions at http://computercraft...tring_%28API%29?

Expected Result:
string.format("a%-2sc", "b") returns "ab c"

Reproduction Steps:
ComputerCraft:
lua> string.format("a%-2sc", "b")
abc

Lua 5.1
bash $ lua
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> =string.format("a%-2sc", "b")
ab c
>



#187221 Bundled Cable API AND Direct Support

Posted by electrodude512 on 08 July 2014 - 05:48 PM in Suggestions

View PostEngineer, on 08 July 2014 - 11:18 AM, said:

Because ComputerCraft is about computers and not redstone.

I disagree. It's about both. Computers would have little practical use (i.e. automation as opposed to pong) without a good redstone interface. Sure, turtles can move stuff around (and I think they can even flip levers), and you can use dedicated computers just for redstone outputs, but many computerized things are much easier with bundled cables, like controlling lots of train switches, actuating lots of pistons, and turning different engines on and off as necessary.



#186413 Need help on opening txt file

Posted by electrodude512 on 01 July 2014 - 04:40 PM in Ask a Pro

Line 15 says "disk_fi:close()" when you meant "disk_f:close()". Get rid of the i in disk_fi and it should work.



#186166 make pocket computers stay on while in non-player entities (such as minecarts)

Posted by electrodude512 on 30 June 2014 - 03:08 AM in Suggestions

But if I lied properly to the pocket computer, it would work without Dan200 having to do anything?



#185709 make pocket computers stay on while in non-player entities (such as minecarts)

Posted by electrodude512 on 26 June 2014 - 08:19 PM in Suggestions

So if I make a special chest minecart that notifies items it contains about location changes and such, then my pocket computer will stay on and GPS will work?



#185708 AE Serializing Item Data for transfer over rednet!

Posted by electrodude512 on 26 June 2014 - 08:16 PM in Suggestions

/me broadcasts a diamond to 100 other computers, now I have 100 diamonds!



#185304 Communication Ideas

Posted by electrodude512 on 23 June 2014 - 09:35 PM in Suggestions

View PostKingofGamesYami, on 23 June 2014 - 02:03 PM, said:

My idea with antennas is that we don't have to put the computer higher, we can keep it low enough that we don't need to.

What's wrong with placing computers up high? If you don't feel like building a 1x1 tower all the way there, have a turtle go up and place the computer for you, after installing a startup file on the computer to be a repeater and allow remote logins (so you don't have to go up there if you want to change something).



#184600 make pocket computers stay on while in non-player entities (such as minecarts)

Posted by electrodude512 on 19 June 2014 - 02:53 AM in Suggestions

Can you please make it so pocket computers don't turn off when in the inventory of a non-player entity such as a minecart?

For a while now, I've been trying to make an automatic train routing system. I was going to just make a rule that the first cart of every train has to be a chest cart, and there has to be a floppy in the first slot with routing information, but I've found this to be nearly impractical. When pocket computers were added, I realized that they were the perfect solution to my problem - I wouldn't have to stop the train so a turtle could unload the floppy, put it in a disk drive, read it, and put it back - the switches could be set up while the train was still far away, and the train could just run right through without stopping (supposing there was no congestion, but that shouldn't be a problem since it's a small server). Unfortunately, my plans were ruined when I realized that pocket computers turn off when in any inventory other than a player inventory.

I can understand why it might not be possible to keep them on while in tile entities, but it would seem that since EntityPlayer is (indirectly) a subclass of Entity, it should be possible to keep the position of a pocket computer updated by just keeping a reference to its containing Entity. The only problem I can see with this is that, while player names never change, entity IDs change (or used to change) across world reloads, so they wouldn't be able to automatically start up again on world load, but still, from the little I know, it should be possible to make pocket computers stay on while in chest minecarts.

electrodude



#182416 Wired Turtles

Posted by electrodude512 on 05 June 2014 - 08:54 PM in Suggestions

/gamerule mobGriefing false
will make it so creepers and other mobs can't break your stuff. Only turn on mobs while you're in the End.



#182415 CMYK Printer

Posted by electrodude512 on 05 June 2014 - 08:48 PM in Suggestions

Or there could just be an Advanced Printer that has 16 slots for all 16 dyes, but that would need non-integer item counts (or tank fill bar thingies) in case you print half of a page in one color and the other half in another.



#182414 Can you pass a variable through to an API?

Posted by electrodude512 on 05 June 2014 - 08:45 PM in Ask a Pro

You can also put your value into a table, because tables are passed by reference
local x = {val=2}

function foo(x)
  x.val = x.val + 1
end

foo(x)

print(x.val) --prints 3



#176958 Piston placement

Posted by electrodude512 on 05 May 2014 - 07:34 PM in Suggestions

The fact that wrenches can turn pistons is probably the reason that making pistons always face up was a viable option.



#176957 Create subforum for peripherals and turtle upgrades for the latest version of...

Posted by electrodude512 on 05 May 2014 - 07:31 PM in Forum Discussion

Individual thread movement would only happen in one direction, from the outdated subforum to the current subforum. Threads wouldn't be moved to the outdated subforum individually - instead, the two subforums would just be merged together as if the current subforum was being discontinued (IP.Board can merge forums, right?), and then a new, empty current subforum would be created.

I don't have to write the script - AfterLifeLochie or someone could probably do it. I'm just saying that it's probably simple enough so that I could write it in a reasonable amount of time. It's just a bunch of MySQL operations (or IP.Board PHP function calls if IP.Board supports that, which it hopefully does).

About searching, people would just search the main Peripherals and Turtle Upgrades subforum, which would have subforums for current and outdated ones. Maybe the outdated ones could go inside the current ones and you would make the current one the main one. Is it possible to make a virtual subforum (all addons) that's really the contents of two other subforums (current and outdated addons) combined?


Instead of all this, how about marking threads for currentness with an tag on the thread listing that shows if a addon is current or not? They would all change to outdated when a CC update comes out, and the mod author would have to manually put it back to current when he updates his mod. This could be as simple as messing with tags in the thread title. Changing thread tags can already be done by the opening poster of a thread, so the script would just have to look for every "current" tag and replace it with "outdated".



#176515 Available Block/Item IDs

Posted by electrodude512 on 03 May 2014 - 10:46 PM in General

(all pre 1.7): Blocks can have IDs from 0-4095, but you should only use 256-4095. Items can have IDs from 0-65536, but you shouldn't use some number of them at the beginning that I can't remember. If a block seems to have an ID greater than 4095, that's because the item has a different ID than the block - the item's ID is greater than 4095 but the block's ID is between 256-4065.

Forge does funny shift-by-256 stuff, so these IDs might all be shifted - you may have seen a block ID with id 4200 = 3944+256.



#176511 Create subforum for peripherals and turtle upgrades for the latest version of...

Posted by electrodude512 on 03 May 2014 - 10:35 PM in Forum Discussion

Thread movement only has to happen in one direction. When CC is upgraded, all addons would be dumped from the outdated subforum into the current subforum by simply merging the current and outdated subforums, which I assume the forum software lets you do, and creating a new subforum for current addons. This new subforum would be empty, as all addon mods inherently become outdated as soon as soon as the next version of CC is released. If and when mod authors update their mods, they would PM a moderator who would move it into the current addons subforum.

If you want to automate things, you could make a script on this website's server to merge the old subforums and make the new one. Dan200 or someone would just have to run it every time a new version of CC was released. Maybe mod authors could have a special page that would allow them to move their own thread from the outdated addons subforum to the current addons subforum so they don't have to bug a moderator every time they update their mod. Obviously, they would have to get this privilege from a moderator, who would just add their username and a link to their thread to a list somewhere. I could write the dumper script and maybe the mark-as-current script Soon™, but don't expect me to be able to do that for at least a few weeks.



#176359 Disable Turtles

Posted by electrodude512 on 02 May 2014 - 10:53 PM in Ask a Pro

Your method won't work. The turtle api will still exist. You have to add a line saying _G.turtle = nil to disable turtles from moving, and even that might not be enough