Jump to content


Unknowntissue's Content

There have been 15 items by Unknowntissue (Search limited from 10-February 22)


By content type

See this member's

Sort by                Order  

#249339 Multi-floor elevator with Redstone in Motion

Posted by Unknowntissue on 02 April 2016 - 05:44 PM in Ask a Pro

I actually found the code for the program i did. I was very new to programming when i made this so take it with a grain of salt.... but it does work. Maybe you can improve on it or just use it.

It works by using a computer on each floor to act like a terminal. Then it will send a wireless rednet signal to the computer controlling the motors. Also keep in mind that is was made to work on a 2 floor building only. You need to improve it a bit if you want more.

this is the code for the terminal: Edit:This terminal is for the top floor
Spoiler
This the code for the computer controlling the motors:
Spoiler

I wish got into the habit of adding more comments when i made this but if you have any questions about it you can just ask and I'm sure i can work it out.



#249338 Immersive Engineering Arc Furnace Program

Posted by Unknowntissue on 02 April 2016 - 05:12 PM in Ask a Pro

I don't really know the api for arc furnaces so if you linked a page with the documentation i can help you better but if i had to take a guess the code should look like this.
arc = peripheral.wrap("left")
while true  do   --# will loop forever. Hold ctrl+ t to stop it
if arc.hasElectrodes() == false then
  redstone.setOutput("top",true)
end
if arc.hasElectrodes()== true then
   redstone.setOutput("top", false)
end
end



#249336 Multi-floor elevator with Redstone in Motion

Posted by Unknowntissue on 02 April 2016 - 04:27 PM in Ask a Pro

I have actually already made this in one of my worlds. It can turn into quite the monster in terms of how you wire it. You will need to use bundled wires not sure if you have them in your mod pack but if you are using tekkit then you should.

For each floor, I had a redstone signal that would go to the computer to tell it the elevator was on that floor. I did this by adding a redstone block to elevator that would land inline with a wire once it reached the floor.

Now that you have a way of reading what floor its on you just have to program how many moves you have to go to reach the goal. I think on my example it was 4 block per floor so if i need to go down 2 floors i moved down 8 times.

If you didn't know, you will be needing this link allot. http://www.computerc.../Redstone_(API)

If you want to eliminate some wire i would also look here. http://www.computerc...ki/Rednet_(API)
P.S: Don't use the rednet if you having to much of a hard time with computercraft it will complicate your code a bit.



#249295 Displaying a countdown timer

Posted by Unknowntissue on 01 April 2016 - 07:26 PM in Ask a Pro

I'm no pro but I think I can help you too. I'm still a beginner at code just like you so i can explain how its done in the point of view of a newbie.

Personally I like it when people tell me what I did wrong in my code so I can correct my way of looking at it.

First thing I would change is move the following to the start of the program and out of the loop:
local mon = peripheral.wrap("left")
Technically this does work but it is good practice to keep variables that will never change out of the repeating loop. The reason for this is if you wanted to move the monitor to the top for some reason you don't have to go fishing for it deep in the code.( It also makes your code run smoother when you get into more intense stuff)

I don't know how much you know but I don't want to post a wall of text if I don't have to so I'll just post how I think the code should look. If you want me to explain more I would be happy to just let me know.
-- Startup
mon = peripheral.find("monitor") --# Will find Monitor no matter what side it is on
mon.setTextScale(4) --# toy with this number until you are happy
engine = "back" --# Just in case you ever need to change the side the engines are on you only need to change this
runProgram  = true --# while this is true the program will keep looping
-- The Program
while runProgram do
mon.clear()
print("Turn on engines? Y/N")
input = read()
if input == "Y" or input == "y" then --# works for both upper and lower y
  print("For how long?(seconds)")
  sec = tonumber(read()) --# how many seconds do you want to run
  redstone.setOutput(engine,true)
  for i = sec, 0 , -1 do --# Start at "sec", stop at 0, and count by -1
   mon.clear()
   mon.cursorPos(1,1)
   mon.write(tostring(i))
   os.sleep(1)
  end
  redstone.setOutput(engine,false)
elseif input == "N"  or input == "n" then
  runProgram = false
end
end



#249178 [Solved] Question About Events Queue.

Posted by Unknowntissue on 30 March 2016 - 03:19 PM in Ask a Pro

Oh alright I see what you mean now. Thanks I will get to work on that.



#249174 [Solved] Question About Events Queue.

Posted by Unknowntissue on 30 March 2016 - 02:09 PM in Ask a Pro

Lyqyd:
Yea I haven't run into that problem yet but I can definitely see your point. I'm just having a hard time visualizing how I will use other computers to keep track of the communications.

My current structure:
client request to server---> server confirms that it is ready and listening to that client with return message ------>client sends information ------> client returns result

You don't have to write any code but what do you think is the best way to add in other computers to keep track of the communications,



#249140 [Solved] Question About Events Queue.

Posted by Unknowntissue on 29 March 2016 - 10:11 PM in Ask a Pro

Ah alright!! That is exactly the answer I needed bloke!

Thanks again for your help everyone!



#249135 [Solved] Question About Events Queue.

Posted by Unknowntissue on 29 March 2016 - 09:42 PM in Ask a Pro

View PostAnavrins, on 29 March 2016 - 09:23 PM, said:

View PostUnknowntissue, on 29 March 2016 - 09:06 PM, said:

I understand that much so far Anavrins.

My question is how do i make sure i don't lose the events that happen while the block running under "rfid detected". The case I' worried about is getting a second rfid while I'm handling the first one. Also the block under "rfid detected" will have to exchange information with other computers so it will be code that runs a bit slowly.(Slow in the computer world).
The same exact thing, though you would use elseif name == "modem_message" or elseif name == "rednet_message"

I'm not sure if my explanation is clear or if I am not seeing your point.

I'm fine with handling different types of events. I'm worried about events that come in while the code is not sniffing for one at that moment when it arrives.



#249134 [Solved] Question About Events Queue.

Posted by Unknowntissue on 29 March 2016 - 09:31 PM in Ask a Pro

Lyqyd:
I'm not sure how that would work or if it will fit in my design plan.

Right now what I have is one computer at the door and other in the building. The one in the building holds the passwords. Then when a player i with an RFID card in their inventory walks into the range of the reader it will send the info on the card to the computer in the building. Then the computer in the building will give the computer at the door permission to open if the information is correct. At the moment, I'm trying to make sure it doesn't miss any RFID cards even if a player is holding many. The problem I will need to solve later is how will the computer in the building handle request if they all come at the same time.

Any input or help you guys can offer is very welcome.



#249129 [Solved] Question About Events Queue.

Posted by Unknowntissue on 29 March 2016 - 09:06 PM in Ask a Pro

I understand that much so far Anavrins.

My question is how do i make sure i don't lose the events that happen while the block running under "rfid detected". The case I' worried about is getting a second rfid while I'm handling the first one. Also the block under "rfid detected" will have to exchange information with other computers so it will be code that runs a bit slowly.(Slow in the computer world).

event,p1,p2,p3 = os.pullEvent()
if event == "key" then
   # -- do stuff
elseif event == "rfid_detected" then
  # -- talk to other computers and wait for response
  #-- possible to get other "rfid_detected" events while this runs
end



#249119 How do i make a key disk?

Posted by Unknowntissue on 29 March 2016 - 07:56 PM in Ask a Pro

The one I'm building now keeps the passwords in a computer that is inside the locked area. then with a rednet message the door pc sends the message to the server pc that gives it the go ahead to open the door. this way the password is never saved on the pc that the intruder is using.



#249117 [Solved] Question About Events Queue.

Posted by Unknowntissue on 29 March 2016 - 07:33 PM in Ask a Pro

I'm working with Immibis's Peripherals RFID readers.(http://www.computerc...ss-peripherals/)

In my understanding, you start the scanning and while the scanning is happening you will get events that pop up until the scanning is done. (please let me know if I'm right about this)

My question is what will happen to the events that come in while the code is running? To make this clear i will try to make a time line.

Event Timeline:

-os.pullEvent()-----------------(code for EventOne running)----

----------------------EventOne------EventTwo---------------

So EventTwo happens when the code is busy but I don't want it to just go away. I want it to be handled. Is there a way to take care of incomeing request as they come in?

EDIT: changed title so others with same issue and search it easily.



#247667 [Solved] Keep getting " attempt to index ? (a nil value)

Posted by Unknowntissue on 09 March 2016 - 04:47 PM in Ask a Pro

Ahhhh alright I think that will do it. Thanks for the help! This there something i have to do once an issue is solved? Like edit the op so it says solved or something?



#247644 [Solved] Keep getting " attempt to index ? (a nil value)

Posted by Unknowntissue on 09 March 2016 - 03:22 AM in Ask a Pro

if moreDetails.Name then

This is actually what i had before. I was still getting the same problem for some reason.

Your comment did just gave me the thought that i should be checking for the nil before it gets to line 24. Do you think that will fix the problem?



#247636 [Solved] Keep getting " attempt to index ? (a nil value)

Posted by Unknowntissue on 09 March 2016 - 01:33 AM in Ask a Pro

the code that I am working with. http://pastebin.com/Fz6hxbuA

I think the problem is that there is something that walks into the range of the sensor that doesn't have a "Name" key.

The program actually runs for a while before i even get this error so it must be something that happens only sometimes. I think i need to find a way to protect the program when this happens.

the problem happens on line 24 according to the error code i get.

Please let me know if I need to clear some things up for you in my code. I am completely self taught so I don't really know if i am following good programming practices.