1
2
3
4
5
6
2
3
4
5
6
function binary_operation(operation_func, operand1, operand2) return operation_func(operand1, operand2) end function add(o1,o2) return o1+o2 end print(binary_operation(add,3,4))
Scripts
Tricks in CS2D Scripting that you might not know.
Poll| All of them | 29.23% (19) | |
| None of them | 40.00% (26) | |
| A few of them | 30.77% (20) |
function binary_operation(operation_func, operand1, operand2) return operation_func(operand1, operand2) end function add(o1,o2) return o1+o2 end print(binary_operation(add,3,4))
Spawn player without any weapons at allcondition=true
addhook("die","Miku_Hatsune")
function Miku_Hatsune(id)
	if conditional then
		local x,y=randomentity(player(id,"team")-1)
		parse("spawnplayer "..id.." "..(x*32+16).." "..(y*32+16))
	end
end
Getting LUA filename that call the functionfunction GetCurrentLUAFilename()
	local traceback_string=debug.traceback():gsub("\t",""):sub(18)
	local index=0
	for line in traceback_string:gmatch("[^\n]+") do
		index=index+1
		if index==2 then
			local t=line:find(":")
			return line:sub(1,t-1)
		end
	end
end
print(GetCurrentLUAFilename()) -- Output "stdin" when you use it at interpreter. If it used on another file, then it output the LUA filename
Creating a errorerror("Your string here")
-- LUA ERROR: filename.lua:1: Your string here
Lee has writtenpackage.cpath = package.cpath.."./lib/?.dll;../lib/?.dll;../../lib/?.dll;../../../lib/?.dll"
FlooD yes, i am. i use that to include a LuaSYS Library on my CS2D mission map
FlooD has written
Lee has writtenpackage.cpath = package.cpath.."./lib/?.dll;../lib/?.dll;../../lib/?.dll;../../../lib/?.dll"
FlooD has written
Lee has writtenpackage.cpath = package.cpath.."./lib/?.dll;../lib/?.dll;../../lib/?.dll;../../../lib/?.dll"
Deleting all selection of menu but make the menu remains.menu(id,"Test,123,456") -- Later. Delay about 5 seconds menu(id,"")
player(id,"weapon") and player(id,"weapontype") is sameprint(player(id,"weapon")==player(id,"weapontype") and "Same" or "Not Same") -- Same
prepare() do for k,v in pairs(var1) do for k2,v2 in pairs(var2) do if v == v2 then match() return end end no_match() end continue()
now i know how to make random number for cs2d tibia lotery
local BinaryFormat = package.cpath:match("%p[\\|/]?%p(%a+)")
if BinaryFormat == "dll" then
	function os.name()
		return "Windows"
	end
elseif BinaryFormat == "so" then
	function os.name()
		return "Linux"
	end
elseif BinaryFormat == "dylib" then
	function os.name()
		return "MacOS"
	end
end
BinaryFormat = nil
nils everywhere? Are you suffering from spats of unfotunate speeling mistekes? Then you'll understand how annoying it is to track down one small typo within your goliath of a codebase. Seriously, that's probably the solution to about 30% of all of the questions that are asked in this forum.
setmetatable(
_G,
{__index = function (_, key) error("Undefined variable " .. key) end })
Starkkz: Useless now
function spawnobject(type, x, y, rot, mode, team, player)
	if type and x and y then
		rot, mode, team, player = rot or 0, mode or 0, team or 0, player or 0
		parse("spawnobject "..type.." "..x.." "..y.." "..rot.." "..mode.." "..team.." "..player)
		return objectat(x, y, type)
	end
end