Posted 12 July 2012 - 01:08 PM
First off I'm using Tekkit so if you don't know what a filter and a detector are they're red-power-2 machines that manipulate items and send/receive Red-stone signal when doing so.
The filter when sent a Red-stone signal(impulse) pulls one item out of an adjacent inventory and sends it through a connected tube.
The detector sends a Red-stone signal(impulse) when an item goes through it.
To the code…I'm making this gambling machine that takes in items turns them into credits that you play with and then returns items based on how many credits you have.
The computer (CC computer) that controls it has 4 buttons, 2 filters and a detector connected to it.
The code is made up of 4 functions corresponding to the 4 buttons : Load, Bet, Play and Pay.
I have Bet, Play and Pay sorted out but i can't figure out Load.
How it's all connected:
Mechanics: input chest -> input filter -> detector -> storage chest -> output filter -> output chest
Electronics: Computer- bundled wire - red wire - Load button- input filter
- bundled wire - blue wire - Bet button
- bundled wire - white wire - Play button
- bundled wire - black wire - Pay button
- bundled wire - green wire - output filter
What i want Load to do:
when i press load a signal is sent to the computer via the red wire and the input filter wich sends an item on it's way to the storage chest.
when the computer receives that signal I want the computer to wait for a signal from the pink wire and, if and when it get's it to send a signal through the red wire ( only the red wire not the green wire as well) and start the loop again ( start waiting for the pink signal again).
also if any wait is greater than 2 seconds i want the function to exit
would this work?
The filter when sent a Red-stone signal(impulse) pulls one item out of an adjacent inventory and sends it through a connected tube.
The detector sends a Red-stone signal(impulse) when an item goes through it.
To the code…I'm making this gambling machine that takes in items turns them into credits that you play with and then returns items based on how many credits you have.
The computer (CC computer) that controls it has 4 buttons, 2 filters and a detector connected to it.
The code is made up of 4 functions corresponding to the 4 buttons : Load, Bet, Play and Pay.
I have Bet, Play and Pay sorted out but i can't figure out Load.
How it's all connected:
Mechanics: input chest -> input filter -> detector -> storage chest -> output filter -> output chest
Electronics: Computer- bundled wire - red wire - Load button- input filter
- bundled wire - blue wire - Bet button
- bundled wire - white wire - Play button
- bundled wire - black wire - Pay button
- bundled wire - green wire - output filter
What i want Load to do:
when i press load a signal is sent to the computer via the red wire and the input filter wich sends an item on it's way to the storage chest.
when the computer receives that signal I want the computer to wait for a signal from the pink wire and, if and when it get's it to send a signal through the red wire ( only the red wire not the green wire as well) and start the loop again ( start waiting for the pink signal again).
also if any wait is greater than 2 seconds i want the function to exit
would this work?
sd="bottom" --this is a global variable for string side as all my cables are connected to the bottom
credits=0 --global variable for credits
function load()
local k=40
while k>0 do
if rs.testBundledInput(sd , colors.pink) then
credits=credits+10
rs.setBundledOutput(sd, colors.red)
sleep(0.05)
rs.setBundledOutput(sd, 0)
break
else
k=k-1
sleep(0.05)
end
end
end
Or should i use os.pullEvent() ?