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

'=' expected error

Started by capnstoobie, 25 May 2015 - 04:51 AM
capnstoobie #1
Posted 25 May 2015 - 06:51 AM
Mmk. I did it. For any of you guys who want to know how, here are my scripts.

ComputerCraft Script

clear
print ("Enter A Message")
local input = read()
http.post(
				"http://example.com/page.php?message="..textutils.urlEncode(tostring(input))
				)

WebPage PHP

<?php
		$message = urldecode($_GET['message']);
		mail("EMAIL", "SUBJECT", "$message" );
?>

This will send an email with the message you put on the computercraft program. Predefine an email and subject, or adapt the program to include an input for the CC program.

Thanks so much for this, it is exactly what I'm looking for. I don't have access to Computer Craft at work so I'm trying out the lua script on Lua 5.1 for Windows. When I run the lua script I get this error message: '=' expected near 'print'. Any ideas what is wrong?

My ultimate goal is to have a switch in Minecraft that when flicked, sends an email that will trigger a Belkin Wemo switch via IFTTT.

(I realise this is an old thread, hope someone can help).
Lyqyd #2
Posted 25 May 2015 - 08:01 AM
Thread split from here.
Bomb Bloke #3
Posted 25 May 2015 - 08:16 AM
Seems elfin8er meant term.clear(), as opposed to just "clear".

Bear in mind that you'll need a properly configured webserver with php (and probably smtp) capabilities for this. The Lua-side of things is relatively simple.
Edited on 25 May 2015 - 06:17 AM
capnstoobie #4
Posted 26 May 2015 - 03:15 AM
Thanks, that was it!

Actually, I had already worked out and tested the php part. I've never used php before and I was surprised how easy it was to create a small script to send an email.