This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Keymaster89's profile picture

Some easy things

Started by Keymaster89, 20 March 2012 - 02:55 PM
Keymaster89 #1
Posted 20 March 2012 - 03:55 PM
Hi! I'm Keymaster89, and i'm new in the forum.
First of all, i want to thanx the developer of this awsome mod! I'll automatize all with this sweetie! XD
Second, i must say that i don't know the Lua language, but i know C++ instead, so i understand program language a bit… i'm trying to learn some of the Lua, but actually i'm a real noob… so i ask for a little help about something that i can't be able to found myself…
Thanx in advice XD

Question 1: what keyboard keys i have to use to make "~" appear ingame in the program editor?

Question 2: if i code:

print("bla bla bla \ / bla bla bla")
it returns:
bla bla bla / bla bla bla
where my "\" go? i'm trying to make a picture for my program interface, but all the "\" characters will dissaper when i launch the program, making a big mess in all my project… so, how can i make it not vanish?

Question 3: it's necessary specify "io." when i call "io.read()"?

Question 4: i really don't get the "os.pullEvent()" function… can someone help me understand? i tryied to insert in my codes many times, trying to get redstone change, keyboard input or also rednet message but i only received a lot of error as response… maybe an idiot-level explanation with a bit of examples will illuminate my path to the clarity XD
Casper7526 #2
Posted 20 March 2012 - 04:07 PM
Check out my in-game tutorial in the tutorials section.

Also is an escape character when used in a string. If you wanted to appear on the screen you would have to escape it with itself.

print ("")

Program Output:
Keymaster89 #3
Posted 21 March 2012 - 09:37 AM
Hey, thanx a lot for that! U're amazing Casper!
I tryied to take a watch to all that tutorial last night, and it resolve me a lot of problems that i had with the lua!
But i guess not all the problems…

I tried to use the code u suggested, to just see what happens:

while true do
ev, p1, p2, p3 = os.pullEvent()
print("Event: "..ev)
print(p1)
print(p2)
print(p3)
end

But, i'm again a little confused… if i don't boring u, could u help me again? ^^

1.If i make a program to take a "CHAR" or "REDSTONE" event, that use only "ev" and "p1" (i think), i'm forced to pick up also "p2" and "p3" even if i never use 'em?

2.I tryied to change the state of a redstone signal direct ot the computer by multiple faces, but it return to me only ev "REDSTONE". So the function don't tell me WHAT'S changed… SO this means that i have to take a memory to confront the old rs state with the new one to know that's changed, right?

3.I used sooooo much times trying hard to understand and experiment how the rednet works, with or without modems, but i'm never be able to pass even a letter by 2 PC…
I also tryied with your guide: http://www.computerc...-modems-rednet/… but nothing, i don't understand where i miss something… but i'm not give up, so: If i want to make my PC wait for a keyboard press, a redstone change AND a rednet signal, i have to alternate the os.pullEvent() with the rednet.receive() (probably loss some messages) or the first one have a specific event for the second one? If this is true, maybe i have to expect something like this:
ev: REDNET
p1: face of the rednet
p2: ID of the sender
p3: message
Or i totally mess around the 2 things and i totally misunderstanding everything???
Thanx for your time XD i'm a lost case… T.T
Casper7526 #4
Posted 21 March 2012 - 11:34 AM
You dont need all the params, only the ones your looking for.

If you wanted to literally just look for an event you could do

event = os.pullEvent()

If you just wanted the first parameter (most events only have 1 parameter)

Also for redstone, there is nothing to tell you what or which changed, you have to test the input for yourself.

if rs.getInput("back") == true then print "Back if on" end

event,param = os.pullEvent()
Keymaster89 #5
Posted 21 March 2012 - 07:46 PM
You dont need all the params, only the ones your looking for.

If you wanted to literally just look for an event you could do

event = os.pullEvent()

If you just wanted the first parameter (most events only have 1 parameter)

Also for redstone, there is nothing to tell you what or which changed, you have to test the input for yourself.

if rs.getInput("back") == true then print "Back if on" end

event,param = os.pullEvent()

Great! i was scared to be forced to consider them all the time…

Mmmhhh… good point… so i have to control the state manually… nothing that i can't handle…

for the rednet… i made anoder couple of test… and i finally make them communicate!
the problem was that i call rednet.open() on the wrong side.
I used to orient myself with the frase "the turtle have modems always on right"
As i see turtles reponding at "go forward" moving in the direction with the lined face, i thinked that that was the "front" side, so i made the reasoning:
If this is the front face and the modem stay always on right, it must be HIS right.
Considering this, i apply the same wrong reasoning with the PCS…
Watching better, when i pose a turtle, i see the face with the "mail", so that must be the front side… am i right?
By the way this direction only apply to modem for turtle because if i command 'em to go forward it go forrward with the teorically back side, am i right again?

thanx Casper for your answer XD