WHat is the program you use to use lua outside gmod? (the one that is behind the programm in teh screenshots)
That's in-game, he's using [url=http://www.garrysmod.org/downloads/?a=view&id=78199]Luapad[/url].
I saw this thread and decided to learn brainfuck:v: It's so simple, yet everything is so hard to make with it. Anyways after much thinking (it really does live up to it's name) I managed to make a small program that multiplies 2 one digit numbers you give as input (IE 23 is read 2*3)
[code]
,
>++++++++
[<------>-]
,
>++++++++
[<------>-]
<
[>+>+<<-]
<
[
>>[>>+<<-]
>
[<<+>>-]
<<
[>+>+<<-]
<-]
>>>>.
[/code]
You'll have to check the log for the answer, since converting it to a readable number seems very distant to me:tinfoil:
If I remember, you add 48 to it, sice 0 is 48 in ascii.
Here goes:
[IMG]http://img689.imageshack.us/img689/1153/gmbf04.png[/IMG]
And the result:
[IMG]http://img149.imageshack.us/img149/7613/gmbf05.png[/IMG]
:neckbeard:
Just need to work out a couple of kinks in the Ook JITter :smile:
[editline]08:01AM[/editline]
Sauce
[code]
local frame = vgui.Create("DFrame")
frame:SetPos(100, 100)
frame:SetSize(400, 300)
frame:SetTitle("GMod Esoteric Language Interpreter")
local topSheet = vgui.Create("DPropertySheet")
topSheet:SetParent(frame)
topSheet:SetPos(0, 20)
topSheet:SetSize(400, 280)
frame:MakePopup()
local sList = vgui.Create("DPanelList")
local debugAD = vgui.Create("DCheckBox")
debugAD:SetText("Show Incrementing/Decrementing")
debugAD:SetValue(1)
debugAD:SizeToContents()
sList:AddItem(debugAD)
local debugMP = vgui.Create("DCheckBox")
debugMP:SetText("Show Pointer Movement")
debugMP:SetValue(1)
debugMP:SizeToContents()
sList:AddItem(debugMP)
local debugIO = vgui.Create("DCheckBox")
debugIO:SetText("Show Input/Output")
debugIO:SetValue(1)
debugIO:SizeToContents()
sList:AddItem(debugIO)
local debugLP = vgui.Create("DCheckBox")
debugLP:SetText("Show Loops")
debugLP:SetValue(1)
debugLP:SizeToContents()
sList:AddItem(debugLP)
local log = vgui.Create("DTextEntry")
log:SetText("Lulz")
log:SetMultiline(true)
log:SetSize( 400, 280 )
local iPanel = vgui.Create("DPanel")
iPanel:SetPos(0, 0)
iPanel:SetSize(400, 260)
local buttonRun = vgui.Create("DButton")
buttonRun:SetParent(iPanel)
buttonRun:SetText( "Run!" )
buttonRun:SetPos( 220, 10 )
buttonRun:SetSize( 160, 30 )
buttonRun.DoClick = function ()
if languageSelect:GetSelectedItems()[1] then
if languageSelect:GetSelectedItems()[1]:GetValue() == "brainfuck" then
log:SetValue("Intitialising memory...\n")
data = {}
for i = 1, 30000 do
data[i] = 0
end
log:SetValue(log:GetValue().."Success! Beginning execution...\n")
local i = 1
local p = 1
local ip = 1
local lc = 0
prog = codeBox:GetValue()
inpt = inputBox:GetValue()
outputBox:SetValue("")
while i <= string.len(prog) do
local v = string.byte(prog, i)
if v == 43 then
data[p] = data[p] + 1
if debugAD:GetChecked() then log:SetValue(log:GetValue().."Incremented cell "..p.." to "..data[p].."\n") end
if data[p] > 255 then data[p] = 0 end
elseif v == 45 then
data[p] = data[p] - 1
if debugAD:GetChecked() then log:SetValue(log:GetValue().."Decremented cell "..p.." to "..data[p].."\n") end
if data[p] < 0 then data[p] = 255 end
elseif v == 60 then
p = p - 1
if debugMP:GetChecked() then log:SetValue(log:GetValue().."Moved pointer to "..p.."\n") end
if p < 0 then
p = 30000
if debugMP:GetChecked() then log:SetValue(log:GetValue().."Wrapped pointer to "..p.."\n")end
end
elseif v == 62 then
p = p + 1
if debugMP:GetChecked() then log:SetValue(log:GetValue().."Moved pointer to "..p.."\n") end
if p > 30000 then
p = 1
if debugMP:GetChecked() then log:SetValue(log:GetValue().."Wrapped pointer to "..p.."\n") end
end
elseif v == 46 then
outputBox:SetValue(outputBox:GetValue()..string.char(data[p]))
if debugIO:GetChecked() then log:SetValue(log:GetValue().."Output char "..string.char(data[p]).." (value "..data[p]..") from cell "..p.."\n") end
elseif v == 44 then
if ip <= string.len(inpt) then
data[p] = string.byte(inpt, ip)
if debugIO:GetChecked() then log:SetValue(log:GetValue().."Cell "..p.." set to char "..string.char(data[p]).." (value "..data[p]..")\n") end
ip = ip + 1
else
data[p] = 0
end
elseif v == 91 then
if data[p] == 0 then
if debugLP:GetChecked() then log:SetValue(log:GetValue().."Skipped loop\n") end
local lco = lc
lc = lc + 1
localvb = 0
while lc ~= lco do
i = i + 1
vb = string.byte(prog, i)
if vb == 91 then lc = lc + 1 end
if vb == 93 then lc = lc - 1 end
end
else
if debugLP:GetChecked() then log:SetValue(log:GetValue().."Entered loop\n") end
lc = lc + 1
end
elseif v == 93 then
if data[p] ~= 0 then
if debugLP:GetChecked() then log:SetValue(log:GetValue().."Returned to start of loop\n") end
local lco = lc
lc = lc + 1
local vb = 0
while lc ~= lco do
i = i - 1
vb = string.byte(prog, i)
if vb == 91 then lc = lc - 1 end
if vb == 93 then lc = lc + 1 end
end
else
lc = lc - 1
if debugLP:GetChecked() then log:SetValue(log:GetValue().."Exited loop\n") end
end
end
i = i + 1
end
elseif languageSelect:GetSelectedItems()[1]:GetValue()== "Ook" then
local progold = codeBox:GetValue()
progold = string.lower(progold)
prognew = ""
for i = 1, string.len(progold) do
if string.byte(progold, i) == 33 then
prognew = prognew.."!"
elseif string.byte(progold, i) == 46 then
prognew = prognew.."."
elseif string.byte(progold, i) == 63 then
prognew = prognew.."?"
end
end
log:SetValue("First substitution: "..prognew.."\n")
prog = ""
local ltable = {}
ltable[33] = {}
ltable[33][33] = "-"
ltable[33][46] = "."
ltable[33][63] = "["
ltable[46] = {}
ltable[46][46] = "+"
ltable[63] = {}
local i = 1
while i < string.len(prognew) do
chat.AddText("LOL")
if string.byte(prognew, i) == "33" then
if string.byte(prognew, i+1) == "46" then
prog = prog.."<"
elseif string.byte(prognew, i+1) == "63" then
prog = prog.."]"
end
elseif string.byte(prognew, i) == "46" then
if string.byte(prognew, i+1) == "33" then
prog = prog..">"
elseif string.byte(prognew, i+1) == "46" then
prog = prog.."+"
elseif string.byte(prognew, i+1) == "63" then
prog = prog..","
end
elseif string.byte(prognew, i) == "63" then
if string.byte(prognew, i+1) == "33" then
prog = prog.."["
elseif string.byte(prognew, i+1) == "46" then
prog = prog.."."
elseif string.byte(prognew, i+1) == "63" then
prog = prog.."-"
end
end
i = i + 2
end
progold = nil
prognew = nil
log:SetValue(log:GetValue().."Second substitution:"..prog.."\nInitialising memory...\n")
data = {}
for i = 1, 30000 do
data[i] = 0
end
log:SetValue(log:GetValue().."Success! Beginning execution...\n")
local i = 1
local p = 1
local ip = 1
local lc = 0
inpt = inputBox:GetValue()
outputBox:SetValue("")
while i <= string.len(prog) do
local v = string.byte(prog, i)
if v == 43 then
data[p] = data[p] + 1
if debugAD:GetChecked() then log:SetValue(log:GetValue().."Incremented cell "..p.." to "..data[p].."\n") end
if data[p] > 255 then data[p] = 0 end
elseif v == 45 then
data[p] = data[p] - 1
if debugAD:GetChecked() then log:SetValue(log:GetValue().."Decremented cell "..p.." to "..data[p].."\n") end
if data[p] < 0 then data[p] = 255 end
elseif v == 6
Looks better already, keep it up.
Thanks guys :smile:
Anyway, off to school now.
[QUOTE=r0b0tsquid;22944189]If I remember, you add 48 to it, sice 0 is 48 in ascii.
[/QUOTE]
I was thinking more of ze 2 digit answers:tinfoil:
You go into a loop where, if the number is greater than or equal to ten (greater than nine), you subtract ten and then add one to an adjacent cell; this gives you your two digits. You then just add 48 to both and output them. Unfortunately, greater than is an absolute bitch in brainfuck. :saddowns:
Exactly:saddowns:
Ook JITter is now working!
[img]http://img718.imageshack.us/img718/2029/gmbf06.png[/img]
Log:
[code]First substitution: .?..................!??..................?!!?!?.!..?..............!??..........?!!?!?...!...............!.!.......!..?.?.?................!??..........?!!?!?.!..?.?.?....................!??....................?!!?!?.!!!!!!!.?.?.?.?.!.......!.!!!!!!!!!!!!!.!!!!!!!!!!!!!!!!!..?.?..!.
Second substitution:>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.>>>++++++++[<++++>-]<.>>>++++++++++[<+++++++++>-]<---.<<<<.+++.------.--------.>>+.
Initialising memory...
Success! Beginning execution...
Moved pointer to 2
Moved pointer to 2
Incremented cell 2 to 1
Incremented cell 2 to 2
Incremented cell 2 to 3
Incremented cell 2 to 4
Incremented cell 2 to 5
Incremented cell 2 to 6
Incremented cell 2 to 7
Incremented cell 2 to 8
Incremented cell 2 to 9
Entered loop
Moved pointer to 1
Incremented cell 1 to 1
Incremented cell 1 to 2
Incremented cell 1 to 3
Incremented cell 1 to 4
Incremented cell 1 to 5
Incremented cell 1 to 6
Incremented cell 1 to 7
Incremented cell 1 to 8
Moved pointer to 2
Moved pointer to 2
Decremented cell 2 to 8
Returned to start of loop
Moved pointer to 1
Incremented cell 1 to 9
Incremented cell 1 to 10
Incremented cell 1 to 11
Incremented cell 1 to 12
Incremented cell 1 to 13
Incremented cell 1 to 14
Incremented cell 1 to 15
Incremented cell 1 to 16
Moved pointer to 2
Moved pointer to 2
Decremented cell 2 to 7
Returned to start of loop
Moved pointer to 1
Incremented cell 1 to 17
Incremented cell 1 to 18
Incremented cell 1 to 19
Incremented cell 1 to 20
Incremented cell 1 to 21
Incremented cell 1 to 22
Incremented cell 1 to 23
Incremented cell 1 to 24
Moved pointer to 2
Moved pointer to 2
Decremented cell 2 to 6
Returned to start of loop
Moved pointer to 1
Incremented cell 1 to 25
Incremented cell 1 to 26
Incremented cell 1 to 27
Incremented cell 1 to 28
Incremented cell 1 to 29
Incremented cell 1 to 30
Incremented cell 1 to 31
Incremented cell 1 to 32
Moved pointer to 2
Moved pointer to 2
Decremented cell 2 to 5
Returned to start of loop
Moved pointer to 1
Incremented cell 1 to 33
Incremented cell 1 to 34
Incremented cell 1 to 35
Incremented cell 1 to 36
Incremented cell 1 to 37
Incremented cell 1 to 38
Incremented cell 1 to 39
Incremented cell 1 to 40
Moved pointer to 2
Moved pointer to 2
Decremented cell 2 to 4
Returned to start of loop
Moved pointer to 1
Incremented cell 1 to 41
Incremented cell 1 to 42
Incremented cell 1 to 43
Incremented cell 1 to 44
Incremented cell 1 to 45
Incremented cell 1 to 46
Incremented cell 1 to 47
Incremented cell 1 to 48
Moved pointer to 2
Moved pointer to 2
Decremented cell 2 to 3
Returned to start of loop
Moved pointer to 1
Incremented cell 1 to 49
Incremented cell 1 to 50
Incremented cell 1 to 51
Incremented cell 1 to 52
Incremented cell 1 to 53
Incremented cell 1 to 54
Incremented cell 1 to 55
Incremented cell 1 to 56
Moved pointer to 2
Moved pointer to 2
Decremented cell 2 to 2
Returned to start of loop
Moved pointer to 1
Incremented cell 1 to 57
Incremented cell 1 to 58
Incremented cell 1 to 59
Incremented cell 1 to 60
Incremented cell 1 to 61
Incremented cell 1 to 62
Incremented cell 1 to 63
Incremented cell 1 to 64
Moved pointer to 2
Moved pointer to 2
Decremented cell 2 to 1
Returned to start of loop
Moved pointer to 1
Incremented cell 1 to 65
Incremented cell 1 to 66
Incremented cell 1 to 67
Incremented cell 1 to 68
Incremented cell 1 to 69
Incremented cell 1 to 70
Incremented cell 1 to 71
Incremented cell 1 to 72
Moved pointer to 2
Moved pointer to 2
Decremented cell 2 to 0
Exited loop
Moved pointer to 1
Output char H (value 72) from cell 1
Moved pointer to 2
Moved pointer to 2
Incremented cell 2 to 1
Incremented cell 2 to 2
Incremented cell 2 to 3
Incremented cell 2 to 4
Incremented cell 2 to 5
Incremented cell 2 to 6
Incremented cell 2 to 7
Entered loop
Moved pointer to 1
Incremented cell 1 to 73
Incremented cell 1 to 74
Incremented cell 1 to 75
Incremented cell 1 to 76
Moved pointer to 2
Moved pointer to 2
Decremented cell 2 to 6
Returned to start of loop
Moved pointer to 1
Incremented cell 1 to 77
Incremented cell 1 to 78
Incremented cell 1 to 79
Incremented cell 1 to 80
Moved pointer to 2
Moved pointer to 2
Decremented cell 2 to 5
Returned to start of loop
Moved pointer to 1
Incremented cell 1 to 81
Incremented cell 1 to 82
Incremented cell 1 to 83
Incremented cell 1 to 84
Moved pointer to 2
Moved pointer to 2
Decremented cell 2 to 4
Returned to start of loop
Moved pointer to 1
Incremented cell 1 to 85
Incremented cell 1 to 86
Incremented cell 1 to 87
Incremented cell 1 to 88
Moved pointer to 2
Moved pointer to 2
Decremented cell 2 to 3
Returned to start of loop
Moved pointer to 1
Incremented cell 1 to 89
Incremented cell 1 to 90
Incremented cell 1 to 91
Incremented cell 1 to 92
Moved pointer to 2
Moved pointer to 2
Decremented cell 2 to 2
Returned to start of loop
Moved pointer to 1
Incremented cell 1 to 93
Incremented cell 1 to 94
Incremented cell 1 to 95
Incremented cell 1 to 96
Moved pointer to 2
Moved pointer to 2
Decremented cell 2 to 1
Returned to start of loop
Moved pointer to 1
Incremented cell 1 to 97
Incremented cell 1 to 98
Incremented cell 1 to 99
Incremented cell 1 to 100
Moved pointer to 2
Moved pointer to 2
Decremented cell 2 to 0
Exited loop
Moved pointer to 1
Incremented cell 1 to 101
Output char e (value 101) from cell 1
Incremented cell 1 to 102
Incremented cell 1 to 103
Incremented cell 1 to 104
Incremented cell 1 to 105
Incremented cell 1 to 106
Incremented cell 1 to 107
Incremented cell 1 to 108
Output char l (value 108) from cell 1
Output char l (value 108) from cell 1
Incremented cell 1 to 109
Incremented cell 1 to 110
Incremented cell 1 to 111
Output char o (value 111) from cell 1
Moved pointer to 2
Moved pointer to 2
Moved pointer to 3
Moved pointer to 3
Moved pointer to 4
Moved pointer to 4
Incremented cell 4 to 1
Incremented cell 4 to 2
Incremented cell 4 to 3
Incremented cell 4 to 4
Incremented cell 4 to 5
Incremented cell 4 to 6
Incremented cell 4 to 7
Incremented cell 4 to 8
Entered loop
Moved pointer to 3
Incremented cell 3 to 1
Incremented cell 3 to 2
Incremented cell 3 to 3
Incremented cell 3 to 4
Moved pointer to 4
Moved pointer to 4
Decremented cell 4 to 7
Returned to start of loop
Moved pointer to 3
Incremented cell 3 to 5
Incremented cell 3 to 6
Incremented cell 3 to 7
Incremented cell 3 to 8
Moved pointer to 4
Moved pointer to 4
Decremented cell 4 to 6
Returned to start of loop
Moved pointer to 3
Incremented cell 3 to 9
Incremented cell 3 to 10
Incremented cell 3 to 11
Incremented cell 3 to 12
Moved pointer to 4
Moved pointer to 4
Decremented cell 4 to 5
Returned to start of loop
Moved pointer to 3
Incremented cell 3 to 13
Incremented cell 3 to 14
Incremented cell 3 to 15
Incremented cell 3 to 16
Moved pointer to 4
Moved pointer to 4
Decremented cell 4 to 4
Returned to start of loop
Moved pointer to 3
Incremented cell 3 to 17
Incremented cell 3 to 18
Incremented cell 3 to 19
Incremented cell 3 to 20
Moved pointer to 4
Moved pointer to 4
Decremented cell 4 to 3
Returned to start of loop
Moved pointer to 3
Incremented cell 3 to 21
Incremented cell 3 to 22
Incremented cell 3 to 23
Incremented cell 3 to 24
Moved pointer to 4
Moved pointer to 4
Decremented cell 4 to 2
Returned to start of loop
Moved pointer to 3
Incremented cell 3 to 25
Incremented cell 3 to 26
Incremented cell 3 to 27
Incremented cell 3 to 28
Moved pointer to 4
Moved pointer to 4
Decremented cell 4 to 1
Returned to start of loop
Moved pointer to 3
Incremented cell 3 to 29
Incremented cell 3 to 30
Incremented cell 3 to 31
Incremented cell 3 to 32
Moved pointer to 4
Moved pointer to 4
Decremented cell 4 to 0
Exited loop
Moved pointer to 3
Output char (value 32) from cell 3
Moved pointer to 4
Moved pointer to 4
Moved pointer to 5
Moved pointer to 5
Moved pointer to 6
Moved pointe
[/code]
What's next? Any other languages that you want supported? Whitespace is (probably) on the list, but any more suggestions will be welcome :smile:
You could try to make an Ook to Lua compiler.
Yeah - would probably be faster. I could make one for brainfuck instead - then I could JIT languages like Ook into brainfuck and then into lua. slower to JIT, but much neater to write. And runs at the same speed :v:
Anyway, I've been trawling through the esolang wiki, and have found another brainfuck-a-like to add to my interpreter: it's called fuckfuck.
Here's the syntax:
[code]
fuck >
shag <
boob +
tits -
cock .
knob ,
arse [
butt ]
[/code]
Hello world:
[code]
f**k b**b!!!!!!!! arse s**g boob!!
boob!!!! fuck tits butt shag cock fuck boob!!!
boob!! arse shag boob!!! fuck tits butt shag boob cock
BOOB!!! booBBoob boob cOCK! boob!! cock arsetits
buttfuck boob!!!!!!! arseshag boob!!
boobfuck t**s b**ts**g cockfuck boob!!!! boob!!
boob!! arse shag boob!!! boob!!! fuck tits
b u t t s h a g t i t s c o c k
tits!!!!!!!
cock boob boob
boobcocktits!!!!! cocktits!!!!!
tits!
c**kar seti tsb ut tfu ckb ooB!!!!!!!
arseshagboobboob boobboob fuckTITS buttshag boobcock arsetitsbutt
BOOB!!!!!!!!! cock
[/code]I'm gonna have fun with this one... :smug:
Sorry, you need to Log In to post a reply to this thread.