Jump to content


Quintuple Agent's Content

There have been 112 items by Quintuple Agent (Search limited from 10-February 22)


By content type

See this member's


Sort by                Order  

#229939 MS Paint

Posted by Quintuple Agent on 13 August 2015 - 07:46 AM in Forum Games

Posted Image
Spoiler

Draw a wizard (Magical or installation)



#223908 string colon operator problem

Posted by Quintuple Agent on 30 June 2015 - 05:54 AM in Ask a Pro

Ok, well I found something strange to go along with this.
Using the code
Spoiler

Used it just to test everything that could mess up, When used in both ccemu and ingame it runs as expected the first time and returns
Spoiler

However, when ran another time after the computer has been restarted it returns
Spoiler

The strVar:upper is still being overwritten
When tested on a different computer without the script on it
string.upper works as it should however strVar:upper() returns "Sill messed up"
so it is being overwritten on the entire ComputerCraft global table
Edit: In 1 of my 6 test strVar:upper() was not overwritten on the other computer, however all other tests had the effect.
Edit2: So as I have tested it appears to work with only upper, I have also tested rep and lower and it does not affect the environment of other computers nor does it change strVar:rep() / strVar:lower() at all
Edit3: A video to prove I am not insane



#222542 attempt to index ? (a nil value)

Posted by Quintuple Agent on 22 June 2015 - 12:37 AM in Ask a Pro

Well if you need it, you could use this function to print out your data table
function checkData()
	for i,d in pairs(data) do
	 print("Indx:"..i..":"..type(d).." "..tostring(d))
end
end
and if for some reason the directories are not being created by fs.open, you can use this
function mkDirTree(tempDir)
    local full=""
    for cd in string.gmatch(tempDir,"%w+/") do
        full=full..cd
        if not fs.exists(full) then
            fs.makeDir(full)
            print("Made "..full)
        else
            print(full.." Exists")
        end
    end
return
end
Just make sure when you call it you do
mkDirTree("UserInfo/"..dir)
instead of
mkDirTree(dir)
(I forgot about that for like 3 minutes and was wondering why it was just creating client and not the UserInfo <_< )



#222534 attempt to index ? (a nil value)

Posted by Quintuple Agent on 21 June 2015 - 11:38 PM in Ask a Pro

View Postbbaayyeerr, on 21 June 2015 - 11:35 PM, said:

Got the error! :S Then i probably need to create the directory "client" before trying to write a file to it! ;)

Possibly. If that fixes it, that is great.
It is strange though, since doing fs.open("blah/halb/wubwub/test.jpg","w") should create all the of needed directories. It did when I ran your code, it created both UserInfo and UserInfo/client
Just wondering, what version of CC are you using?



#222532 attempt to index ? (a nil value)

Posted by Quintuple Agent on 21 June 2015 - 11:29 PM in Ask a Pro

Weird, I just ran
data={"this","is","a","test"}
dir = "client/"..data[4]
function saveUserInfo(dir)
		local username = {"user1", "user2", "user3"}  -- Here you need to define all default usernames
		local password = {"password1", "password2", "password3"}  -- Here you define what password each default user has

		local file = fs.open("UserInfo/"..dir, "w")
		print("Successfully opened file...") --debugging
		file.write(textutils.serialize(username).."\n"..textutils.serialize(password))
		file.close()
end
saveUserInfo(dir)
and it worked, created the correct directories UserInfo/client with the file inside and appeared as
{
   "user1",
   "user2",
   "user3",
}
{
   "password1",
   "password2",
   "password3",
}

View PostTheOddByte, on 21 June 2015 - 11:23 PM, said:

My guess is that it didn't return a file handle, to make sure it did, try this
Yah I started to wonder if he has something confliting like he has a file named UserInfo or UserInfo/client or a directory inside UserInfo/client/ named main

He could also do print(type(file)) just to see what it is returning.



#222527 attempt to index ? (a nil value)

Posted by Quintuple Agent on 21 June 2015 - 11:13 PM in Ask a Pro

I just tried this on a computer and it worked fine.
Check and make sure you copied everything over verbatim. You might have an error in your code but you fixed it when typing the text again into the forum.



#222044 Execute code in a table

Posted by Quintuple Agent on 19 June 2015 - 01:15 AM in Ask a Pro

to execute a string all you have to do is
local exeTab = loadstring("print('hello')")
exeTab()
I would suggest reading the lua tutorial page for this
Also an FYI, if the code inside loadstring is invalid and would throw an error the exeTab return nil plus an error message
From the tutorial page

Quote

print(loadstring("i i"))
--> nil [string "i i"]:1: `=' expected near `i'



#221854 Why doesn't concatenation of a substring work

Posted by Quintuple Agent on 18 June 2015 - 01:46 AM in Ask a Pro

I believe your problem is you are drawing the text before your name edit.



#221835 Having trouble with a startup program...

Posted by Quintuple Agent on 17 June 2015 - 11:09 PM in Ask a Pro

The problem with you trying to exit out using your admin password is that once your door script has stopped, your run command in your startup file is in a loop and so it will run it again, you can just remove the loop and have the run command. Since the main part of your door program is in a while loop it should keep running until you call error() (you could also just use return )
Also another tip, in your code for correct password (123) you should have it reset x to 1

Edit: I just remembered that cc has that pesky terminate keypress <_< however you can avoid the termination by putting
local oldEve = os.pullEvent
os.pullEvent = os.pullEventRaw
at the top of your code, this is make it so the termination event will not work
Then before you exit your script you can do
os.pullEvent = oldEve
to change it back to normal

And yet another edit: I noticed that the code already has the os.pullEventRaw, good, however it is a good idea to save the old pullEvent then return it to normal, so that still stands.

Ex:
Spoiler



#221134 Deleting Portions of Tables?

Posted by Quintuple Agent on 13 June 2015 - 02:32 AM in Ask a Pro

yah, we need some clarification on what you are asking.
Is you have text stored like so:
txtTab={
"this",
"is a test",
"On storing",
"Text"
}
So each index is a new line, or do you have some other way of storing it?
And what do you mean by reaches this portion of the table? If the text gets too long or if the table has so many lines?
Also, recreate it? make a new table, append it somewhere else?



#220678 [Solved] How to use externally written programs?

Posted by Quintuple Agent on 10 June 2015 - 01:01 AM in Ask a Pro

If he is talking about non-rom files
All files should be in "saves/(your world)/computer/" then you need to find the computer id and all of that computers files are in there.
Also cc still does files with no extensions, however it will also work with files that do

However now that I look at it again it looks as if he is talking about ROM files, in which case I think the newer versions have some special files you can make to have your own custom rom file (I think i was remember some old suggestion posts). Older versions you will need to extract and remake the .jar



#219835 Useless Inventions

Posted by Quintuple Agent on 04 June 2015 - 12:31 AM in Forum Games

You'd find that in the 1970's

Fallout 4
jk

A mini mini fridge. It can hold a few drops of water.



#219832 MS Paint

Posted by Quintuple Agent on 04 June 2015 - 12:01 AM in Forum Games

Painted before DOG figured out he had been :ph34r: 'd
Posted Image
Honestly the ASCII fish is probably better than any fish I could have drawn

Paint a football playing king in space
or a Pegasus, either one is fine.



#219222 MS Paint

Posted by Quintuple Agent on 29 May 2015 - 09:51 PM in Forum Games

Posted Image


Paint a happy little tree
Posted Image



#217349 Confusion: arg and ...

Posted by Quintuple Agent on 15 May 2015 - 05:57 PM in Ask a Pro

View Postflaghacker, on 15 May 2015 - 05:54 PM, said:

Edit2: Is there a shortcut text for the ninja? like : ) -> :)
:ph34r: (: ph34r :)



#217346 Confusion: arg and ...

Posted by Quintuple Agent on 15 May 2015 - 05:54 PM in Ask a Pro

I found a forum post here from StackOverflow that asked the same question.
In short it is the compiler and compatibility with 5.0 and 5.1 lua code. If ... is detected it will default to that instead of arg.



#217128 Concatenation using ternary operators

Posted by Quintuple Agent on 14 May 2015 - 02:51 AM in Ask a Pro

I believe it is trying to concatenate the string first, then check the or statement. It should look like this
write("Type: "..(alias[list[num].label] or list[num].label))

I tried a simple code of
print("Hello ".. nil or "world")
print("Hello ".. (nil or "world"))
print("Hello ".. (nil) or "world")
Only the one that has the whole OR statement in brackets worked



#215104 How to grab text

Posted by Quintuple Agent on 22 April 2015 - 07:04 PM in Ask a Pro

Spaces seperate arguments, so
> message Hello World
would have tArgs[1] be "Hello" and tArgs[2] be "World" you can recombine these by doing
newMsg = table.concat(tArgs," ")
What this does is take the table tArgs and adds a space in between each argument. The " " is what it will add, so "," would return Hello,World and "-.-" would return Hello-.-World as an example.



#214884 Attempt to index a nil value

Posted by Quintuple Agent on 21 April 2015 - 03:33 PM in Ask a Pro

Also remember that fs.list returns directories too. So you will need to add a check before you open the file to make sure it is not a directory.



#212241 Could somebody help me with this monitor code?

Posted by Quintuple Agent on 03 April 2015 - 09:46 PM in Ask a Pro

Ok, I believe I see the problem.
First off is your centerText function
1. At the start do
userString=tostring(userString)
That way it will still work in case you give the function a number
2. You have
monitor.write(UserString)
change that to
monitor.write(userString)
3. While not really needed, make your x and y variables local, this is a good thing to practice.
Also remove the i= i + 1 in your monitorTimer function, it is unneeded as the for loop automatically increments it.



#209842 Special syntax in Lua

Posted by Quintuple Agent on 16 March 2015 - 05:15 PM in Ask a Pro

Looks to me like they are checking if term exists and if it does set write to term.write.
To go a little more in-depth, when using 'and' if both statements before and after it are not nil or false, it will return what is on the right side of the 'and'
It would be just like
if term then
write=term.write
end
the reason they would not simply do write=term.write is because if term is not a table then trying to access term.write would throw back an error.(however it should be write = type(term)=="table" and term.write, however if term does exist it should be a table, unless someone redefined it.



#209627 tm

Posted by Quintuple Agent on 14 March 2015 - 11:14 PM in Ask a Pro

Just an fyi, you don't have to do file.flush(), .close will still save the file and close the handle. .flush is if you want to keep the handle open but save the file (just in-case the user terminates the program, or the script crashes, etc). .flush is good for things like logging programs, or games that save every time you do something.



#209201 Nevardon Editor [0.5.4]

Posted by Quintuple Agent on 12 March 2015 - 12:03 AM in Programs

View PostGeforce Fan, on 11 March 2015 - 11:30 PM, said:

Bit of an odd bug, if you type exactly:
osStuff.dirColor
This crashes.
Would be nice if you posted the error that followed, however I think I know the problem.
I take it that you have something in _G as osStuff and if that is the case then the next update I put out will fix it.
Edit: Update is out, problem is fixed



#209192 Secure sleep() and read() [Un-Solved]

Posted by Quintuple Agent on 11 March 2015 - 11:29 PM in Ask a Pro

If you have
os.pullEvent = os.pullEventRaw
near the start of your code, it will change os.pullEvent to os.pullEventRaw for all programs (until you change it back or restart the computer)
If you want to save the old pullEvent (which you should) do
local oldPull = os.pullEvent
os.pullEvent = os.pullEventRaw
That way you can do
os.pullEvent = oldPull
to change it back.



#209069 event?

Posted by Quintuple Agent on 11 March 2015 - 12:34 AM in Ask a Pro

Well, you would most likely be using os.pullEvent instead of os.pullEventRaw (however raw is almost exactly the same except it can catch the Terminate event)
But if you wanted to get a keyboard key you could go about it like so
local eve,key=os.pullEvent("key")
if key==keys.backspace then --Would trigger if the user hit the backspace key
doBackspaceStuff()
end
I would recommend looking at the keyAPI for the available key variables, or the key Event for a list of which keys return which numbers.

If you wanted to get a little more complex you could do
local eve,key=os.pullEvent()
if eve=="key" then  --Will trigger everytime the user presses a key
if key==keys.backspace then
  doBackspaceStuff()
else
  otherKeystuff()
end
elseif eve=="char" then  --Will trigger whenever the user presses a key that is printable (a-z,0-9,!@#$%,etc.)
print("I just pressed "..key)
end
They char event is thrown if you press a key that is printable, however the key event is always thrown.
Meaning, if I press X both a key and char event are created, but if i press backspace, only a key event is created.
Keep in mind that if you use pullEventRaw, terminate will go though any filter, so if you have os.pullEventRaw("key"), terminate will still pass as an event.