Hey,
Is it possible, to host a lua file online, like on my website, and then make a lua_run open it?
Like you have include("file.lua")?
I would like to know, since a lua_run entity in Hammer can't go longer than 255 characters, and I want to run a little bigger scripts than that in my map.
That's a pretty good idea. No idea if it's possible or not though.
Then you can edit scripts while the map is online. So you won't have to release a new map edit anyways.
possible , but it would need to be downloaded unless some c++ coder makes a nice module to compile lua from the web and run it ingame :)
But when you do
include("http://www.domain.com/lua/lua.lua"), it would be the same as include("/lua/lua.lua"), not?
I do this in FapHack.
For running the code:
[lua]if SERVER then
-- Hey, we want people to use this in singleplayer with SE on.
AddCSLuaFile("faphack.lua")
AddCSLuaFile("FapHack/faphack.lua")
return
end
local cs = CompileString
if GetConVar("fap_shouldload"):GetInt() != 1 then return end
if GetConVar("fap_alwaysloadhardcopy"):GetInt() == 1 then
MsgN("[FapHack] Loading hard copy.")
include("FapHack/FapHack.lua")
return
end
if not file.Exists("faphack_bot.txt") then
MsgN("[FapHack] No up to date copy present, loading original.")
include("FapHack/FapHack.lua")
return
end
local code = file.Read("faphack_bot.txt")
xpcall(cs(code , "FapHack/FapHack.lua") , function(err)
if err then
ErrorNoHalt("FapHack: "..err.."\n")
MsgN("Up to date copy is corrupt. Loading original backup.")
file.Delete("faphack_bot.txt") -- No longer needed, since it doesn't work. A working copy would hopefully download later.
include("FapHack/FapHack.lua")
end
end )[/lua]
And for downloading it
[lua]local function DownloadUpdate(rev , url , changelog)
MsgN("[FapHack] Downloading revision "..rev..":\n"..changelog)
local downreps = 0
local function GetHTTPSource(url)
http.Get(url , "" , function(cont , size)
if size > 0 and string.find(cont , "FapHack = {}") then
file.Write("faphack_bot.txt" , cont)
elseif downreps < 5 then
downreps = downreps + 1
GetHTTPSource(url)
end
end)
end
GetHTTPSource(url)
end[/lua]
If I would make a lua run, which can't contain too much characters, what would be the shortest way?
Can someone make me a little script?
Since I know 0 lua.
[QUOTE=Cyberuben;26428519]If I would make a lua run, which can't contain too much characters, what would be the shortest way?
Can someone make me a little script?
Since I know 0 lua.[/QUOTE]
[lua]http.Get("http://website.com/file.txt" , "" , function(c,s) if s>0 then xpcall(CompileString(c , "mapname.bsp" , function(err) ErrorNoHalt(err.."\n") end) end end )[/lua]
-snip-
And then? What do I have to do to open that script? I mean, run it.
Yes... I mean...
I upload a lua file at the website, then I use the command shown above to get it, and then?
What do I have to do then? Like activating a trigger or something?
Do I have to run some other lua_run with include("file.lua")?
Which path, etc, that's what I mean.
should do it : [LUA]local old = include
function include( f , b )
if !b then
local r = old( f )
return r
elseif b == true then
http.Get( f , "", function( c , s )
if c then
xpcall( f , print )
end
end)
end
end
old = nil
[/LUA]
intested, but should work, when you use include, use a bool and it will be loaded through internet
But it has to fit in a lua_run, that's the restriction I'm facing.
I know, but, what next? T.T
I know those things.
I mean, when I used the http.Get script, how to run it?
Trigger your lua_run entity.
So, it says:
it gets the file, then it executes the file?
lua_run http.Get("yourwebsite.com/file.lua", "", function(c) RunString(c) end)
[editline]1st December 2010[/editline]
What's all this xpcall bullshit?
[QUOTE=Chief Tiger;26429358]lua_run http.Get("yourwebsite.com/file.lua", "", function(c) RunString(c) end)
[editline]1st December 2010[/editline]
What's all this xpcall bullshit?[/QUOTE]
Awesome way of stopping errors from messing stuff up. Also, if you wanted to do it that way:
[lua]http.Get("yourwebsite.com/file.lua" , "" , RunString)[/lua]
Then it executes the script automaticly after it downloaded?
Yeah, both sets of code do. It's executed as soon as it's downloaded, which will be the frame after you trigger the lua_run entity.
Ah thanks.
So, you trigger it once, then it downloads the file, and automaticly updates the code in the lua_run?
[QUOTE=Cyberuben;26429591]Ah thanks.
So, you trigger it once, then it downloads the file, and automaticly updates the code in the lua_run?[/QUOTE]
No. You trigger the lua_run entity, which fetches the code from your webserver and then runs it. It doesn't put the code into the lua_run entity.
] lua_run http.Get("http://dj-ruben.nl/lua/kill.lua" , "" , RunString)
> http.Get("http://dj-ruben.nl/lua/kill.lua" , "" , RunString)...
test
Lua file contained: print("test")
It worked :D
[editline]1st December 2010[/editline]
Oh crap.
It takes ages to download.
Is it possible to download on map spawn, and then use the script with a different trigger?
[editline]1st December 2010[/editline]
Someone who can help me through Teamviewer?
I don't really get it...
my steam name is NeburRebyc.
I would really like if someone can get this working for me?
Maybe I'll give the one who can make it fully working a reward.
No, choco cookies.
Ofcourse it's money.
I don't know, maybe a few bucks :D
But depends on how much work it is, you know?
Everyone has pretty much given you all the information you need...
Because I can't get it working?
] lua_run http.Get("http://dj-ruben.nl/lua/kill.lua" , "" , function(c,s) if s>0 then xpcall(CompileString(c , "rpmap.bsp" , function(err) ErrorNoHalt(err.."\n") end) end end )
> http.Get("http://dj-ruben.nl/lua/kill.lua" , "" , function(c,s) if s>0 then xpcall(CompileString(c , "rpmap.bsp" , function(err) ErrorNoHalt(err.."\n") end) end end )...
[lua_run:1] ')' expected near 'end'
]
[editline]1st December 2010[/editline]
[QUOTE=thejjokerr;26430497][lua]
StringToRun = "";
hook.Add( "InitPostEntity", "DownloadTheScript", function()
http.Get("yourwebsite.com/file.lua", "", function(c) StringToRun = c end);
end);
function CallThisToRunThatStringYouSaved()
xpcall(CompileString(StringToRun , "mapname.bsp") , function(err) ErrorNoHalt(err.."\n") end);
end;[/lua]
Something like this maybe? lua_run CallThisToRunThatStringYouSaved() to actually run the saved string.[/QUOTE]
This is why I want someone to help me, because I don't know lua T.T
Which one of the 3?
[editline]1st December 2010[/editline]
[QUOTE=thejjokerr;26430532]Put that code in a lua file in lua/autorun. Then lua_run CallThisToRunThatStringYouSaved() in your map or w/e.[/QUOTE]
That's the problem.
I want to keep anything without a .lua file you have to place in your folders. My map is going to be download able, and I only want to make 1 .bsp and nothing more.
Sorry, you need to Log In to post a reply to this thread.