The optimization patches in OpenComputers's repository are not yet merged into mainline, but you can install lunatic86 regardless! (Just with worse performance.)
$ oppm install lunatic86
$ lunatic86 -h
No spoiler in the title. Just watch the video.
EDIT: Apparently someone's ComputerCraft fork is more findable on Google than the original OpenComputers repository, so here's the official source code: https://github.com/asiekierka/lunatic86
Hey,
in these if statements, you need to use relational operators. Since you want to see if you're variable is equal to a certain string, you need the '==' (two equal signs).
So you're code would look like this
-- local require commands start
local component= require (“component”)
local sides = require(“sides”)
local rs = component.redstone
local event = require(“event”)
-- local os = require(“os”) remove this, the os lib does not need to be required, I think
-- local require commands end
-- Main function start
local function main()
local username, message = event.pull(“chat_message”) -- you head a period (.) between both variables
-- problematic loop start
if username == “Hakz_Studios” and message == “ Alice Refuel” then
component.speech_box.say(“Refueling”)
component.chat_box.say(“Refueling”)
repeat
local username,message = event.pull(“chat_message”)
rs.setoutput(sides.bottom, 15) -- you need to give the redstone output a value, otherwise it wont turn on
-- also, by putting it into a loop, the redstone output will be set a ton of times
-- it helps putting the statement before the repeat until loop
until username == “Hakz_Studios” and message == “Stop Refueling”
-- restarting function
function main() -- idk what is this line about, but i dont think it belongs here
elseif username == “Hakz_Studios” and message == “Stop Refuel Systems”
os.execute(“Shutdown”) -- it will look for a program called 'Shutdown' with a capital S
else
function main() -- also, dont know what you want to do here, do you want to start the function again (to have the code repeated endlessly)
--problematic loop end
end
-- main function end
end
Some small info: you don't have to put brackets around your condition in the if-statements, you can, but it's not necessary.
Also, here is a program that repeats the main loop over and over again, as I think that is what you want to do in your original code, if I'm wrong tho and misinterpreting you're code, just ignore my suggestion
-- require libs
local component = require("component")
local rs = component.redstone
local sides = require("sides")
local event = require("event")
-- main function
local function main()
local username, message = event.pull("chat_message")
if username == "Hakz_Studios" and message == "Alice Refuel" then
component.speech_box.say("Refueling")
component.chat_box.say("Refueling")
-- this time I set the redstone output once, and then wait for the message 'Stop refueling' then deactivate the redstoneoutput again
rs.setOutput(sides.bottom, 15)
repeat
username, message = event.pull("chat_message")
-- you dont have to use 'local' in front of username and message here, since you already created these variables at the top of the main function
-- it will override these values but it actually doesnt matter since from this part you will skip to the end and these initial values for both variables
-- wont be needed anymore
until username == "Hakz_Studios" and message == "Stop Refueling"
rs.setOutput(sides.bottom, 0) -- I assume you want to deactivate the redstone after you're done refueling
elseif username == "Hakz_Studios" and message == "Stop Refuel System" then
os.execute("Shutdown") -- again, this will start the program "Shutdown" with a capital "S"
end
-- as you can see, we skip the last else statement, as it will call the main function recursively, resulting in a overflow error pretty fast
-- you could get away with returning a call to the main function, but this wouldnt be good practice eiter, I guess
end
-- we add a last while loop, which will repeat endlessly calling the main function
while true do
main()
end
I hope this helps.
Also you did great for your first shot at programming!