http://filesmelt.com/dl/gmbf01.png
http://img822.imageshack.us/img822/7599/gmbf01.png
This is my first project using GMod Lua, so I just wanted to try something simple to get to know it. The screenshot is of it running numwarp. It outputs a debug log as well - here is the one for hello world:
Intitialising memory...
Success! Beginning execution...
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
Incremented cell 1 to 9
Incremented cell 1 to 10
Entered loop
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
Moved pointer to 3
Incremented cell 3 to 1
Incremented cell 3 to 2
Incremented cell 3 to 3
Incremented cell 3 to 4
Incremented cell 3 to 5
Incremented cell 3 to 6
Incremented cell 3 to 7
Incremented cell 3 to 8
Incremented cell 3 to 9
Incremented cell 3 to 10
Moved pointer to 4
Incremented cell 4 to 1
Incremented cell 4 to 2
Incremented cell 4 to 3
Moved pointer to 5
Incremented cell 5 to 1
Moved pointer to 4
Moved pointer to 3
Moved pointer to 2
Moved pointer to 1
Decremented cell 1 to 9
Returned to start of loop
Moved pointer to 2
Incremented cell 2 to 8
Incremented cell 2 to 9
Incremented cell 2 to 10
Incremented cell 2 to 11
Incremented cell 2 to 12
Incremented cell 2 to 13
Incremented cell 2 to 14
Moved pointer to 3
Incremented cell 3 to 11
Incremented cell 3 to 12
Incremented cell 3 to 13
Incremented cell 3 to 14
Incremented cell 3 to 15
Incremented cell 3 to 16
Incremented cell 3 to 17
Incremented cell 3 to 18
Incremented cell 3 to 19
Incremented cell 3 to 20
Moved pointer to 4
Incremented cell 4 to 4
Incremented cell 4 to 5
Incremented cell 4 to 6
Moved pointer to 5
Incremented cell 5 to 2
Moved pointer to 4
Moved pointer to 3
Moved pointer to 2
Moved pointer to 1
Decremented cell 1 to 8
Returned to start of loop
Moved pointer to 2
Incremented cell 2 to 15
Incremented cell 2 to 16
Incremented cell 2 to 17
Incremented cell 2 to 18
Incremented cell 2 to 19
Incremented cell 2 to 20
Incremented cell 2 to 21
Moved pointer to 3
Incremented cell 3 to 21
Incremented cell 3 to 22
Incremented cell 3 to 23
Incremented cell 3 to 24
Incremented cell 3 to 25
Incremented cell 3 to 26
Incremented cell 3 to 27
Incremented cell 3 to 28
Incremented cell 3 to 29
Incremented cell 3 to 30
Moved pointer to 4
Incremented cell 4 to 7
Incremented cell 4 to 8
Incremented cell 4 to 9
Moved pointer to 5
Incremented cell 5 to 3
Moved pointer to 4
Moved pointer to 3
Moved pointer to 2
Moved pointer to 1
Decremented cell 1 to 7
Returned to start of loop
Moved pointer to 2
Incremented cell 2 to 22
Incremented cell 2 to 23
Incremented cell 2 to 24
Incremented cell 2 to 25
Incremented cell 2 to 26
Incremented cell 2 to 27
Incremented cell 2 to 28
Moved pointer to 3
Incremented cell 3 to 31
Incremented cell 3 to 32
Incremented cell 3 to 33
Incremented cell 3 to 34
Incremented cell 3 to 35
Incremented cell 3 to 36
Incremented cell 3 to 37
Incremented cell 3 to 38
Incremented cell 3 to 39
Incremented cell 3 to 40
Moved pointer to 4
Incremented cell 4 to 10
Incremented cell 4 to 11
Incremented cell 4 to 12
Moved pointer to 5
Incremented cell 5 to 4
Moved pointer to 4
Moved pointer to 3
Moved pointer to 2
Moved pointer to 1
Decremented cell 1 to 6
Returned to start of loop
Moved pointer to 2
Incremented cell 2 to 29
Incremented cell 2 to 30
Incremented cell 2 to 31
Incremented cell 2 to 32
Incremented cell 2 to 33
Incremented cell 2 to 34
Incremented cell 2 to 35
Moved pointer to 3
Incremented cell 3 to 41
Incremented cell 3 to 42
Incremented cell 3 to 43
Incremented cell 3 to 44
Incremented cell 3 to 45
Incremented cell 3 to 46
Incremented cell 3 to 47
Incremented cell 3 to 48
Incremented cell 3 to 49
Incremented cell 3 to 50
Moved pointer to 4
Incremented cell 4 to 13
Incremented cell 4 to 14
Incremented cell 4 to 15
Moved pointer to 5
Incremented cell 5 to 5
Moved pointer to 4
Moved pointer to 3
Moved pointer to 2
Moved pointer to 1
Decremented cell 1 to 5
Returned to start of loop
Moved pointer to 2
Incremented cell 2 to 36
Incremented cell 2 to 37
Incremented cell 2 to 38
Incremented cell 2 to 39
Incremented cell 2 to 40
Incremented cell 2 to 41
Incremented cell 2 to 42
Moved pointer to 3
Incremented cell 3 to 51
Incremented cell 3 to 52
Incremented cell 3 to 53
Incremented cell 3 to 54
Incremented cell 3 to 55
Incremented cell 3 to 56
Incremented cell 3 to 57
Incremented cell 3 to 58
Incremented cell 3 to 59
Incremented cell 3 to 60
Moved pointer to 4
Incremented cell 4 to 16
Incremented cell 4 to 17
Incremented cell 4 to 18
Moved pointer to 5
Incremented cell 5 to 6
Moved pointer to 4
Moved pointer to 3
Moved pointer to 2
Moved pointer to 1
Decremented cell 1 to 4
Returned to start of loop
Moved pointer to 2
Incremented cell 2 to 43
Incremented cell 2 to 44
Incremented cell 2 to 45
Incremented cell 2 to 46
Incremented cell 2 to 47
Incremented cell 2 to 48
Incremented cell 2 to 49
Moved pointer to 3
Incremented cell 3 to 61
Incremented cell 3 to 62
Incremented cell 3 to 63
Incremented cell 3 to 64
Incremented cell 3 to 65
Incremented cell 3 to 66
Incremented cell 3 to 67
Incremented cell 3 to 68
Incremented cell 3 to 69
Incremented cell 3 to 70
Moved pointer to 4
Incremented cell 4 to 19
Incremented cell 4 to 20
Incremented cell 4 to 21
Moved pointer to 5
Incremented cell 5 to 7
Moved pointer to 4
Moved pointer to 3
Moved pointer to 2
Moved pointer to 1
Decremented cell 1 to 3
Returned to start of loop
Moved pointer to 2
Incremented cell 2 to 50
Incremented cell 2 to 51
Incremented cell 2 to 52
Incremented cell 2 to 53
Incremented cell 2 to 54
Incremented cell 2 to 55
Incremented cell 2 to 56
Moved pointer to 3
Incremented cell 3 to 71
Incremented cell 3 to 72
Incremented cell 3 to 73
Incremented cell 3 to 74
Incremented cell 3 to 75
Incremented cell 3 to 76
Incremented cell 3 to 77
Incremented cell 3 to 78
Incremented cell 3 to 79
Incremented cell 3 to 80
Moved pointer to 4
Incremented cell 4 to 22
Incremented cell 4 to 23
Incremented cell 4 to 24
Moved pointer to 5
Incremented cell 5 to 8
Moved pointer to 4
Moved pointer to 3
Moved pointer to 2
Moved pointer to 1
Decremented cell 1 to 2
Returned to start of loop
Moved pointer to 2
Incremented cell 2 to 57
Incremented cell 2 to 58
Incremented cell 2 to 59
Incremented cell 2 to 60
Incremented cell 2 to 61
Incremented cell 2 to 62
Incremented cell 2 to 63
Moved pointer to 3
Incremented cell 3 to 81
Incremented cell 3 to 82
Incremented cell 3 to 83
Incremented cell 3 to 84
Incremented cell 3 to 85
Incremented cell 3 to 86
Incremented cell 3 to 87
Incremented cell 3 to 88
Incremented cell 3 to 89
Incremented cell 3 to 90
Moved pointer to 4
Incremented cell 4 to 25
Incremented cell 4 to 26
Incremented cell 4 to 27
Moved pointer to 5
Incremented cell 5 to 9
Moved pointer to 4
Moved pointer to 3
Moved pointer to 2
Moved pointer to 1
Decremented cell 1 to 1
Returned to start of loop
Moved pointer to 2
Incremented cell 2 to 64
Incremented cell 2 to 65
Incremented cell 2 to 66
Incremented cell 2 to 67
Incremented cell 2 to 68
Incremented cell 2 to 69
Incremented cell 2 to 70
Moved pointer to 3
Incremented cell 3 to 91
Incremented cell 3 to 92
Incremented cell 3 to 93
Incremented cell 3 to 94
Incremented cell 3 to 95
Incremented cell 3 to 96
Incremented cell 3 to 97
Incremented cell 3 to 98
Incremented cell 3 to 99
Incremented cell 3 to 100
Moved pointer to 4
Incremented cell 4 to 28
Incremented cell 4 to 29
Incremented cell 4 to 30
Moved pointer to 5
Incremented cell 5 to 10
Moved pointer to 4
Moved pointer to 3
Moved pointer to 2
Moved pointer to 1
Decremented cell 1 to 0
Exited loop
Moved pointer to 2
Incremented cell 2 to 71
Incremented cell 2 to 72
Output char H (value 72) from cell 2
Moved pointer to 3
Incremented cell 3 to 101
Output char e (value 101) from cell 3
Incremented cell 3 to 102
Incremented cell 3 to 103
Incremented cell 3 to 104
Incremented cell 3 to 105
Incremented cell 3 to 106
Incremented cell 3 to 107
Incremented cell 3 to 108
Output char l (value 108) from cell 3
Output char l (value 108) from cell 3
Incremented cell 3 to 109
Incremented cell 3 to 110
Incremented cell 3 to 111
Output char o (value 111) from cell 3
Moved pointer to 4
Incremented cell 4 to 31
Incremented cell 4 to 32
Output char (value 32) from cell 4
Moved pointer to 3
Moved pointer to 2
Incremented cell 2 to 73
Incremented cell 2 to 74
Incremented cell 2 to 75
Incremented cell 2 to 76
Incremented cell 2 to 77
Incremented cell 2 to 78
Incremented cell 2 to 79
Incremented cell 2 to 80
Incremented cell 2 to 81
Incremented cell 2 to 82
Incremented cell 2 to 83
Incremented cell 2 to 84
Incremented cell 2 to 85
Incremented cell 2 to 86
Incremented cell 2 to 87
Output char W (value 87) from cell 2
Moved pointer to 3
Output char o (value 111) from cell 3
Incremented cell 3 to 112
Incremented cell 3 to 113
Incremented cell 3 to 114
Output char r (value 114) from cell 3
Decremented cell 3 to 113
Decremented cell 3 to 112
Decremented cell 3 to 111
Decremented cell 3 to 110
Decremented cell 3 to 109
Decremented cell 3 to 108
Output char l (value 108) from cell 3
Decremented cell 3 to 107
Decremented cell 3 to 106
Decremented cell 3 to 105
Decremented cell 3 to 104
Decremented cell 3 to 103
Decremented cell 3 to 102
Decremented cell 3 to 101
Decremented cell 3 to 100
Output char d (value 100) from cell 3
Moved pointer to 4
Incremented cell 4 to 33
Output char ! (value 33) from cell 4
Moved pointer to 5
Output char
(value 10) from cell 5
I’ll add settings and stuff, once I get DPropertySheets sorted out - as far as I can tell from the examples, you can only add one item to each sheet. I might need some help with this bit :saddowns:
Source, if you guys want it:
local frame = vgui.Create("DFrame")
frame:SetPos(100, 100)
frame:SetSize(400, 240)
frame:SetTitle("GMod Brainfuck by r0b0tsquid")
frame:MakePopup()
local buttonRun = vgui.Create("DButton")
buttonRun:SetParent(frame)
buttonRun:SetText( "Run!" )
buttonRun:SetPos( 220, 40 )
buttonRun:SetSize( 160, 30 )
buttonRun.DoClick = function ()
chat.AddText("Intitialising memory...")
data = {}
for i = 1, 30000 do
data* = 0
end
chat.AddText("Success! Beginning execution...")
i = 1
p = 1
ip = 1
lc = 0
prog = codeBox:GetValue()
inpt = inputBox:GetValue()
outputBox:SetValue("")
while i <= string.len(prog) do
v = string.byte(prog, i)
if v == 43 then
data[p] = data[p] + 1
chat.AddText("Incremented cell "..p.." to "..data[p])
if data[p] > 255 then data[p] = 0 end
elseif v == 45 then
data[p] = data[p] - 1
chat.AddText("Decremented cell "..p.." to "..data[p])
if data[p] < 0 then data[p] = 255 end
elseif v == 60 then
p = p - 1
chat.AddText("Moved pointer to "..p)
if p < 0 then
p = 30000
chat.AddText("Wrapped pointer to "..p)
end
elseif v == 62 then
p = p + 1
chat.AddText("Moved pointer to "..p)
if p > 30000 then
p = 1
chat.AddText("Wrapped pointer to "..p)
end
elseif v == 46 then
outputBox:SetValue(outputBox:GetValue()..string.char(data[p]))
chat.AddText("Output char "..string.char(data[p]).." (value "..data[p]..") from cell "..p)
elseif v == 44 then
if ip <= string.len(inpt) then
data[p] = string.byte(inpt, ip)
chat.AddText("Cell "..p.." set to "..data[p])
ip = ip + 1
else
data[p] = 0
end
elseif v == 91 then
if data[p] == 0 then
chat.AddText("Skipped loop")
lco = lc
lc = lc + 1
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
chat.AddText("Entered loop")
lc = lc + 1
end
elseif v == 93 then
if data[p] ~= 0 then
chat.AddText("Returned to start of loop")
lco = lc
lc = lc + 1
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
chat.AddText("Exited loop")
end
end
i = i + 1
end
end
inputBox = vgui.Create("DTextEntry")
inputBox:SetParent(frame)
inputBox:SetText("Enter Input:")
inputBox:SetPos( 20, 40 )
inputBox:SetSize( 160, 30 )
codeBox = vgui.Create("DTextEntry")
codeBox:SetParent(frame)
codeBox:SetText(",>++++++[<-------->-],[<+>-]<.")
codeBox:SetMultiline(true)
codeBox:SetPos( 20, 90 )
codeBox:SetSize( 160, 130 )
outputBox = vgui.Create("DTextEntry")
outputBox:SetParent(frame)
outputBox:SetText("Lulz")
outputBox:SetMultiline(true)
outputBox:SetPos( 220, 90 )
outputBox:SetSize( 160, 130 )