`,]']>S}Wup8d%qy)6o;]AsVl3S}Wup8d%qy)6o,AsVl3?: ̜̙ ̜ ̙̙̙̙̙̜ ̙ ̜YUU YUUUU ̙ YUUUUUU̜UUUUUUU ̙UUUUUUU̜ YUUUUUUUU̜ YUUUUUUUU ̜ UUUUUUUUU ̜ UUUUUUUUU ̜ UUUUUUUUU ̙UUUUUUUUU ̜UUUUUUUUU ̙ YUUUUUUUU YUUUUUUUU UUUUUUU"" UUUUUUU """"YUUUUUU)"""""YUUUU """""" YUU"""""" ̙ )"""""""̜ )"""""""̙)"""""""̜ )"""""""̜ )"""""""̜ """""" ̜ """""" ̜ )"""""̙""""̜"" ̙  "" """")""""""""""" """""" )""""""")""""""")""""""")""""""")""""""""""""" """""" )""""""""" "" "" """")""""" """""" """""" )""""""")""""""" )""""""" )""""""" )""""""""""""" """""" )""""" """""" ,`,]']>S}Wup8d%qy)6o;]AsVl3 0 then cam.x = atoms[select].pos[1] cam.y = atoms[select].pos[2] end if keyp(17) then mode = mode + 1 mode = mode % 2 end --atoms[2].pos[2] = atoms[2].pos[2] + 0.25 if btn(0) and select == 0 then cam.y = cam.y - 1 end if btn(1) and select == 0 then cam.y = cam.y + 1 end if btn(2) and select == 0 then cam.x = cam.x - 1 end if btn(3) and select == 0 then cam.x = cam.x + 1 end if btnp(4) and select == 0 then createAtom(type[atom], cam.x, cam.y) end if state == 0 then print("Element "..atom.."/"..#type.." ("..type[atom]..")", 0, 0, 12-alt) if select == 0 then circ(oX, oY, 2, 12-alt) circb(oX, oY, 2, 15) if btnp(6) and atom ~= 1 then atom = atom - 1 end if btnp(7) and atom ~= #type then atom = atom + 1 end end end if select ~= 0 then if #atoms > 0 then print("Atom "..select.."/"..#atoms.." ("..atoms[select].type..")", 0, 7, 12-alt) -- with "..sumBonds(select).."/"..info[atoms[select].type].bondLimit.." bond(s)" end --if btn(6) and btn(7) then select = 0 end if state == 0 then if btn(0) and select ~= #atoms then select = select + 1 end if btn(1) and select ~= 1 then select = select - 1 end if btnp(2) and select ~= 1 then select = select - 1 end if btnp(3) and select ~= #atoms then select = select + 1 end if btn(6) and btn(7) then select = 0 end if btnp(4) and #atoms > 1 then state = 1 end elseif state == 1 then --trace(select) print("Moving atom...?", 0, 0, 12-alt) print(bonds.."/"..info[atoms[select].type].bondLimit.." bond(s)", 0, 14, 12-alt) if btn(0) then atoms[select].pos[2] = atoms[select].pos[2] - 1 end if btn(1) then atoms[select].pos[2] = atoms[select].pos[2] + 1 end if btn(2) then atoms[select].pos[1] = atoms[select].pos[1] - 1 end if btn(3) then atoms[select].pos[1] = atoms[select].pos[1] + 1 end --[[if btnp(6) and bonds ~= 1 then bonds = bonds - 1 end if btnp(7) and bonds ~= 4 then bonds = bonds + 1 end]] if btnp(6) and select ~= 1 then select = select - 1 end if btnp(7) and select ~= #atoms then select = select + 1 end if btn(6) and btn(7) then state = 0 end if btnp(4) and #atoms > 1 then tempID = select state = 2 end elseif state == 2 then print("Establishing bond(s)...?", 0, 0, 12-alt) if btn(0) and select ~= #atoms then select = select + 1 end if btn(1) and select ~= 1 then select = select - 1 end if btnp(2) and select ~= 1 then select = select - 1 end if btnp(3) and select ~= #atoms then select = select + 1 end line(atoms[tempID].pos[1]-cam.x+oX, atoms[tempID].pos[2]-cam.y+oY, atoms[select].pos[1]-cam.x+oX, atoms[select].pos[2]-cam.y+oY, 15-(bonds-1)) print(bonds.."/"..info[atoms[select].type].bondLimit.." bond(s)", 0, 14, 12-alt) if btnp(6) and bonds ~= 1 then bonds = bonds - 1 end if btnp(7) and bonds ~= maxBonds then bonds = bonds + 1 end if btn(6) and btn(7) then state = 0 end if tempID == select then popup("An atom cannot establish a bond to itself.", 4, 1) end if btnp(4) and #atoms > 1 then if sumBonds(tempID)+bonds <= info[atoms[tempID].type].bondLimit and sumBonds(select)+bonds <= info[atoms[select].type].bondLimit and tempID ~= select then createBond(tempID, select, bonds) else popup("Failed to establish bonds to one or both atoms.", 2+alt, 180) end state = 0 end end end --::out:: if btnp(5) and select ~= 0 then table.remove(atoms, select) for i = 1, #atoms do atoms[i].id = i end for i = 1, #atoms do local bonds = atoms[i].bonds for j = #bonds, 1, -1 do local target = bonds[j].target if target == select then table.remove(bonds, j) -- remove bond to deleted atom elseif target > select then bonds[j].target = target - 1 -- shift target index down end end end --select = select - 1 end if select > #atoms then select = #atoms end if #atoms == 0 then select = 0 else --[[if #atoms > 0 then print(select, 32, 32) end]] end if btnp(5) and select == 0 then select = 1 end if text[3] ~= 0 then print(text[1], 0, 110, text[2], false, 1, true) text[3] = text[3] - 1 end --print(atoms[#atoms].id) end