2014-01-08 1 views
0

루아에서 간단한 웹 브라우저를 만들고 싶습니다. 다음 스크립트가 있습니다. 하지만 그 컴파일 및 제공 오류 : 글로벌 'concommand'(없음 값) 인덱스 시도 아무도 내 스크립트에 뭐가 잘못 말할 수 있습니까?루아 오류 : 전역 'concommand'색인 생성 시도 (제로 값)

-- Simple Web Browser by Drunkie 

if SERVER then AddCSLuaFile("web_browser.lua") return end 

concommand.Add("OpenWebBrowser", function() 

local homepage = "http://www.google.com" 

local frame = vgui.Create("DFrame") 
frame:SetSize(ScrW()*0.8, ScrH()*0.8) 
frame:SetTitle("") 
frame:SetDraggable(false) 
frame:Center() 
frame:MakePopup() 
frame.Paint = function() 
    surface.SetDrawColor(0, 0, 0, 150) 
    surface.DrawRect(0, 0, frame:GetWide(), frame:GetTall()) 
end 

local lbl_loading = vgui.Create("DLabel", frame) 
lbl_loading:SetText("Loading . . .") 
surface.CreateFont("coolvetica", 64, 400, true, false, "LoadFont") 
lbl_loading:SetFont("LoadFont") 
lbl_loading:SetColor(Color(255, 255, 255)) 
lbl_loading:SizeToContents() 
lbl_loading:Center() 

local html_pos = { 12, 48 } 
local html_size = { frame:GetWide()-html_pos[1]*2, frame:GetTall()-html_pos[2]-html_pos[1] } 
local html_frame = vgui.Create("HTML", frame) 
html_frame:SetPos(html_pos[1], html_pos[2]) 
html_frame:SetSize(html_size[1], html_size[2]) 
html_frame:OpenURL(homepage) 

local lbl_goto = vgui.Create("DLabel", frame) 
lbl_goto:SetText("Goto:") 
surface.CreateFont("coolvetica", 24, 400, true, false, "GotoFont") 
lbl_goto:SetFont("GotoFont") 
lbl_goto:SetColor(Color(255, 255, 255)) 
lbl_goto:SetPos(12, 16) 
lbl_goto:SizeToContents() 

local txt_goto = vgui.Create("DTextEntry", frame) 
txt_goto:SetSize(frame:GetWide()-96, 24) 
txt_goto:SetPos(64, 14) 
txt_goto:SetText(homepage) 
txt_goto.OnEnter = function() 
    local site = string.lower(txt_goto:GetValue()) 
    --  if string.Left(site, 7) != "http://" then 
    --   site = "http://" .. site 
    --  txt_goto:SetText(site) 
    -- end 
    html_frame:OpenURL(site) 
end 

end) 
+4

'concommand'는 존재하지 않는 객체입니다. 정의 된 위치는 어디입니까? – Aesthete

+0

루아의 미리 정의 된 객체가 아닙니까? 나는 루아에서 초보자이며 여기에서이 코드를 얻었습니다. http://www.wiremod.com/forum/wiremod-addons-coding/21477-simple-web-browser.html – foobar

+0

도와 주시겠습니까? – foobar

답변

2

철수 링크 (다운로드하려면 로그인해야 함)를 따르지 못했습니다. 그러나이 스크립트는 Lua를 스크립트로 만들 수있는 응용 프로그램 내에서 실행해야합니다 (gmod http://www.garrysmod.com/). 이 스크립트에서 볼 수있는 몇 가지 변수는 호스트 응용 프로그램의 데이터에 연결됩니다.

스크립트가 수행하는 웹 브라우저를 만들려면 해당 응용 프로그램을 설치해야합니다. 또는이 방법을 사용하지 않고 Lua를 사용하는 Corona처럼 더 쉽고 재미있는 것으로 시작하면 훨씬 더 문서화되고 더 많은 커뮤니티가 지원됩니다.

+0

답변 해 주셔서 감사합니다. 글쎄요, wiremod에서 "web_browser.lua를 lua/autorun/ 에 넣으십시오. 서버 및 클라이언트에 설치할 수 있습니다. OpenWebBrowser를 사용할 콘솔에 입력하십시오."어디에 넣어야할지 모르겠다. 사실 저는 ll 웹 브라우저를 vlc 확장자로 추가하려고했습니다. 코로나를 사용하여 작동하는지 확신하지 못합니다. – foobar

+0

@ user2681573 네가 준'lua/autorun' 경로는 네가 넣어야 할 곳이다. 그 경로가 정확히 어디 있는지 모르겠지만 아마도 Garry의 Mod에 대한 문서가 알려줄 것입니다. –

+0

@ user2681573 .lua는 코로나에서 작동하지 않을 것이고, 나는 더 나은 워드 프로세서를 가지고 배우기 쉽도록 시도 할 것을 제안하고 있습니다. – Schollii

0

이 스크립트는 2010 년에 나온 반면, Garry는 2012/13에 Garry 's Mod에 API를 일부 변경했습니다. 스크립트가있는 그대로 작동하는 것은 거의 없습니다.

또한 Schollii는 Garry 's Mod로 프로그래밍을 시작하지 않을 것에 동의합니다. API가 좋지 않습니다.