- ComputerCraft | Programmable Computers for Minecraft
- → The Crazy Phoenix's Content
The Crazy Phoenix's Content
There have been 73 items by The Crazy Phoenix (Search limited from 10-February 22)
#268506 SBox | Sandboxing utility
Posted by
The Crazy Phoenix
on 24 July 2017 - 03:30 PM
in
APIs and Utilities
In other cases, the sandbox fails if using "../rom/../<path>" (can be used to access "/<path>")
#268507 litPix - Little Pixels without Limits [v0.8]
Posted by
The Crazy Phoenix
on 24 July 2017 - 03:41 PM
in
APIs and Utilities
#268509 Secure File System [sfs]
Posted by
The Crazy Phoenix
on 24 July 2017 - 04:23 PM
in
APIs and Utilities
Use "error(msg, index)" instead of just "error(msg)" to make it easier for users to debug their programs.
The screen appears to flicker when the program is active.
Attempting to run a file with no read access crashes the shell.
It is possible to set the user to root, granting full access regardless of what user was previously set.
getfenv(sfs.setOtherRead).start({userName = "root"})
The environments of other SFS API functions can also be used in that manner.
#268510 Quartz OS. True sandboxed users.
Posted by
The Crazy Phoenix
on 24 July 2017 - 04:32 PM
in
Operating Systems
MineRobber___T, on 06 July 2017 - 06:05 AM, said:
fs.isReadOnly is not checked by the other fs API functions, which means that even though the edit program doesn't work, the files can still be edited using fs.open.
#268539 help with a function
Posted by
The Crazy Phoenix
on 25 July 2017 - 10:22 AM
in
Ask a Pro
#268546 help with a function
Posted by
The Crazy Phoenix
on 25 July 2017 - 07:08 PM
in
Ask a Pro
if fuel.getAnalogInput(fuelside) > 14 then mainpwr.setAnalogOutput(mainpwrsde, 0) elseif temp.getAnalogInput(tempsd) > 10 or sat.getAnalogInput(satsd) < 3 then mainpwr.setAnalogOutput(mainpwrsde, 0) elseif oldfuel < fuel.getAnalogInput(fuelside) then for i = 1, 15 do [...] end end
You should check if the above is written the way you want it to behave.
If the issue still exists, check that the sleep just before the break has the right delay.
I recommend that you fix your indentation to make your code easier to read.
#268560 Control redstone over wireless modems!
Posted by
The Crazy Phoenix
on 25 July 2017 - 11:14 PM
in
APIs and Utilities
For example, if you were to generate a server ID from the sync key (which you'd keep secret), you could then create a single hash of the message, sync key and some sort of timestamp (to prevent someone from retransmitting a previously transmitted message).
Then all the server needs to do is hash the received message with its copy of the sync key and compare it to the received hash to verify that the sender can be trusted.
It may not be as good as one-way key encryption, but it's certainly better than nothing and very easy to implement. There are plenty of SHA-1 implementations on these forums.
#268562 Copy _ENV
Posted by
The Crazy Phoenix
on 25 July 2017 - 11:53 PM
in
Ask a Pro
Ideally this would be achieved without ever touching the _G environment (and thankfully it can).
If you need a more in-depth explanation for any of the following code, feel free to ask.
env = {fs = {...}}
setmetatable(env, {__index = _G})
--# For every function
env[name] = function(...)
_ENV = env
--# Keep in mind that anything that isn't local or global (i.e. something in the previous _ENV) cannot be accessed beyond this point
return func(...)
end
To get the APIs to use your environment, you'd need to reload them with the proper environment.
For example, if I wanted to load the settings API into the environment:
local settings_env = {}
setmetatable(settings_env, {__index = env})
local func, err = loadfile("/rom/apis/settings", settings_env)
if func then
--# Call the function in a way that the error will not terminate the program
local status, err = pcall(func)
if status then
settings_env._ENV = nil
env.settings = settings_env
else
--# Runtime error
printError(err)
end
else
--# Compile error
printError(err)
end
Both these solutions still don't work with os.run or loadfile, but there's a nice workaround for that.
env.os.run = load(string.dump(os.run), "filename", "t", env) env.loadfile = load(string.dump(os.run), "filename", "t", env)
#268564 Corrupt-A-Wish!
Posted by
The Crazy Phoenix
on 26 July 2017 - 12:35 AM
in
Forum Games
I wish there were no desensitization to positive feelings and any form of entertainment were no less effective than it currently is.
#268565 How to easily anonymize yourself.
Posted by
The Crazy Phoenix
on 26 July 2017 - 12:50 AM
in
Tutorials
Sure, you could use pcall to catch any potential errors, but it's still safer to use peripheral.call/modem.
#268581 Copy _ENV
Posted by
The Crazy Phoenix
on 26 July 2017 - 09:14 AM
in
Ask a Pro
Metatables are still vulnerable to getmetatable(_ENV).__index though, so you should also set "__metatable = {}" to force getmetatable to return the table {} and setmetatable to error.
#268586 help with buttons
Posted by
The Crazy Phoenix
on 26 July 2017 - 11:57 AM
in
Ask a Pro
If you're only planning on listening to the "mouse_click" event, use os.pullEvent("mouse_click") so that you don't have to manually filter events.
The given snippet of code won't compile because there are 2 "end" statements too many.
#268591 Corrupt-A-Wish!
Posted by
The Crazy Phoenix
on 26 July 2017 - 05:17 PM
in
Forum Games
I wish I could come up with a wish that does not involve coming up with wishes.
#268597 Temporarily change your computer ID and version string!
Posted by
The Crazy Phoenix
on 26 July 2017 - 11:32 PM
in
APIs and Utilities
#268608 Textpaint - A better Paint Program
Posted by
The Crazy Phoenix
on 27 July 2017 - 12:41 PM
in
Programs
#268609 Corrupt-A-Wish!
Posted by
The Crazy Phoenix
on 27 July 2017 - 12:45 PM
in
Forum Games
I wish I didn't burnout any time I try working on any programming project that isn't small.
#268620 Just wanted to say thank you for the mod!
Posted by
The Crazy Phoenix
on 27 July 2017 - 06:10 PM
in
General
#268621 The Quartz Platform - IKTM [1.10.2] [Latest CC] [Other Mods] [Sponge] [GriefP...
Posted by
The Crazy Phoenix
on 27 July 2017 - 06:15 PM
in
Servers
#268630 Corrupt-A-Wish!
Posted by
The Crazy Phoenix
on 28 July 2017 - 02:35 PM
in
Forum Games
I wish I could find something to do whenever I'm bored.
#268632 rednet:87: Expected number
Posted by
The Crazy Phoenix
on 28 July 2017 - 02:39 PM
in
Ask a Pro
Modems only need to be opened for receiving, you don't need to open them for sending.
tonumber("connect") is nil, that's the cause of the error. "connect" is not a valid string representation of a number
#268644 netNav - Networked mapping system and turtle pathfinding
Posted by
The Crazy Phoenix
on 28 July 2017 - 09:26 PM
in
Programs
blunty666, on 28 July 2017 - 05:05 PM, said:
Creator, on 23 December 2016 - 11:52 PM, said:
Sorry I completely missed this post!
It's just the A* algorithm but in 3 dimensions, so instead of just looking forward, back, left, and right, it also looks up and down when looking at which path to take.
It's not a straight forward implementation of A* though, it actually starts searching from both the start and end goals at the same time (essentially runs two instances of the A* algorithm), and detects when the two paths meet which ends up being the optimal path between the two points. It does all the calculation in one thread, but switches execution between the two algorithms when it notices the open nodes jumping around a lot (ie when it is not searching down a continuous path but is searching through lots of very different options). This helps it to find a path quicker when either the start or goal point is in a very complicated area and not in open space - there is a more mathematical explanation for why this is quicker if you want it!).
The other custom part of the algorithm is the heuristic it uses for tie breaking, it is set up to prefer going in straight lines instead of diagonals as they end up being quicker when you factor in the time it takes for the turtle to turn.
In terms of mapping the environment, the turtles all have 2 maps they use to determine the best path. The shared map that all turtles update is used as more of a suggestion of the best path - if a lot of turtles keep finding an object at the same point the value of that point in the shared map will keep increasing, so the turtles become less likely to try and go there. Then all turtles also maintain a local map that gets wiped between each call to netNav.goto, this is used to record obstacles that the turtle has ran into in this pathfinding session, so if they find an obstacle it gets recorded in the local map and the turtle will not attempt to go to that point again in that pathfinding session.
Hope that sheds a bit more light on it!? I will try and write all this down in a more ordered format at some point, just to remind myself how it works!!!
Doesn't A*'s design make accounting for turns simpler by adjusting the cost based on the turtle's facing?
I'd also be interested in the explanation as to why your approach is faster than simply pathfinding from the destination to the current location.
#268667 Message remote execution
Posted by
The Crazy Phoenix
on 29 July 2017 - 11:20 PM
in
Ask a Pro
loadstring(message)()/thread
loadstring(message) creates a function using the code inside the message variable, and the "()" following it calls that function.
If you don't want an error to crash your program, you can use pcall to invoke the loaded string instead. pcall will catch the error (it's basically how the Shell and Lua programs catch errors)
local ok, err = pcall(loadstring(message)) if not ok then -- There was an error calling the function. printError(err) end
If the string does not compile, then loadstring will return nil. All that needs to be done is verify that it isn't nil before attempting to call the function.
local func, err = loadstring(message) if func ~= nil then local ok, err = pcall(func) if not ok then -- Runtime error printError(err) end else -- Compilation error printError(err) end
#268689 Turtle bomber
Posted by
The Crazy Phoenix
on 30 July 2017 - 12:58 PM
in
Ask a Pro
#268698 Opus OS
Posted by
The Crazy Phoenix
on 31 July 2017 - 01:54 AM
in
Operating Systems
Homedog, on 30 July 2017 - 07:32 PM, said:
The turtles track their current position and facing as they move around (by checking whether the movement succeeded).
This information can be used for dynamic GPS hosts (which may be what's used for the "follow" command), as well as instructing the turtle where to go.
All it takes at setup is to feed the turtle its coordinates (manually or through GPS) and facing (manually or by moving the turtle and using GPS again).
#268704 rednet:87: Expected number
Posted by
The Crazy Phoenix
on 31 July 2017 - 11:49 AM
in
Ask a Pro
Feolthanos, on 31 July 2017 - 11:00 AM, said:
You could create a file that tracks the number, but that'd mean that the program breaks if you tamper with the save data.
Instead, try using fs.complete("user#", dir) and then using the length operator to count how many files start with "user#".
Then, to make sure, verify that the next index exists, and as long as it doesn't, keep incrementing.
In other words...
local files = fs.complete("user#", dir)
local index = #files + 1
while (fs.exists("user#"..index)) do
index = index + 1
end
- ComputerCraft | Programmable Computers for Minecraft
- → The Crazy Phoenix's Content


