Forum

> > CS2D > Scripts > Is there a way to know a lua file name?
Forums overviewCS2D overview Scripts overviewLog in to reply

English Is there a way to know a lua file name?

11 replies
To the start Previous 1 Next To the start

old Is there a way to know a lua file name?

MikuAuahDark
User Off Offline

Quote
i want to create a "Update Lua" lua but i don't know is there a way to know a lua filename(when dofile command is executed)? i found a way to know it with table.concat and table.sort here my code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function luafile(path)
	t = {}
	i = 0
	for word in string.gmatch(path,".") do
		i = i + 1           
		t[i] = word       
	end
	table.sort(t,function(a,b) return a>b end)
	remov=false
	for num,val in pairs(t) do
		if val=="/" then
				remov=true
				table.remove(t,num)
			end
		end
		if remov==true then
			table.remove(t,num)
		end
	end
	table.sort(t)
	return table.concat(t)
end
print(luafile("sys/lua/pointscript.lua"))
but after i execute that code on my Text command line(file cs2d Text Console v2 ) it shows this:
1
.aaciillnopprsssttuuy
so is there any another way to know lua file(without opening windows explore/folders)?
EDIT: it has been fixed. i use string.sub
edited 1×, last 22.07.12 12:53:45 pm

old Re: Is there a way to know a lua file name?

MikuAuahDark
User Off Offline

Quote
@user Avo: update lua without restarting the server, updated lua file will be placed at sys/lua/update and after updated the lua will write the luafile that used on servers, dofile the updated lua, and update the file by write system. afterwards the update file will be deleted but you know, the script will still active even if you delete the lua(not updated) so it will still active

old Re: Is there a way to know a lua file name?

DC
Admin Off Offline

Quote
You can also reset the whole Lua script engine with the command cs2d cmd luareset
But this will also stop the script that is currently running. Maybe CS2D will even crash when you execute this command with a Lua script. I'm not sure.

old Re: Is there a way to know a lua file name?

Avo
User Off Offline

Quote
Way to fix this is edit addhook and freehook functions, create table with all variables and functions names(as strings). Then use loadstring() function to remove them (variable=nil; function=nil etc)

Pretty possible but complicated.

EDIT: Could be easier with metatables.
edited 1×, last 21.07.12 06:03:54 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview