repo_name
stringlengths
6
69
path
stringlengths
6
178
copies
stringclasses
278 values
size
stringlengths
4
7
content
stringlengths
671
917k
license
stringclasses
15 values
yejr/MyDBAtools
bench-tools/sysbench/sysbench/tests/db/select_random_ranges.lua
11
4066
-- This test is designed for testing MariaDB's key_cache_segments for MyISAM, -- and should work with other storage engines as well. -- -- For details about key_cache_segments please refer to: -- http://kb.askmonty.org/v/segmented-key-cache -- function prepare() local query local i set_vars() db_connect() print("Creating table 'sbtest'...") if (db_driver == "mysql") then query = [[ CREATE TABLE sbtest ( id INTEGER UNSIGNED NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[, k INTEGER UNSIGNED DEFAULT '0' NOT NULL, c CHAR(120) DEFAULT '' NOT NULL, pad CHAR(60) DEFAULT '' NOT NULL, PRIMARY KEY (id) ) /*! ENGINE = ]] .. mysql_table_engine .. " MAX_ROWS = " .. myisam_max_rows .. " */" elseif (db_driver == "oracle") then query = [[ CREATE TABLE sbtest ( id INTEGER NOT NULL, k INTEGER, c CHAR(120) DEFAULT '' NOT NULL, pad CHAR(60 DEFAULT '' NOT NULL, PRIMARY KEY (id) ) ]] elseif (db_driver == "pgsql") then query = [[ CREATE TABLE sbtest ( id ]] .. (sb.oltp_auto_inc and "SERIAL") or "" .. [[, k INTEGER DEFAULT '0' NOT NULL, c CHAR(120) DEFAULT '' NOT NULL, pad CHAR(60) DEFAULT '' NOT NULL, PRIMARY KEY (id) ) ]] elseif (db_driver == "drizzle") then query = [[ CREATE TABLE sbtest ( id INTEGER NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[, k INTEGER DEFAULT '0' NOT NULL, c CHAR(120) DEFAULT '' NOT NULL, pad CHAR(60) DEFAULT '' NOT NULL, PRIMARY KEY (id) ) ]] else print("Unknown database driver: " .. db_driver) return 1 end db_query(query) if (db_driver == "oracle") then db_query("CREATE SEQUENCE sbtest_seq") db_query([[CREATE TRIGGER sbtest_trig BEFORE INSERT ON sbtest FOR EACH ROW BEGIN SELECT sbtest_seq.nextval INTO :new.id FROM DUAL; END;]]) end db_query("CREATE INDEX k on sbtest(k)") print("Inserting " .. oltp_table_size .. " records into 'sbtest'") if (oltp_auto_inc) then db_bulk_insert_init("INSERT INTO sbtest(k, c, pad) VALUES") else db_bulk_insert_init("INSERT INTO sbtest(id, k, c, pad) VALUES") end for i = 1,oltp_table_size do if (oltp_auto_inc) then db_bulk_insert_next("("..i..", ' ', 'qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')") else db_bulk_insert_next("("..i..", "..i..", ' ', 'qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')") end end db_bulk_insert_done() return 0 end function cleanup() print("Dropping table 'sbtest'...") db_query("DROP TABLE sbtest") end function thread_init(thread_id) set_vars() ranges = "" for i = 1,number_of_ranges do ranges = ranges .. "k BETWEEN ? AND ? OR " end -- Get rid of last OR and space. ranges = string.sub(ranges, 1, string.len(ranges) - 3) stmt = db_prepare([[ SELECT count(k) FROM sbtest WHERE ]] .. ranges .. [[ ]]) params = {} for j = 1,number_of_ranges * 2 do params[j] = 1 end db_bind_param(stmt, params) end function event(thread_id) local rs -- To prevent overlapping of our range queries we need to partition the whole table -- into num_threads segments and then make each thread work with its own segment. for i = 1,number_of_ranges * 2,2 do params[i] = sb_rand(oltp_table_size / num_threads * thread_id, oltp_table_size / num_threads * (thread_id + 1)) params[i + 1] = params[i] + delta end rs = db_execute(stmt) db_store_results(rs) db_free_results(rs) end function set_vars() oltp_table_size = oltp_table_size or 10000 number_of_ranges = number_of_ranges or 10 delta = random_ranges_delta or 5 if (oltp_auto_inc == 'off') then oltp_auto_inc = false else oltp_auto_inc = true end end
bsd-3-clause
praveenjha527/Algorithm-Implementations
Gauss_Seidel_Algorithm/Lua/Yonaba/gauss_seidel_test.lua
26
2074
-- Tests for sor.lua local gauss_seidel = require 'gauss_seidel' local total, pass = 0, 0 local function dec(str, len) return #str < len and str .. (('.'):rep(len-#str)) or str:sub(1,len) end local function run(message, f) total = total + 1 local ok, err = pcall(f) if ok then pass = pass + 1 end local status = ok and 'PASSED' or 'FAILED' print(('%02d. %68s: %s'):format(total, dec(message,68), status)) end -- Fuzzy equality test local function fuzzy_eq(a, b, eps) eps = eps or 1e-3 return math.abs(a - b) < eps end run('Testing Gauss Seidel', function() local m = { {-4,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0}, {1,-4,1,0,0,1,0,0,0,0,0,0,0,0,0,0}, {0,1,-4,1,0,0,1,0,0,0,0,0,0,0,0,0}, {0,0,1,-4,0,0,0,1,0,0,0,0,0,0,0,0}, {1,0,0,0,-4,1,0,0,1,0,0,0,0,0,0,0}, {0,1,0,0,1,-4,1,0,0,1,0,0,0,0,0,0}, {0,0,1,0,0,1,-4,1,0,0,1,0,0,0,0,0}, {0,0,0,1,0,0,1,-4,0,0,0,1,0,0,0,0}, {0,0,0,0,1,0,0,0,-4,1,0,0,1,0,0,0}, {0,0,0,0,0,1,0,0,1,-4,1,0,0,1,0,0}, {0,0,0,0,0,0,1,0,0,1,-4,1,0,0,1,0}, {0,0,0,0,0,0,0,1,0,0,1,-4,0,0,0,1}, {0,0,0,0,0,0,0,0,1,0,0,0,-4,1,0,0}, {0,0,0,0,0,0,0,0,0,1,0,0,1,-4,1,0}, {0,0,0,0,0,0,0,0,0,0,1,0,0,1,-4,1}, {0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,-4}, } local b = {-11, -3, -3, -11, -8, 0, 0, -8, -8, 0, 0, -8, -10,-2, -2, -10} local x = gauss_seidel(m, b) assert(fuzzy_eq(x[1], 5.454459)) assert(fuzzy_eq(x[2], 4.594688)) assert(fuzzy_eq(x[3], 4.594679)) assert(fuzzy_eq(x[4], 5.454531)) assert(fuzzy_eq(x[5], 6.223469)) assert(fuzzy_eq(x[6], 5.329580)) assert(fuzzy_eq(x[7], 5.329561)) assert(fuzzy_eq(x[8], 6.223491)) assert(fuzzy_eq(x[9], 6.109833)) assert(fuzzy_eq(x[10], 5.170488)) assert(fuzzy_eq(x[11], 5.170455)) assert(fuzzy_eq(x[12], 6.109845)) assert(fuzzy_eq(x[13], 5.045460)) assert(fuzzy_eq(x[14], 4.071980)) assert(fuzzy_eq(x[15], 4.071964)) assert(fuzzy_eq(x[16], 5.045457)) end) print(('-'):rep(80)) print(('Total : %02d: Pass: %02d - Failed : %02d - Success: %.2f %%') :format(total, pass, total-pass, (pass*100/total)))
mit
TheAnswer/FirstTest
bin/scripts/items/objects/armor/composite/composite_bicep_r.lua
1
2424
--Copyright (C) 2007 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. composite_bicep_r = Armor:new{ objectName = "Composite Bicep", templateName = "armor_composite_bicep_r", objectCRC = 1668390786, objectType = ARMARMOR, armorType = ARMOR_BICEPR, energyResist = 35, kineticResist = 35, healthEncum = 70, actionEncum = 70, mindEncum = 70, itemMask = HUMANOIDS }
lgpl-3.0
hamode-Aliraq/HAMODE_ALIRAQE
libs/dateparser.lua
502
6212
local difftime, time, date = os.difftime, os.time, os.date local format = string.format local tremove, tinsert = table.remove, table.insert local pcall, pairs, ipairs, tostring, tonumber, type, setmetatable = pcall, pairs, ipairs, tostring, tonumber, type, setmetatable local dateparser={} --we shall use the host OS's time conversion facilities. Dealing with all those leap seconds by hand can be such a bore. local unix_timestamp do local now = time() local local_UTC_offset_sec = difftime(time(date("!*t", now)), time(date("*t", now))) unix_timestamp = function(t, offset_sec) local success, improper_time = pcall(time, t) if not success or not improper_time then return nil, "invalid date. os.time says: " .. (improper_time or "nothing") end return improper_time - local_UTC_offset_sec - offset_sec end end local formats = {} -- format names local format_func = setmetatable({}, {__mode='v'}) --format functions ---register a date format parsing function function dateparser.register_format(format_name, format_function) if type(format_name)~="string" or type(format_function)~='function' then return nil, "improper arguments, can't register format handler" end local found for i, f in ipairs(format_func) do --for ordering if f==format_function then found=true break end end if not found then tinsert(format_func, format_function) end formats[format_name] = format_function return true end ---register a date format parsing function function dateparser.unregister_format(format_name) if type(format_name)~="string" then return nil, "format name must be a string" end formats[format_name]=nil end ---return the function responsible for handling format_name date strings function dateparser.get_format_function(format_name) return formats[format_name] or nil, ("format %s not registered"):format(format_name) end ---try to parse date string --@param str date string --@param date_format optional date format name, if known --@return unix timestamp if str can be parsed; nil, error otherwise. function dateparser.parse(str, date_format) local success, res, err if date_format then if not formats[date_format] then return 'unknown date format: ' .. tostring(date_format) end success, res = pcall(formats[date_format], str) else for i, func in ipairs(format_func) do success, res = pcall(func, str) if success and res then return res end end end return success and res end dateparser.register_format('W3CDTF', function(rest) local year, day_of_year, month, day, week local hour, minute, second, second_fraction, offset_hours local alt_rest year, rest = rest:match("^(%d%d%d%d)%-?(.*)$") day_of_year, alt_rest = rest:match("^(%d%d%d)%-?(.*)$") if day_of_year then rest=alt_rest end month, rest = rest:match("^(%d%d)%-?(.*)$") day, rest = rest:match("^(%d%d)(.*)$") if #rest>0 then rest = rest:match("^T(.*)$") hour, rest = rest:match("^([0-2][0-9]):?(.*)$") minute, rest = rest:match("^([0-6][0-9]):?(.*)$") second, rest = rest:match("^([0-6][0-9])(.*)$") second_fraction, alt_rest = rest:match("^%.(%d+)(.*)$") if second_fraction then rest=alt_rest end if rest=="Z" then rest="" offset_hours=0 else local sign, offset_h, offset_m sign, offset_h, rest = rest:match("^([+-])(%d%d)%:?(.*)$") local offset_m, alt_rest = rest:match("^(%d%d)(.*)$") if offset_m then rest=alt_rest end offset_hours = tonumber(sign .. offset_h) + (tonumber(offset_m) or 0)/60 end if #rest>0 then return nil end end year = tonumber(year) local d = { year = year and (year > 100 and year or (year < 50 and (year + 2000) or (year + 1900))), month = tonumber(month) or 1, day = tonumber(day) or 1, hour = tonumber(hour) or 0, min = tonumber(minute) or 0, sec = tonumber(second) or 0, isdst = false } local t = unix_timestamp(d, (offset_hours or 0) * 3600) if second_fraction then return t + tonumber("0."..second_fraction) else return t end end) do local tz_table = { --taken from http://www.timeanddate.com/library/abbreviations/timezones/ A = 1, B = 2, C = 3, D = 4, E=5, F = 6, G = 7, H = 8, I = 9, K = 10, L = 11, M = 12, N = -1, O = -2, P = -3, Q = -4, R = -5, S = -6, T = -7, U = -8, V = -9, W = -10, X = -11, Y = -12, Z = 0, EST = -5, EDT = -4, CST = -6, CDT = -5, MST = -7, MDT = -6, PST = -8, PDT = -7, GMT = 0, UT = 0, UTC = 0 } local month_val = {Jan=1, Feb=2, Mar=3, Apr=4, May=5, Jun=6, Jul=7, Aug=8, Sep=9, Oct=10, Nov=11, Dec=12} dateparser.register_format('RFC2822', function(rest) local year, month, day, day_of_year, week_of_year, weekday local hour, minute, second, second_fraction, offset_hours local alt_rest weekday, alt_rest = rest:match("^(%w%w%w),%s+(.*)$") if weekday then rest=alt_rest end day, rest=rest:match("^(%d%d?)%s+(.*)$") month, rest=rest:match("^(%w%w%w)%s+(.*)$") month = month_val[month] year, rest = rest:match("^(%d%d%d?%d?)%s+(.*)$") hour, rest = rest:match("^(%d%d?):(.*)$") minute, rest = rest:match("^(%d%d?)(.*)$") second, alt_rest = rest:match("^:(%d%d)(.*)$") if second then rest = alt_rest end local tz, offset_sign, offset_h, offset_m tz, alt_rest = rest:match("^%s+(%u+)(.*)$") if tz then rest = alt_rest offset_hours = tz_table[tz] else offset_sign, offset_h, offset_m, rest = rest:match("^%s+([+-])(%d%d)(%d%d)%s*(.*)$") offset_hours = tonumber(offset_sign .. offset_h) + (tonumber(offset_m) or 0)/60 end if #rest>0 or not (year and day and month and hour and minute) then return nil end year = tonumber(year) local d = { year = year and ((year > 100) and year or (year < 50 and (year + 2000) or (year + 1900))), month = month, day = tonumber(day), hour= tonumber(hour) or 0, min = tonumber(minute) or 0, sec = tonumber(second) or 0, isdst = false } return unix_timestamp(d, offset_hours * 3600) end) end dateparser.register_format('RFC822', formats.RFC2822) --2822 supercedes 822, but is not a strict superset. For our intents and purposes though, it's perfectly good enough dateparser.register_format('RFC3339', formats.W3CDTF) --RFC3339 is a subset of W3CDTF return dateparser
gpl-2.0
amirfo18/Star-Queen
libs/dateparser.lua
502
6212
local difftime, time, date = os.difftime, os.time, os.date local format = string.format local tremove, tinsert = table.remove, table.insert local pcall, pairs, ipairs, tostring, tonumber, type, setmetatable = pcall, pairs, ipairs, tostring, tonumber, type, setmetatable local dateparser={} --we shall use the host OS's time conversion facilities. Dealing with all those leap seconds by hand can be such a bore. local unix_timestamp do local now = time() local local_UTC_offset_sec = difftime(time(date("!*t", now)), time(date("*t", now))) unix_timestamp = function(t, offset_sec) local success, improper_time = pcall(time, t) if not success or not improper_time then return nil, "invalid date. os.time says: " .. (improper_time or "nothing") end return improper_time - local_UTC_offset_sec - offset_sec end end local formats = {} -- format names local format_func = setmetatable({}, {__mode='v'}) --format functions ---register a date format parsing function function dateparser.register_format(format_name, format_function) if type(format_name)~="string" or type(format_function)~='function' then return nil, "improper arguments, can't register format handler" end local found for i, f in ipairs(format_func) do --for ordering if f==format_function then found=true break end end if not found then tinsert(format_func, format_function) end formats[format_name] = format_function return true end ---register a date format parsing function function dateparser.unregister_format(format_name) if type(format_name)~="string" then return nil, "format name must be a string" end formats[format_name]=nil end ---return the function responsible for handling format_name date strings function dateparser.get_format_function(format_name) return formats[format_name] or nil, ("format %s not registered"):format(format_name) end ---try to parse date string --@param str date string --@param date_format optional date format name, if known --@return unix timestamp if str can be parsed; nil, error otherwise. function dateparser.parse(str, date_format) local success, res, err if date_format then if not formats[date_format] then return 'unknown date format: ' .. tostring(date_format) end success, res = pcall(formats[date_format], str) else for i, func in ipairs(format_func) do success, res = pcall(func, str) if success and res then return res end end end return success and res end dateparser.register_format('W3CDTF', function(rest) local year, day_of_year, month, day, week local hour, minute, second, second_fraction, offset_hours local alt_rest year, rest = rest:match("^(%d%d%d%d)%-?(.*)$") day_of_year, alt_rest = rest:match("^(%d%d%d)%-?(.*)$") if day_of_year then rest=alt_rest end month, rest = rest:match("^(%d%d)%-?(.*)$") day, rest = rest:match("^(%d%d)(.*)$") if #rest>0 then rest = rest:match("^T(.*)$") hour, rest = rest:match("^([0-2][0-9]):?(.*)$") minute, rest = rest:match("^([0-6][0-9]):?(.*)$") second, rest = rest:match("^([0-6][0-9])(.*)$") second_fraction, alt_rest = rest:match("^%.(%d+)(.*)$") if second_fraction then rest=alt_rest end if rest=="Z" then rest="" offset_hours=0 else local sign, offset_h, offset_m sign, offset_h, rest = rest:match("^([+-])(%d%d)%:?(.*)$") local offset_m, alt_rest = rest:match("^(%d%d)(.*)$") if offset_m then rest=alt_rest end offset_hours = tonumber(sign .. offset_h) + (tonumber(offset_m) or 0)/60 end if #rest>0 then return nil end end year = tonumber(year) local d = { year = year and (year > 100 and year or (year < 50 and (year + 2000) or (year + 1900))), month = tonumber(month) or 1, day = tonumber(day) or 1, hour = tonumber(hour) or 0, min = tonumber(minute) or 0, sec = tonumber(second) or 0, isdst = false } local t = unix_timestamp(d, (offset_hours or 0) * 3600) if second_fraction then return t + tonumber("0."..second_fraction) else return t end end) do local tz_table = { --taken from http://www.timeanddate.com/library/abbreviations/timezones/ A = 1, B = 2, C = 3, D = 4, E=5, F = 6, G = 7, H = 8, I = 9, K = 10, L = 11, M = 12, N = -1, O = -2, P = -3, Q = -4, R = -5, S = -6, T = -7, U = -8, V = -9, W = -10, X = -11, Y = -12, Z = 0, EST = -5, EDT = -4, CST = -6, CDT = -5, MST = -7, MDT = -6, PST = -8, PDT = -7, GMT = 0, UT = 0, UTC = 0 } local month_val = {Jan=1, Feb=2, Mar=3, Apr=4, May=5, Jun=6, Jul=7, Aug=8, Sep=9, Oct=10, Nov=11, Dec=12} dateparser.register_format('RFC2822', function(rest) local year, month, day, day_of_year, week_of_year, weekday local hour, minute, second, second_fraction, offset_hours local alt_rest weekday, alt_rest = rest:match("^(%w%w%w),%s+(.*)$") if weekday then rest=alt_rest end day, rest=rest:match("^(%d%d?)%s+(.*)$") month, rest=rest:match("^(%w%w%w)%s+(.*)$") month = month_val[month] year, rest = rest:match("^(%d%d%d?%d?)%s+(.*)$") hour, rest = rest:match("^(%d%d?):(.*)$") minute, rest = rest:match("^(%d%d?)(.*)$") second, alt_rest = rest:match("^:(%d%d)(.*)$") if second then rest = alt_rest end local tz, offset_sign, offset_h, offset_m tz, alt_rest = rest:match("^%s+(%u+)(.*)$") if tz then rest = alt_rest offset_hours = tz_table[tz] else offset_sign, offset_h, offset_m, rest = rest:match("^%s+([+-])(%d%d)(%d%d)%s*(.*)$") offset_hours = tonumber(offset_sign .. offset_h) + (tonumber(offset_m) or 0)/60 end if #rest>0 or not (year and day and month and hour and minute) then return nil end year = tonumber(year) local d = { year = year and ((year > 100) and year or (year < 50 and (year + 2000) or (year + 1900))), month = month, day = tonumber(day), hour= tonumber(hour) or 0, min = tonumber(minute) or 0, sec = tonumber(second) or 0, isdst = false } return unix_timestamp(d, offset_hours * 3600) end) end dateparser.register_format('RFC822', formats.RFC2822) --2822 supercedes 822, but is not a strict superset. For our intents and purposes though, it's perfectly good enough dateparser.register_format('RFC3339', formats.W3CDTF) --RFC3339 is a subset of W3CDTF return dateparser
gpl-3.0
TheAnswer/FirstTest
bin/scripts/creatures/objects/npcs/imperial/imperialStormtrooperNovatrooper.lua
1
4619
--Copyright (C) 2008 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. imperialStormTrooperNovatrooper = Creature:new { objectName = "imperialStormTrooperNovatrooper", -- Lua Object Name creatureType = "NPC", faction = "imperial", factionPoints = 20, gender = "", speciesName = "stormtrooper_novatrooper", stfName = "mob/creature_names", objectCRC = 2706161932, socialGroup = "imperial", level = 97, combatFlags = 0, healthMax = 105000, healthMin = 95000, strength = 0, constitution = 0, actionMax = 105000, actionMin = 95000, quickness = 0, stamina = 0, mindMax = 105000, mindMin = 95000, focus = 0, willpower = 0, height = 1, -- Size of creature armor = 2, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy kinetic = 65, energy = 65, electricity = 35, stun = 45, blast = 80, heat = 30, cold = 35, acid = 30, lightsaber = 0, accuracy = 0, healer = 0, pack = 1, herd = 0, stalker = 0, killer = 1, ferocity = 0, aggressive = 1, invincible = 0, attackCreatureOnSight = "", -- Enter socialGroups weapon = "object/weapon/ranged/carbine/shared_carbine_e11.iff", -- File path to weapon -> object\xxx\xxx\xx weaponName = "a e11 Carbine", -- Name ex. 'a Vibrolance' weaponTemp = "carbine_e11", -- Weapon Template ex. 'lance_vibrolance' weaponClass = "CarbineRangedWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon' weaponEquipped = 1, weaponMinDamage = 620, weaponMaxDamage = 950, weaponAttackSpeed = 2, weaponDamageType = "ENERGY", -- ELECTRICITY, KINETIC, etc weaponArmorPiercing = "LIGHT", -- LIGHT, NONE, MEDIUM, HEAVY alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx alternateWeaponName = "", -- Name ex. 'a Vibrolance' alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance' alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon' alternateWeaponEquipped = 0, alternateWeaponMinDamage = 0, alternateWeaponMaxDamage = 0, alternateWeaponAttackSpeed = 0, alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's lootGroup = "0", -- Group it belongs to for loot tame = 0, datapadItemCRC = 0, mountCRC = 0, mountSpeed = 0, mountAcceleration = 0, milk = 0, boneType = "", boneMax = 0, hideType = "", hideMax = 0, meatType = "", meatMax = 0, skills = { "imperialStormTrooperNovaTrooperAttack1" }, respawnTimer = 180, behaviorScript = "", -- Link to the behavior script for this object } Creatures:addCreature(imperialStormTrooperNovatrooper, 2706161932) -- Add to Global Table
lgpl-3.0
sweetbot0/sweetbot
plugin/insta.lua
3
4894
--[[ ▀▄ ▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀ ▀▄ ▄▀ ▀▄ ▄▀ ▀▄ ▄▀ BY Th3_BOOS ▀▄ ▄▀ ▀▄ ▄▀ BY Th3_BOOS (@Th3_BOOS) ▀▄ ▄▀ ▀▄ ▄▀ JUST WRITED BY Th3_BOOS ▀▄ ▄▀ ▀▄ ▄▀ insta : انستا ▀▄ ▄▀ ▀▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀ --]] local access_token = "3084249803.280d5d7.999310365c8248f8948ee0f6929c2f02" -- your api key local function instagramUser(msg, query) local receiver = get_receiver(msg) local url = "https://api.instagram.com/v1/users/search?q="..URL.escape(query).."&access_token="..access_token local jstr, res = https.request(url) if res ~= 200 then return "❌ لآيــوجـدِ أتـصـأَلَ ✔️" end local jdat = json:decode(jstr) if #jdat.data == 0 then send_msg(receiver,"#عذرا\n❌ لمِ يـَتْم اَلــعثـْور ع يـوزرَ 👍🏻",ok_cb,false) end if jdat.meta.error_message then send_msg(receiver,"#عذرا\n"..jdat.meta.error_message,ok_cb,false) end local id = jdat.data[1].id local gurl = "https://api.instagram.com/v1/users/"..id.."/?access_token="..access_token local ress = https.request(gurl) local user = json:decode(ress) if user.meta.error_message then send_msg(receiver,"#عذرا\n"..user.meta.error_message,ok_cb,false) end local text = '' if user.data.bio ~= '' then text = text.."❣ اليوزر : "..user.data.username:upper().."\n\n" else text = text.."❣ اليوزر : "..user.data.username:upper().."\n" end if user.data.bio ~= '' then text = text..user.data.bio.."\n\n" end if user.data.full_name ~= '' then text = text.."❣ الاسم : "..user.data.full_name.."\n" end text = text.."❣ عدد الوسائط : "..user.data.counts.media.."\n" text = text.."❣ اتابعهم : "..user.data.counts.follows.."\n" text = text.."❣ المتابعون : "..user.data.counts.followed_by.."\n" if user.data.website ~= '' then text = text.."❣ الموقع : "..user.data.website.."\n" end text = text.."\n❣ #المطور @Th3_BOOS\n❣ #قناة_البوت : @dev_Th3_BOOS" local file_path = download_to_file(user.data.profile_picture,"insta.png") -- disable this line if you want to send profile photo as sticker --local file_path = download_to_file(user.data.profile_picture,"insta.webp") -- enable this line if you want to send profile photo as sticker local cb_extra = {file_path=file_path} local mime_type = mimetype.get_content_type_no_sub(ext) send_photo(receiver, file_path, rmtmp_cb, cb_extra) -- disable this line if you want to send profile photo as sticker --send_document(receiver, file_path, rmtmp_cb, cb_extra) -- enable this line if you want to send profile photo as sticker send_msg(receiver,text,ok_cb,false) end local function instagramMedia(msg, query) local receiver = get_receiver(msg) local url = "https://api.instagram.com/v1/media/shortcode/"..URL.escape(query).."?access_token="..access_token local jstr, res = https.request(url) if res ~= 200 then return "❌ لآيــوجـدِ أتـصـأَلَ ✔️" end local jdat = json:decode(jstr) if jdat.meta.error_message then send_msg(receiver,"#Error\n"..jdat.meta.error_type.."\n"..jdat.meta.error_message,ok_cb,false) end local text = '' local data = '' if jdat.data.caption then data = jdat.data.caption text = text.."❣ اليوزر : "..data.from.username:upper().."\n\n" text = text..data.from.full_name.."\n\n" text = text..data.text.."\n\n" text = text.."❣ عدد الايك : "..jdat.data.likes.count.."\n" else text = text.."❣ اليوزر : "..jdat.data.user.username:upper().."\n" text = text.."❣ الاسم : "..jdat.data.user.full_name.."\n" text = text.."❣ عدد الايك: "..jdat.data.likes.count.."\n" end text = text.."\n@Th3_BOOS\n❣ #قناة_البوت : @dev_Th3_BOOS" send_msg(receiver,text,ok_cb,false) end local function run(msg, matches) if matches[1] == "انستا" and not matches[3] then return instagramUser(msg,matches[2]) end if matches[1] == "انستا" and matches[3] then local media = matches[3] if string.match(media , '/') then media = media:gsub("/", "") end return instagramMedia(msg,media) end end return { patterns = { "^(انستا) ([Hh]ttps://www.instagram.com/p/)([^%s]+)$", "^(انستا) ([Hh]ttps://instagram.com/p/)([^%s]+)$", "^(انستا) ([Hh]ttp://www.instagram.com/p/)([^%s]+)$", "^(انستا) ([Hh]ttp://instagram.com/p/)([^%s]+)$", "^(انستا) ([^%s]+)$", }, run = run }
gpl-3.0
Andrettin/Wyrmsun
scripts/civilizations/goth/icons.lua
1
2950
-- _________ __ __ -- / _____// |_____________ _/ |______ ____ __ __ ______ -- \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ -- / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ -- /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > -- \/ \/ \//_____/ \/ -- ______________________ ______________________ -- T H E W A R B E G I N S -- Stratagus - A free fantasy real time strategy game engine -- -- (c) Copyright 2017-2022 by Andrettin -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- DefineIcon({ Name = "icon-gothic-horse-rider-black-hair", Size = {46, 38}, File = "goth/icons/horse_rider_black_hair.png" }) DefineIcon({ Name = "icon-gothic-horse-rider-blond-hair", Size = {46, 38}, File = "goth/icons/horse_rider_blond_hair.png" }) DefineIcon({ Name = "icon-gothic-horse-rider-brown-hair", Size = {46, 38}, File = "goth/icons/horse_rider_brown_hair.png" }) DefineIcon({ Name = "icon-gothic-horse-rider-gray-hair", Size = {46, 38}, File = "goth/icons/horse_rider_gray_hair.png" }) DefineIcon({ Name = "icon-gothic-horse-rider-hairless", Size = {46, 38}, File = "goth/icons/horse_rider_hairless.png" }) DefineIcon({ Name = "icon-gothic-horse-rider-orange-hair", Size = {46, 38}, File = "goth/icons/horse_rider_orange_hair.png" }) DefineIcon({ Name = "icon-gothic-horse-lord-beardless", Size = {46, 38}, File = "goth/icons/horse_lord_beardless.png" }) DefineIcon({ Name = "icon-gothic-horse-lord-black-hair", Size = {46, 38}, File = "goth/icons/horse_lord_black_hair.png" }) DefineIcon({ Name = "icon-gothic-horse-lord-blond-hair", Size = {46, 38}, File = "goth/icons/horse_lord_blond_hair.png" }) DefineIcon({ Name = "icon-gothic-horse-lord-brown-hair", Size = {46, 38}, File = "goth/icons/horse_lord_brown_hair.png" }) DefineIcon({ Name = "icon-gothic-horse-lord-gray-hair", Size = {46, 38}, File = "goth/icons/horse_lord_gray_hair.png" }) DefineIcon({ Name = "icon-gothic-horse-lord-orange-hair", Size = {46, 38}, File = "goth/icons/horse_lord_orange_hair.png" })
gpl-2.0
TheAnswer/FirstTest
bin/scripts/crafting/objects/draftschematics/armorsmith/personalArmorIvPadded/kashyyykianBlackMountainChestPlate.lua
1
5260
--Copyright (C) 2009 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. kashyyykianBlackMountainChestPlate = Object:new { objectName = "Kashyyykian Black Mountain Chest Plate", stfName = "armor_kashyyykian_black_mtn_chest_plate", stfFile = "wearables_name", objectCRC = 4154804782, groupName = "craftArmorPersonalGroupE", -- Group schematic is awarded in (See skills table) craftingToolTab = 2, -- (See DraftSchemticImplementation.h) complexity = 40, size = 4, xpType = "crafting_clothing_armor", xp = 700, assemblySkill = "armor_assembly", experimentingSkill = "armor_experimentation", ingredientTemplateNames = "craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n", ingredientTitleNames = "auxilary_coverage, body, liner, hardware_and_attachments, binding_and_reinforcement, padding, armor, load_bearing_harness, reinforcement", ingredientSlotType = "0, 0, 0, 0, 0, 1, 1, 2, 0", resourceTypes = "wood_deciduous_endor, hide_leathery, hide_wooly_naboo, copper, petrochem_inert_polymer, object/tangible/component/clothing/shared_padding_segment.iff, object/tangible/component/armor/shared_armor_segment_kashyyykian_black_mtn.iff, object/tangible/component/clothing/shared_synthetic_cloth.iff, fiberplast", resourceQuantities = "80, 80, 40, 50, 50, 4, 4, 1, 20", combineTypes = "0, 0, 0, 0, 0, 1, 1, 1, 0", contribution = "100, 100, 100, 100, 100, 100, 100, 100, 100", numberExperimentalProperties = "1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1", experimentalProperties = "XX, XX, XX, OQ, SR, OQ, SR, OQ, UT, MA, OQ, MA, OQ, MA, OQ, XX, XX, OQ, SR, XX", experimentalWeights = "1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1", experimentalGroupTitles = "null, null, null, exp_durability, exp_quality, exp_durability, exp_durability, exp_durability, exp_durability, null, null, exp_resistance, null", experimentalSubGroupTitles = "null, null, sockets, hit_points, armor_effectiveness, armor_integrity, armor_health_encumbrance, armor_action_encumbrance, armor_mind_encumbrance, armor_rating, armor_special_type, armor_special_effectiveness, armor_special_integrity", experimentalMin = "0, 0, 0, 1000, 1, 18750, 233, 142, 370, 1, 1, 1, 18750", experimentalMax = "0, 0, 0, 1000, 30, 31250, 143, 88, 221, 1, 1, 40, 31250", experimentalPrecision = "0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0", tanoAttributes = "objecttype=257:objectcrc=2677805339:stfFile=wearables_name:stfName=armor_kashyyykian_black_mtn_chest_plate:stfDetail=:itemmask=61955:customattributes=specialprotection=kineticeffectiveness;vunerability=heateffectiveness,stuneffectiveness,coldeffectiveness;armorPiece=256;armorStyle=4109;:", blueFrogAttributes = "", blueFrogEnabled = False, customizationOptions = "", customizationDefaults = "", customizationSkill = "armor_customization" } DraftSchematics:addDraftSchematic(kashyyykianBlackMountainChestPlate, 4154804782)--- Add to global DraftSchematics table
lgpl-3.0
nullifye/tg-bot-pi
tg_bot/plugins/poslaju.lua
1
1027
return function(msg) cmd = "pi:poslaju" if args[1]==cmd then if #args == 2 then curr_ptt = os.time() try = os.execute('wget -qO- "http://api.pos.com.my/v2TrackNTraceWebApi/api/Details/'..args[2]..'?sKey=7oHHMvxM0" --connect-timeout='..TIMEOUT..' | grep -Po \'"date":.*?[^\\\\]",|"process":.*?[^\\\\]",|"office":.*?[^\\\\]",|},{\' | awk -F\'"[:]"\' \'{print $2}\' | sed -e "s/\\",//" | sed -e \':a;N;$!ba;s/\\n\\n/\\n----------\\n/g\' > '..TMP_PATH..'/ppos'..curr_ptt..'.out') if try then if filesize(TMP_PATH..'/ppos'..curr_ptt..'.out') == 0 then send_msg (target, "("..cmd..") record NOT FOUND", ok_cb, false) return true end send_text (target, TMP_PATH.."/ppos"..curr_ptt..".out", ok_cb, false) else send_text (target, "("..cmd..") server takes too long to respond.\ntry again", ok_cb, false) end else send_msg (target, "📝 "..cmd.." <TRACKING-NO>", ok_cb, false) end return true end end
apache-2.0
Xeltor/ovale
dist/Icon.lua
1
13639
local __exports = LibStub:NewLibrary("ovale/Icon", 80300) if not __exports then return end local __class = LibStub:GetLibrary("tslib").newClass local __Localization = LibStub:GetLibrary("ovale/Localization") local L = __Localization.L local format = string.format local find = string.find local sub = string.sub local next = next local tostring = tostring local _G = _G local kpairs = pairs local GetTime = GetTime local PlaySoundFile = PlaySoundFile local CreateFrame = CreateFrame local GameTooltip = GameTooltip local huge = math.huge local INFINITY = huge local COOLDOWN_THRESHOLD = 0.1 __exports.OvaleIcon = __class(nil, { HasScriptControls = function(self) return (next(self.parent.checkBoxWidget) ~= nil or next(self.parent.listWidget) ~= nil) end, constructor = function(self, name, parent, secure, ovaleOptions, ovaleSpellBook) self.parent = parent self.ovaleOptions = ovaleOptions self.ovaleSpellBook = ovaleSpellBook self.actionButton = false self.shouldClick = false self.cdShown = false if not secure then self.frame = CreateFrame("CheckButton", name, parent.frame, "ActionButtonTemplate") else self.frame = CreateFrame("CheckButton", name, parent.frame, "SecureActionButtonTemplate, ActionButtonTemplate") end local profile = self.ovaleOptions.db.profile self.icone = _G[name .. "Icon"] self.shortcut = _G[name .. "HotKey"] self.remains = _G[name .. "Name"] self.rangeIndicator = _G[name .. "Count"] self.rangeIndicator:SetText(profile.apparence.targetText) self.cd = _G[name .. "Cooldown"] self.normalTexture = _G[name .. "NormalTexture"] local fontName, fontHeight, fontFlags = self.shortcut:GetFont() self.fontName = fontName self.fontHeight = fontHeight self.fontFlags = fontFlags self.focusText = self.frame:CreateFontString(nil, "OVERLAY") self.cdShown = true self.shouldClick = false self.help = nil self.value = nil self.fontScale = nil self.lastSound = nil self.cooldownEnd = nil self.cooldownStart = nil self.texture = nil self.positionalParams = nil self.namedParams = nil self.actionButton = false self.actionType = nil self.actionId = nil self.actionHelp = nil self.frame:SetScript("OnMouseUp", function() return self:OvaleIcon_OnMouseUp() end) self.frame:SetScript("OnEnter", function() return self:OvaleIcon_OnEnter() end) self.frame:SetScript("OnLeave", function() return self:OvaleIcon_OnLeave() end) self.focusText:SetFontObject("GameFontNormalSmall") self.focusText:SetAllPoints(self.frame) self.focusText:SetTextColor(1, 1, 1) self.focusText:SetText(L["Focus"]) self.frame:RegisterForClicks("AnyUp") if profile.apparence.clickThru then self.frame:EnableMouse(false) end end, SetValue = function(self, value, actionTexture) self.icone:Show() self.icone:SetTexture(actionTexture) self.icone:SetAlpha(self.ovaleOptions.db.profile.apparence.alpha) self.cd:Hide() self.focusText:Hide() self.rangeIndicator:Hide() self.shortcut:Hide() if value then self.actionType = "value" self.actionHelp = nil self.value = value if value < 10 then self.remains:SetFormattedText("%.1f", value) elseif value == INFINITY then self.remains:SetFormattedText("inf") else self.remains:SetFormattedText("%d", value) end self.remains:Show() else self.remains:Hide() end self.frame:Show() end, Update = function(self, element, startTime, actionTexture, actionInRange, actionCooldownStart, actionCooldownDuration, actionUsable, actionShortcut, actionIsCurrent, actionEnable, actionType, actionId, actionTarget, actionResourceExtend) self.actionType = actionType self.actionId = actionId self.value = nil local now = GetTime() local profile = self.ovaleOptions.db.profile if startTime and actionTexture then local cd = self.cd local resetCooldown = false if startTime > now then local duration = cd:GetCooldownDuration() if duration == 0 and self.texture == actionTexture and self.cooldownStart and self.cooldownEnd then resetCooldown = true end if self.texture ~= actionTexture or not self.cooldownStart or not self.cooldownEnd then self.cooldownStart = now self.cooldownEnd = startTime resetCooldown = true elseif startTime < self.cooldownEnd - COOLDOWN_THRESHOLD or startTime > self.cooldownEnd + COOLDOWN_THRESHOLD then if startTime - self.cooldownEnd > 0.25 or startTime - self.cooldownEnd < -0.25 then self.cooldownStart = now else local oldCooldownProgressPercent = (now - self.cooldownStart) / (self.cooldownEnd - self.cooldownStart) self.cooldownStart = (now - oldCooldownProgressPercent * startTime) / (1 - oldCooldownProgressPercent) end self.cooldownEnd = startTime resetCooldown = true end self.texture = actionTexture else self.cooldownStart = nil self.cooldownEnd = nil end if self.cdShown and profile.apparence.flashIcon and self.cooldownStart and self.cooldownEnd then local start, ending = self.cooldownStart, self.cooldownEnd local duration = ending - start if resetCooldown and duration > COOLDOWN_THRESHOLD then cd:SetDrawEdge(false) cd:SetSwipeColor(0, 0, 0, 0.8) cd:SetCooldown(start, duration) cd:Show() end else self.cd:Hide() end self.icone:Show() self.icone:SetTexture(actionTexture) if actionUsable then self.icone:SetAlpha(1) else self.icone:SetAlpha(0.5) end if element then if element.namedParams.nored ~= 1 and actionResourceExtend and actionResourceExtend > 0 then self.icone:SetVertexColor(0.75, 0.2, 0.2) else self.icone:SetVertexColor(1, 1, 1) end self.actionHelp = element.namedParams.help if not (self.cooldownStart and self.cooldownEnd) then self.lastSound = nil end if element.namedParams.sound and not self.lastSound then local delay = element.namedParams.soundtime or 0.5 if now >= startTime - delay then self.lastSound = element.namedParams.sound PlaySoundFile(self.lastSound) end end end local red = false if not red and startTime > now and profile.apparence.highlightIcon then local lag = 0.6 local newShouldClick = (startTime < now + lag) if self.shouldClick ~= newShouldClick then if newShouldClick then self.frame:SetChecked(true) else self.frame:SetChecked(false) end self.shouldClick = newShouldClick end elseif self.shouldClick then self.shouldClick = false self.frame:SetChecked(false) end if (profile.apparence.numeric or self.namedParams.text == "always") and startTime > now then self.remains:SetFormattedText("%.1f", startTime - now) self.remains:Show() else self.remains:Hide() end if profile.apparence.raccourcis then self.shortcut:Show() self.shortcut:SetText(actionShortcut) else self.shortcut:Hide() end if actionInRange == nil then self.rangeIndicator:Hide() elseif actionInRange then self.rangeIndicator:SetVertexColor(0.6, 0.6, 0.6) self.rangeIndicator:Show() else self.rangeIndicator:SetVertexColor(1, 0.1, 0.1) self.rangeIndicator:Show() end if element and element.namedParams.text then self.focusText:SetText(tostring(element.namedParams.text)) self.focusText:Show() elseif actionTarget and actionTarget ~= "target" then self.focusText:SetText(actionTarget) self.focusText:Show() else self.focusText:Hide() end self.frame:Show() else self.icone:Hide() self.rangeIndicator:Hide() self.shortcut:Hide() self.remains:Hide() self.focusText:Hide() if profile.apparence.hideEmpty then self.frame:Hide() else self.frame:Show() end if self.shouldClick then self.frame:SetChecked(false) self.shouldClick = false end end return startTime, element end, SetHelp = function(self, help) self.help = help end, SetParams = function(self, positionalParams, namedParams, secure) self.positionalParams = positionalParams self.namedParams = namedParams self.actionButton = false if secure then for k, v in kpairs(namedParams) do local index = find(k, "spell") if index then local prefix = sub(k, 1, index - 1) local suffix = sub(k, index + 5) self.frame:SetAttribute(prefix .. "type" .. suffix, "spell") self.frame:SetAttribute("unit", self.namedParams.target or "target") self.frame:SetAttribute(k, self.ovaleSpellBook:GetSpellName(v) or "Unknown spell") self.actionButton = true end end end end, SetRemainsFont = function(self, color) self.remains:SetTextColor(color.r, color.g, color.b, 1) self.remains:SetJustifyH("left") self.remains:SetPoint("BOTTOMLEFT", 2, 2) end, SetFontScale = function(self, scale) self.fontScale = scale self.remains:SetFont(self.fontName, self.fontHeight * self.fontScale, self.fontFlags) self.shortcut:SetFont(self.fontName, self.fontHeight * self.fontScale, self.fontFlags) self.rangeIndicator:SetFont(self.fontName, self.fontHeight * self.fontScale, self.fontFlags) self.focusText:SetFont(self.fontName, self.fontHeight * self.fontScale, self.fontFlags) end, SetRangeIndicator = function(self, text) self.rangeIndicator:SetText(text) end, OvaleIcon_OnMouseUp = function(self) if not self.actionButton then self.parent:ToggleOptions() end self.frame:SetChecked(true) end, OvaleIcon_OnEnter = function(self) if self.help or self.actionType or self:HasScriptControls() then GameTooltip:SetOwner(self.frame, "ANCHOR_BOTTOMLEFT") if self.help then GameTooltip:SetText(L[self.help]) end if self.actionType then local actionHelp if self.actionHelp then actionHelp = self.actionHelp else if self.actionType == "spell" then actionHelp = self.ovaleSpellBook:GetSpellName(self.actionId) or "Unknown spell" elseif self.actionType == "value" then actionHelp = (self.value < INFINITY) and tostring(self.value) or "infinity" else actionHelp = format("%s %s", self.actionType, tostring(self.actionId)) end end GameTooltip:AddLine(actionHelp, 0.5, 1, 0.75) end if self:HasScriptControls() then GameTooltip:AddLine(L["Cliquer pour afficher/cacher les options"], 1, 1, 1) end GameTooltip:Show() end end, OvaleIcon_OnLeave = function(self) if self.help or self:HasScriptControls() then GameTooltip:Hide() end end, SetPoint = function(self, anchor, reference, refAnchor, x, y) self.frame:SetPoint(anchor, reference, refAnchor, x, y) end, Show = function(self) self.frame:Show() end, Hide = function(self) self.frame:Hide() end, SetScale = function(self, scale) self.frame:SetScale(scale) end, EnableMouse = function(self, enabled) self.frame:EnableMouse(enabled) end, })
mit
TheAnswer/FirstTest
bin/scripts/crafting/objects/draftschematics/tailor/casualWearIBasics/pleatedSkirt.lua
1
4513
--Copyright (C) 2009 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. pleatedSkirt = Object:new { objectName = "Pleated Skirt", stfName = "skirt_s04", stfFile = "wearables_name", objectCRC = 670770673, groupName = "craftClothingCasualGroupA", -- Group schematic is awarded in (See skills table) craftingToolTab = 8, -- (See DraftSchemticImplementation.h) complexity = 19, size = 3, xpType = "crafting_clothing_general", xp = 80, assemblySkill = "clothing_assembly", experimentingSkill = "clothing_experimentation", ingredientTemplateNames = "craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n", ingredientTitleNames = "trim_and_binding, extra_trim, hardware, skirt", ingredientSlotType = "0, 2, 2, 2", resourceTypes = "fiberplast, object/tangible/component/clothing/shared_synthetic_cloth.iff, object/tangible/component/clothing/shared_metal_fasteners.iff, object/tangible/component/clothing/shared_synthetic_cloth.iff", resourceQuantities = "35, 1, 1, 1", combineTypes = "0, 1, 1, 1", contribution = "100, 100, 100, 100", numberExperimentalProperties = "1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1", experimentalProperties = "XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX", experimentalWeights = "1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1", experimentalGroupTitles = "null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null", experimentalSubGroupTitles = "null, null, sockets, hitpoints, mod_idx_one, mod_val_one, mod_idx_two, mod_val_two, mod_idx_three, mod_val_three, mod_idx_four, mod_val_four, mod_idx_five, mod_val_five, mod_idx_six, mod_val_six", experimentalMin = "0, 0, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0", experimentalMax = "0, 0, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0", experimentalPrecision = "0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0", tanoAttributes = "objecttype=16777234:objectcrc=3715418756:stfFile=wearables_name:stfName=skirt_s04:stfDetail=:itemmask=62974::", blueFrogAttributes = "", blueFrogEnabled = False, customizationOptions = "/private/index_color_1, /private/index_color_2", customizationDefaults = "20, 18", customizationSkill = "clothing_customization" } DraftSchematics:addDraftSchematic(pleatedSkirt, 670770673)--- Add to global DraftSchematics table
lgpl-3.0
TheAnswer/FirstTest
bin/scripts/slashcommands/skills/cover.lua
1
2536
--Copyright (C) 2007 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. --true = 1, false = 0 CoverSlashCommand = { name = "cover", alternativeNames = "", animation = "", invalidStateMask = 3894804497, --cover, alert, frozen, swimming, glowingJedi, ridingMount, pilotingShip, shipOperations, shipGunner, invalidPostures = "3,5,6,7,8,9,10,11,12,13,14,4,", target = 2, targeType = 2, disabled = 0, maxRangeToTarget = 0, --adminLevel = 0, addToCombatQueue = 0, } AddCoverSlashCommand(CoverSlashCommand)
lgpl-3.0
TheAnswer/FirstTest
bin/scripts/creatures/objects/npcs/corsec/corsecInspectorSergeant.lua
1
4589
--Copyright (C) 2008 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. corsecInspectorSergeant = Creature:new { objectName = "corsecInspectorSergeant", -- Lua Object Name creatureType = "NPC", faction = "corsec", factionPoints = 20, gender = "", speciesName = "corsec_inspector_sergeant", stfName = "mob/creature_names", objectCRC = 152421728, socialGroup = "corsec", level = 19, combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG, healthMax = 5500, healthMin = 4500, strength = 0, constitution = 0, actionMax = 5500, actionMin = 4500, quickness = 0, stamina = 0, mindMax = 5500, mindMin = 4500, focus = 0, willpower = 0, height = 1, -- Size of creature armor = 0, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy kinetic = 0, energy = 0, electricity = 0, stun = -1, blast = 0, heat = 0, cold = 0, acid = 0, lightsaber = 0, accuracy = 0, healer = 0, pack = 1, herd = 0, stalker = 0, killer = 1, ferocity = 0, aggressive = 0, invincible = 0, attackCreatureOnSight = "", -- Enter socialGroups weapon = "object/weapon/ranged/pistol/shared_pistol_cdef_corsec.iff", -- File path to weapon -> object\xxx\xxx\xx weaponName = "Corsec Pistol", -- Name ex. 'a Vibrolance' weaponTemp = "pistol_cdef_corsec", -- Weapon Template ex. 'lance_vibrolance' weaponClass = "PistolRangedWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon' weaponEquipped = 1, weaponMinDamage = 180, weaponMaxDamage = 190, weaponAttackSpeed = 2, weaponDamageType = "ENERGY", -- ELECTRICITY, KINETIC, etc weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx alternateWeaponName = "", -- Name ex. 'a Vibrolance' alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance' alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon' alternateWeaponEquipped = 0, alternateWeaponMinDamage = 0, alternateWeaponMaxDamage = 0, alternateweaponAttackSpeed = 2, alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc alternateweaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's lootGroup = "0", -- Group it belongs to for loot tame = 0, datapadItemCRC = 0, mountCRC = 0, mountSpeed = 0, mountAcceleration = 0, milk = 0, boneType = "", boneMax = 0, hideType = "", hideMax = 0, meatType = "", meatMax = 0, skills = { "corsecAttack1" }, respawnTimer = 180, behaviorScript = "", -- Link to the behavior script for this object } Creatures:addCreature(corsecInspectorSergeant, 152421728) -- Add to Global Table
lgpl-3.0
TheAnswer/FirstTest
bin/scripts/creatures/objects/tatooine/npcs/mosEisley/mosEisleyPoliceLieutenant.lua
1
4553
--Copyright (C) 2008 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. mosEisleyPoliceLieutenant = Creature:new { objectName = "mosEisleyPoliceLieutenant", -- Lua Object Name creatureType = "NPC", gender = "", speciesName = "mos_eisley_police_lieutenant", stfName = "mob/creature_names", objectCRC = 4175079995, socialGroup = "imperial", level = 15, combatFlags = ATTACKABLE_FLAG, healthMax = 3000, healthMin = 2400, strength = 0, constitution = 0, actionMax = 3000, actionMin = 2400, quickness = 0, stamina = 0, mindMax = 3000, mindMin = 2400, focus = 0, willpower = 0, height = 1, -- Size of creature armor = 1, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy kinetic = 0, energy = 0, electricity = 0, stun = 0, blast = 0, heat = 0, cold = 0, acid = 0, lightsaber = 0, accuracy = 0, healer = 0, pack = 1, herd = 0, stalker = 1, killer = 0, ferocity = 0, aggressive = 0, invincible = 0, attackCreatureOnSight = "", -- Enter socialGroups weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance' weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance' weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon' weaponEquipped = 0, weaponMinDamage = 160, weaponMaxDamage = 170, weaponAttackSpeed = 2, weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx alternateWeaponName = "", -- Name ex. 'a Vibrolance' alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance' alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon' alternateWeaponEquipped = 0, alternateWeaponMinDamage = 0, alternateWeaponMaxDamage = 0, alternateWeaponAttackSpeed = 0, alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's lootGroup = "0", -- Group it belongs to for loot tame = 0, datapadItemCRC = 0, mountCRC = 0, mountSpeed = 0, mountAcceleration = 0, milk = 0, boneType = "", boneMax = 0, hideType = "", hideMax = 0, meatType = "", meatMax = 0, skills = { "mosEisleyAttack1" }, respawnTimer = 180, behaviorScript = "", -- Link to the behavior script for this object } Creatures:addCreature(mosEisleyPoliceLieutenant, 4175079995) -- Add to Global Table
lgpl-3.0
JarnoVgr/ZombieSurvival
gamemodes/zombiesurvival/entities/entities/prop_obj_exit/cl_init.lua
1
5894
include("shared.lua") ENT.RenderGroup = RENDERGROUP_TRANSLUCENT function ENT:Initialize() self:SetRenderBounds(Vector(-128, -128, -128), Vector(128, 128, 200)) local ent = ClientsideModel("models/props_doors/door01_dynamic.mdl", RENDERGROUP_TRANSLUCENT) if ent:IsValid() then ent:SetPos(self:LocalToWorld(Vector(0, 0, 52))) ent:SetAngles(self:GetAngles()) ent:DrawShadow(false) ent:SetNoDraw(true) ent:SetParent(self) ent:Spawn() self.Door = ent end ent = ClientsideModel("models/props_debris/wood_board07a.mdl", RENDERGROUP_TRANSLUCENT) if ent:IsValid() then ent:SetPos(self:LocalToWorld(Vector(0, 0, 49))) ent:SetAngles(self:GetAngles()) ent:DrawShadow(false) ent:SetNoDraw(true) ent:SetParent(self) ent:Spawn() self.LeftBoard = ent end ent = ClientsideModel("models/props_debris/wood_board07a.mdl", RENDERGROUP_TRANSLUCENT) if ent:IsValid() then ent:SetPos(self:LocalToWorld(Vector(-52, 0, 49))) ent:SetAngles(self:GetAngles()) ent:DrawShadow(false) ent:SetNoDraw(true) ent:SetParent(self) ent:Spawn() self.RightBoard = ent end ent = ClientsideModel("models/props_debris/wood_board07a.mdl", RENDERGROUP_TRANSLUCENT) if ent:IsValid() then ent:SetPos(self:LocalToWorld(Vector(-24, 0, 109))) ent:SetAngles(self:LocalToWorldAngles(Angle(90, 0, 0))) ent:DrawShadow(false) ent:SetNoDraw(true) ent:SetParent(self) ent:Spawn() ent:SetModelScaleVector(Vector(1, 1, 0.38)) self.TopBoard = ent end ent = ClientsideModel("models/props_debris/wood_board07a.mdl", RENDERGROUP_TRANSLUCENT) if ent:IsValid() then ent:SetPos(self:LocalToWorld(Vector(-24, 0, 48))) ent:SetAngles(self:GetAngles()) ent:DrawShadow(false) ent:SetNoDraw(true) ent:SetParent(self) ent:Spawn() ent:SetModelScaleVector(Vector(6, 0.001, 1)) self.Rift = ent end hook.Add("RenderScreenspaceEffects", self, self.RenderScreenspaceEffects) end local CModWhiteOut = { ["$pp_colour_addr"] = 0, ["$pp_colour_addg"] = 0, ["$pp_colour_addb"] = 0, ["$pp_colour_brightness"] = 0, ["$pp_colour_contrast"] = 1, ["$pp_colour_colour"] = 1, ["$pp_colour_mulr"] = 0, ["$pp_colour_mulg"] = 0, ["$pp_colour_mulb"] = 0 } function ENT:RenderScreenspaceEffects() local eyepos = EyePos() local nearest = self:NearestPoint(eyepos) local dist = eyepos:Distance(nearest) local power = math.Clamp(1 - dist / 300, 0, 1) ^ 2 * self:GetOpenedPercent() if power > 0 then local size = 5 + power * 10 CModWhiteOut["$pp_colour_brightness"] = power * 0.5 DrawBloom(1 - power, power * 4, size, size, 1, 1, 1, 1, 1) DrawColorModify(CModWhiteOut) if render.SupportsPixelShaders_2_0() then local eyevec = EyeVector() local pos = self:LocalToWorld(self:OBBCenter()) - eyevec * 16 local distance = eyepos:Distance(pos) local dot = (pos - eyepos):GetNormalized():Dot(eyevec) - distance * 0.0005 if dot > 0 then local srcpos = pos:ToScreen() DrawSunbeams(0.8, dot * power, 0.1, srcpos.x / w, srcpos.y / h) end end end end ENT.NextEmit = 0 local matWhite = Material("models/debug/debugwhite") function ENT:DrawTranslucent() local curtime = CurTime() local rise = self:GetRise() ^ 2 local normal = self:GetUp() local openedpercent = self:GetOpenedPercent() local dlight = DynamicLight(self:EntIndex()) if dlight then local size = 100 + openedpercent * 200 size = size * (1 + math.sin(curtime * math.pi) * 0.075) dlight.Pos = self:LocalToWorld(Vector(-24, 0, 40)) dlight.r = 180 dlight.g = 200 dlight.b = 255 dlight.Brightness = 1 + openedpercent * 4 dlight.Size = size dlight.Decay = size * 2 dlight.DieTime = curtime + 1 end render.EnableClipping(true) render.PushCustomClipPlane(normal, normal:Dot(self:GetPos())) cam.Start3D(EyePos() + Vector(0, 0, (1 - rise) * 150), EyeAngles()) self.Door:SetPos(self:LocalToWorld(Vector(0, 0, 52))) self.Door:SetAngles(self:LocalToWorldAngles(Angle(0, openedpercent * 80, 0))) self.Door:DrawModel() self.LeftBoard:DrawModel() self.RightBoard:DrawModel() self.TopBoard:DrawModel() cam.End3D() if openedpercent > 0 then --[[normal = normal * -1 render.PushCustomClipPlane(normal, normal:Dot(self.TopBoard:GetPos())) normal = self:GetForward() render.PushCustomClipPlane(normal, normal:Dot(self.RightBoard:GetPos())) normal = normal * -1 render.PushCustomClipPlane(normal, normal:Dot(self.LeftBoard:GetPos()))]] local brightness = openedpercent ^ 0.4 render.SuppressEngineLighting(true) render.SetColorModulation(brightness, brightness, brightness) render.ModelMaterialOverride(matWhite) self.Rift:DrawModel() render.ModelMaterialOverride() render.SetColorModulation(1, 1, 1) render.SuppressEngineLighting(false) --[[render.PopCustomClipPlane() render.PopCustomClipPlane() render.PopCustomClipPlane()]] end render.PopCustomClipPlane() render.EnableClipping(false) if curtime < self.NextEmit or openedpercent == 0 then return end self.NextEmit = curtime + 0.01 + (1 - openedpercent) * 0.15 local dir = self:GetRight() * 2 + VectorRand() dir:Normalize() local startpos = self:LocalToWorld(Vector(-24, 0, 48)) local emitter = ParticleEmitter(startpos) emitter:SetNearClip(24, 32) for i=1, 4 do dir = dir * -1 local particle = emitter:Add("sprites/glow04_noz", startpos + dir * 180) particle:SetDieTime(0.5) particle:SetVelocity(dir * -360) particle:SetStartAlpha(0) particle:SetEndAlpha(255 * openedpercent) particle:SetStartSize(math.Rand(2, 5) * openedpercent) particle:SetEndSize(0) if math.random(2) == 2 then particle:SetColor(220, 240, 255) end particle:SetRoll(math.Rand(0, 360)) particle:SetRollDelta(math.Rand(-5, 5)) end emitter:Finish() end
gpl-2.0
ludi1991/skynet
gamelogic/rankmgr.lua
1
1181
local skynet = require "skynet" local rankmgr = {} function rankmgr:init(player) self.player = player end function rankmgr:get_player_rank(rank_type) local player = self.player local rank = skynet.call("RANK_SERVICE","lua","get_index_by_playerid",player.basic.playerid,rank_type) local fight_power = skynet.call("DATA_CENTER","lua","get_player_fightpower",player.basic.playerid,rank_type,1) return { rank = rank , fightpower = fight_power} end function rankmgr:get_rank_data(start,count,rank_type) local res = {} for i=start,start+count-1 do local playerid = skynet.call("RANK_SERVICE","lua","get_playerid_by_index",i,rank_type) local data = skynet.call("DATA_CENTER","lua","get_player_data",playerid) local fight_power = skynet.call("DATA_CENTER","lua","get_player_fightpower",playerid,rank_type,1) table.insert(res, { playerid = playerid, name = data.basic.nickname, score = fight_power, rank = i, level = data.basic.level, head_sculpture = data.basic.head_sculpture, }) end return { data = res } end return rankmgr
mit
zain211/zain.aliraqe
plugins.lua
14
6574
--[[ # For More Information ....! # Developer : Aziz < @devss_bot > #Dev # our channel: @help_tele ]] do -- Returns the key (index) in the config.enabled_plugins table local function plugin_enabled( name ) for k,v in pairs(_config.enabled_plugins) do if name == v then return k end end -- If not found return false end -- Returns true if file exists in plugins folder local function plugin_exists( name ) for k,v in pairs(plugins_names()) do if name..'.lua' == v then return true end end return false end local function list_all_plugins(only_enabled) local text = '' local nsum = 0 for k, v in pairs( plugins_names( )) do -- ✔ enabled, ❌ disabled local status = '❌' nsum = nsum+1 nact = 0 -- Check if is enabled for k2, v2 in pairs(_config.enabled_plugins) do if v == v2..'.lua' then status = '✔' end nact = nact+1 end if not only_enabled or status == '✔' then -- get the name v = string.match (v, "(.*)%.lua") text = text..nsum..'. '..v..' '..status..'\n' end end local text = text..'\n الملفات المثبته 🔨. '..nsum..'\nالملفات المفعله ✔️ .'..nact..'\nغير مفعل 🚫 '..nsum-nact..'' return text end local function list_plugins(only_enabled) local text = '' local nsum = 0 for k, v in pairs( plugins_names( )) do -- ✔ enabled, ❌ disabled local status = '❌' nsum = nsum+1 nact = 0 -- Check if is enabled for k2, v2 in pairs(_config.enabled_plugins) do if v == v2..'.lua' then status = '✔' end nact = nact+1 end if not only_enabled or status == '✔' then -- get the name v = string.match (v, "(.*)%.lua") text = text..v..' '..status..'\n' end end local text = text..'\n'..nact..' plugins enabled from '..nsum..' plugins installed.' return text end local function reload_plugins( ) plugins = {} load_plugins() return list_plugins(true) end local function enable_plugin( plugin_name ) print('checking if '..plugin_name..' exists') -- Check if plugin is enabled if plugin_enabled(plugin_name) then return 'اَلـَمِلفَ 📙 '..plugin_name..' مفـَعـلَِ 👍🏻 ✔️' end -- Checks if plugin exists if plugin_exists(plugin_name) then -- Add to the config table table.insert(_config.enabled_plugins, plugin_name) print(plugin_name..' added to _config table') save_config() -- Reload the plugins return reload_plugins( ) else return ''..plugin_name..' ✋🏿لآَ يـَوْجـدِ مـلفَ 📙 بأسـم ' end end local function disable_plugin( name, chat ) -- Check if plugins exists if not plugin_exists(name) then return ''..name..' ✋🏿لآَ يـَوْجـدِ مـلفَ 📙 بأسـم ' end local k = plugin_enabled(name) -- Check if plugin is enabled if not k then return 'اَلـَمِلفَ 📙 '..name..' غـيرَ مفـَعـلَِ 👍🏻 ❌' end -- Disable and reload table.remove(_config.enabled_plugins, k) save_config( ) return reload_plugins(true) end local function disable_plugin_on_chat(receiver, plugin) if not plugin_exists(plugin) then return "Plugin doesn't exists" end if not _config.disabled_plugin_on_chat then _config.disabled_plugin_on_chat = {} end if not _config.disabled_plugin_on_chat[receiver] then _config.disabled_plugin_on_chat[receiver] = {} end _config.disabled_plugin_on_chat[receiver][plugin] = true save_config() return 'Plugin '..plugin..' disabled on this chat' end local function reenable_plugin_on_chat(receiver, plugin) if not _config.disabled_plugin_on_chat then return 'There aren\'t any disabled plugins' end if not _config.disabled_plugin_on_chat[receiver] then return 'There aren\'t any disabled plugins for this chat' end if not _config.disabled_plugin_on_chat[receiver][plugin] then return 'This plugin is not disabled' end _config.disabled_plugin_on_chat[receiver][plugin] = false save_config() return 'Plugin '..plugin..' is enabled again' end local function run(msg, matches) -- Show the available plugins if matches[1] == 'الملفات' and is_sudo(msg) then --after changed to moderator mode, set only sudo return list_all_plugins() end -- Re-enable a plugin for this chat if matches[1] == 'تفعيل ملف' and matches[3] == 'chat' then local receiver = get_receiver(msg) local plugin = matches[2] print("enable "..plugin..' on this chat') return reenable_plugin_on_chat(receiver, plugin) end -- Enable a plugin if matches[1] == 'تفعيل ملف' and is_sudo(msg) then --after changed to moderator mode, set only sudo local plugin_name = matches[2] print("enable: "..matches[2]) return enable_plugin(plugin_name) end -- Disable a plugin on a chat if matches[1] == 'تعطيل ملف' and matches[3] == 'chat' then local plugin = matches[2] local receiver = get_receiver(msg) print("disable "..plugin..' on this chat') return disable_plugin_on_chat(receiver, plugin) end -- Disable a plugin if matches[1] == 'تعطيل ملف' and is_sudo(msg) then --after changed to moderator mode, set only sudo if matches[2] == 'plugins' then return 'This plugin can\'t be disabled' end print("disable: "..matches[2]) return disable_plugin(matches[2]) end -- Reload all the plugins! if matches[1] == 'الملفات المفعله' and is_sudo(msg) then --after changed to moderator mode, set only sudo return reload_plugins(true) end end return { description = "Plugin to manage other plugins. Enable, disable or reload.", usage = { moderator = { "!plugins disable [plugin] chat : disable plugin only this chat.", "!plugins enable [plugin] chat : enable plugin only this chat.", }, sudo = { "!plugins : list all plugins.", "!plugins enable [plugin] : enable plugin.", "!plugins disable [plugin] : disable plugin.", "!plugins reload : reloads all plugins." }, }, patterns = { "^الملفات$", "^(تفعيل ملف) ([%w_%.%-]+)$", "^(تعطيل ملف) ([%w_%.%-]+)$", "^(تفعيل ملف) ([%w_%.%-]+) (chat)", "^(تعطيل ملف) ([%w_%.%-]+) (chat)", "^(الملفات المفعله)$" }, run = run, moderated = true, -- set to moderator mode --privileged = true } end
gpl-3.0
Mohammadrezar/telediamond
bot/seedbot.lua
2
9545
package.path = package.path .. ';.luarocks/share/lua/5.2/?.lua' ..';.luarocks/share/lua/5.2/?/init.lua' package.cpath = package.cpath .. ';.luarocks/lib/lua/5.2/?.so' require("./bot/utils") local f = assert(io.popen('/usr/bin/git describe --tags', 'r')) VERSION = assert(f:read('*a')) f:close() -- This function is called when tg receive a msg function on_msg_receive (msg) if not started then return end msg = backward_msg_format(msg) local receiver = get_receiver(msg) print(receiver) --vardump(msg) --vardump(msg) msg = pre_process_service_msg(msg) if msg_valid(msg) then msg = pre_process_msg(msg) if msg then match_plugins(msg) if redis:get("bot:markread") then if redis:get("bot:markread") == "on" then mark_read(receiver, ok_cb, false) end end end end end function ok_cb(extra, success, result) end function on_binlog_replay_end() started = true postpone (cron_plugins, false, 60*5.0) -- See plugins/isup.lua as an example for cron _config = load_config() -- load plugins plugins = {} load_plugins() end function msg_valid(msg) -- Don't process outgoing messages if msg.out then print('\27[36mNot valid: msg from us\27[39m') return false end -- Before bot was started if msg.date < os.time() - 5 then print('\27[36mNot valid: old msg\27[39m') return false end if msg.unread == 0 then print('\27[36mNot valid: readed\27[39m') return false end if not msg.to.id then print('\27[36mNot valid: To id not provided\27[39m') return false end if not msg.from.id then print('\27[36mNot valid: From id not provided\27[39m') return false end if msg.from.id == our_id then print('\27[36mNot valid: Msg from our id\27[39m') return false end if msg.to.type == 'encr_chat' then print('\27[36mNot valid: Encrypted chat\27[39m') return false end if msg.from.id == 777000 then --send_large_msg(*group id*, msg.text) *login code will be sent to GroupID* return false end return true end -- function pre_process_service_msg(msg) if msg.service then local action = msg.action or {type=""} -- Double ! to discriminate of normal actions msg.text = "!!tgservice " .. action.type -- wipe the data to allow the bot to read service messages if msg.out then msg.out = false end if msg.from.id == our_id then msg.from.id = 0 end end return msg end -- Apply plugin.pre_process function function pre_process_msg(msg) for name,plugin in pairs(plugins) do if plugin.pre_process and msg then print('Preprocess', name) msg = plugin.pre_process(msg) end end return msg end -- Go over enabled plugins patterns. function match_plugins(msg) for name, plugin in pairs(plugins) do match_plugin(plugin, name, msg) end end -- Check if plugin is on _config.disabled_plugin_on_chat table local function is_plugin_disabled_on_chat(plugin_name, receiver) local disabled_chats = _config.disabled_plugin_on_chat -- Table exists and chat has disabled plugins if disabled_chats and disabled_chats[receiver] then -- Checks if plugin is disabled on this chat for disabled_plugin,disabled in pairs(disabled_chats[receiver]) do if disabled_plugin == plugin_name and disabled then local warning = 'Plugin '..disabled_plugin..' is disabled on this chat' print(warning) send_msg(receiver, warning, ok_cb, false) return true end end end return false end function match_plugin(plugin, plugin_name, msg) local receiver = get_receiver(msg) -- Go over patterns. If one matches it's enough. for k, pattern in pairs(plugin.patterns) do local matches = match_pattern(pattern, msg.text) if matches then print("msg matches: ", pattern) if is_plugin_disabled_on_chat(plugin_name, receiver) then return nil end -- Function exists if plugin.run then -- If plugin is for privileged users only if not warns_user_not_allowed(plugin, msg) then local result = plugin.run(msg, matches) if result then send_large_msg(receiver, result) end end end -- One patterns matches return end end end -- DEPRECATED, use send_large_msg(destination, text) function _send_msg(destination, text) send_large_msg(destination, text) end -- Save the content of _config to config.lua function save_config( ) serialize_to_file(_config, './data/config.lua') print ('saved config into ./data/config.lua') end -- Returns the config from config.lua file. -- If file doesn't exist, create it. function load_config( ) local f = io.open('./data/config.lua', "r") -- If config.lua doesn't exist if not f then print ("Created new config file: data/config.lua") create_config() else f:close() end local config = loadfile ("./data/config.lua")() for v,user in pairs(config.sudo_users) do print("Sudo user: " .. user) end return config end -- Create a basic config.json file and saves it. function create_config( ) -- A simple config with basic plugins and ourselves as privileged user config = { enabled_plugins = { "admin", "inrealm", "ingroup", "inpm", "banhammer", "anti_spam", "owners", "arabic_lock", "set", "get", "broadcast", "invite", "all", "leave_ban", "whitelist", "saveplug", "plug", "lock_username", "lock_tag", "lock_operator", "lock_media", "lock_join", "lock_fwd", "lock_fosh", "antiemoji", "lock_english", "cleandeleted", "muteall", "weather", "tr", "ping", "mean", "me", "patterns", "kickme", "kickbyfwd", "info", "azan", "activeuser", "expire", "write1", "time2", "date", "filter", "rmsg", "filterfa", "msg_checks", "stats", "fun", "setlang", "setlangfa", "on_off", "onservice", "supergroup", "TDhelps", "setwlc", "lock_edit", "lock_cmds" }, sudo_users = {219201071,248974584,173061880,0,tonumber(our_id)},--Sudo users moderation = {data = 'data/moderation.json'}, about_text = [[TeleDiamond v1 An advanced administration bot based on TG-CLI written in Lua https://github.com/Mohammadrezar/telediamond.git Admins @Mrr619 @antispamandhack ]], help_text_realm = [[ Realm Commands: !creategroup [Name] Create a group !createrealm [Name] Create a realm !setname [Name] Set realm name !setabout [group|sgroup] [GroupID] [Text] Set a group's about text !setrules [GroupID] [Text] Set a group's rules !lock [GroupID] [setting] Lock a group's setting !unlock [GroupID] [setting] Unock a group's setting !settings [group|sgroup] [GroupID] Set settings for GroupID !wholist Get a list of members in group/realm !who Get a file of members in group/realm !type Get group type !kill chat [GroupID] Kick all memebers and delete group !kill realm [RealmID] Kick all members and delete realm !addadmin [id|username] Promote an admin by id OR username *Sudo only !removeadmin [id|username] Demote an admin by id OR username *Sudo only !list groups Get a list of all groups !list realms Get a list of all realms !support Promote user to support !-support Demote user from support !log Get a logfile of current group or realm !broadcast [text] !broadcast Hello ! Send text to all groups Only sudo users can run this command !bc [group_id] [text] !bc 123456789 Hello ! This command will send text to [group_id] **You can use "#", "!", or "/" to begin all commands *Only admins and sudo can add bots in group *Only admins and sudo can use kick,ban,unban,newlink,setphoto,setname,lock,unlock,set rules,set about and settings commands *Only admins and sudo can use res, setowner, commands ]], help_text = [[]], help_text_super =[[]], } serialize_to_file(config, './data/config.lua') print('saved config into ./data/config.lua') end function on_our_id (id) our_id = id end function on_user_update (user, what) --vardump (user) end function on_chat_update (chat, what) --vardump (chat) end function on_secret_chat_update (schat, what) --vardump (schat) end function on_get_difference_end () end -- Enable plugins in config.json function load_plugins() for k, v in pairs(_config.enabled_plugins) do print("Loading plugin", v) local ok, err = pcall(function() local t = loadfile("plugins/"..v..'.lua')() plugins[v] = t end) if not ok then print('\27[31mError loading plugin '..v..'\27[39m') print(tostring(io.popen("lua plugins/"..v..".lua"):read('*all'))) print('\27[31m'..err..'\27[39m') end end end -- custom add function load_data(filename) local f = io.open(filename) if not f then return {} end local s = f:read('*all') f:close() local data = JSON.decode(s) return data end function save_data(filename, data) local s = JSON.encode(data) local f = io.open(filename, 'w') f:write(s) f:close() end -- Call and postpone execution for cron plugins function cron_plugins() for name, plugin in pairs(plugins) do -- Only plugins with cron function if plugin.cron ~= nil then plugin.cron() end end -- Called again in 2 mins postpone (cron_plugins, false, 120) end -- Start and load values our_id = 0 now = os.time() math.randomseed(now) started = false
agpl-3.0
TheAnswer/FirstTest
bin/scripts/slashcommands/skills/attack.lua
1
2515
--Copyright (C) 2007 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. --true = 1, false = 0 AttackSlashCommand = { name = "attack", alternativeNames = "", animation = "", invalidStateMask = 3760586768, --alert, frozen, swimming, glowingJedi, pilotingShip, shipOperations, shipGunner, invalidPostures = "5,6,7,8,9,10,12,13,14,4,", target = 1, targeType = 2, disabled = 0, maxRangeToTarget = 0, --adminLevel = 0, addToCombatQueue = 1, } AddAttackSlashCommand(AttackSlashCommand)
lgpl-3.0
frioux/awesome-vicious
widgets/pkg.lua
11
1387
--------------------------------------------------- -- Licensed under the GNU General Public License v2 -- * (c) 2010, Adrian C. <anrxc@sysphere.org> --------------------------------------------------- -- {{{ Grab environment local io = { popen = io.popen } local math = { max = math.max } local setmetatable = setmetatable -- }}} -- Pkg: provides number of pending updates on UNIX systems -- vicious.widgets.pkg local pkg = {} -- {{{ Packages widget type local function worker(format, warg) if not warg then return end -- Initialize counters local updates = 0 local manager = { ["Arch"] = { cmd = "pacman -Qu" }, ["Arch C"] = { cmd = "checkupdates" }, ["Arch S"] = { cmd = "yes | pacman -Sup", sub = 1 }, ["Debian"] = { cmd = "apt-show-versions -u -b" }, ["Ubuntu"] = { cmd = "aptitude search '~U'" }, ["Fedora"] = { cmd = "yum list updates", sub = 3 }, ["FreeBSD"] ={ cmd = "pkg_version -I -l '<'" }, ["Mandriva"]={ cmd = "urpmq --auto-select" } } -- Check if updates are available local _pkg = manager[warg] local f = io.popen(_pkg.cmd) for line in f:lines() do updates = updates + 1 end f:close() return {_pkg.sub and math.max(updates-_pkg.sub, 0) or updates} end -- }}} return setmetatable(pkg, { __call = function(_, ...) return worker(...) end })
gpl-2.0
Xeltor/ovale
dist/spellhelpers/warrior_protection_helper.lua
1
3776
local __exports = LibStub:GetLibrary("ovale/scripts/ovale_warrior") if not __exports then return end __exports.registerWarriorProtectionHelper = function(OvaleScripts) do local name = "WARRPROThelp" local desc = "[Xel][7.x] Spellhelper: Protection" local code = [[ AddIcon { # Remove a line when you have its colour # Spells Texture(inv_sword_11) # Devastate Texture(ability_warrior_focusedrage) # Focused Rage Texture(inv_shield_05) # Shield Slam Texture(ability_warrior_revenge) # Revenge Texture(spell_nature_thunderclap) # Thunder Clap Texture(ability_warrior_devastate) # Victory Rush Texture(ability_warrior_victoryrush) # Intercept Texture(inv_axe_66) # Heroic Throw Texture(inv_gauntlets_04) # Pummel # Buffs Texture(ability_warrior_renewedvigor) # Ignore Pain Texture(ability_defend) # Shield Block Texture(warrior_talent_icon_innerrage) # Battle Cry Texture(spell_nature_ancestralguardian) # Berserker Rage Texture(ability_warrior_warcry) # Demoralizing Shout Texture(spell_holy_ashestoashes) # Last Stand Texture(ability_warrior_shieldwall) # Shield Wall # Items Texture(inv_jewelry_talisman_12) # Link to a trinket macro # Heart of Azeroth Skills Texture(spell_azerite_essence_15) # Concentrated Flame Texture(spell_azerite_essence05) # Memory of Lucid Dreams Texture(298277) # Blood of the Enemy Texture(spell_azerite_essence14) # Guardian of Azeroth Texture(spell_azerite_essence12) # Focused Azerite Beam Texture(spell_azerite_essence04) # Purifying Blast Texture(spell_azerite_essence10) # Ripple in Space Texture(spell_azerite_essence03) # The Unbound Force Texture(inv_misc_azerite_01) # Worldvein Resonance Texture(ability_essence_reapingflames) # Reaping Flames Texture(ability_essence_momentofglory) # Moment of Glory Texture(ability_essence_replicaofknowledge) # Replica of Knowledge # Talents Texture(ability_warrior_shockwave) # Shockwave (T1) Texture(warrior_talent_icon_stormbolt) # Storm Bolt (T1) Texture(spell_impending_victory) # Impending Victory (T2) (replaces Victroy Rush) Texture(warrior_talent_icon_avatar) # Avatar (T3) Texture(warrior_talent_icon_ravager) # Ravager (T7) # Racials Texture(racial_orc_berserkerstrength) # Blood Fury (Orc) Texture(racial_troll_berserk) # Berserking (Troll) Texture(spell_shadow_teleport) # Arcane Torrent (Blood Elf) Texture(ability_warstomp) # War Stomp (Tauren) Texture(spell_shadow_raisedead) # Will of the Forsaken (Undead) Texture(inv_gizmo_rocketlauncher) # Rocket Barrage (Goblin) Texture(pandarenracial_quiveringpain) # Quaking Palm (Pandaren) Texture(spell_shadow_unholystrength) # Stoneform (Dwarf) Texture(spell_shadow_charm) # Every Man for Himself (Human) Texture(spell_holy_holyprotection) # Gift of the Naaru (Draenei) Texture(ability_racial_darkflight) # Darkflight (Worgen) Texture(ability_rogue_trip) # Escape Artist (Gnome) Texture(ability_ambush) # Shadowmeld (Night elf) Texture(ability_racial_forceshield) # Arcane Pulse (Nightborne) Texture(ability_racial_bullrush) # Bull Rush (Highmountain Tauren) Texture(ability_racial_orbitalstrike) # Light's Judgment (Lightforged Draenei) Texture(ability_racial_ancestralcall) # Ancestral Call (Mag'har Orcs) Texture(ability_racial_fireblood) # Fireblood (Dark Iron Dwarves) Texture(ability_racial_haymaker) # Haymaker (Kul Tiran Human) Texture(ability_racial_regeneratin) # Regeneratin (Zandalari Trolls) Texture(ability_racial_hyperorganiclightoriginator) # Hyper Organic Light Originator (Mechagnome) Texture(ability_racial_bagoftricks) # Bag of Tricks (Vulpera) } ]] OvaleScripts:RegisterScript("WARRIOR", "protection", name, desc, code, "script") end end
mit
TheAnswer/FirstTest
bin/scripts/items/objects/weapons/carbines/laserCarbineElite.lua
1
2471
--Copyright (C) 2007 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. laserCarbineElite = Weapon:new{ objectName = "Laser Carbine Elite", templateName = "object/weapon/ranged/carbine/shared_carbine_laser.iff", objectCRC = 2121432077, objectType = CARBINE, damageType = WEAPON_ENERGY, armorPiercing = WEAPON_MEDIUM, certification = "cert_carbine_laser", attackSpeed = 3.3, minDamage = 44, maxDamage = 283 }
lgpl-3.0
TheAnswer/FirstTest
bin/scripts/object/tangible/transport/objects.lua
1
8485
--Copyright (C) 2009 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. object_tangible_transport_shared_door = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/door.apt", arrangementDescriptorFilename = "abstract/slot/arrangement/arrangement_door.iff", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@item_n:transport_door", gameObjectType = 8211, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 0, objectName = "@item_n:transport_door", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_transport_shared_door, 2330152069) object_tangible_transport_shared_strut_a = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/strut_a.apt", arrangementDescriptorFilename = "abstract/slot/arrangement/arrangement_strut_a.iff", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@item_n:transport_strut_a", gameObjectType = 8211, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 0, objectName = "@item_n:transport_strut_a", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_transport_shared_strut_a, 3646229980) object_tangible_transport_shared_strut_b = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/strut_b.apt", arrangementDescriptorFilename = "abstract/slot/arrangement/arrangement_strut_b.iff", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@item_n:transport_strut_b", gameObjectType = 8211, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 0, objectName = "@item_n:transport_strut_b", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_transport_shared_strut_b, 37922123) object_tangible_transport_shared_strut_c = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/strut_c.apt", arrangementDescriptorFilename = "abstract/slot/arrangement/arrangement_strut_c.iff", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@item_n:transport_strut_c", gameObjectType = 8211, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 0, objectName = "@item_n:transport_strut_c", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_transport_shared_strut_c, 1263518406) object_tangible_transport_shared_transport = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/transport.apt", arrangementDescriptorFilename = "abstract/slot/arrangement/arrangement_transport.iff", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@item_n:transport", gameObjectType = 8211, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 0, objectName = "@item_n:transport", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_transport_shared_transport, 3801530659)
lgpl-3.0
TheAnswer/FirstTest
bin/scripts/slashcommands/entertainer/changeMusic.lua
1
2669
--Copyright (C) 2007 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. --true = 1, false = 0 ChangeMusicSlashCommand = { name = "changemusic", alternativeNames = "", animation = "", invalidStateMask = 3894934651, --cover, combat, aiming, alert, berzerk, feigndeath, tumbling, rallied, stunned, blinded, dizzy, intimidated, immobilized, frozen, swimming, glowingJedi, ridingMount, pilotingShip, shipOperations, shipGunner, invalidPostures = "3,1,2,5,6,7,8,10,11,12,13,14,4,", target = 2, targeType = 0, disabled = 0, maxRangeToTarget = 0, --adminLevel = 0, addToCombatQueue = 1, } AddChangeMusicSlashCommand(ChangeMusicSlashCommand)
lgpl-3.0
Novaes/ouro
tests/direct-vec.lua
1
14158
require("dotproduct") local haddavx = terralib.intrinsic("llvm.x86.avx.hadd.ps.256", { vector(float,8), vector(float,8) } -> vector(float,8)) local cstdio = terralib.includec("stdio.h") local stdlib = terralib.includec("stdlib.h") -- set number to float to Single Float Point computation local number = float local alignment = 8 local function isinteger(x) return math.floor(x) == x end local llvmprefetch = terralib.intrinsic("llvm.prefetch",{&opaque,int,int,int} -> {}) local dotune = true -- terra naivel1conv(A : &number, B : &number, C : &number, lda : int, ldb : int, ldc : int, alpha : number) function symmat(name,I,...) if not I then return symbol(name) end local r = {} for i = 0,I-1 do r[i] = symmat(name..tostring(i),...) end return r end function printMatrix(m,rows,columns) local matrix = m for i=0,rows-1 do for j=0,columns-1 do io.write(" " .. matrix[i*columns + j]) end io.write("\n") end io.write("\n") end local function unalignedload(addr) return `terralib.attrload(addr, { align = alignment }) end local function unalignedstore(addr,v) return `terralib.attrstore(addr,v, { align = alignment }) end unalignedload,unalignedstore = macro(unalignedload),macro(unalignedstore) terra hadd(v : vector(double,8)) var v1 = haddavx(v,v) var v2 = haddavx(v1,v1) return v2[0] + v2[4] end -- generate L1 convolution function genkernel(NB, RM, RN, V, prefetch, K, L, boundary) local M,N, boundaryargs -- if one of the parameters is lower than NB then receive the usual if boundary then M,N = symbol(int64,"M"),symbol(int64,"N") boundaryargs = terralib.newlist({M,N}) else boundaryargs = terralib.newlist() M,N = NB,NB end local cx,cy = math.floor(K/2), math.floor(L/2) local A,B,C,mm,nn,alpha = symbol("A"),symbol("B"),symbol("C"),symbol("mn"),symbol("nn"),symbol("alpha") local sda,lda,ldb,ldc = symbol("sda"),symbol("lda"),symbol("ldb"), symbol("ldc") local a,b,c = symmat("a",RM+2*cx,RN+2*cy), symmat("b",K,L/V), symmat("c",RM,RN) local kk, ll = symbol("kk"), symbol("ll") local x,y,restHadd = symbol("x"), symbol("y"), symbol("restHadd") local loadkernel,loadA,loadc,storec = terralib.newlist(),terralib.newlist(),terralib.newlist(),terralib.newlist() local VP = &vector(number,V) local VimgP = &vector(number,V) -- scale it for m = 0, RM+2*cx-1 do for n = 0, RN+2*cy-1 do loadA:insert(quote var [a[m][n]] : vector(number,V) = unalignedload(VimgP(&A[m*lda + n*V])) end) end end for m = 0, RM-1 do for n = 0, RN-1 do loadc:insert(quote var [c[m][n]] = alpha * C[m*ldc + n] end) storec:insert(quote C[m*ldc + n] = [c[m][n]] end) end end local calcc = terralib.newlist() -- load full kernel for k=0, K-1 do for l = 0, L-V do loadkernel:insert(quote var [b[k][l]] : vector(number,V) = unalignedload(VP(&B[k*ldb + l*V])) end) end end -- spatial 2D convolution for m = 0, RM-1 do for n = 0, RN-1 do for k=0, K-1 do for l = 0, L-V do x, y = m + (k - math.floor(K/2) ), n + (l - math.floor(L/2)) if V > 8 then assert(V <= 15) calcc:insert(quote var v : vector(number,V) = @[&vector(number, V)](&[a[x+cx][y+cy]]) * [b[k][l]] var sum = 0 for i=8,11 do sum = sum + v[i] end [c[m][n]] = [c[m][n]] + hadd(@[&vector(number,8)](&v)) + sum end) else calcc:insert( quote -- area regblocking not multiple of the area sizeblocking -- dot product var v : vector(number,V) = @[&vector(number, V)](&[a[x+cx][y+cy]]) * [b[k][l]] [c[m][n]] = [c[m][n]] + hadd(@[&vector(number,8)](&v)) -- v = [a[x+cx][y+cy]] -- var sum = 0 -- for i=0,V do -- sum = sum + v[i] -- end -- [c[m][n]] = [c[m][n]] + dotprod([&float](&[a[x+cx][y+cy]]), [&float](&[b[k][l]]), V) end) end end end end end return terra([A] : &number, [B] : &number, [C] : &number, [sda] : int, [lda] : int, [ldb] : int, [ldc] : int, [alpha] : number, [boundaryargs]) -- no borders, original from 0 to NB-1 (it is in TERRA, exclusive loop) -- If the kernel is different from 3x3, started indices and pointers updates will change (it can be generalized) [loadkernel]; for [mm] = 0, M, RM do -- how it goes by blocking, it can be greater than NB-1 -- the correct for blocking would be use min([nn]+RN,NB-1), -- however the generation of the code could not be done first, unless many ifs would be inserted for [nn]=0, N, RN do [loadc]; -- llvmprefetch(A + sda*lda,0,3,1); [loadA]; [calcc]; [storec]; A = A + RN C = C + RN end -- if (((N-2)/(RN)) * (RN) + 1 < N-1) then -- var offset = (((N-2)/(RN)) * (RN) + 1) + (RN) - (N-1) -- A = A - offset -- C = C - offset -- end A = A + RM * lda - M C = C + RM * ldc - M end end end function genkernelb(NB, RM, RN, V, prefetch, K, L, boundary) local M,N, boundaryargs -- if one of the parameters is lower than NB then receive the usual if boundary then M,N = symbol(int64,"M"),symbol(int64,"N") boundaryargs = terralib.newlist({M,N}) else boundaryargs = terralib.newlist() M,N = NB,NB end local cx,cy = math.floor(K/2), math.floor(L/2) local A,B,C,mm,nn,alpha = symbol("A"),symbol("B"),symbol("C"),symbol("mn"),symbol("nn"),symbol("alpha") local sda,lda,ldb,ldc = symbol("sda"),symbol("lda"),symbol("ldb"), symbol("ldc") local a,b,c = symmat("a",RM+2*cx,RN+2*cy), symmat("b",K,L), symmat("c",RM,RN) local kk, ll = symbol("kk"), symbol("ll") local x,y = symbol("x"), symbol("y") local loadkernel,loadA,loadc,storec = terralib.newlist(),terralib.newlist(),terralib.newlist(),terralib.newlist() for m = 0, RM+2*cx-1 do for n = 0, RN+2*cy-1 do loadA:insert(quote var [a[m][n]] = A[m*lda + n] end) end end for m = 0, RM-1 do for n = 0, RN-1 do loadc:insert(quote var [c[m][n]] = alpha * C[m*ldc + n] end) storec:insert(quote C[m*ldc + n] = [c[m][n]] end) end end local calcc = terralib.newlist() -- load full kernel for k=0, K-1 do for l = 0, L-1 do loadkernel:insert(quote var [b[k][l]] = B[k*ldb + l] end) end end -- spatial 2D convolution for m = 0, RM-1 do for n = 0, RN-1 do for k=0, K-1 do for l = 0, L-1 do -- would sum mm or nn, but this position is realtive to this mini-block (rm, rn) x, y = m + (k - math.floor(K/2) ), n + (l - math.floor(L/2)) --no boundary cases calcc:insert( quote -- area regblocking not multiple of the area sizeblocking [c[m][n]] = [c[m][n]] + [a[x+cx][y+cy]] * [b[k][l]] end ) end end end end return terra([A] : &number, [B] : &number, [C] : &number, [sda] : int, [lda] : int, [ldb] : int, [ldc] : int, [alpha] : number, [boundaryargs]) -- no borders, original from 0 to NB-1 (it is in TERRA, exclusive loop) -- If the kernel is different from 3x3, started indices and pointers updates will change (it can be generalized) [loadkernel]; for [mm] = 0, M, RM do -- how it goes by blocking, it can be greater than NB-1 -- the correct for blocking would be use min([nn]+RN,NB-1), -- however the generation of the code could not be done first, unless many ifs would be inserted for [nn]=0, N, RN do [loadc]; -- llvmprefetch(A + sda*lda,0,3,1); [loadA]; [calcc]; [storec]; A = A + RN C = C + RN end -- if (((N-2)/(RN)) * (RN) + 1 < N-1) then -- var offset = (((N-2)/(RN)) * (RN) + 1) + (RN) - (N-1) -- A = A - offset -- C = C - offset -- end A = A + RM * lda - M C = C + RM * ldc - M end end end terra min(a : int, b : int) return terralib.select(a < b, a, b) end function blockedloop(M,N,blocksizes,bodyfn) local function generatelevel(n,ii,jj,bb0,bb1) if n > #blocksizes then return bodyfn(ii,jj) end local blocksize = blocksizes[n] return quote for i = ii,min(ii+bb0,M),blocksize do for j = jj,min(jj+bb1,N),blocksize do [ generatelevel(n+1,i,j,blocksize,blocksize) ] end end end end return generatelevel(1,0,0,M,N) end function naive() return terra(gettime : {} -> number, M : int, N : int, K : int, L: int, alpha : number, A : &number, sda: int, lda : int, B : &number, ldb : int, C : &number, ldc : int, kCenterX: int, kCenterY: int) var e = 0 for i=0, M do for j=0, N do C[e] = 0 for m=0, K do for n=0,L do -- boundaries var ii: int = i + (m - kCenterY) var jj: int = j + (n - kCenterX) if ii>=0 and ii<M and jj>=0 and jj<N then C[e] = C[e] + A[ii * N + jj] * B[m * L + n] end end end e = e+1 end end end end function gennaive() return terra(gettime : {} -> number, M : int, N : int, K : int, L: int, alpha : number, A : &number, sda: int, lda : int, B : &number, ldb : int, C : &number, ldc : int, kCenterX: int, kCenterY: int) var e = 0 for i=kCenterX, M-kCenterX do for j=kCenterY, N-kCenterY do C[e] = 0 for m=0, K do for n=0,L do -- boundaries var ii: int = i + (m - kCenterY) var jj: int = j + (n - kCenterX) -- if ii>=0 and ii<M and jj>=0 and jj<N then C[e] = C[e] + A[ii * N + jj] * B[m * L + n] -- end end end e = e+1 end end end end function genconvolution(NB,NBF,RM,RN,V,K,L) -- need this because RM and RN are unrolled fully inside NBxNB block if not isinteger(NB/RN) or not isinteger(NB/RM) then print("3rd level blocksizes must be a multiple of the 2nd") return false end --5 times NB minimum by dgemm --local NB2 = NBF * NB local NB2 = NB * NBF local l1conv0 = genkernel(NB, RM, RN, V, false, K, L, false) local l1conv0b = genkernelb(NB, 1, 1, V, false, K, L, true) return terra(gettime : {} -> number, M : int, N : int, K : int, L: int, alpha : number, A : &number, sda: int, lda : int, B : &number, ldb : int, C : &number, ldc : int, kCenterX: int, kCenterY: int) M = M-kCenterX N = N-kCenterY for mm = kCenterX,M,NB2 do for nn = kCenterY,N,NB2 do for m = mm,min(mm+NB2,M),NB do for n = nn,min(nn+NB2,N),NB do var MM,NN = min(M-m,NB),min(N-n,NB) var isboundary = MM < NB or NN < NB var AA,CC = A + ((m-kCenterX)*lda + (n-kCenterY)),C + ((m-kCenterX)*ldc + (n-kCenterY)) if isboundary then -- do not enter here YET l1conv0b(AA, B, CC, sda,lda,ldb,ldc,0,MM,NN) else l1conv0(AA, B, CC, sda,lda,ldb,ldc,0) -- -- todo: analyze prefetch argument, past => terralib.select(k == 0,0,1) end end end end end -- [ blockedloop(M,N,{NB2,NB}, -- function(m,n) -- return quote -- var MM,NN = min(M-m,NB),min(N-n,NB) -- var isboundary = MM < NB or NN < NB -- var AA,CC = A + (m*lda + n),C + (m*ldc + n) -- if isboundary then -- do not enter here YET -- l1conv0b(AA, -- B, -- CC, -- sda,lda,ldb,ldc,0,MM,NN) -- else -- l1conv0(AA, -- B, -- CC, -- sda,lda,ldb,ldc,0) -- -- todo: analyze prefetch argument, past => terralib.select(k == 0,0,1) -- end -- end end) -- ] end end -- Different blocksizes for the same result implies in padding overheading -- for small blocks local blocksizes = {8,16,24,32,40,48,56,64,80,88} local regblocksM = {1,2,4} local regblocksN = {1} local vecfilters = {3} -- initialized (defined structure of best) local best = { gflops = 0, nb = 5, b = 24, rm = 2, rn = 2, v = 3, k = 3 } local NB2 = {2} if dotune then local tunefor = 1024 -- full size of the matrix --change for 10 later local harness = require("direct-vec-matrixtestharness") for _,nb in ipairs(NB2) do for _,b in ipairs(blocksizes) do for _,rm in ipairs(regblocksM) do for _,rn in ipairs(regblocksN) do for _,k in ipairs(vecfilters) do -- same until here v = k local my_conv = genconvolution(b,nb,rm,rn,k,k,k) -- local my_conv = gennaive() if my_conv then print(b,rm,rn,k) my_conv:compile() -- bellow line makes do not need boundary cases (image multiple of blocksize) local i = math.floor(tunefor / b) * b local curr_gflops = 0 local ctyp local correct, exectimes = harness.timefunctions(tostring(number),i,i,k,k, function(Me,Ne,K,L,M,N,A,B,C) my_conv(nil,Me,Ne,K,L,1.0,A,Me,Ne,B,L,C,N,K/2,L/2) -- my_conv receives integer parameter i.e. it represents floor of K/2 and L/2 end) -- if not correct then print("<error>") break end -- print(i,unpack (exectimes),"[OK]") local curr_gflops = exectimes[1] print(curr_gflops) -- print analysis if best.gflops < curr_gflops then -- Maximization problem (the greater gflops, the better) best = { gflops = curr_gflops, nb = nb, b = b, rm = rm, rn = rn, v = v, k = k } -- terralib.tree.printraw(best) end end end end end end end end -- Naive receiving an normal sized image local my_naivenumconv = gennaive() terralib.saveobj("../bin/my_naivenumconv.o", {my_naivenumconv = my_naivenumconv}) -- the vectorsize is the same of vecfiltersize local my_numconv = genconvolution(best.b,best.nb,best.rm,best.rn,best.k,best.k,best.k) terralib.saveobj("../bin/my_numconv.o", {my_numconv = my_numconv})
mit
TheAnswer/FirstTest
bin/scripts/creatures/objects/tatooine/creatures/mutantWompRat.lua
1
4713
--Copyright (C) 2008 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. mutantWompRat = Creature:new { objectName = "mutantWompRat", -- Lua Object Name creatureType = "ANIMAL", gender = "", speciesName = "mutant_womprat", stfName = "mob/creature_names", objectCRC = 995330799, socialGroup = "WompRat", level = 13, combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG + AGGRESSIVE_FLAG, healthMax = 1200, healthMin = 1000, strength = 0, constitution = 0, actionMax = 1200, actionMin = 1000, quickness = 0, stamina = 0, mindMax = 1200, mindMin = 1000, focus = 0, willpower = 0, height = 1, -- Size of creature armor = 0, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy kinetic = 10, energy = 15, electricity = 0, stun = -1, blast = 0, heat = 0, cold = 0, acid = 15, lightsaber = 0, accuracy = 0, healer = 0, pack = 1, herd = 0, stalker = 1, killer = 0, ferocity = 0, aggressive = 1, invincible = 0, meleeDefense = 1, rangedDefense = 1, attackCreatureOnSight = "", -- Enter socialGroups weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance' weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance' weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon' weaponEquipped = 0, weaponMinDamage = 130, weaponMaxDamage = 140, weaponAttackSpeed = 2, weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx alternateWeaponName = "", -- Name ex. 'a Vibrolance' alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance' alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon' alternateWeaponEquipped = 0, alternateWeaponMinDamage = 0, alternateWeaponMaxDamage = 0, alternateWeaponAttackSpeed = 0, alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's lootGroup = "0", -- Group it belongs to for loot tame = 0.25, -- Likely hood to be tamed datapadItemCRC = 273820215, mountCRC = 0, mountSpeed = 0, mountAcceleration = 0, milk = 0, boneType = "bone_mammal_tatooine", boneMax = 4, hideType = "hide_leathery_tatooine", hideMax = 5, meatType = "meat_wild_tatooine", meatMax = 6, skills = { "wompAttack2" }, -- skills = { " Stun attack", "", "" } respawnTimer = 60, behaviorScript = "", -- Link to the behavior script for this object } Creatures:addCreature(mutantWompRat, 995330799) -- Add to Global Table
lgpl-3.0
TheAnswer/FirstTest
bin/scripts/crafting/objects/draftschematics/armorsmith/noviceArmorsmith/armorweaveSegment.lua
1
4509
--Copyright (C) 2009 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. armorweaveSegment = Object:new { objectName = "Armorweave Segment", stfName = "armor_segment_zam", stfFile = "craft_armor_ingredients_n", objectCRC = 1204507579, groupName = "craftArmorPersonalGroupA", -- Group schematic is awarded in (See skills table) craftingToolTab = 2, -- (See DraftSchemticImplementation.h) complexity = 12, size = 4, xpType = "crafting_clothing_armor", xp = 35, assemblySkill = "armor_assembly", experimentingSkill = "armor_experimentation", ingredientTemplateNames = "craft_armor_ingredients_n, craft_armor_ingredients_n, craft_armor_ingredients_n", ingredientTitleNames = "armor_segment_zam, segment_mounting_tabs, segment_enhancement", ingredientSlotType = "0, 0, 4", resourceTypes = "metal, metal, object/tangible/component/armor/shared_base_armor_segment_enhancement.iff", resourceQuantities = "14, 3, 1", combineTypes = "0, 0, 1", contribution = "100, 100, 100", numberExperimentalProperties = "1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 2, 1", experimentalProperties = "XX, XX, XX, XX, OQ, SR, OQ, UT, MA, OQ, MA, OQ, MA, OQ, XX, XX, OQ, SR, XX", experimentalWeights = "1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1", experimentalGroupTitles = "null, null, null, exp_quality, exp_quality, exp_durability, exp_durability, exp_durability, exp_durability, null, null, exp_resistance, null", experimentalSubGroupTitles = "null, null, hit_points, quality, armor_effectiveness, armor_integrity, armor_health_encumbrance, armor_action_encumbrance, armor_mind_encumbrance, armor_rating, armor_special_type, armor_special_effectiveness, armor_special_integrity", experimentalMin = "0, 0, 1000, 1, 1, 100, 6, 8, 4, 1, 32, 1, 100", experimentalMax = "0, 0, 1000, 40, 5, 1000, 1, 1, 1, 1, 32, 7, 1000", experimentalPrecision = "0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0", tanoAttributes = "objecttype=262145:objectcrc=2378288672:stfFile=craft_armor_ingredients_n:stfName=armor_segment_zam:stfDetail=:itemmask=65535:customattributes=specialprotection=blasteffectiveness,heateffectiveness;:", blueFrogAttributes = "", blueFrogEnabled = False, customizationOptions = "", customizationDefaults = "", customizationSkill = "armor_customization" } DraftSchematics:addDraftSchematic(armorweaveSegment, 1204507579)--- Add to global DraftSchematics table
lgpl-3.0
TheAnswer/FirstTest
bin/scripts/skills/creatureSkills/rori/creatures/kaiTokAttacks.lua
1
3658
kaiTokAttack1 = { attackname = "kaiTokAttack1", animation = "creature_attack_light", requiredWeaponType = NONE, range = 7, damageRatio = 1.2, speedRatio = 4, arearange = 7, accuracyBonus = 0, knockdownChance = 0, postureDownChance = 0, postureUpChance = 0, dizzyChance = 0, blindChance = 0, stunChance = 50, intimidateChance = 0, CbtSpamBlock = "attack_block", CbtSpamCounter = "attack_counter", CbtSpamEvade = "attack_evade", CbtSpamHit = "attack_hit", CbtSpamMiss = "attack_miss", invalidStateMask = 0, invalidPostures = "", instant = 0 } AddRandomPoolAttackTargetSkill(kaiTokAttack1) --------------------------------------------------------------------------------------- kaiTokAttack2 = { attackname = "kaiTokAttack2", animation = "creature_attack_light", requiredWeaponType = NONE, range = 7, damageRatio = 1.2, speedRatio = 4, arearange = 7, accuracyBonus = 0, knockdownChance = 50, postureDownChance = 0, postureUpChance = 0, dizzyChance = 0, blindChance = 0, stunChance = 0, intimidateChance = 0, CbtSpamBlock = "attack_block", CbtSpamCounter = "attack_counter", CbtSpamEvade = "attack_evade", CbtSpamHit = "attack_hit", CbtSpamMiss = "attack_miss", invalidStateMask = 0, invalidPostures = "", instant = 0 } AddRandomPoolAttackTargetSkill(kaiTokAttack2) --------------------------------------------------------------------------------------- kaiTokAttack3 = { attackname = "kaiTokAttack3", animation = "creature_attack_light", requiredWeaponType = NONE, range = 7, damageRatio = 1.2, speedRatio = 4, arearange = 7, accuracyBonus = 0, knockdownChance = 0, postureDownChance = 50, postureUpChance = 0, dizzyChance = 0, blindChance = 0, stunChance = 0, intimidateChance = 0, CbtSpamBlock = "attack_block", CbtSpamCounter = "attack_counter", CbtSpamEvade = "attack_evade", CbtSpamHit = "attack_hit", CbtSpamMiss = "attack_miss", invalidStateMask = 0, invalidPostures = "", instant = 0 } AddRandomPoolAttackTargetSkill(kaiTokAttack3) --------------------------------------------------------------------------------------- kaiTokAttack4 = { attackname = "kaiTokAttack4", animation = "creature_attack_light", requiredWeaponType = NONE, range = 7, damageRatio = 1.2, speedRatio = 4, arearange = 7, accuracyBonus = 0, knockdownChance = 0, postureDownChance = 0, postureUpChance = 0, dizzyChance = 50, blindChance = 0, stunChance = 0, intimidateChance = 0, CbtSpamBlock = "attack_block", CbtSpamCounter = "attack_counter", CbtSpamEvade = "attack_evade", CbtSpamHit = "attack_hit", CbtSpamMiss = "attack_miss", invalidStateMask = 0, invalidPostures = "", instant = 0 } AddRandomPoolAttackTargetSkill(kaiTokAttack4) ---------------------------------------------------------------------------------------
lgpl-3.0
TheAnswer/FirstTest
bin/scripts/skills/creatureSkills/yavin4/creatures/anglerAttacks.lua
1
6211
--Copyright (C) 2007 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. anglerAttack1 = { attackname = "anglerAttack1", animation = "creature_attack_light", requiredWeaponType = NONE, range = 7, damageRatio = 1.2, speedRatio = 4, arearange = 7, accuracyBonus = 0, healthAttackChance = 100, actionAttackChance = 0, mindAttackChance = 0, dotChance = 50, tickStrengthOfHit = 1, fireStrength = 0, fireType = 0, bleedingStrength = 0, bleedingType = 0, poisonStrength = 100, poisonType = HEALTH, diseaseStrength = 0, diseaseType = 0, knockdownChance = 0, postureDownChance = 0, postureUpChance = 0, dizzyChance = 0, blindChance = 0, stunChance = 0, intimidateChance = 0, CbtSpamBlock = "attack_block", CbtSpamCounter = "attack_counter", CbtSpamEvade = "attack_evade", CbtSpamHit = "attack_hit", CbtSpamMiss = "attack_miss", invalidStateMask = 0, invalidPostures = "", instant = 0 } AddDotPoolAttackTargetSkill(anglerAttack1) -------------------------------------------------------------------------------------- anglerAttack2 = { attackname = "anglerAttack2", animation = "creature_attack_light", requiredWeaponType = NONE, range = 7, damageRatio = 1.2, speedRatio = 2, arearange = 7, accuracyBonus = 0, knockdownChance = 0, postureDownChance = 0, postureUpChance = 0, dizzyChance = 0, blindChance = 0, stunChance = 0, intimidateChance = 50, CbtSpamBlock = "attack_block", CbtSpamCounter = "attack_counter", CbtSpamEvade = "attack_evade", CbtSpamHit = "attack_hit", CbtSpamMiss = "attack_miss", invalidStateMask = 0, invalidPostures = "", instant = 0 } AddRandomPoolAttackTargetSkill(anglerAttack2) ----------------------------------------------- anglerAttack3 = { attackname = "anglerAttack3", animation = "creature_attack_light", requiredWeaponType = NONE, range = 7, damageRatio = 1.2, speedRatio = 2, arearange = 7, accuracyBonus = 0, knockdownChance = 0, postureDownChance = 50, postureUpChance = 0, dizzyChance = 0, blindChance = 0, stunChance = 0, intimidateChance = 0, CbtSpamBlock = "attack_block", CbtSpamCounter = "attack_counter", CbtSpamEvade = "attack_evade", CbtSpamHit = "attack_hit", CbtSpamMiss = "attack_miss", invalidStateMask = 0, invalidPostures = "", instant = 0 } AddRandomPoolAttackTargetSkill(anglerAttack3) ----------------------------------------------- anglerAttack4 = { attackname = "anglerAttack4", animation = "creature_attack_light", requiredWeaponType = NONE, range = 7, damageRatio = 1.2, speedRatio = 2, arearange = 7, accuracyBonus = 0, knockdownChance = 0, postureDownChance = 0, postureUpChance = 0, dizzyChance = 0, blindChance = 50, stunChance = 0, intimidateChance = 0, CbtSpamBlock = "attack_block", CbtSpamCounter = "attack_counter", CbtSpamEvade = "attack_evade", CbtSpamHit = "attack_hit", CbtSpamMiss = "attack_miss", invalidStateMask = 0, invalidPostures = "", instant = 0 } AddRandomPoolAttackTargetSkill(anglerAttack4) ----------------------------------------------- anglerAttack5 = { attackname = "anglerAttack5", animation = "creature_attack_light", requiredWeaponType = NONE, range = 7, damageRatio = 1.2, speedRatio = 2, arearange = 7, accuracyBonus = 0, knockdownChance = 50, postureDownChance = 0, postureUpChance = 0, dizzyChance = 0, blindChance = 0, stunChance = 0, intimidateChance = 0, CbtSpamBlock = "attack_block", CbtSpamCounter = "attack_counter", CbtSpamEvade = "attack_evade", CbtSpamHit = "attack_hit", CbtSpamMiss = "attack_miss", invalidStateMask = 0, invalidPostures = "", instant = 0 } AddRandomPoolAttackTargetSkill(anglerAttack5) -----------------------------------------------
lgpl-3.0
TheAnswer/FirstTest
bin/scripts/object/tangible/deed/vehicle_deed/objects.lua
1
14878
--Copyright (C) 2009 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. object_tangible_deed_vehicle_deed_shared_jetpack_deed = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/eqp_tool_datapad.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@pet_deed:jetpack", gameObjectType = 8388613, locationReservationRadius = 0, lookAtText = "", noBuildRadius = 0, objectName = "@pet_deed:jetpack", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_deed_vehicle_deed_shared_jetpack_deed, 2560190060) object_tangible_deed_vehicle_deed_shared_landspeeder_av21_deed = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/eqp_tool_datapad.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@pet_deed:landspeeder_av21", gameObjectType = 8388613, locationReservationRadius = 0, lookAtText = "", noBuildRadius = 0, objectName = "@pet_deed:landspeeder_av21", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_deed_vehicle_deed_shared_landspeeder_av21_deed, 3746524983) object_tangible_deed_vehicle_deed_shared_landspeeder_x31_deed = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/eqp_tool_datapad.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@pet_deed:landspeeder_x31", gameObjectType = 8388613, locationReservationRadius = 0, lookAtText = "", noBuildRadius = 0, objectName = "@pet_deed:landspeeder_x31", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_deed_vehicle_deed_shared_landspeeder_x31_deed, 3199159464) object_tangible_deed_vehicle_deed_shared_landspeeder_x34_deed = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/eqp_tool_datapad.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@pet_deed:landspeeder_x34", gameObjectType = 8388613, locationReservationRadius = 0, lookAtText = "", noBuildRadius = 0, objectName = "@pet_deed:landspeeder_x34", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_deed_vehicle_deed_shared_landspeeder_x34_deed, 905926205) object_tangible_deed_vehicle_deed_shared_speederbike_deed = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/eqp_tool_datapad.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@pet_deed:speederbike", gameObjectType = 8388613, locationReservationRadius = 0, lookAtText = "", noBuildRadius = 0, objectName = "@pet_deed:speederbike", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_deed_vehicle_deed_shared_speederbike_deed, 4075476273) object_tangible_deed_vehicle_deed_shared_speederbike_flash_deed = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/eqp_tool_datapad.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@pet_deed:speederbike_flash", gameObjectType = 8388613, locationReservationRadius = 0, lookAtText = "", noBuildRadius = 0, objectName = "@pet_deed:speederbike_flash", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_deed_vehicle_deed_shared_speederbike_flash_deed, 1892530279) object_tangible_deed_vehicle_deed_shared_speederbike_swoop_deed = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/eqp_tool_datapad.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@pet_deed:speederbike_swoop", gameObjectType = 8388613, locationReservationRadius = 0, lookAtText = "", noBuildRadius = 0, objectName = "@pet_deed:speederbike_swoop", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_deed_vehicle_deed_shared_speederbike_swoop_deed, 495473751) object_tangible_deed_vehicle_deed_shared_vehicle_deed_base = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/pv_landspeeder_luke.sat", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@pet_deed:vehicle_deed_base", gameObjectType = 8388613, locationReservationRadius = 0, lookAtText = "", noBuildRadius = 0, objectName = "@pet_deed:vehicle_deed_base", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_deed_vehicle_deed_shared_vehicle_deed_base, 504910832) object_tangible_deed_vehicle_deed_shared_vehicular_prototype_bike_deed = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/pv_speeder_bike.sat", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@pet_deed:vehicular_prototype_bike", gameObjectType = 8211, locationReservationRadius = 0, lookAtText = "", noBuildRadius = 0, objectName = "@pet_deed:vehicular_prototype_bike", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_deed_vehicle_deed_shared_vehicular_prototype_bike_deed, 1262265566) object_tangible_deed_vehicle_deed_shared_vehicular_prototype_deed = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/monstrosity.sat", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@pet_deed:vehicular_prototype", gameObjectType = 8211, locationReservationRadius = 0, lookAtText = "", noBuildRadius = 0, objectName = "@pet_deed:vehicular_prototype", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_deed_vehicle_deed_shared_vehicular_prototype_deed, 3990622047)
lgpl-3.0
TheAnswer/FirstTest
bin/scripts/object/tangible/wearables/armor/zam/objects.lua
1
15230
--Copyright (C) 2009 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. object_tangible_wearables_armor_zam_shared_armor_zam_wesell_belt = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/armor_zam_wesell_belt_f.sat", arrangementDescriptorFilename = "abstract/slot/arrangement/wearables/belt.iff", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@wearables_detail:armor_zam_wesell_belt", gameObjectType = 259, locationReservationRadius = 0, lookAtText = "@wearables_lookat:armor_zam_wesell_belt", noBuildRadius = 0, objectName = "@wearables_name:armor_zam_wesell_belt", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "abstract/slot/descriptor/tangible.iff", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_wearables_armor_zam_shared_armor_zam_wesell_belt, 1255925428) object_tangible_wearables_armor_zam_shared_armor_zam_wesell_boots = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/armor_zam_wesell_boots_f.sat", arrangementDescriptorFilename = "abstract/slot/arrangement/wearables/shoe.iff", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@wearables_detail:armor_zam_wesell_boots", gameObjectType = 263, locationReservationRadius = 0, lookAtText = "@wearables_lookat:armor_zam_wesell_boots", noBuildRadius = 0, objectName = "@wearables_name:armor_zam_wesell_boots", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "abstract/slot/descriptor/tangible.iff", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_wearables_armor_zam_shared_armor_zam_wesell_boots, 509585055) object_tangible_wearables_armor_zam_shared_armor_zam_wesell_chest_plate = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/armor_zam_wesell_chest_plate_f.sat", arrangementDescriptorFilename = "abstract/slot/arrangement/wearables/vest.iff", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@wearables_detail:armor_zam_wesell_chest_plate", gameObjectType = 257, locationReservationRadius = 0, lookAtText = "@wearables_lookat:armor_zam_wesell_chest_plate", noBuildRadius = 0, objectName = "@wearables_name:armor_zam_wesell_chest_plate", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "abstract/slot/descriptor/tangible.iff", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_wearables_armor_zam_shared_armor_zam_wesell_chest_plate, 3303691594) object_tangible_wearables_armor_zam_shared_armor_zam_wesell_chest_plate_quest = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/armor_zam_wesell_chest_plate_f.sat", arrangementDescriptorFilename = "abstract/slot/arrangement/wearables/vest.iff", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@wearables_detail:armor_zam_wesell_chest_plate_quest", gameObjectType = 257, locationReservationRadius = 0, lookAtText = "@wearables_lookat:armor_zam_wesell_chest_plate", noBuildRadius = 0, objectName = "@wearables_name:armor_zam_wesell_chest_plate_quest", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "abstract/slot/descriptor/tangible.iff", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_wearables_armor_zam_shared_armor_zam_wesell_chest_plate_quest, 2543046725) object_tangible_wearables_armor_zam_shared_armor_zam_wesell_gloves = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/armor_zam_wesell_gloves_f.sat", arrangementDescriptorFilename = "abstract/slot/arrangement/wearables/gauntlets_long.iff", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@wearables_detail:armor_zam_wesell_gloves", gameObjectType = 262, locationReservationRadius = 0, lookAtText = "@wearables_lookat:armor_zam_wesell_gloves", noBuildRadius = 0, objectName = "@wearables_name:armor_zam_wesell_gloves", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "abstract/slot/descriptor/tangible.iff", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_wearables_armor_zam_shared_armor_zam_wesell_gloves, 2822062160) object_tangible_wearables_armor_zam_shared_armor_zam_wesell_helmet = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/armor_zam_wesell_helmet_f.sat", arrangementDescriptorFilename = "abstract/slot/arrangement/wearables/helmet_closed_full.iff", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@wearables_detail:armor_zam_wesell_helmet", gameObjectType = 258, locationReservationRadius = 0, lookAtText = "@wearables_lookat:armor_zam_wesell_helmet", noBuildRadius = 0, objectName = "@wearables_name:armor_zam_wesell_helmet", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "abstract/slot/descriptor/tangible.iff", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_wearables_armor_zam_shared_armor_zam_wesell_helmet, 519414104) object_tangible_wearables_armor_zam_shared_armor_zam_wesell_helmet_quest = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/armor_zam_wesell_helmet_f.sat", arrangementDescriptorFilename = "abstract/slot/arrangement/wearables/helmet_closed_full.iff", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@wearables_detail:armor_zam_wesell_helmet_quest", gameObjectType = 258, locationReservationRadius = 0, lookAtText = "@wearables_lookat:armor_zam_wesell_helmet", noBuildRadius = 0, objectName = "@wearables_name:armor_zam_wesell_helmet_quest", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "abstract/slot/descriptor/tangible.iff", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_wearables_armor_zam_shared_armor_zam_wesell_helmet_quest, 2324855644) object_tangible_wearables_armor_zam_shared_armor_zam_wesell_pants = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/armor_zam_wesell_pants_f.sat", arrangementDescriptorFilename = "abstract/slot/arrangement/wearables/skirt.iff", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@wearables_detail:armor_zam_wesell_pants", gameObjectType = 260, locationReservationRadius = 0, lookAtText = "@wearables_lookat:armor_zam_wesell_pants", noBuildRadius = 0, objectName = "@wearables_name:armor_zam_wesell_pants", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "abstract/slot/descriptor/tangible.iff", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_wearables_armor_zam_shared_armor_zam_wesell_pants, 2684655133) object_tangible_wearables_armor_zam_shared_armor_zam_wesell_pants_quest = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/armor_zam_wesell_pants_f.sat", arrangementDescriptorFilename = "abstract/slot/arrangement/wearables/skirt.iff", certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@wearables_detail:armor_zam_wesell_pants_quest", gameObjectType = 260, locationReservationRadius = 0, lookAtText = "@wearables_lookat:armor_zam_wesell_pants", noBuildRadius = 0, objectName = "@wearables_name:armor_zam_wesell_pants_quest", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "abstract/slot/descriptor/tangible.iff", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_wearables_armor_zam_shared_armor_zam_wesell_pants_quest, 3252715807)
lgpl-3.0
thkhxm/TGame
LuaEncoder/luajit_ios/x86/jit/vmdef.lua
9
7368
-- This is a generated file. DO NOT EDIT! return { bcnames = "ISLT ISGE ISLE ISGT ISEQV ISNEV ISEQS ISNES ISEQN ISNEN ISEQP ISNEP ISTC ISFC IST ISF ISTYPEISNUM MOV NOT UNM LEN ADDVN SUBVN MULVN DIVVN MODVN ADDNV SUBNV MULNV DIVNV MODNV ADDVV SUBVV MULVV DIVVV MODVV POW CAT KSTR KCDATAKSHORTKNUM KPRI KNIL UGET USETV USETS USETN USETP UCLO FNEW TNEW TDUP GGET GSET TGETV TGETS TGETB TGETR TSETV TSETS TSETB TSETM TSETR CALLM CALL CALLMTCALLT ITERC ITERN VARG ISNEXTRETM RET RET0 RET1 FORI JFORI FORL IFORL JFORL ITERL IITERLJITERLLOOP ILOOP JLOOP JMP FUNCF IFUNCFJFUNCFFUNCV IFUNCVJFUNCVFUNCC FUNCCW", irnames = "LT GE LE GT ULT UGE ULE UGT EQ NE ABC RETF NOP BASE PVAL GCSTEPHIOP LOOP USE PHI RENAMEPROF KPRI KINT KGC KPTR KKPTR KNULL KNUM KINT64KSLOT BNOT BSWAP BAND BOR BXOR BSHL BSHR BSAR BROL BROR ADD SUB MUL DIV MOD POW NEG ABS ATAN2 LDEXP MIN MAX FPMATHADDOV SUBOV MULOV AREF HREFK HREF NEWREFUREFO UREFC FREF STRREFLREF ALOAD HLOAD ULOAD FLOAD XLOAD SLOAD VLOAD ASTOREHSTOREUSTOREFSTOREXSTORESNEW XSNEW TNEW TDUP CNEW CNEWI BUFHDRBUFPUTBUFSTRTBAR OBAR XBAR CONV TOBIT TOSTR STRTO CALLN CALLA CALLL CALLS CALLXSCARG ", irfpm = { [0]="floor", "ceil", "trunc", "sqrt", "exp", "exp2", "log", "log2", "log10", "sin", "cos", "tan", "other", }, irfield = { [0]="str.len", "func.env", "func.pc", "func.ffid", "thread.env", "tab.meta", "tab.array", "tab.node", "tab.asize", "tab.hmask", "tab.nomm", "udata.meta", "udata.udtype", "udata.file", "cdata.ctypeid", "cdata.ptr", "cdata.int", "cdata.int64", "cdata.int64_4", }, ircall = { [0]="lj_str_cmp", "lj_str_find", "lj_str_new", "lj_strscan_num", "lj_strfmt_int", "lj_strfmt_num", "lj_strfmt_char", "lj_strfmt_putint", "lj_strfmt_putnum", "lj_strfmt_putquoted", "lj_strfmt_putfxint", "lj_strfmt_putfnum_int", "lj_strfmt_putfnum_uint", "lj_strfmt_putfnum", "lj_strfmt_putfstr", "lj_strfmt_putfchar", "lj_buf_putmem", "lj_buf_putstr", "lj_buf_putchar", "lj_buf_putstr_reverse", "lj_buf_putstr_lower", "lj_buf_putstr_upper", "lj_buf_putstr_rep", "lj_buf_puttab", "lj_buf_tostr", "lj_tab_new_ah", "lj_tab_new1", "lj_tab_dup", "lj_tab_clear", "lj_tab_newkey", "lj_tab_len", "lj_gc_step_jit", "lj_gc_barrieruv", "lj_mem_newgco", "lj_math_random_step", "lj_vm_modi", "sinh", "cosh", "tanh", "fputc", "fwrite", "fflush", "lj_vm_floor", "lj_vm_ceil", "lj_vm_trunc", "sqrt", "exp", "lj_vm_exp2", "log", "lj_vm_log2", "log10", "sin", "cos", "tan", "lj_vm_powi", "pow", "atan2", "ldexp", "lj_vm_tobit", "softfp_add", "softfp_sub", "softfp_mul", "softfp_div", "softfp_cmp", "softfp_i2d", "softfp_d2i", "softfp_ui2d", "softfp_f2d", "softfp_d2ui", "softfp_d2f", "softfp_i2f", "softfp_ui2f", "softfp_f2i", "softfp_f2ui", "fp64_l2d", "fp64_ul2d", "fp64_l2f", "fp64_ul2f", "fp64_d2l", "fp64_d2ul", "fp64_f2l", "fp64_f2ul", "lj_carith_divi64", "lj_carith_divu64", "lj_carith_modi64", "lj_carith_modu64", "lj_carith_powi64", "lj_carith_powu64", "lj_cdata_newv", "lj_cdata_setfin", "strlen", "memcpy", "memset", "lj_vm_errno", "lj_carith_mul64", "lj_carith_shl64", "lj_carith_shr64", "lj_carith_sar64", "lj_carith_rol64", "lj_carith_ror64", }, traceerr = { [0]="error thrown or hook called during recording", "trace too short", "trace too long", "trace too deep", "too many snapshots", "blacklisted", "retry recording", "NYI: bytecode %d", "leaving loop in root trace", "inner loop in root trace", "loop unroll limit reached", "bad argument type", "JIT compilation disabled for function", "call unroll limit reached", "down-recursion, restarting", "NYI: C function %s", "NYI: FastFunc %s", "NYI: unsupported variant of FastFunc %s", "NYI: return to lower frame", "store with nil or NaN key", "missing metamethod", "looping index lookup", "NYI: mixed sparse/dense table", "symbol not in cache", "NYI: unsupported C type conversion", "NYI: unsupported C function type", "guard would always fail", "too many PHIs", "persistent type instability", "failed to allocate mcode memory", "machine code too long", "hit mcode limit (retrying)", "too many spill slots", "inconsistent register allocation", "NYI: cannot assemble IR instruction %d", "NYI: PHI shuffling too complex", "NYI: register coalescing too complex", }, ffnames = { [0]="Lua", "C", "assert", "type", "next", "pairs", "ipairs_aux", "ipairs", "getmetatable", "setmetatable", "getfenv", "setfenv", "rawget", "rawset", "rawequal", "unpack", "select", "tonumber", "tostring", "error", "pcall", "xpcall", "loadfile", "load", "loadstring", "dofile", "gcinfo", "collectgarbage", "newproxy", "print", "coroutine.status", "coroutine.running", "coroutine.create", "coroutine.yield", "coroutine.resume", "coroutine.wrap_aux", "coroutine.wrap", "math.abs", "math.floor", "math.ceil", "math.sqrt", "math.log10", "math.exp", "math.sin", "math.cos", "math.tan", "math.asin", "math.acos", "math.atan", "math.sinh", "math.cosh", "math.tanh", "math.frexp", "math.modf", "math.log", "math.atan2", "math.pow", "math.fmod", "math.ldexp", "math.min", "math.max", "math.random", "math.randomseed", "bit.tobit", "bit.bnot", "bit.bswap", "bit.lshift", "bit.rshift", "bit.arshift", "bit.rol", "bit.ror", "bit.band", "bit.bor", "bit.bxor", "bit.tohex", "string.byte", "string.char", "string.sub", "string.rep", "string.reverse", "string.lower", "string.upper", "string.dump", "string.find", "string.match", "string.gmatch_aux", "string.gmatch", "string.gsub", "string.format", "table.maxn", "table.insert", "table.concat", "table.sort", "table.new", "table.clear", "io.method.close", "io.method.read", "io.method.write", "io.method.flush", "io.method.seek", "io.method.setvbuf", "io.method.lines", "io.method.__gc", "io.method.__tostring", "io.open", "io.popen", "io.tmpfile", "io.close", "io.read", "io.write", "io.flush", "io.input", "io.output", "io.lines", "io.type", "os.execute", "os.remove", "os.rename", "os.tmpname", "os.getenv", "os.exit", "os.clock", "os.date", "os.time", "os.difftime", "os.setlocale", "debug.getregistry", "debug.getmetatable", "debug.setmetatable", "debug.getfenv", "debug.setfenv", "debug.getinfo", "debug.getlocal", "debug.setlocal", "debug.getupvalue", "debug.setupvalue", "debug.upvalueid", "debug.upvaluejoin", "debug.sethook", "debug.gethook", "debug.debug", "debug.traceback", "jit.on", "jit.off", "jit.flush", "jit.status", "jit.attach", "jit.util.funcinfo", "jit.util.funcbc", "jit.util.funck", "jit.util.funcuvname", "jit.util.traceinfo", "jit.util.traceir", "jit.util.tracek", "jit.util.tracesnap", "jit.util.tracemc", "jit.util.traceexitstub", "jit.util.ircalladdr", "jit.opt.start", "jit.profile.start", "jit.profile.stop", "jit.profile.dumpstack", "ffi.meta.__index", "ffi.meta.__newindex", "ffi.meta.__eq", "ffi.meta.__len", "ffi.meta.__lt", "ffi.meta.__le", "ffi.meta.__concat", "ffi.meta.__call", "ffi.meta.__add", "ffi.meta.__sub", "ffi.meta.__mul", "ffi.meta.__div", "ffi.meta.__mod", "ffi.meta.__pow", "ffi.meta.__unm", "ffi.meta.__tostring", "ffi.meta.__pairs", "ffi.meta.__ipairs", "ffi.clib.__index", "ffi.clib.__newindex", "ffi.clib.__gc", "ffi.callback.free", "ffi.callback.set", "ffi.cdef", "ffi.new", "ffi.cast", "ffi.typeof", "ffi.typeinfo", "ffi.istype", "ffi.sizeof", "ffi.alignof", "ffi.offsetof", "ffi.errno", "ffi.string", "ffi.copy", "ffi.fill", "ffi.abi", "ffi.metatype", "ffi.gc", "ffi.load", }, }
apache-2.0
loklaan/TexMate
TexMateStatic.lua
2
2326
local class = require('middleclass') local _M = class("texmate") --pass in the atlas, and it will make a deck, and preseve offset data. --framerate, works as a global number function round(num, idp) if idp and idp>0 then local mult = 10^idp return math.floor(num * mult + 0.5) / mult end return math.floor(num + 0.5) end function _M:initialize (Atlas,imageid,x,y,pivotx,pivoty,rot,flip,scalex,scaley,offsetstyle,ignoretrim) self.ignoretrim = ignoretrim or false self.offsetStyle = offsetstyle or "topleft" self.Atlas = Atlas self.image = imageid self.offset = {} self.offset.x = pivotx or 0 self.offset.y = pivoty or 0 self.batch = love.graphics.newSpriteBatch( Atlas.texture, 100, "stream" ) self.active = true self.x = x or 100 self.y = y or 100 self.rot = rot or 0 self.scale = {} self.scale.x = scalex or 1 self.scale.y = scaley or scalex or 1 self.flip = -1 self.endCallback = {} if flip then self.scale.x = self.scale.x *-1 end --ofs is the number that it uses to work out the offset. if self.offsetStyle == "center" then self.ofs = 0.5 else self.ofs = 1 end end function _M:changeLoc (x,y) self.x = x or self.x self.y = y or self.y end function _M:changeRot(angle) self.rot = angle end function _M:changeRotVec(vec) self.rot = math.deg(math.atan2(vec.y,vec.x))+90 end function _M:getLoc() return self.x,self.y end function _M:draw () --Reset graphics colour back to white love.graphics.setColor(255,255,255,255) --Binds the SpriteBatch to memory for more efficient updating. self.batch:clear() self.batch:bind() --find the center of the sprite. local tempWidth = self.Atlas.size[self.image].width*self.ofs local tempHeight = self.Atlas.size[self.image].height*self.ofs local atlas = self.Atlas.quads[self.image] local extra = self.Atlas.extra[self.image] if ignoretrim then extra[1] = 0 extra[2] = 0 end self.batch:add( atlas, self.x, --x self.y, --y math.rad(self.rot), -- rot self.scale.x*self.flip, -- scale x self.scale.y, -- scale y -extra[1]+tempWidth-self.offset.x, --pivotx, needs to add in the trimming data here. -extra[2]+tempHeight-self.offset.y -- pivoty ) self.batch:unbind() love.graphics.draw(self.batch) end return _M
mit
TheAnswer/FirstTest
bin/scripts/crafting/objects/draftschematics/tailor/fieldWearIvParamilitaryGear/heavyGloves.lua
1
3864
--Copyright (C) 2009 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. heavyGloves = Object:new { objectName = "Heavy Gloves", stfName = "gloves_s10", stfFile = "wearables_name", objectCRC = 3775249290, groupName = "craftClothingFieldGroupD", -- Group schematic is awarded in (See skills table) craftingToolTab = 8, -- (See DraftSchemticImplementation.h) complexity = 17, size = 2, xpType = "crafting_clothing_general", xp = 215, assemblySkill = "clothing_assembly", experimentingSkill = "clothing_experimentation", ingredientTemplateNames = "craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n", ingredientTitleNames = "shell, liner, grip_pads, reinforcement", ingredientSlotType = "0, 0, 0, 0", resourceTypes = "petrochem_inert, hide, petrochem_inert, metal", resourceQuantities = "20, 20, 30, 10", combineTypes = "0, 0, 0, 0", contribution = "100, 100, 100, 100", numberExperimentalProperties = "1, 1, 1, 1", experimentalProperties = "XX, XX, XX, XX", experimentalWeights = "1, 1, 1, 1", experimentalGroupTitles = "null, null, null, null", experimentalSubGroupTitles = "null, null, sockets, hitpoints", experimentalMin = "0, 0, 0, 1000", experimentalMax = "0, 0, 0, 1000", experimentalPrecision = "0, 0, 0, 0", tanoAttributes = "objecttype=16777224:objectcrc=3964437147:stfFile=wearables_name:stfName=gloves_s10:stfDetail=:itemmask=62975::", blueFrogAttributes = "", blueFrogEnabled = False, customizationOptions = "/private/index_color_1", customizationDefaults = "31", customizationSkill = "clothing_customization" } DraftSchematics:addDraftSchematic(heavyGloves, 3775249290)--- Add to global DraftSchematics table
lgpl-3.0
judos/rocketAutoStarter
source/libs/prototypes.lua
1
1060
require "constants" function addItem(itemName, subgroup, order, stackSize) data:extend({ { type = "item", name = itemName, icon = "__"..fullModName.."__/graphics/icons/"..itemName..".png", flags = {"goes-to-main-inventory"}, subgroup = subgroup, order = order, stack_size = stackSize } }) end function addRecipe(name,category,subgroup,timeRequired,ingredients,results,order) local resultsDetailled = {} if not results then print("No results found for recipe with name: "..name) end for _,s in pairs(results) do local typ = "item" if s[1] == "sulfuric-acid" or s[1] == "water" then typ = "fluid" end table.insert(resultsDetailled, {type=typ, name=s[1], amount=s[2]}) end local imageName = removeAfterSign(name,"|") data:extend({ { type = "recipe", name = name, category = category, subgroup = subgroup, energy_required = timeRequired, ingredients = ingredients, icon = "__"..fullModName.."__/graphics/icons/"..imageName..".png", results = resultsDetailled, order = order } }) end
gpl-3.0
weiDDD/WSSParticleSystem
cocos2d/cocos/scripting/lua-bindings/auto/api/ActionCamera.lua
1
2186
-------------------------------- -- @module ActionCamera -- @extend ActionInterval -- @parent_module cc -------------------------------- -- @overload self, float, float, float -- @overload self, vec3_table -- @function [parent=#ActionCamera] setEye -- @param self -- @param #float x -- @param #float y -- @param #float z -- @return ActionCamera#ActionCamera self (return value: cc.ActionCamera) -------------------------------- -- -- @function [parent=#ActionCamera] getEye -- @param self -- @return vec3_table#vec3_table ret (return value: vec3_table) -------------------------------- -- -- @function [parent=#ActionCamera] setUp -- @param self -- @param #vec3_table up -- @return ActionCamera#ActionCamera self (return value: cc.ActionCamera) -------------------------------- -- -- @function [parent=#ActionCamera] getCenter -- @param self -- @return vec3_table#vec3_table ret (return value: vec3_table) -------------------------------- -- -- @function [parent=#ActionCamera] setCenter -- @param self -- @param #vec3_table center -- @return ActionCamera#ActionCamera self (return value: cc.ActionCamera) -------------------------------- -- -- @function [parent=#ActionCamera] getUp -- @param self -- @return vec3_table#vec3_table ret (return value: vec3_table) -------------------------------- -- -- @function [parent=#ActionCamera] startWithTarget -- @param self -- @param #cc.Node target -- @return ActionCamera#ActionCamera self (return value: cc.ActionCamera) -------------------------------- -- -- @function [parent=#ActionCamera] clone -- @param self -- @return ActionCamera#ActionCamera ret (return value: cc.ActionCamera) -------------------------------- -- -- @function [parent=#ActionCamera] reverse -- @param self -- @return ActionCamera#ActionCamera ret (return value: cc.ActionCamera) -------------------------------- -- js ctor -- @function [parent=#ActionCamera] ActionCamera -- @param self -- @return ActionCamera#ActionCamera self (return value: cc.ActionCamera) return nil
apache-2.0
TheAnswer/FirstTest
bin/scripts/creatures/spawns/lok/kimoTown.lua
1
3344
--Copyright (C) 2008 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. spawnCreature(kimogilaHatchling, 4, -104.7, 2650.16) spawnCreature(kimogilaHatchling, 4, -98.8467, 2653.42) spawnCreature(kimogilaHatchling, 4, -98.0349, 2647.25) spawnCreature(kimoTownCommon1, 4, -89.4283, 2679.48) spawnCreature(kimoTownCommon2, 4, -95.9296, 2685.26) spawnCreature(kimoTownCommon3, 4, -102.416, 2685.17) spawnCreature(kimoTownCommon4, 4, -109.065, 2690.12) spawnCreature(kimoTownCommon5, 4, -102.322, 2684.85) spawnCreature(kimoTownCommon6, 4, -86.1488, 2709.89) spawnCreature(kimoTownCommon7, 4, -92.9387, 2708.29) spawnCreature(kimoTownCommon8, 4, -95.2094, 2710.35) spawnCreature(kimoTownCommon9, 4, -98.4221, 2716.59) spawnCreature(kimoTownCommon10, 4, -93.4888, 2717.4) spawnCreature(kimogilaHatchling, 4, -125.891, 2747.89) spawnCreature(kimogilaHatchling, 4, -127.63, 2751.88) spawnCreature(kimogilaHatchling, 4, -134.281, 2759.8) spawnCreature(kimoTownCommon11, 4, -51.6445, 2718.56) spawnCreature(kimoTownCommon12, 4, -45.2733, 2713.45) spawnCreature(kimoTownCommon13, 4, -41.4249, 2711.64) spawnCreature(kimoTownCommon14, 4, -35.1539, 2708.05) spawnCreature(kimoTownCommon15, 4, -42.6069, 2713.9) spawnCreature(casVankoo, 4, -18.5213, 2729.13) spawnCreature(giantDuneKimogila, 4, -3.64837, 2716.32)
lgpl-3.0
Modified-MW-DF/modified-MDF
MWDF Project/Dwarf Fortress/hack/scripts/masterwork/tesb-add-pets.lua
2
4072
-- Made by Dirst for the Earth Strikes Back mod -- Based on AddPetToCiv local utils=require 'utils' local args = utils.processArgs({...}, validArgs) validArgs = validArgs or utils.invert({ 'help', 'entity', 'race', 'sort' }) if args.help then print([[tesb-add-pets.lua Adds specific castes to each civ based on discovered minerals Based on AddPetToCiv.lua arguments -help print this help message -entity <ENTITY_ID> The raw id of the target entity, e.g. MOUNTAIN -race <CREATURE_ID> The raw id of a creature, e.g. TESB_PET_ROCK -sort Sorts the castes alphabetically (by ID) before adding ]]) return end function insertPet(civ_id,creature,caste) local exists=false civ = df.global.world.entities.all[civ_id] -- Original AddPetToCiv targets all civs belonging to the same ENTITY raw -- This version allows each instanced civ to have its own list for k,v in pairs(civ.resources.animals.pet_races) do local checkrace = df.creature_raw.find(v) local checkcaste = checkrace.caste[civ.resources.animals.pet_castes[k]] if checkrace.creature_id == creature and checkcaste.caste_id == caste then exists=true end end if exists==true then else --the civ doesn't have the creature as a pet --add the creature as a pet local racenum=-1 local castenum=-1 for k,v in pairs(df.global.world.raws.creatures.all) do if v.creature_id==creature then racenum=k for kk,vv in pairs(v.caste) do if vv.caste_id==caste then castenum=kk end end break end end if racenum > -1 and castenum > -1 then civ.resources.animals.pet_races:insert('#',racenum) civ.resources.animals.pet_castes:insert('#',castenum) --print("Inserted "..creature..":"..caste.." in civ "..dfhack.TranslateName(df.global.world.entities.all[civ_id].name)) else -- Invalid caste. Print a message and do NOT increment the pet count. print(creature..":"..caste.." not found in the raws") exists = true end end return not exists end --Find race's common name for k,v in ipairs(df.global.world.raws.creatures.all) do if v.creature_id == args.race then raceSingle = df.creature_raw.find(k).name[0] racePlural = df.creature_raw.find(k).name[1] break end end -- List of layer stones that coincide with Pet Rock castes stone_list = { "ANDESITE", "BASALT", "CHALK", "CHERT", "CLAYSTONE", "CONGLOMERATE", "DACITE", "DIORITE", "DOLOMITE", "GABBRO", "GNEISS", "GRANITE", "LIMESTONE", "MARBLE", "MUDSTONE", "PHYLLITE", "QUARTZITE", "RHYOLITE", "ROCK_SALT", "SANDSTONE", "SCHIST", "SHALE", "SILTSTONE", "SLATE" } caste_list = {} -- Lists indexed by material ID numbers for mat = 1, #stone_list do local index = dfhack.matinfo.find(stone_list[mat]).index caste_list[index] = stone_list[mat] end -- Identify appropriate castes for each instanced civ of the correct entity type for k,civ in pairs(df.global.world.entities.all) do local pet_list = {} if civ.type==0 and civ.entity_raw.code==args.entity then for kk,mat in pairs(civ.resources.stones) do if caste_list[mat] then pet_list[1 + #pet_list] = caste_list[mat] end end if args.sort then table.sort(pet_list) end local pet_count = 0 -- Pets aren't valid until successfully inserted, so maintaining a count of successes for kk,pet_caste in ipairs(pet_list) do if insertPet(civ.id,args.race,pet_caste) then pet_count = pet_count + 1 end end if pet_count > 1 then print("Added "..pet_count.." kinds of "..racePlural.." to "..dfhack.df2console(dfhack.TranslateName(df.global.world.entities.all[civ.id].name)).." ("..dfhack.df2console(dfhack.TranslateName(df.global.world.entities.all[civ.id].name,true))..").") elseif pet_count == 1 then print("Added 1 kind of "..raceSingle.." to "..dfhack.df2console(dfhack.TranslateName(df.global.world.entities.all[civ.id].name)).." ("..dfhack.df2console(dfhack.TranslateName(df.global.world.entities.all[civ.id].name,true))..").") end end end
mit
TheAnswer/FirstTest
bin/scripts/creatures/objects/yavin4/creatures/kliknikWorker.lua
1
4705
--Copyright (C) 2008 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. kliknikWorker = Creature:new { objectName = "kliknikWorker", -- Lua Object Name creatureType = "ANIMAL", gender = "", speciesName = "kliknik_worker", stfName = "mob/creature_names", objectCRC = 965104200, socialGroup = "Kliknik", level = 23, combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG + AGGRESSIVE_FLAG, healthMax = 8300, healthMin = 6800, strength = 0, constitution = 0, actionMax = 8300, actionMin = 6800, quickness = 0, stamina = 0, mindMax = 8300, mindMin = 6800, focus = 0, willpower = 0, height = 1, -- Size of creature armor = 0, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy kinetic = 0, energy = 25, electricity = -1, stun = -1, blast = 0, heat = 0, cold = -1, acid = -1, lightsaber = 0, accuracy = 0, healer = 0, pack = 1, herd = 0, stalker = 0, killer = 0, ferocity = 0, aggressive = 1, invincible = 0, meleeDefense = 1, rangedDefense = 1, attackCreatureOnSight = "", -- Enter socialGroups weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance' weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance' weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon' weaponEquipped = 0, weaponMinDamage = 210, weaponMaxDamage = 220, weaponAttackSpeed = 2, weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx alternateWeaponName = "", -- Name ex. 'a Vibrolance' alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance' alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon' alternateweaponEquipped = 0, alternateWeaponMinDamage = 0, alternateWeaponMaxDamage = 0, alternateWeaponAttackSpeed = 0, alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's lootGroup = "0", -- Group it belongs to for loot tame = 0.25, -- Likely hood to be tamed datapadItemCRC = 2970580359, mountCRC = 0, mountSpeed = 0, mountAcceleration = 0, milk = 0, boneType = "", boneMax = 20, hideType = "hide_scaley_yavin4", hideMax = 4, meatType = "meat_carnivore_yavin4", meatMax = 6, --skills = { " Posture down attack", "", "" } skills = { "kliknikAttack4" }, respawnTimer = 60, behaviorScript = "", -- Link to the behavior script for this object } Creatures:addCreature(kliknikWorker, 965104200) -- Add to Global Table
lgpl-3.0
vgire/nn
VolumetricDeconvolution.lua
6
1862
local VolumetricDeconvolution, parent = torch.class('nn.VolumetricDeconvolution', 'nn.Module') function VolumetricDeconvolution:__init(nInputPlane, nOutputPlane, kT, kH, kW, dT, dH, dW, pT, pH, pW) parent.__init(self) dT = dT or 1 dW = dW or 1 dH = dH or 1 pT = pT or 0 pW = pW or 0 pH = pH or 0 self.nInputPlane = nInputPlane self.nOutputPlane = nOutputPlane self.kT = kT self.kW = kW self.kH = kH self.dT = dT self.dW = dW self.dH = dH self.pT = pT self.pW = pW self.pH = pH self.weight = torch.Tensor(nOutputPlane, nInputPlane, kT, kH, kW) self.bias = torch.Tensor(nOutputPlane) self.gradWeight = torch.Tensor(nOutputPlane, nInputPlane, kT, kH, kW) self.gradBias = torch.Tensor(nOutputPlane) -- temporary buffers for unfolding (CUDA) self.finput = torch.Tensor() self.fgradInput = torch.Tensor() self:reset() end function VolumetricDeconvolution:reset(stdv) -- initialization of parameters if stdv then stdv = stdv * math.sqrt(3) else stdv = 1/math.sqrt(self.kT*self.kW*self.kH*self.nInputPlane) end if nn.oldSeed then self.weight:apply(function() return torch.uniform(-stdv, stdv) end) self.bias:apply(function() return torch.uniform(-stdv, stdv) end) else self.weight:uniform(-stdv, stdv) self.bias:uniform(-stdv, stdv) end end function VolumetricDeconvolution:updateOutput(input) return input.nn.VolumetricDeconvolution_updateOutput(self, input) end function VolumetricDeconvolution:updateGradInput(input, gradOutput) return input.nn.VolumetricDeconvolution_updateGradInput(self, input, gradOutput) end function VolumetricDeconvolution:accGradParameters(input, gradOutput, scale) return input.nn.VolumetricDeconvolution_accGradParameters(self, input, gradOutput, scale) end
bsd-3-clause
Andrettin/Wyrmsun
scripts/ai/land_attack.lua
1
4715
-- _________ __ __ -- / _____// |_____________ _/ |______ ____ __ __ ______ -- \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ -- / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ -- /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > -- \/ \/ \//_____/ \/ -- ______________________ ______________________ -- T H E W A R B E G I N S -- Stratagus - A free fantasy real time strategy game engine -- -- land_attack.lua - Default land attack AI. -- -- (c) Copyright 2000-2022 by José Ignacio Rodríguez, Carlo Almario and Andrettin -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- local land_funcs = { function() return AiSleep(AiGetSleepCycles()) end, function() if (AiGetRace() == "dwarf") then -- dwarves collect more stone than other civilizations, as they need it for their structures, rather than lumber AiSetCollect("copper", 45, "lumber", 20, "stone", 35) else AiSetCollect("copper", 45, "lumber", 45, "stone", 10) end return false; end, function() return AiSet(GetAiUnitType("worker"), 1) end, function() return AiWait(GetAiUnitType("worker")) end, -- start hangs if nothing available function() return AiWait(GetAiUnitType("town_hall")) end, -- don't spend resources on other buildings if the AI player doesn't have a town hall yet function() return AiSet(GetAiUnitType("worker"), 4) end, -- 4 function() return AiSet(GetAiUnitType("worker"), 8) end, -- 8 function() return AiWait(GetAiUnitType("barracks")) end, function() return AiSet(GetAiUnitType("worker"), 12) end, function() return AiSet(GetAiUnitType("worker"), 20) end, function() return AiWait(GetAiUnitType("lumber_mill")) end, function() if (AiGetRace() == "dwarf") then return AiWait(GetAiUnitType("masons_shop")); end return false; end, function() if (AiGetRace() == "germanic") then -- if is Germanic, wait until becomes Anglo-Saxon/Frankish/Gothic/Norse/Suebi/Teuton for the next step return true; end end, function() return AiResearch(GetAiUnitType("masonry")) end, -- needed for the stronghold function() return AiWait(GetAiUnitType("masonry")) end, function() return AiWait(GetAiUnitType("stronghold")) end, function() return AiSet(GetAiUnitType("worker"), 25) end, function() return AiResearch(GetAiUnitType("writing")) end, -- research writing to become a polity, and is needed for Engineering function() return AiWait(GetAiUnitType("stables")) end, function() return AiWait(GetAiUnitType("writing")) end, -- BUILDING A DEFENSE function() return AiSet(GetAiUnitType("worker"), 30) end, -- function() return AiWait(AiBestCityCenter()) end, function() return AiWait(GetAiUnitType("temple")) end, -- MAGE TOWER -- function() return AiNeed(AiMageTower()) end, function() return AiWait(GetAiUnitType("university")) end, function() return AiResearch(GetAiUnitType("mathematics")) end, -- needed for engineering function() return AiWait(GetAiUnitType("mathematics")) end, function() return AiResearch(GetAiUnitType("engineering")) end, -- needed for siege engines function() return AiWait(GetAiUnitType("engineering")) end, function() return AiSet(GetAiUnitType("worker"), 35) end, function() return AiSet(GetAiUnitType("worker"), 40) end, function() return AiSet(GetAiUnitType("worker"), 45) end, function() return true end, } local ai_call_counter = {} function AiLandAttack() if (ai_call_counter[AiPlayer()] == nil) then ai_call_counter[AiPlayer()] = 0 end ai_call_counter[AiPlayer()] = ai_call_counter[AiPlayer()] + 1 if (GameSettings.Difficulty == DifficultyEasy and (ai_call_counter[AiPlayer()] % 50) ~= 0) then -- on easy difficulty, the AI is slower to do things return; end AiLoop(land_funcs, stratagus.gameData.AIState.index); end DefineAi("land-attack", "*", "land-attack", AiLandAttack)
gpl-2.0
asmagill/hammerspoon
extensions/audiodevice/test_audiodevice.lua
5
12804
hs.audiodevice = require("hs.audiodevice") -- Test constructors/functions function testGetDefaultEffect() assertIsUserdataOfType("hs.audiodevice", hs.audiodevice.defaultEffectDevice()) return success() end function testGetDefaultOutput() assertIsUserdataOfType("hs.audiodevice", hs.audiodevice.defaultOutputDevice()) return success() end function testGetDefaultInput() assertIsUserdataOfType("hs.audiodevice", hs.audiodevice.defaultInputDevice()) return success() end function testGetCurrentOutput() local current = hs.audiodevice.current() assertIsTable(current) assertIsUserdataOfType("hs.audiodevice", current["device"]) return success() end function testGetCurrentInput() local current = hs.audiodevice.current(true) assertIsTable(current) assertIsUserdataOfType("hs.audiodevice", current["device"]) return success() end function testGetAllDevices() assertTableNotEmpty(hs.audiodevice.allDevices()) return success() end function testGetAllInputDevices() assertTableNotEmpty(hs.audiodevice.allInputDevices()) return success() end function testGetAllOutputDevices() assertTableNotEmpty(hs.audiodevice.allOutputDevices()) return success() end function testFindDeviceByName() local devices = hs.audiodevice.allOutputDevices() local found = hs.audiodevice.findDeviceByName(devices[1]:name()) assertIsEqual(devices[1], found) assertIsUserdataOfType("hs.audiodevice", found) return success() end function testFindDeviceByUID() local device = hs.audiodevice.defaultOutputDevice() assertIsEqual(device, hs.audiodevice.findDeviceByUID(device:uid())) return success() end function testFindInputByName() local device = hs.audiodevice.defaultInputDevice() local foundDevice = hs.audiodevice.findInputByName(device:name()) assertIsEqual(device, foundDevice) return success() end function testFindInputByUID() local device = hs.audiodevice.defaultInputDevice() local foundDevice = hs.audiodevice.findInputByUID(device:uid()) assertIsEqual(device, foundDevice) return success() end function testFindOutputByName() local device = hs.audiodevice.defaultOutputDevice() local foundDevice = hs.audiodevice.findOutputByName(device:name()) assertIsEqual(device, foundDevice) return success() end function testFindOutputByUID() local device = hs.audiodevice.defaultOutputDevice() local foundDevice = hs.audiodevice.findOutputByUID(device:uid()) assertIsEqual(device, foundDevice) return success() end -- Test hs.audiodevice methods function testToString() assertIsString(tostring(hs.audiodevice.defaultOutputDevice())) return success() end function testSetDefaultEffect() local beforeDevice = hs.audiodevice.defaultEffectDevice() assertTrue(beforeDevice:setDefaultEffectDevice()) local afterDevice = hs.audiodevice.defaultEffectDevice() assertIsEqual(beforeDevice, afterDevice) return success() end function testSetDefaultOutput() local beforeDevice = hs.audiodevice.defaultOutputDevice() assertTrue(beforeDevice:setDefaultOutputDevice()) local afterDevice = hs.audiodevice.defaultOutputDevice() assertIsEqual(beforeDevice, afterDevice) return success() end function testSetDefaultInput() local beforeDevice = hs.audiodevice.defaultInputDevice() assertTrue(beforeDevice:setDefaultInputDevice()) local afterDevice = hs.audiodevice.defaultInputDevice() assertIsEqual(beforeDevice, afterDevice) return success() end function testName() assertIsString(hs.audiodevice.defaultOutputDevice():name()) return success() end function testUID() assertIsString(hs.audiodevice.defaultOutputDevice():uid()) return success() end function testIsInputDevice() assertTrue(hs.audiodevice.defaultInputDevice():isInputDevice()) return success() end function testIsOutputDevice() assertTrue(hs.audiodevice.defaultOutputDevice():isOutputDevice()) return success() end function testMute() local device = hs.audiodevice.defaultOutputDevice() local wasMuted = device:muted() if (type(wasMuted) ~= "boolean") then -- This device does not support muting. Not much we can do about it, so log it and move on print("Audiodevice does not support muting, unable to test muting functionality. Skipping test due to lack of hardware") return success() end device:setMuted(not wasMuted) assertIsEqual(not wasMuted, device:muted()) -- Be nice to whoever is running the test and restore the original state device:setMuted(wasMuted) return success() end function testJackConnected() local jackConnected = hs.audiodevice.defaultOutputDevice():jackConnected() if (type(jackConnected) ~= "boolean") then print("Audiodevice does not support Jack Sense. Skipping test due to lack of hardware") end return success() end function testTransportType() local transportType = hs.audiodevice.defaultOutputDevice():transportType() if (type(transportType) ~= "string") then print("Audiodevice does not have a transport type. Skipping test due to lack of hardware") end return success() end function testVolume() local device = hs.audiodevice.defaultOutputDevice() local originalVolume = device:volume() local wantVolume = 25 if (type(originalVolume) ~= "number") then print("Audiodevice does not support volume. Skipping test due to lack of hardware") return success() end -- Set the volume to 0 and test if we can set it to a high value assertTrue(device:setVolume(0)) assertTrue(device:setVolume(wantVolume)) assertIsAlmostEqual(wantVolume, device:volume(), 2) -- Be nice and put the volume back where we found it device:setVolume(originalVolume) return success() end function testInputVolume() local device = hs.audiodevice.defaultInputDevice() local originalVolume = device:inputVolume() local wantVolume = 25 if (type(originalVolume) ~= "number") then print("Audiodevice does not support volume. Skipping test due to lack of hardware") return success() end -- Set the volume to 0 and test if we can set it to a high value assertTrue(device:setInputVolume(0)) assertTrue(device:setInputVolume(wantVolume)) assertIsAlmostEqual(wantVolume, device:inputVolume(), 2) -- Be nice and put the volume back where we found it device:setInputVolume(originalVolume) return success() end function testOutputVolume() local device = hs.audiodevice.defaultOutputDevice() local originalVolume = device:outputVolume() local wantVolume = 25 if (type(originalVolume) ~= "number") then print("Audiodevice does not support volume. Skipping test due to lack of hardware") return success() end -- Set the volume to 0 and test if we can set it to a high value assertTrue(device:setOutputVolume(0)) assertTrue(device:setOutputVolume(wantVolume)) assertIsAlmostEqual(wantVolume, device:outputVolume(), 2) -- Be nice and put the volume back where we found it device:setOutputVolume(originalVolume) return success() end function testWatcher() local device = hs.audiodevice.defaultOutputDevice() -- Call this first so we exercise the codepath for "there is no callback set" assertIsNil(device:watcherStart()) assertIsUserdataOfType("hs.audiodevice", device:watcherCallback(function(a,b,c,d) print("hs.audiodevice watcher callback, this will never be called") end)) assertFalse(device:watcherIsRunning()) assertIsUserdataOfType("hs.audiodevice", device:watcherStart()) assertTrue(device:watcherIsRunning()) -- Call this again so we exercise the codepath for "the watcher is already running" assertIsUserdataOfType("hs.audiodevice", device:watcherStart()) assertIsUserdataOfType("hs.audiodevice", device:watcherStop()) assertFalse(device:watcherIsRunning()) assertIsUserdataOfType("hs.audiodevice", device:watcherCallback(nil)) return success() end testWatcherCallbackSuccess = false function testWatcherCallback() local device = hs.audiodevice.defaultOutputDevice() device:watcherCallback(function(uid, eventName, eventScope, eventElement) print("testWatcherCallback callback fired: uid:'"..uid.."' eventName:'"..eventName.."' eventScope:'"..eventScope.."' eventElement:'"..eventElement.."'") testWatcherCallbackSuccess = true end) device:watcherStart() device:setMuted(not device:muted()) -- Be nice and put it back device:setMuted(not device:muted()) end function testWatcherCallbackResult() if testWatcherCallbackSuccess then return success() else return "Waiting for success..." end end function testInputSupportsDataSources() local input = hs.audiodevice.findInputByName("Built-in Microphone") if not input then print("Host does not have an internal microphone. Skipping due to lack of hardware") else assertTrue(input:supportsInputDataSources()) end local output = hs.audiodevice.findOutputByName("Built-in Output") or hs.audiodevice.findOutputByName("Mac Pro Speakers") assertFalse(output:supportsInputDataSources()) return success() end function testOutputSupportsDataSources() local output = hs.audiodevice.findOutputByName("Built-in Output") or hs.audiodevice.findOutputByName("Mac Pro Speakers") assertTrue(output:supportsOutputDataSources()) local input = hs.audiodevice.findInputByName("Built-in Microphone") if not input then print("Host does not have an internal microphone. Skipping due to lack of hardware") else assertFalse(input:supportsOutputDataSources()) end return success() end function testCurrentInputDataSource() local device = hs.audiodevice.findInputByName("Built-in Microphone") if not device then print("Host does not have an internal microphone. Skipping due to lack of hardware") else local dataSource = device:currentInputDataSource() assertIsUserdataOfType("hs.audiodevice.datasource", dataSource) end return success() end function testCurrentOutputDataSource() local device = hs.audiodevice.findOutputByName("Built-in Output") or hs.audiodevice.findOutputByName("Mac Pro Speakers") local dataSource = device:currentOutputDataSource() assertIsUserdataOfType("hs.audiodevice.datasource", dataSource) return success() end function testAllInputDataSources() local device = hs.audiodevice.findInputByName("Built-in Microphone") if not device then print("Host does not have an internal microphone. Skipping due to lack of hardware") return success() end local sources = device:allInputDataSources() assertIsTable(sources) assertGreaterThanOrEqualTo(1, #sources) return success() end function testAllOutputDataSources() local device = hs.audiodevice.findOutputByName("Built-in Output") or hs.audiodevice.findOutputByName("Mac Pro Speakers") local sources = device:allOutputDataSources() assertIsTable(sources) assertGreaterThanOrEqualTo(1, #sources) return success() end -- hs.audiodevice.datasource methods function testDataSourceToString() local device = hs.audiodevice.findOutputByName("Built-in Output") or hs.audiodevice.findOutputByName("Mac Pro Speakers") local source = device:currentOutputDataSource() assertIsString(tostring(source)) return success() end function testDataSourceName() local outputDevice = hs.audiodevice.findOutputByName("Built-in Output") or hs.audiodevice.findOutputByName("Mac Pro Speakers") local outputDataSource = outputDevice:currentOutputDataSource() assertIsString(outputDataSource:name()) local inputDevice = hs.audiodevice.findInputByName("Built-in Microphone") if not inputDevice then print("Host does not have an internal microphone. Skipping due to lack of hardware") else local inputDataSource = inputDevice:currentInputDataSource() assertIsString(inputDataSource:name()) end return success() end function testDataSourceSetDefault() local outputDevice = hs.audiodevice.findOutputByName("Built-in Output") or hs.audiodevice.findOutputByName("Mac Pro Speakers") local outputDataSourceBefore = outputDevice:currentOutputDataSource() assertIsUserdataOfType("hs.audiodevice.datasource", outputDataSourceBefore:setDefault()) local outputDataSourceAfter = outputDevice:currentOutputDataSource() assertIsEqual(outputDataSourceBefore, outputDataSourceAfter) local inputDevice = hs.audiodevice.findInputByName("Built-in Microphone") if not inputDevice then print("Host does not have an internal microphone. Skipping due to lack of hardware") return success() end local inputDataSourceBefore = inputDevice:currentInputDataSource() assertIsUserdataOfType("hs.audiodevice.datasource", inputDataSourceBefore:setDefault()) local inputDataSourceAfter = inputDevice:currentInputDataSource() assertIsEqual(inputDataSourceBefore, inputDataSourceAfter) return success() end
mit
TheAnswer/FirstTest
bin/scripts/object/tangible/lair/rock_mite/objects.lua
1
7412
--Copyright (C) 2009 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. object_tangible_lair_rock_mite_shared_lair_rock_mite = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/poi_all_lair_antpile_light.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 25, clientDataFile = "clientdata/lair/shared_poi_all_lair_bones.cdf", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@lair_d:rock_mite", gameObjectType = 4, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 64, objectName = "@lair_n:rock_mite", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_lair_rock_mite_shared_lair_rock_mite, 3536993046) object_tangible_lair_rock_mite_shared_lair_rock_mite_desert = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/poi_all_lair_antpile_light.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 25, clientDataFile = "clientdata/lair/shared_poi_all_lair_bones.cdf", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@lair_d:rock_mite_desert", gameObjectType = 4, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 64, objectName = "@lair_n:rock_mite_desert", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_lair_rock_mite_shared_lair_rock_mite_desert, 4213428417) object_tangible_lair_rock_mite_shared_lair_rock_mite_mountain = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/poi_all_lair_antpile_dark.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 25, clientDataFile = "clientdata/lair/shared_poi_all_lair_bones.cdf", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@lair_d:rock_mite_mountain", gameObjectType = 4, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 64, objectName = "@lair_n:rock_mite_mountain", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_lair_rock_mite_shared_lair_rock_mite_mountain, 151987616) object_tangible_lair_rock_mite_shared_lair_rock_mite_wasteland = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/poi_all_lair_antpile_light.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 25, clientDataFile = "clientdata/lair/shared_poi_all_lair_bones.cdf", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@lair_d:rock_mite_wasteland", gameObjectType = 4, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 64, objectName = "@lair_n:rock_mite_wasteland", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_lair_rock_mite_shared_lair_rock_mite_wasteland, 1944425271)
lgpl-3.0
CrackedP0t/models
hump/class.lua
25
3024
--[[ Copyright (c) 2010-2013 Matthias Richter Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. Except as contained in this notice, the name(s) of the above copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ]]-- local function include_helper(to, from, seen) if from == nil then return to elseif type(from) ~= 'table' then return from elseif seen[from] then return seen[from] end seen[from] = to for k,v in pairs(from) do k = include_helper({}, k, seen) -- keys might also be tables if to[k] == nil then to[k] = include_helper({}, v, seen) end end return to end -- deeply copies `other' into `class'. keys in `other' that are already -- defined in `class' are omitted local function include(class, other) return include_helper(class, other, {}) end -- returns a deep copy of `other' local function clone(other) return setmetatable(include({}, other), getmetatable(other)) end local function new(class) -- mixins local inc = class.__includes or {} if getmetatable(inc) then inc = {inc} end for _, other in ipairs(inc) do if type(other) == "string" then other = _G[other] end include(class, other) end -- class implementation class.__index = class class.init = class.init or class[1] or function() end class.include = class.include or include class.clone = class.clone or clone -- constructor call return setmetatable(class, {__call = function(c, ...) local o = setmetatable({}, c) o:init(...) return o end}) end -- interface for cross class-system compatibility (see https://github.com/bartbes/Class-Commons). if class_commons ~= false and not common then common = {} function common.class(name, prototype, parent) return new{__includes = {prototype, parent}} end function common.instance(class, ...) return class(...) end end -- the module return setmetatable({new = new, include = include, clone = clone}, {__call = function(_,...) return new(...) end})
mit
Andrettin/Wyrmsun
scripts/grand_strategy/christianity_events.lua
1
2285
-- _________ __ __ -- / _____// |_____________ _/ |______ ____ __ __ ______ -- \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ -- / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ -- /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > -- \/ \/ \//_____/ \/ -- ______________________ ______________________ -- T H E W A R B E G I N S -- Stratagus - A free fantasy real time strategy game engine -- -- (c) Copyright 2015-2022 by Andrettin -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- DefineGrandStrategyEvent("Palladius, Bishop of Ireland", { -- Source: Philip Schaff, "History of the Christian Church", 1997, §14. Description = "The Pope has ordained the Briton deacon Palladius as the first bishop of Ireland, sending him to administer the small community of the faithful there, and to promote Christianity amongst the non-believers.", World = "earth", MinYear = 431, MaxYear = 431, Conditions = function(s) if ( GetProvinceOwner("Leinster") == EventFaction.Name -- correct? and GetProvinceCivilization("Essex") == "celt" -- Essex correct? ) then EventProvince = WorldMapProvinces.Leinster return true else return false end end, Options = {"~!OK"}, OptionEffects = { function(s) ChangeFactionResource(EventFaction.Civilization, EventFaction.Name, "prestige", 1) end }, OptionTooltips = {"+1 Prestige"} })
gpl-2.0
hamode-Aliraq/HAMODE_ALIRAQE
plugins/lock_english.lua
16
1429
--[[ # #ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ #:(( # For More Information ....! # Developer : Aziz < @TH3_GHOST > # our channel: @DevPointTeam # Version: 1.1 #:)) #ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ # ]] local function run(msg, matches) if is_momod(msg) then return end local data = load_data(_config.moderation.data) if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['settings'] then if data[tostring(msg.to.id)]['settings']['english'] then lock_english = data[tostring(msg.to.id)]['settings']['english'] end end end local chat = get_receiver(msg) local user = "user#id"..msg.from.id if lock_english == "yes" then delete_msg(msg.id, ok_cb, true) end end return { patterns = { "[Aa](.*)", "[Bb](.*)", "[Cc](.*)", "[Dd](.*)", "[Ee](.*)", "[Ff](.*)", "[Gg](.*)", "[Hh](.*)", "[Ii](.*)", "[Jj](.*)", "[Kk](.*)", "[Ll](.*)", "[Mm](.*)", "[Nn](.*)", "[Oo](.*)", "[Pp](.*)", "[Qq](.*)", "[Rr](.*)", "[Ss](.*)", "[Tt](.*)", "[Uu](.*)", "[Vv](.*)", "[Ww](.*)", "[Xx](.*)", "[Yy](.*)", "[Zz](.*)", }, run = run }
gpl-2.0
PAPAGENO-devels/papageno
test/benchmarks/Lua/lua-regression-test/grim/lz.lua
1
4629
CheckFirstTime("lz.lua") lz = Set:create("lz.set", "lola zapata", { lz_top = 0, lz_intha = 1, lz_dorcu = 2 }) lz.call_count = 0 lz.call_down_pipe = function(arg1) -- line 14 lz.call_count = lz.call_count + 1 system_prefs:set_voice_effect("Basic Reverb") break_here() if lz.call_count == 1 then manny:say_line("/lzma001/") wait_for_message() sleep_for(1000) system_prefs:set_voice_effect("OFF") manny:say_line("/lzma002/") elseif lz.call_count == 2 then manny:say_line("/lzma003/") elseif lz.call_count == 3 then manny:say_line("/lzma004/") elseif lz.call_count == 4 then manny:say_line("/lzma005/") elseif lz.call_count == 5 then manny:say_line("/lzma006/") elseif lz.call_count == 6 then manny:say_line("/lzma007/") elseif lz.call_count == 7 then manny:say_line("/lzma008/") else manny:say_line("/lzma009/") end manny:wait_for_message() system_prefs:set_voice_effect("OFF") end lz.enter = function(arg1) -- line 69 lz:current_setup(lz_intha) SetShadowColor(10, 10, 10) SetActiveShadow(manny.hActor, 0) SetActorShadowPoint(manny.hActor, -1000, -800, 1000) SetActorShadowPlane(manny.hActor, "shadow1") AddShadowPlane(manny.hActor, "shadow1") AddShadowPlane(manny.hActor, "shadow2") AddShadowPlane(manny.hActor, "shadow3") SetActiveShadow(manny.hActor, 1) SetActorShadowPoint(manny.hActor, -1000, -800, 1000) SetActorShadowPlane(manny.hActor, "shadow_slant") AddShadowPlane(manny.hActor, "shadow_slant") AddShadowPlane(manny.hActor, "shadow_slant1") end lz.camerachange = function(arg1, arg2, arg3) -- line 90 if arg3 == lz_intha then StartMovie("lz.snm", TRUE, 0, 170) else StopMovie() end end lz.exit = function(arg1) -- line 98 StopMovie() KillActorShadows(manny.hActor) end lz.port_pipe = Object:create(lz, "vent", 5.13587, 3.31918, 2.76, { range = 0.89999998 }) lz.port_pipe.use_pnt_x = 5.0358701 lz.port_pipe.use_pnt_y = 2.9891801 lz.port_pipe.use_pnt_z = 2.23 lz.port_pipe.use_rot_x = 0 lz.port_pipe.use_rot_y = 2502.5801 lz.port_pipe.use_rot_z = 0 lz.port_pipe.lookAt = function(arg1) -- line 118 manny:say_line("/lzma010/") end lz.port_pipe.pickUp = function(arg1) -- line 122 system.default_response("attached") end lz.port_pipe.use = function(arg1) -- line 126 if manny:walkto(arg1) then lz:call_down_pipe() end end lz.starboard_pipe1 = Object:create(lz, "vent", 1.77544, 3.3091099, 2.77, { range = 0.89999998 }) lz.starboard_pipe1.use_pnt_x = 1.77544 lz.starboard_pipe1.use_pnt_y = 2.8891101 lz.starboard_pipe1.use_pnt_z = 2.23 lz.starboard_pipe1.use_rot_x = 0 lz.starboard_pipe1.use_rot_y = 2886.77 lz.starboard_pipe1.use_rot_z = 0 lz.starboard_pipe1.parent = lz.port_pipe lz.starboard_pipe2 = Object:create(lz, "vent", 1.8003401, 5.5474801, 2.8399999, { range = 0.89999998 }) lz.starboard_pipe2.use_pnt_x = 1.66034 lz.starboard_pipe2.use_pnt_y = 5.2174802 lz.starboard_pipe2.use_pnt_z = 2.23 lz.starboard_pipe2.use_rot_x = 0 lz.starboard_pipe2.use_rot_y = 2890.72 lz.starboard_pipe2.use_rot_z = 0 lz.starboard_pipe2.parent = lz.port_pipe lz.cleat1 = Object:create(lz, "cleat", 1.64306, 0.26737201, 2.6500001, { range = 1 }) lz.cleat1.use_pnt_x = 2.08306 lz.cleat1.use_pnt_y = -0.36262801 lz.cleat1.use_pnt_z = 2.23 lz.cleat1.use_rot_x = 0 lz.cleat1.use_rot_y = 2641.4199 lz.cleat1.use_rot_z = 0 lz.cleat1.lookAt = function(arg1) -- line 163 soft_script() manny:say_line("/lzma011/") wait_for_message() manny:say_line("/lzma012/") wait_for_message() manny:say_line("/lzma013/") end lz.cleat1.use = function(arg1) -- line 172 manny:say_line("/lzma014/") end lz.cleat1.pickUp = lz.cleat1.use lz.cleat2 = Object:create(lz, "cleat", 1.96306, -1.1926301, 2.51, { range = 1 }) lz.cleat2.use_pnt_x = 2.08306 lz.cleat2.use_pnt_y = -0.36262801 lz.cleat2.use_pnt_z = 2.23 lz.cleat2.use_rot_x = 0 lz.cleat2.use_rot_y = 2641.4199 lz.cleat2.use_rot_z = 0 lz.cleat2.parent = lz.cleat1 lz.il_door = Object:create(lz, "door", 2.7634599, 6.99156, 3.6600001, { range = 0 }) lz.il_door.use_pnt_x = 2.7634599 lz.il_door.use_pnt_y = 6.99156 lz.il_door.use_pnt_z = 3.6600001 lz.il_door.use_rot_x = 0 lz.il_door.use_rot_y = -84.268204 lz.il_door.use_rot_z = 0 lz.il_door.out_pnt_x = 2.7634599 lz.il_door.out_pnt_y = 6.99156 lz.il_door.out_pnt_z = 3.6600001 lz.il_door.out_rot_x = 0 lz.il_door.out_rot_y = -84.268204 lz.il_door.out_rot_z = 0 lz.il_box = lz.il_door lz.il_door.walkOut = function(arg1) -- line 209 il:come_out_door(il.lz_door) end
gpl-2.0
TheAnswer/FirstTest
bin/scripts/creatures/spawns/talus/staticSpawns.lua
2
2107
--Copyright (C) 2007 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. --global clusters
lgpl-3.0
TheAnswer/FirstTest
bin/scripts/creatures/objects/lok/creatures/anglatchDestroyer.lua
1
4877
--Copyright (C) 2008 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. anglatchDestroyer = Creature:new { objectName = "anglatchDestroyer", -- Lua Object Name creatureType = "ANIMAL", faction = "Langlatch", gender = "", name = "a Anglatch Destroyer", objectCRC = 2513300255, socialGroup = "Langlatch", named = FALSE, level = 20, xp = 1803, combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG + AGGRESSIVE_FLAG, healthMax = 3000, healthMin = 2400, strength = 0, constitution = 0, actionMax = 3000, actionMin = 2400, quickness = 0, stamina = 0, mindMax = 3000, mindMin = 2400, focus = 0, willpower = 0, height = 1, -- Size of creature armor = 1, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy kinetic = 20, energy = 0, electricity = 45, stun = -1, blast = 0, heat = 15, cold = 15, acid = 45, lightsaber = 0, accuracy = 0, healer = 0, pack = 1, herd = 1, stalker = 1, killer = 1, aggressive = 1, invincible = 0, attackCreatureOnSight = "", -- Enter socialGroups weapon = "", -- File path to weapon -> object\xxx\xxx\xx weaponName = "", -- Name ex. 'a Vibrolance' weaponTemp = "", -- Weapon Template ex. 'lance_vibrolance' weaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon' weaponEquipped = 0, weaponMinDamage = 0, weaponMaxDamage = 0, weaponAttackSpeed = 0, weaponDamageType = "", -- ELECTRICITY, KINETIC, etc weaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx alternateWeaponName = "", -- Name ex. 'a Vibrolance' alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance' alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon' alternateWeaponEquipped = 0, alternateWeaponMinDamage = 0, alternateWeaponMaxDamage = 0, alternateWeaponAttackSpeed = 0, alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's lootGroup = 0, -- Group it belongs to for loot tame = 0, datapadItemCRC = 0, mountCRC = 0, mountSpeed = 0, mountAcceleration = 0, milk = 0, boneType = "bone_mammal_lok", boneMax = 10, hideType = "hide_wooly_lok", hideMax = 10, meatType = "meat_carnivore_lok", meatMax = 18, skills = { " Stun attack", " Knockdown attack", "" } -- respawnTimer = 180, behaviorScript = "", -- Link to the behavior script for this object } Creatures:addCreature(anglatchDestroyer, 2513300255) -- Add to Global Table
lgpl-3.0
hamode-Aliraq/HAMODE_ALIRAQE
plugins/ingroup.lua
156
60323
do -- Check Member local function check_member_autorealm(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.peer_id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { group_type = 'Realm', settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes' } } save_data(_config.moderation.data, data) local realms = 'realms' if not data[tostring(realms)] then data[tostring(realms)] = {} save_data(_config.moderation.data, data) end data[tostring(realms)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Welcome to your new realm !') end end end local function check_member_realm_add(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.peer_id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { group_type = 'Realm', settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes' } } save_data(_config.moderation.data, data) local realms = 'realms' if not data[tostring(realms)] then data[tostring(realms)] = {} save_data(_config.moderation.data, data) end data[tostring(realms)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Realm has been added!') end end end function check_member_group(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.peer_id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { group_type = 'Group', moderators = {}, set_owner = member_id , settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes', } } save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = {} save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, 'You have been promoted as the owner.') end end end local function check_member_modadd(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.peer_id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { group_type = 'Group', long_id = msg.to.peer_id, moderators = {}, set_owner = member_id , settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes', } } save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = {} save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Group is added and you have been promoted as the owner ') end end end local function automodadd(msg) local data = load_data(_config.moderation.data) if msg.action.type == 'chat_created' then receiver = get_receiver(msg) chat_info(receiver, check_member_group,{receiver=receiver, data=data, msg = msg}) end end local function autorealmadd(msg) local data = load_data(_config.moderation.data) if msg.action.type == 'chat_created' then receiver = get_receiver(msg) chat_info(receiver, check_member_autorealm,{receiver=receiver, data=data, msg = msg}) end end local function check_member_realmrem(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Realm configuration removal data[tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) local realms = 'realms' if not data[tostring(realms)] then data[tostring(realms)] = nil save_data(_config.moderation.data, data) end data[tostring(realms)][tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Realm has been removed!') end end end local function check_member_modrem(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.peer_id if member_id ~= our_id then -- Group configuration removal data[tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = nil save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Group has been removed') end end end --End Check Member function show_group_settingsmod(msg, target) if not is_momod(msg) then return "For moderators only!" end local data = load_data(_config.moderation.data) if data[tostring(target)] then if data[tostring(target)]['settings']['flood_msg_max'] then NUM_MSG_MAX = tonumber(data[tostring(target)]['settings']['flood_msg_max']) print('custom'..NUM_MSG_MAX) else NUM_MSG_MAX = 5 end end local bots_protection = "Yes" if data[tostring(target)]['settings']['lock_bots'] then bots_protection = data[tostring(target)]['settings']['lock_bots'] end local leave_ban = "no" if data[tostring(target)]['settings']['leave_ban'] then leave_ban = data[tostring(target)]['settings']['leave_ban'] end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['lock_link'] then data[tostring(target)]['settings']['lock_link'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['lock_sticker'] then data[tostring(target)]['settings']['lock_sticker'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['public'] then data[tostring(target)]['settings']['public'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['lock_rtl'] then data[tostring(target)]['settings']['lock_rtl'] = 'no' end end local settings = data[tostring(target)]['settings'] local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nLock group leave : "..leave_ban.."\nflood sensitivity : "..NUM_MSG_MAX.."\nBot protection : "..bots_protection.."\nLock links : "..settings.lock_link.."\nLock RTL: "..settings.lock_rtl.."\nLock sticker: "..settings.lock_sticker.."\nPublic: "..settings.public return text end local function set_descriptionmod(msg, data, target, about) if not is_momod(msg) then return end local data_cat = 'description' data[tostring(target)][data_cat] = about save_data(_config.moderation.data, data) return 'Set group description to:\n'..about end local function get_description(msg, data) local data_cat = 'description' if not data[tostring(msg.to.id)][data_cat] then return 'No description available.' end local about = data[tostring(msg.to.id)][data_cat] local about = string.gsub(msg.to.print_name, "_", " ")..':\n\n'..about return 'About '..about end local function lock_group_arabic(msg, data, target) if not is_momod(msg) then return end local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic'] if group_arabic_lock == 'yes' then return 'Arabic is already locked' else data[tostring(target)]['settings']['lock_arabic'] = 'yes' save_data(_config.moderation.data, data) return 'Arabic has been locked' end end local function unlock_group_arabic(msg, data, target) if not is_momod(msg) then return end local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic'] if group_arabic_lock == 'no' then return 'Arabic is already unlocked' else data[tostring(target)]['settings']['lock_arabic'] = 'no' save_data(_config.moderation.data, data) return 'Arabic has been unlocked' end end local function lock_group_bots(msg, data, target) if not is_momod(msg) then return end local group_bots_lock = data[tostring(target)]['settings']['lock_bots'] if group_bots_lock == 'yes' then return 'Bots protection is already enabled' else data[tostring(target)]['settings']['lock_bots'] = 'yes' save_data(_config.moderation.data, data) return 'Bots protection has been enabled' end end local function unlock_group_bots(msg, data, target) if not is_momod(msg) then return end local group_bots_lock = data[tostring(target)]['settings']['lock_bots'] if group_bots_lock == 'no' then return 'Bots protection is already disabled' else data[tostring(target)]['settings']['lock_bots'] = 'no' save_data(_config.moderation.data, data) return 'Bots protection has been disabled' end end local function lock_group_namemod(msg, data, target) if not is_momod(msg) then return end local group_name_set = data[tostring(target)]['settings']['set_name'] local group_name_lock = data[tostring(target)]['settings']['lock_name'] if group_name_lock == 'yes' then return 'Group name is already locked' else data[tostring(target)]['settings']['lock_name'] = 'yes' save_data(_config.moderation.data, data) rename_chat('chat#id'..target, group_name_set, ok_cb, false) return 'Group name has been locked' end end local function unlock_group_namemod(msg, data, target) if not is_momod(msg) then return end local group_name_set = data[tostring(target)]['settings']['set_name'] local group_name_lock = data[tostring(target)]['settings']['lock_name'] if group_name_lock == 'no' then return 'Group name is already unlocked' else data[tostring(target)]['settings']['lock_name'] = 'no' save_data(_config.moderation.data, data) return 'Group name has been unlocked' end end local function lock_group_floodmod(msg, data, target) if not is_momod(msg) then return end local group_flood_lock = data[tostring(target)]['settings']['flood'] if group_flood_lock == 'yes' then return 'Group flood is locked' else data[tostring(target)]['settings']['flood'] = 'yes' save_data(_config.moderation.data, data) return 'Group flood has been locked' end end local function unlock_group_floodmod(msg, data, target) if not is_momod(msg) then return end if not is_owner(msg) then return "Only owners can unlock flood" end local group_flood_lock = data[tostring(target)]['settings']['flood'] if group_flood_lock == 'no' then return 'Group flood is not locked' else data[tostring(target)]['settings']['flood'] = 'no' save_data(_config.moderation.data, data) return 'Group flood has been unlocked' end end local function lock_group_membermod(msg, data, target) if not is_momod(msg) then return end local group_member_lock = data[tostring(target)]['settings']['lock_member'] if group_member_lock == 'yes' then return 'Group members are already locked' else data[tostring(target)]['settings']['lock_member'] = 'yes' save_data(_config.moderation.data, data) end return 'Group members has been locked' end local function unlock_group_membermod(msg, data, target) if not is_momod(msg) then return end local group_member_lock = data[tostring(target)]['settings']['lock_member'] if group_member_lock == 'no' then return 'Group members are not locked' else data[tostring(target)]['settings']['lock_member'] = 'no' save_data(_config.moderation.data, data) return 'Group members has been unlocked' end end local function set_public_membermod(msg, data, target) if not is_momod(msg) then return end local group_member_lock = data[tostring(target)]['settings']['public'] local long_id = data[tostring(target)]['long_id'] if not long_id then data[tostring(target)]['long_id'] = msg.to.peer_id save_data(_config.moderation.data, data) end if group_member_lock == 'yes' then return 'Group is already public' else data[tostring(target)]['settings']['public'] = 'yes' save_data(_config.moderation.data, data) end return 'Group is now: public' end local function unset_public_membermod(msg, data, target) if not is_momod(msg) then return end local group_member_lock = data[tostring(target)]['settings']['public'] local long_id = data[tostring(target)]['long_id'] if not long_id then data[tostring(target)]['long_id'] = msg.to.peer_id save_data(_config.moderation.data, data) end if group_member_lock == 'no' then return 'Group is not public' else data[tostring(target)]['settings']['public'] = 'no' save_data(_config.moderation.data, data) return 'Group is now: not public' end end local function lock_group_leave(msg, data, target) if not is_momod(msg) then return end local leave_ban = data[tostring(target)]['settings']['leave_ban'] if leave_ban == 'yes' then return 'Leaving users will be banned' else data[tostring(target)]['settings']['leave_ban'] = 'yes' save_data(_config.moderation.data, data) end return 'Leaving users will be banned' end local function unlock_group_leave(msg, data, target) if not is_momod(msg) then return end local leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban'] if leave_ban == 'no' then return 'Leaving users will not be banned' else data[tostring(target)]['settings']['leave_ban'] = 'no' save_data(_config.moderation.data, data) return 'Leaving users will not be banned' end end local function unlock_group_photomod(msg, data, target) if not is_momod(msg) then return end local group_photo_lock = data[tostring(target)]['settings']['lock_photo'] if group_photo_lock == 'no' then return 'Group photo is not locked' else data[tostring(target)]['settings']['lock_photo'] = 'no' save_data(_config.moderation.data, data) return 'Group photo has been unlocked' end end local function lock_group_links(msg, data, target) if not is_momod(msg) then return end local group_link_lock = data[tostring(target)]['settings']['lock_link'] if group_link_lock == 'yes' then return 'Link posting is already locked' else data[tostring(target)]['settings']['lock_link'] = 'yes' save_data(_config.moderation.data, data) return 'Link posting has been locked' end end local function unlock_group_links(msg, data, target) if not is_momod(msg) then return end local group_link_lock = data[tostring(target)]['settings']['lock_link'] if group_link_lock == 'no' then return 'Link posting is not locked' else data[tostring(target)]['settings']['lock_link'] = 'no' save_data(_config.moderation.data, data) return 'Link posting has been unlocked' end end local function lock_group_rtl(msg, data, target) if not is_momod(msg) then return end local group_rtl_lock = data[tostring(target)]['settings']['lock_rtl'] if group_rtl_lock == 'yes' then return 'RTL is already locked' else data[tostring(target)]['settings']['lock_rtl'] = 'yes' save_data(_config.moderation.data, data) return 'RTL has been locked' end end local function unlock_group_rtl(msg, data, target) if not is_momod(msg) then return end local group_rtl_lock = data[tostring(target)]['settings']['lock_rtl'] if group_rtl_lock == 'no' then return 'RTL is already unlocked' else data[tostring(target)]['settings']['lock_rtl'] = 'no' save_data(_config.moderation.data, data) return 'RTL has been unlocked' end end local function lock_group_sticker(msg, data, target) if not is_momod(msg) then return end local group_sticker_lock = data[tostring(target)]['settings']['lock_sticker'] if group_sticker_lock == 'yes' then return 'Sticker posting is already locked' else data[tostring(target)]['settings']['lock_sticker'] = 'yes' save_data(_config.moderation.data, data) return 'Sticker posting has been locked' end end local function unlock_group_sticker(msg, data, target) if not is_momod(msg) then return end local group_sticker_lock = data[tostring(target)]['settings']['lock_sticker'] if group_sticker_lock == 'no' then return 'Sticker posting is already unlocked' else data[tostring(target)]['settings']['lock_sticker'] = 'no' save_data(_config.moderation.data, data) return 'Sticker posting has been unlocked' end end local function lock_group_contacts(msg, data, target) if not is_momod(msg) then return end local group_rtl_lock = data[tostring(target)]['settings']['lock_contacts'] if group_contacts_lock == 'yes' then return 'Contact posting is already locked' else data[tostring(target)]['settings']['lock_contacts'] = 'yes' save_data(_config.moderation.data, data) return 'Contact posting has been locked' end end local function unlock_group_contacts(msg, data, target) if not is_momod(msg) then return end local group_contacts_lock = data[tostring(target)]['settings']['lock_contacts'] if group_contacts_lock == 'no' then return 'Contact posting is already unlocked' else data[tostring(target)]['settings']['lock_contacts'] = 'no' save_data(_config.moderation.data, data) return 'Contact posting has been unlocked' end end local function enable_strict_rules(msg, data, target) if not is_momod(msg) then return end local group_rtl_lock = data[tostring(target)]['settings']['strict'] if strict == 'yes' then return 'Settings are already strictly enforced' else data[tostring(target)]['settings']['strict'] = 'yes' save_data(_config.moderation.data, data) return 'Settings will be strictly enforced' end end local function disable_strict_rules(msg, data, target) if not is_momod(msg) then return end local group_contacts_lock = data[tostring(target)]['settings']['strict'] if strict == 'no' then return 'Settings are not strictly enforced' else data[tostring(target)]['settings']['strict'] = 'no' save_data(_config.moderation.data, data) return 'Settings will not be strictly enforced' end end local function set_rulesmod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local data_cat = 'rules' data[tostring(target)][data_cat] = rules save_data(_config.moderation.data, data) return 'Set group rules to:\n\n'..rules end local function modadd(msg) -- superuser and admins only (because sudo are always has privilege) if not is_momod(msg) then return end if not is_admin1(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if is_group(msg) then return 'Group is already added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_modadd,{receiver=receiver, data=data, msg = msg}) end local function realmadd(msg) -- superuser and admins only (because sudo are always has privilege) if not is_momod(msg) then return end if not is_admin1(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if is_realm(msg) then return 'Realm is already added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_realm_add,{receiver=receiver, data=data, msg = msg}) end -- Global functions function modrem(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin1(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if not is_group(msg) then return 'Group is not added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_modrem,{receiver=receiver, data=data, msg = msg}) end function realmrem(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin1(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if not is_realm(msg) then return 'Realm is not added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_realmrem,{receiver=receiver, data=data, msg = msg}) end local function get_rules(msg, data) local data_cat = 'rules' if not data[tostring(msg.to.id)][data_cat] then return 'No rules available.' end local rules = data[tostring(msg.to.id)][data_cat] local rules = 'Chat rules:\n\n'..rules return rules end local function set_group_photo(msg, success, result) local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) if success then local file = 'data/photos/chat_photo_'..msg.to.id..'.jpg' print('File downloaded to:', result) os.rename(result, file) print('File moved to:', file) chat_set_photo (receiver, file, ok_cb, false) data[tostring(msg.to.id)]['settings']['set_photo'] = file save_data(_config.moderation.data, data) data[tostring(msg.to.id)]['settings']['lock_photo'] = 'yes' save_data(_config.moderation.data, data) send_large_msg(receiver, 'Photo saved!', ok_cb, false) else print('Error downloading: '..msg.id) send_large_msg(receiver, 'Failed, please try again!', ok_cb, false) end end local function promote(receiver, member_username, member_id) local data = load_data(_config.moderation.data) local group = string.gsub(receiver, 'chat#id', '') if not data[group] then return send_large_msg(receiver, 'Group is not added.') end if data[group]['moderators'][tostring(member_id)] then return send_large_msg(receiver, member_username..' is already a moderator.') end data[group]['moderators'][tostring(member_id)] = member_username save_data(_config.moderation.data, data) return send_large_msg(receiver, member_username..' has been promoted.') end local function promote_by_reply(extra, success, result) local msg = result local full_name = (msg.from.first_name or '')..' '..(msg.from.last_name or '') if msg.from.username then member_username = '@'.. msg.from.username else member_username = full_name end local member_id = msg.from.peer_id if msg.to.peer_type == 'chat' then return promote(get_receiver(msg), member_username, member_id) end end local function demote(receiver, member_username, member_id) local data = load_data(_config.moderation.data) local group = string.gsub(receiver, 'chat#id', '') if not data[group] then return send_large_msg(receiver, 'Group is not added.') end if not data[group]['moderators'][tostring(member_id)] then return send_large_msg(receiver, member_username..' is not a moderator.') end data[group]['moderators'][tostring(member_id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, member_username..' has been demoted.') end local function demote_by_reply(extra, success, result) local msg = result local full_name = (msg.from.first_name or '')..' '..(msg.from.last_name or '') if msg.from.username then member_username = '@'..msg.from.username else member_username = full_name end local member_id = msg.from.peer_id if msg.to.peer_type == 'chat' then return demote(get_receiver(msg), member_username, member_id) end end local function setowner_by_reply(extra, success, result) local msg = result local receiver = get_receiver(msg) local data = load_data(_config.moderation.data) local name_log = msg.from.print_name:gsub("_", " ") data[tostring(msg.to.id)]['set_owner'] = tostring(msg.from.id) save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] set ["..msg.from.id.."] as owner") local text = msg.from.print_name:gsub("_", " ").." is the owner now" return send_large_msg(receiver, text) end local function promote_demote_res(extra, success, result) --vardump(result) --vardump(extra) local member_id = result.peer_id local member_username = "@"..result.username local chat_id = extra.chat_id local mod_cmd = extra.mod_cmd local receiver = "chat#id"..chat_id if mod_cmd == 'promote' then return promote(receiver, member_username, member_id) elseif mod_cmd == 'demote' then return demote(receiver, member_username, member_id) end end local function mute_user_callback(extra, success, result) if result.service then local action = result.action.type if action == 'chat_add_user' or action == 'chat_del_user' or action == 'chat_rename' or action == 'chat_change_photo' then if result.action.user then user_id = result.action.user.peer_id end end else user_id = result.from.peer_id end local receiver = extra.receiver local chat_id = string.gsub(receiver, 'channel#id', '') if is_muted_user(chat_id, user_id) then mute_user(chat_id, user_id) send_large_msg(receiver, "["..user_id.."] removed from the muted user list") else unmute_user(chat_id, user_id) send_large_msg(receiver, " ["..user_id.."] added to the muted user list") end end local function modlist(msg) local data = load_data(_config.moderation.data) local groups = "groups" if not data[tostring(groups)][tostring(msg.to.id)] then return 'Group is not added.' end -- determine if table is empty if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way return 'No moderator in this group.' end local i = 1 local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n' for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do message = message ..i..' - '..v..' [' ..k.. '] \n' i = i + 1 end return message end local function callbackres(extra, success, result) local user = result.peer_id local name = string.gsub(result.print_name, "_", " ") local chat = 'chat#id'..extra.chatid send_large_msg(chat, user..'\n'..name) return user end local function callback_mute_res(extra, success, result) local user_id = result.peer_id local receiver = extra.receiver local chat_id = string.gsub(receiver, 'chat#id', '') if is_muted_user(chat_id, user_id) then unmute_user(chat_id, user_id) send_large_msg(receiver, " ["..user_id.."] removed from muted user list") else mute_user(chat_id, user_id) send_large_msg(receiver, " ["..user_id.."] added to muted user list") end end local function help() local help_text = tostring(_config.help_text) return help_text end local function cleanmember(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name for k,v in pairs(result.members) do kick_user(v.id, result.peer_id) end end local function killchat(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name for k,v in pairs(result.members) do kick_user_any(v.id, result.peer_id) end end local function killrealm(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name for k,v in pairs(result.members) do kick_user_any(v.id, result.peer_id) end end --[[local function user_msgs(user_id, chat_id) local user_info local uhash = 'user:'..user_id local user = redis:hgetall(uhash) local um_hash = 'msgs:'..user_id..':'..chat_id user_info = tonumber(redis:get(um_hash) or 0) return user_info end local function kick_zero(cb_extra, success, result) local chat_id = cb_extra.chat_id local chat = "chat#id"..chat_id local ci_user local re_user for k,v in pairs(result.members) do local si = false ci_user = v.peer_id local hash = 'chat:'..chat_id..':users' local users = redis:smembers(hash) for i = 1, #users do re_user = users[i] if tonumber(ci_user) == tonumber(re_user) then si = true end end if not si then if ci_user ~= our_id then if not is_momod2(ci_user, chat_id) then chat_del_user(chat, 'user#id'..ci_user, ok_cb, true) end end end end end local function kick_inactive(chat_id, num, receiver) local hash = 'chat:'..chat_id..':users' local users = redis:smembers(hash) -- Get user info for i = 1, #users do local user_id = users[i] local user_info = user_msgs(user_id, chat_id) local nmsg = user_info if tonumber(nmsg) < tonumber(num) then if not is_momod2(user_id, chat_id) then chat_del_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, true) end end end return chat_info(receiver, kick_zero, {chat_id = chat_id}) end]] local function run(msg, matches) local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) local name_log = user_print_name(msg.from) local group = msg.to.id if msg.media then if msg.media.type == 'photo' and data[tostring(msg.to.id)] and data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' and is_chat_msg(msg) and is_momod(msg) then load_photo(msg.id, set_group_photo, msg) end end if msg.to.type == 'chat' then if is_admin1(msg) or not is_support(msg.from.id) then-- Admin only if matches[1] == 'add' and not matches[2] then if not is_admin1(msg) and not is_support(msg.from.id) then-- Admin only savelog(msg.to.id, name_log.." ["..msg.from.id.."] attempted to add group [ "..msg.to.id.." ]") return end if is_realm(msg) then return 'Error: Already a realm.' end savelog(msg.to.id, name_log.." ["..msg.from.id.."] added group [ "..msg.to.id.." ]") print("group "..msg.to.print_name.."("..msg.to.id..") added") return modadd(msg) end if matches[1] == 'add' and matches[2] == 'realm' then if not is_sudo(msg) then-- Admin only savelog(msg.to.id, name_log.." ["..msg.from.id.."] attempted to add realm [ "..msg.to.id.." ]") return end if is_group(msg) then return 'Error: Already a group.' end savelog(msg.to.id, name_log.." ["..msg.from.id.."] added realm [ "..msg.to.id.." ]") print("group "..msg.to.print_name.."("..msg.to.id..") added as a realm") return realmadd(msg) end if matches[1] == 'rem' and not matches[2] then if not is_admin1(msg) and not is_support(msg.from.id) then-- Admin only savelog(msg.to.id, name_log.." ["..msg.from.id.."] attempted to remove group [ "..msg.to.id.." ]") return end if not is_group(msg) then return 'Error: Not a group.' end savelog(msg.to.id, name_log.." ["..msg.from.id.."] removed group [ "..msg.to.id.." ]") print("group "..msg.to.print_name.."("..msg.to.id..") removed") return modrem(msg) end if matches[1] == 'rem' and matches[2] == 'realm' then if not is_sudo(msg) then-- Sudo only savelog(msg.to.id, name_log.." ["..msg.from.id.."] attempted to remove realm [ "..msg.to.id.." ]") return end if not is_realm(msg) then return 'Error: Not a realm.' end savelog(msg.to.id, name_log.." ["..msg.from.id.."] removed realm [ "..msg.to.id.." ]") print("group "..msg.to.print_name.."("..msg.to.id..") removed as a realm") return realmrem(msg) end end if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "group" then return automodadd(msg) end --[[Experimental if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "super_group" then local chat_id = get_receiver(msg) users = {[1]="user#id167472799",[2]="user#id170131770"} for k,v in pairs(users) do chat_add_user(chat_id, v, ok_cb, false) end --chat_upgrade(chat_id, ok_cb, false) end ]] if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "realm" then return autorealmadd(msg) end if msg.to.id and data[tostring(msg.to.id)] then local settings = data[tostring(msg.to.id)]['settings'] if matches[1] == 'chat_add_user' then if not msg.service then return end local group_member_lock = settings.lock_member local user = 'user#id'..msg.action.user.id local chat = 'chat#id'..msg.to.id if group_member_lock == 'yes' and not is_owner2(msg.action.user.id, msg.to.id) then chat_del_user(chat, user, ok_cb, true) elseif group_member_lock == 'yes' and tonumber(msg.from.id) == tonumber(our_id) then return nil elseif group_member_lock == 'no' then return nil end end if matches[1] == 'chat_del_user' then if not msg.service then -- return "Are you trying to troll me?" end local user = 'user#id'..msg.action.user.id local chat = 'chat#id'..msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..user) end if matches[1] == 'chat_delete_photo' then if not msg.service then return end local group_photo_lock = settings.lock_photo if group_photo_lock == 'yes' then local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:incr(picturehash) --- local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id local picprotectionredis = redis:get(picturehash) if picprotectionredis then if tonumber(picprotectionredis) == 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id) end if tonumber(picprotectionredis) == 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:set(picturehash, 0) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to deleted picture but failed ") chat_set_photo(receiver, settings.set_photo, ok_cb, false) elseif group_photo_lock == 'no' then return nil end end if matches[1] == 'chat_change_photo' and msg.from.id ~= 0 then if not msg.service then return end local group_photo_lock = settings.lock_photo if group_photo_lock == 'yes' then local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:incr(picturehash) --- local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id local picprotectionredis = redis:get(picturehash) if picprotectionredis then if tonumber(picprotectionredis) == 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id) end if tonumber(picprotectionredis) == 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:set(picturehash, 0) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change picture but failed ") chat_set_photo(receiver, settings.set_photo, ok_cb, false) elseif group_photo_lock == 'no' then return nil end end if matches[1] == 'chat_rename' then if not msg.service then return end local group_name_set = settings.set_name local group_name_lock = settings.lock_name local to_rename = 'chat#id'..msg.to.id if group_name_lock == 'yes' then if group_name_set ~= tostring(msg.to.print_name) then local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id redis:incr(namehash) local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id local nameprotectionredis = redis:get(namehash) if nameprotectionredis then if tonumber(nameprotectionredis) == 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id) end if tonumber(nameprotectionredis) == 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id redis:set(namehash, 0) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change name but failed ") rename_chat(to_rename, group_name_set, ok_cb, false) end elseif group_name_lock == 'no' then return nil end end if matches[1] == 'setname' and is_momod(msg) then local new_name = string.gsub(matches[2], '_', ' ') data[tostring(msg.to.id)]['settings']['set_name'] = new_name save_data(_config.moderation.data, data) local group_name_set = data[tostring(msg.to.id)]['settings']['set_name'] local to_rename = 'chat#id'..msg.to.id rename_chat(to_rename, group_name_set, ok_cb, false) savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]") end if matches[1] == 'setphoto' and is_momod(msg) then data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting' save_data(_config.moderation.data, data) return 'Please send me new group photo now' end if matches[1] == 'promote' and not matches[2] then if not is_momod(msg) then return end if not is_owner(msg) then return "Only the owner can prmote new moderators" end if type(msg.reply_id)~="nil" then msgr = get_message(msg.reply_id, promote_by_reply, false) end end if matches[1] == 'promote' and matches[2] then if not is_momod(msg) then return end if not is_owner(msg) then return "Only owner can promote" end local member = matches[2] savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted @".. member) local cbres_extra = { chat_id = msg.to.id, mod_cmd = 'promote', from_id = msg.from.id } local username = matches[2] local username = string.gsub(matches[2], '@', '') return resolve_username(username, promote_demote_res, cbres_extra) end if matches[1] == 'demote' and not matches[2] then if not is_momod(msg) then return end if not is_owner(msg) then return "Only the owner can demote moderators" end if type(msg.reply_id)~="nil" then msgr = get_message(msg.reply_id, demote_by_reply, false) end end if matches[1] == 'demote' and matches[2] then if not is_momod(msg) then return end if not is_owner(msg) then return "Only owner can demote" end if string.gsub(matches[2], "@", "") == msg.from.username and not is_owner(msg) then return "You can't demote yourself" end local member = matches[2] savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted @".. member) local cbres_extra = { chat_id = msg.to.id, mod_cmd = 'demote', from_id = msg.from.id } local username = matches[2] local username = string.gsub(matches[2], '@', '') return resolve_username(username, promote_demote_res, cbres_extra) end if matches[1] == 'modlist' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group modlist") return modlist(msg) end if matches[1] == 'about' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group description") return get_description(msg, data) end if matches[1] == 'rules' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group rules") return get_rules(msg, data) end if matches[1] == 'set' then if matches[2] == 'rules' then rules = matches[3] local target = msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group rules to ["..matches[3].."]") return set_rulesmod(msg, data, target) end if matches[2] == 'about' then local data = load_data(_config.moderation.data) local target = msg.to.id local about = matches[3] savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group description to ["..matches[3].."]") return set_descriptionmod(msg, data, target, about) end end end --Begin chat settings if matches[1] == 'lock' then local target = msg.to.id if matches[2] == 'name' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked name ") return lock_group_namemod(msg, data, target) end if matches[2] == 'member' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked member ") return lock_group_membermod(msg, data, target) end if matches[2] == 'flood' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked flood ") return lock_group_floodmod(msg, data, target) end if matches[2] == 'arabic' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked arabic ") return lock_group_arabic(msg, data, target) end if matches[2] == 'bots' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked bots ") return lock_group_bots(msg, data, target) end if matches[2] == 'leave' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked leaving ") return lock_group_leave(msg, data, target) end if matches[2] == 'links' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked link posting ") return lock_group_links(msg, data, target) end if matches[2]:lower() == 'rtl' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked rtl chars. in names") return lock_group_rtl(msg, data, target) end if matches[2] == 'sticker' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked sticker posting") return lock_group_sticker(msg, data, target) end if matches[2] == 'contacts' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked contact posting") return lock_group_contacts(msg, data, target) end end if matches[1] == 'unlock' then local target = msg.to.id if matches[2] == 'name' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked name ") return unlock_group_namemod(msg, data, target) end if matches[2] == 'member' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked member ") return unlock_group_membermod(msg, data, target) end if matches[2] == 'photo' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked photo ") return unlock_group_photomod(msg, data, target) end if matches[2] == 'flood' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked flood ") return unlock_group_floodmod(msg, data, target) end if matches[2] == 'arabic' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked arabic ") return unlock_group_arabic(msg, data, target) end if matches[2] == 'bots' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked bots ") return unlock_group_bots(msg, data, target) end if matches[2] == 'leave' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked leaving ") return unlock_group_leave(msg, data, target) end if matches[2] == 'links' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked link posting") return unlock_group_links(msg, data, target) end if matches[2]:lower() == 'rtl' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked RTL chars. in names") return unlock_group_rtl(msg, data, target) end if matches[2] == 'sticker' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked sticker posting") return unlock_group_sticker(msg, data, target) end if matches[2] == 'contacts' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked contact posting") return unlock_group_contacts(msg, data, target) end end --End chat settings --Begin Chat mutes if matches[1] == 'mute' and is_owner(msg) then local chat_id = msg.to.id if matches[2] == 'audio' then local msg_type = 'Audio' if not is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: mute "..msg_type) mute(chat_id, msg_type) return "Group "..matches[2].." has been muted" else return "Group mute "..matches[2].." is already on" end end if matches[2] == 'photo' then local msg_type = 'Photo' if not is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: mute "..msg_type) mute(chat_id, msg_type) return "Group "..matches[2].." has been muted" else return "Group mute "..matches[2].." is already on" end end if matches[2] == 'video' then local msg_type = 'Video' if not is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: mute "..msg_type) mute(chat_id, msg_type) return "Group "..matches[2].." has been muted" else return "Group mute "..matches[2].." is already on" end end if matches[2] == 'gifs' then local msg_type = 'Gifs' if not is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: mute "..msg_type) mute(chat_id, msg_type) return msg_type.." have been muted" else return "Group mute "..msg_type.." is already on" end end if matches[2] == 'documents' then local msg_type = 'Documents' if not is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: mute "..msg_type) mute(chat_id, msg_type) return msg_type.." have been muted" else return "Group mute "..msg_type.." is already on" end end if matches[2] == 'text' then local msg_type = 'Text' if not is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: mute "..msg_type) mute(chat_id, msg_type) return "Group text has been muted" else return "Group mute text is already on" end end if matches[2] == 'all' then local msg_type = 'All' if not is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: mute "..msg_type) mute(chat_id, msg_type) return "Mute "..msg_type.." has been enabled" else return "Mute "..msg_type.." is already on" end end end if matches[1] == 'unmute' and is_owner(msg) then local chat_id = msg.to.id if matches[2] == 'audio' then local msg_type = 'Audio' if is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: unmute "..msg_type) unmute(chat_id, msg_type) return "Group "..msg_type.." has been unmuted" else return "Group mute "..msg_type.." is already off" end end if matches[2] == 'photo' then local msg_type = 'Photo' if is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: unmute "..msg_type) unmute(chat_id, msg_type) return "Group "..msg_type.." has been unmuted" else return "Group mute "..msg_type.." is already off" end end if matches[2] == 'Video' then local msg_type = 'Video' if is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: unmute "..msg_type) unmute(chat_id, msg_type) return "Group "..msg_type.." has been unmuted" else return "Group mute "..msg_type.." is already off" end end if matches[2] == 'gifs' then local msg_type = 'Gifs' if is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: unmute "..msg_type) unmute(chat_id, msg_type) return msg_type.." have been unmuted" else return "Mute "..msg_type.." is already off" end end if matches[2] == 'documents' then local msg_type = 'Documents' if is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: unmute "..msg_type) unmute(chat_id, msg_type) return msg_type.." have been unmuted" else return "Mute "..msg_type.." is already off" end end if matches[2] == 'text' then local msg_type = 'Text' if is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: unmute message") unmute(chat_id, msg_type) return "Group text has been unmuted" else return "Group mute text is already off" end end if matches[2] == 'all' then local msg_type = 'All' if is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: unmute "..msg_type) unmute(chat_id, msg_type) return "Mute "..msg_type.." has been disabled" else return "Mute "..msg_type.." is already disabled" end end end --Begin chat muteuser if matches[1] == "muteuser" and is_momod(msg) then local chat_id = msg.to.id local hash = "mute_user"..chat_id local user_id = "" if type(msg.reply_id) ~= "nil" then local receiver = get_receiver(msg) local get_cmd = "mute_user" get_message(msg.reply_id, mute_user_callback, {receiver = receiver, get_cmd = get_cmd}) elseif matches[1] == "muteuser" and string.match(matches[2], '^%d+$') then local user_id = matches[2] if is_muted_user(chat_id, user_id) then mute_user(chat_id, user_id) return "["..user_id.."] removed from the muted users list" else unmute_user(chat_id, user_id) return "["..user_id.."] added to the muted user list" end elseif matches[1] == "muteuser" and not string.match(matches[2], '^%d+$') then local receiver = get_receiver(msg) local get_cmd = "mute_user" local username = matches[2] local username = string.gsub(matches[2], '@', '') resolve_username(username, callback_mute_res, {receiver = receiver, get_cmd = get_cmd}) end end --End Chat muteuser if matches[1] == "muteslist" and is_momod(msg) then local chat_id = msg.to.id if not has_mutes(chat_id) then set_mutes(chat_id) return mutes_list(chat_id) end savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup muteslist") return mutes_list(chat_id) end if matches[1] == "mutelist" and is_momod(msg) then local chat_id = msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup mutelist") return muted_user_list(chat_id) end if matches[1] == 'settings' and is_momod(msg) then local target = msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group settings ") return show_group_settingsmod(msg, target) end if matches[1] == 'public' and is_momod(msg) then local target = msg.to.id if matches[2] == 'yes' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: public") return set_public_membermod(msg, data, target) end if matches[2] == 'no' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: not public") return unset_public_membermod(msg, data, target) end end if msg.to.type == 'chat' then if matches[1] == 'newlink' and not is_realm(msg) then if not is_momod(msg) then return "For moderators only!" end local function callback (extra , success, result) local receiver = 'chat#'..msg.to.id if success == 0 then return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.') end send_large_msg(receiver, "Created a new link") data[tostring(msg.to.id)]['settings']['set_link'] = result save_data(_config.moderation.data, data) end local receiver = 'chat#'..msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] revoked group link ") return export_chat_link(receiver, callback, true) end if matches[1] == 'link' then if not is_momod(msg) then return "For moderators only!" end local group_link = data[tostring(msg.to.id)]['settings']['set_link'] if not group_link then return "Create a link using /newlink first !" end savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group link ["..group_link.."]") return "Group link:\n"..group_link end if matches[1] == 'setowner' and matches[2] then if not is_owner(msg) then return "For owner only!" end data[tostring(msg.to.id)]['set_owner'] = matches[2] save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] set ["..matches[2].."] as owner") local text = matches[2].." added as owner" return text end if matches[1] == 'setowner' and not matches[2] then if not is_owner(msg) then return "only for the owner!" end if type(msg.reply_id)~="nil" then msgr = get_message(msg.reply_id, setowner_by_reply, false) end end end if matches[1] == 'owner' then local group_owner = data[tostring(msg.to.id)]['set_owner'] if not group_owner then return "no owner,ask admins in support groups to set owner for your group" end savelog(msg.to.id, name_log.." ["..msg.from.id.."] used /owner") return "Group owner is ["..group_owner..']' end if matches[1] == 'setgpowner' then local receiver = "chat#id"..matches[2] if not is_admin1(msg) then return "For admins only!" end data[tostring(matches[2])]['set_owner'] = matches[3] save_data(_config.moderation.data, data) local text = matches[3].." added as owner" send_large_msg(receiver, text) return end if matches[1] == 'setflood' then if not is_momod(msg) then return "For moderators only!" end if tonumber(matches[2]) < 5 or tonumber(matches[2]) > 20 then return "Wrong number,range is [5-20]" end local flood_max = matches[2] data[tostring(msg.to.id)]['settings']['flood_msg_max'] = flood_max save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] set flood to ["..matches[2].."]") return 'Group flood has been set to '..matches[2] end if msg.to.type == 'chat' then if matches[1] == 'clean' then if not is_owner(msg) then return "Only owner can clean" end if matches[2] == 'member' then if not is_owner(msg) then return "Only admins can clean members" end local receiver = get_receiver(msg) chat_info(receiver, cleanmember, {receiver=receiver}) end end if matches[2] == 'modlist' then if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way return 'No moderator in this group.' end local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n' for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do data[tostring(msg.to.id)]['moderators'][tostring(k)] = nil save_data(_config.moderation.data, data) end savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned modlist") end if matches[2] == 'rules' then local data_cat = 'rules' data[tostring(msg.to.id)][data_cat] = nil save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned rules") end if matches[2] == 'about' then local data_cat = 'description' data[tostring(msg.to.id)][data_cat] = nil save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned about") end end if msg.to.type == 'chat' then if matches[1] == 'kill' and matches[2] == 'chat' then if not is_admin1(msg) then return nil end if not is_realm(msg) then local receiver = get_receiver(msg) return modrem(msg), print("Closing Group..."), chat_info(receiver, killchat, {receiver=receiver}) else return 'This is a realm' end end if matches[1] == 'kill' and matches[2] == 'realm' then if not is_admin1(msg) then return nil end if not is_group(msg) then local receiver = get_receiver(msg) return realmrem(msg), print("Closing Realm..."), chat_info(receiver, killrealm, {receiver=receiver}) else return 'This is a group' end end if matches[1] == 'help' then if not is_momod(msg) or is_realm(msg) then return end savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help") return help() end if matches[1] == 'res' then local cbres_extra = { chatid = msg.to.id } local username = matches[2] local username = username:gsub("@","") resolve_username(username, callbackres, cbres_extra) return end if matches[1] == 'kickinactive' then --send_large_msg('chat#id'..msg.to.id, 'I\'m in matches[1]') if not is_momod(msg) then return 'Only a moderator can kick inactive users' end local num = 1 if matches[2] then num = matches[2] end local chat_id = msg.to.id local receiver = get_receiver(msg) return kick_inactive(chat_id, num, receiver) end end end end local function pre_process(msg) if not msg.text and msg.media then msg.text = '['..msg.media.type..']' end return msg end return { patterns = { "^[#!/](add)$", "^[#!/](add) (realm)$", "^[#!/](rem)$", "^[#!/](rem) (realm)$", "^[#!/](rules)$", "^[#!/](about)$", "^[#!/](setname) (.*)$", "^[#!/](setphoto)$", "^[#!/](promote) (.*)$", "^[#!/](promote)", "^[#!/](help)$", "^[#!/](clean) (.*)$", "^[#!/](kill) (chat)$", "^[#!/](kill) (realm)$", "^[#!/](demote) (.*)$", "^[#!/](demote)", "^[#!/](set) ([^%s]+) (.*)$", "^[#!/](lock) (.*)$", "^[#!/](setowner) (%d+)$", "^[#!/](setowner)", "^[#!/](owner)$", "^[#!/](res) (.*)$", "^[#!/](setgpowner) (%d+) (%d+)$",-- (group id) (owner id) "^[#!/](unlock) (.*)$", "^[#!/](setflood) (%d+)$", "^[#!/](settings)$", "^[#!/](public) (.*)$", "^[#!/](modlist)$", "^[#!/](newlink)$", "^[#!/](link)$", "^[#!/]([Mm]ute) ([^%s]+)$", "^[#!/]([Uu]nmute) ([^%s]+)$", "^[#!/]([Mm]uteuser)$", "^[#!/]([Mm]uteuser) (.*)$", "^[#!/]([Mm]uteslist)$", "^[#!/]([Mm]utelist)$", "^[#!/](kickinactive)$", "^[#!/](kickinactive) (%d+)$", "%[(document)%]", "%[(photo)%]", "%[(video)%]", "%[(audio)%]", "^!!tgservice (.+)$", }, run = run, pre_process = pre_process } end
gpl-2.0
TheAnswer/FirstTest
bin/scripts/creatures/objects/yavin4/creatures/giantMawgax.lua
1
4695
--Copyright (C) 2008 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. giantMawgax = Creature:new { objectName = "giantMawgax", -- Lua Object Name creatureType = "ANIMAL", gender = "", speciesName = "giant_mawgax", stfName = "mob/creature_names", objectCRC = 2940660181, socialGroup = "Mawgax", level = 32, combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG, healthMax = 10500, healthMin = 8600, strength = 0, constitution = 0, actionMax = 10500, actionMin = 8600, quickness = 0, stamina = 0, mindMax = 10500, mindMin = 8600, focus = 0, willpower = 0, height = 1, -- Size of creature armor = 0, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy kinetic = 0, energy = 30, electricity = -1, stun = 0, blast = 0, heat = -1, cold = 30, acid = 0, lightsaber = 0, accuracy = 0, healer = 0, pack = 1, herd = 1, stalker = 0, killer = 0, ferocity = 0, aggressive = 0, invincible = 0, meleeDefense = 1, rangedDefense = 1, attackCreatureOnSight = "", -- Enter socialGroups weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance' weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance' weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon' weaponEquipped = 0, weaponMinDamage = 305, weaponMaxDamage = 320, weaponAttackSpeed = 2, weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx alternateWeaponName = "", -- Name ex. 'a Vibrolance' alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance' alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon' alternateweaponEquipped = 0, alternateWeaponMinDamage = 0, alternateWeaponMaxDamage = 0, alternateWeaponAttackSpeed = 0, alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's lootGroup = "0", -- Group it belongs to for loot tame = 0.2, -- Likely hood to be tamed datapadItemCRC = 10709435, mountCRC = 0, mountSpeed = 0, mountAcceleration = 0, milk = 0, boneType = "bone_avian_yavin4", boneMax = 70, hideType = "hide_leathery_yavin4", hideMax = 85, meatType = "meat_domesticated_yavin4", meatMax = 130, --skills = { " Stun attack", "", "" } skills = { "mawgaxAttack1" }, respawnTimer = 60, behaviorScript = "", -- Link to the behavior script for this object } Creatures:addCreature(giantMawgax, 2940660181) -- Add to Global Table
lgpl-3.0
ludi1991/skynet
service/datacenterd.lua
100
1928
local skynet = require "skynet" local command = {} local database = {} local wait_queue = {} local mode = {} local function query(db, key, ...) if key == nil then return db else return query(db[key], ...) end end function command.QUERY(key, ...) local d = database[key] if d then return query(d, ...) end end local function update(db, key, value, ...) if select("#",...) == 0 then local ret = db[key] db[key] = value return ret, value else if db[key] == nil then db[key] = {} end return update(db[key], value, ...) end end local function wakeup(db, key1, ...) if key1 == nil then return end local q = db[key1] if q == nil then return end if q[mode] == "queue" then db[key1] = nil if select("#", ...) ~= 1 then -- throw error because can't wake up a branch for _,response in ipairs(q) do response(false) end else return q end else -- it's branch return wakeup(q , ...) end end function command.UPDATE(...) local ret, value = update(database, ...) if ret or value == nil then return ret end local q = wakeup(wait_queue, ...) if q then for _, response in ipairs(q) do response(true,value) end end end local function waitfor(db, key1, key2, ...) if key2 == nil then -- push queue local q = db[key1] if q == nil then q = { [mode] = "queue" } db[key1] = q else assert(q[mode] == "queue") end table.insert(q, skynet.response()) else local q = db[key1] if q == nil then q = { [mode] = "branch" } db[key1] = q else assert(q[mode] == "branch") end return waitfor(q, key2, ...) end end skynet.start(function() skynet.dispatch("lua", function (_, _, cmd, ...) if cmd == "WAIT" then local ret = command.QUERY(...) if ret then skynet.ret(skynet.pack(ret)) else waitfor(wait_queue, ...) end else local f = assert(command[cmd]) skynet.ret(skynet.pack(f(...))) end end) end)
mit
TheAnswer/FirstTest
bin/scripts/crafting/objects/draftschematics/armorsmith/personalArmorIvPadded/paddedArmorLeftBicep.lua
1
5220
--Copyright (C) 2009 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. paddedArmorLeftBicep = Object:new { objectName = "Padded Armor Left Bicep", stfName = "armor_padded_s01_bicep_l", stfFile = "wearables_name", objectCRC = 18400770, groupName = "craftArmorPersonalGroupE", -- Group schematic is awarded in (See skills table) craftingToolTab = 2, -- (See DraftSchemticImplementation.h) complexity = 40, size = 4, xpType = "crafting_clothing_armor", xp = 360, assemblySkill = "armor_assembly", experimentingSkill = "armor_experimentation", ingredientTemplateNames = "craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n", ingredientTitleNames = "auxilary_coverage, body, liner, hardware_and_attachments, binding_and_reinforcement, padding, armor, load_bearing_harness, reinforcement", ingredientSlotType = "0, 0, 0, 0, 0, 0, 2, 1, 2", resourceTypes = "hide_leathery_lok, hide_scaley, fiberplast_corellia, metal, petrochem_inert_polymer, hide_wooly, object/tangible/component/armor/shared_armor_segment_padded.iff, object/tangible/component/clothing/shared_synthetic_cloth.iff, object/tangible/component/clothing/shared_reinforced_fiber_panels.iff", resourceQuantities = "40, 40, 20, 25, 25, 30, 1, 2, 1", combineTypes = "0, 0, 0, 0, 0, 0, 1, 1, 1", contribution = "100, 100, 100, 100, 100, 100, 100, 100, 100", numberExperimentalProperties = "1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1", experimentalProperties = "XX, XX, XX, OQ, SR, OQ, SR, OQ, UT, MA, OQ, MA, OQ, MA, OQ, XX, XX, OQ, SR, XX", experimentalWeights = "1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1", experimentalGroupTitles = "null, null, null, exp_durability, exp_quality, exp_durability, exp_durability, exp_durability, exp_durability, null, null, exp_resistance, null", experimentalSubGroupTitles = "null, null, sockets, hit_points, armor_effectiveness, armor_integrity, armor_health_encumbrance, armor_action_encumbrance, armor_mind_encumbrance, armor_rating, armor_special_type, armor_special_effectiveness, armor_special_integrity", experimentalMin = "0, 0, 0, 1000, 1, 18750, 17, 22, 23, 1, 4, 1, 18750", experimentalMax = "0, 0, 0, 1000, 30, 31250, 10, 13, 14, 1, 4, 40, 31250", experimentalPrecision = "0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0", tanoAttributes = "objecttype=261:objectcrc=3710375326:stfFile=wearables_name:stfName=armor_padded_s01_bicep_l:stfDetail=:itemmask=62975:customattributes=specialprotection=blasteffectiveness;vunerability=stuneffectiveness,heateffectiveness,acideffectiveness;armorPiece=259;armorStyle=4121;:", blueFrogAttributes = "", blueFrogEnabled = False, customizationOptions = "/private/index_color_1, /private/index_color_2", customizationDefaults = "117, 159", customizationSkill = "armor_customization" } DraftSchematics:addDraftSchematic(paddedArmorLeftBicep, 18400770)--- Add to global DraftSchematics table
lgpl-3.0
TheAnswer/FirstTest
bin/scripts/creatures/objects/yavin4/creatures/punyGackleBat.lua
1
4696
--Copyright (C) 2008 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. punyGackleBat = Creature:new { objectName = "punyGackleBat", -- Lua Object Name creatureType = "ANIMAL", gender = "", speciesName = "puny_gackle_bat", stfName = "mob/creature_names", objectCRC = 539898393, socialGroup = "Gacklebat", level = 6, combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG + AGGRESSIVE_FLAG, healthMax = 220, healthMin = 180, strength = 0, constitution = 0, actionMax = 220, actionMin = 180, quickness = 0, stamina = 0, mindMax = 220, mindMin = 180, focus = 0, willpower = 0, height = 1, -- Size of creature armor = 0, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy kinetic = 0, energy = 0, electricity = 0, stun = -1, blast = 0, heat = 0, cold = 0, acid = 0, lightsaber = 0, accuracy = 0, healer = 0, pack = 1, herd = 0, stalker = 0, killer = 0, ferocity = 0, aggressive = 1, invincible = 0, meleeDefense = 1, rangedDefense = 1, attackCreatureOnSight = "", -- Enter socialGroups weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance' weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance' weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon' weaponEquipped = 0, weaponMinDamage = 50, weaponMaxDamage = 55, weaponAttackSpeed = 2, weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx alternateWeaponName = "", -- Name ex. 'a Vibrolance' alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance' alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon' alternateweaponEquipped = 0, alternateWeaponMinDamage = 0, alternateWeaponMaxDamage = 0, alternateWeaponAttackSpeed = 0, alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's lootGroup = "0", -- Group it belongs to for loot tame = 0, -- Likely hood to be tamed datapadItemCRC = 0, mountCRC = 0, mountSpeed = 0, mountAcceleration = 0, milk = 0, boneType = "bone_mammal_yavin4", boneMax = 1, hideType = "hide_bristley_yavin4", hideMax = 1, meatType = "meat_carnivore_yavin4", meatMax = 2, --skills = { " Stun attack", "", "" } skills = { "gackleBatAttack3" }, respawnTimer = 60, behaviorScript = "", -- Link to the behavior script for this object } Creatures:addCreature(punyGackleBat, 539898393) -- Add to Global Table
lgpl-3.0
asmagill/hammerspoon
extensions/doc/makeLuaDocs.lua
6
14716
-- -[x] do separate parse of manual text for lua.man and lua.func so manual actually approximates real manual with function defs in chapters -- -[x] instead of converting . to _ in func, create sub tables -- -[x] same for man? No, hs.doc then splits toc into submodules/modules -- -[x] move func to root? -- -[ ] a way to programmatically figure out SkipThese? local http = require("hs.http") local inspect = require("hs.inspect") local timer = require("hs.timer") local json = require("hs.json") local verNum = string.gsub(_VERSION,"Lua ","") local luaDocsBaseURL = "http://www.lua.org/manual/"..verNum.."/" local destinationDocFile = "lua.json" local luaPrefix = "lua" local manualPrefix = luaPrefix.."._man" local functionPrefix = luaPrefix local cAPIPrefix = functionPrefix.."._C" -- Known to be in lists or otherwise problematic local SkipThese = { ["pdf-luaopen_base"] = true, ["pdf-luaopen_package"] = true, ["pdf-luaopen_coroutine"] = true, ["pdf-luaopen_string"] = true, ["pdf-luaopen_utf8"] = true, ["pdf-luaopen_table"] = true, ["pdf-luaopen_math"] = true, ["pdf-luaopen_io"] = true, ["pdf-luaopen_os"] = true, ["pdf-luaopen_debug"] = true, ["pdf-lualib.h"] = true, ["pdf-LUA_MASKCALL"] = true, ["pdf-LUA_MASKRET"] = true, ["pdf-LUA_MASKLINE"] = true, ["pdf-LUA_MASKCOUNT"] = true, ["pdf-io.stdin"] = true, ["pdf-io.stdout"] = true, ["pdf-io.stderr"] = true, ["pdf-LUA_HOOKCALL"] = true, ["pdf-LUA_HOOKRET"] = true, ["pdf-LUA_HOOKTAILCALL"] = true, ["pdf-LUA_HOOKLINE"] = true, ["pdf-LUA_HOOKCOUNT"] = true, ["pdf-LUA_MININTEGER"] = true, ["pdf-LUA_MAXINTEGER"] = true, ["pdf-LUA_OK"] = true, ["pdf-LUA_ERRRUN"] = true, ["pdf-LUA_ERRMEM"] = true, ["pdf-LUA_ERRERR"] = true, ["pdf-LUA_ERRGCMM"] = true, ["pdf-LUA_TNIL"] = true, ["pdf-LUA_TNUMBER"] = true, ["pdf-LUA_TBOOLEAN"] = true, ["pdf-LUA_TSTRING"] = true, ["pdf-LUA_TTABLE"] = true, ["pdf-LUA_TFUNCTION"] = true, ["pdf-LUA_TUSERDATA"] = true, ["pdf-LUA_TTHREAD"] = true, ["pdf-LUA_TLIGHTUSERDATA"] = true, ["pdf-LUA_OPADD"] = true, ["pdf-LUA_OPSUB"] = true, ["pdf-LUA_OPMUL"] = true, ["pdf-LUA_OPDIV"] = true, ["pdf-LUA_OPIDIV"] = true, ["pdf-LUA_OPMOD"] = true, ["pdf-LUA_OPPOW"] = true, ["pdf-LUA_OPUNM"] = true, ["pdf-LUA_OPBNOT"] = true, ["pdf-LUA_OPBAND"] = true, ["pdf-LUA_OPBOR"] = true, ["pdf-LUA_OPBXOR"] = true, ["pdf-LUA_OPSHL"] = true, ["pdf-LUA_OPSHR"] = true, ["pdf-LUA_OPEQ"] = true, ["pdf-LUA_OPLT"] = true, ["pdf-LUA_OPLE"] = true, ["pdf-LUA_ERRSYNTAX"] = true, ["pdf-LUA_RIDX_MAINTHREAD"] = true, ["pdf-LUA_RIDX_GLOBALS"] = true, ["pdf-LUAL_BUFFERSIZE"] = true, ["pdf-LUA_CPATH"] = true, ["pdf-LUA_CPATH_5_3"] = true, ["pdf-LUA_ERRFILE"] = true, ["pdf-LUA_INIT"] = true, ["pdf-LUA_INIT_5_3"] = true, ["pdf-LUA_MINSTACK"] = true, ["pdf-LUA_MULTRET"] = true, ["pdf-LUA_NOREF"] = true, ["pdf-LUA_PATH"] = true, ["pdf-LUA_PATH_5_3"] = true, ["pdf-LUA_REFNIL"] = true, ["pdf-LUA_REGISTRYINDEX"] = true, ["pdf-LUA_TNONE"] = true, ["pdf-LUA_USE_APICHECK"] = true, ["pdf-LUA_YIELD"] = true, } local LuaContents = nil local LuaManual = nil local StripHTML = function(inString, showHR) showHR = showHR or false return inString:gsub("<([^>]+)>", function(c) local d = c:lower() if d == "code" or d == "/code" then return "`" elseif d == "li" then return " * " elseif d == "br" then return "\n" elseif d == "p" then return "\n" elseif d:match("^/?pre") then return "\n~~~\n" elseif d:match("^/?h%d+") then return "\n\n" elseif d == "hr" and showHR then return "\n\n"..string.rep("-",80).."\n\n" else return "" end end) end print("++ Initiating requests for "..luaDocsBaseURL.." and "..luaDocsBaseURL.."manual.html") -- Issue a request for the contents page and for the manual page http.asyncGet(luaDocsBaseURL,nil,function(rc, data, headers) if rc == 200 then LuaContents = data else if rc < 0 then print("++ Request failure for Contents:", rc, data) else print("++ Unable to retrieve Contents:", rc, data, inspect(headers)) end LuaContents = false end end) http.asyncGet(luaDocsBaseURL.."manual.html",nil,function(rc, data, headers) if rc == 200 then LuaManual = data else if rc < 0 then print("++ Request failure for Manual:", rc, data) else print("++ Unable to retrieve Manual:", rc, data, inspect(headers)) end LuaManual = false end end) -- Wait until requests are done and then parse them local waitForIt waitForIt = timer.new(2, function() -- If we're not done yet, wait for another go around... if type(LuaContents) == "nil" or type(LuaManual) == "nil" then return end -- Since both are not nil, we've got our data... no need to recheck again. waitForIt:stop() -- If either is false, then we failed to get the data we need. if not (LuaContents and LuaManual) then print("++ Unable to parse manual due to request failure.") return end print("++ Parsing manual...") -- Ok... parse away... -- Identify keys from the table of contents local Keys -- comment out for debugging purposes Keys = {} for k,v in LuaContents:gmatch("<[aA][^\r\n]*%s+[hH][rR][eE][fF]%s*=%s*\"manual.html#([^\">]+)\"[^\r\n]*>([^<]+)</[aA][^\r\n]*>") do if not SkipThese[k] then if Keys[k] then table.insert(Keys[k].labels, v) else Keys[k] = {labels = {(http.convertHtmlEntities(v))}} end end end -- Introduction not marked as a target tag, so force it. if not Keys["1"] then Keys["1"] = { labels = {"1 – Introduction" }} end -- Trick builtin cleanup code into pasting Section 4's text into the c-api submodule section table.insert(Keys["4"].labels, "capi") -- Get manual version first -- first pass we ignore keys that aren't numbers local a = 1 local b, k local text, posTable = nil, nil while a < LuaManual:len() do a, b, k = LuaManual:find("[\r\n][^\r\n]*<[aA][^\r\n]*%s+[nN][aA][mM][eE]%s*=%s*\"([%d%.]+)\"[^\r\n]*>", a) if not a then a = LuaManual:len() else if Keys[k] then if posTable then table.insert(posTable, a - 1) local actualText, _ = StripHTML(LuaManual:sub(posTable[1], posTable[2]), true) table.insert(text, (http.convertHtmlEntities(actualText))) end posTable = {a} text = {} Keys[k].manpos = posTable Keys[k].mantext = text --else -- if not SkipThese[k] then print("++ No key found for '"..k.."', skipping...") end end a = b + 1 end end if not next(text) then table.insert(posTable, LuaManual:len() - 1) local actualText, _ = StripHTML(LuaManual:sub(posTable[1], posTable[2]), true) table.insert(text, (http.convertHtmlEntities(actualText))) end -- Get function version -- this pass we capture for all keys that were found in the contents -- This time we'll also post about keys from the Text that weren't found in the contents... probably -- ignorable, as they're likely links within the manual itself to lists already included in a manual section, -- but post them just in case I need to look for them later if the format changes. a = 1 text, posTable = nil, nil while a < LuaManual:len() do a, b, k = LuaManual:find("[\r\n][^\r\n]*<[aA][^\r\n>]*%s+[nN][aA][mM][eE]%s*=%s*\"([^\r\n\">]+)\"[^\r\n>]*>", a) if not a then a = LuaManual:len() else if Keys[k] then if posTable then table.insert(posTable, a - 1) local actualText, _ = StripHTML(LuaManual:sub(posTable[1], posTable[2])) table.insert(text, (http.convertHtmlEntities(actualText))) end posTable = {a} text = {} Keys[k].funcpos = {func = posTable} Keys[k].functext = text else if not SkipThese[k] then print("++ No key found for '"..k.."', probably safe...") end end a = b + 1 end end if not next(text) then table.insert(posTable, LuaManual:len() - 1) local actualText, _ = StripHTML(LuaManual:sub(posTable[1], posTable[2])) table.insert(text, (http.convertHtmlEntities(actualText))) end -- Turn into JSON for hs.doc local docRoots -- comment out for debugging purposes docRoots = { manual = { name = manualPrefix, desc = _VERSION.." manual", doc = "Select a section from the ".._VERSION.." manual by prefacing it's number with and replacing all periods with an '_'; e.g. Section 6.4 would be _6_4.", items = {} }, capi = { name = cAPIPrefix, desc = _VERSION.." C API", doc = "C API for external library integration.", items = {} }, builtin = { name = luaPrefix, desc = _VERSION.." Documentation", doc = [[ Built in ]].._VERSION..[[ functions and variables. The text for this documentation is originally from ]]..luaDocsBaseURL..[[ but has been programmatically parsed and rearranged for use with the Hammerspoon internal documentation system. Any errors, mistakes, or omissions are likely the result of this processing and is in no way a reflection on Lua.org or their work. If in doubt about anything presented in this lua section of the Hammerspoon documentation, please check the above web site for the authoritative answer. ]], items = {} }, } for i,v in pairs(Keys) do for _,bb in ipairs(v.labels) do local destItems, itemDef, theText if bb:match("^%d+") then -- part of the manual destItems = docRoots.manual.items itemDef = { type="manual", name = "_"..i:gsub("%.","_"), def = bb, } if v.mantext then theText = v.mantext[1] end else if bb:match("^_") then -- builtin variable destItems = docRoots.builtin.items itemDef = { type="builtin", name = bb, def = bb, } if v.functext then theText = v.functext[1] end elseif bb:match("_") then -- part of the capi destItems = docRoots.capi.items itemDef = { type="c-api", name = bb, def = bb, } if v.functext then theText = v.functext[1] end elseif bb:match("[%.:]") then -- builtin two part function local myRoot, myLabel = bb:match("^([^%.:]+)[%.:]([^%.:]+)$") if not docRoots[myRoot] then docRoots[myRoot] = { name = functionPrefix.."."..myRoot, desc = myRoot, doc = "", items = {}, } end destItems = docRoots[myRoot].items itemDef = { type="builtin", name = myLabel, def = bb, } if v.functext then theText = v.functext[1] end else -- builtin single part function destItems = docRoots.builtin.items itemDef = { type="builtin", name = bb, def = bb, } if v.functext then theText = v.functext[1] end end end if v.mantext or v.functext then itemDef.doc = theText:gsub("([^\r\n~])[\r\n]([^%s\r\n~])","%1 %2") -- join short lines :gsub("[\r\n][\r\n][\r\n]+","\n\n") -- reduce bunches of newlines :gsub("^[\r\n]+",""):gsub("[\r\n]+$","") -- string beginning and ending newlines table.insert(destItems, itemDef) else print("++ No text found for '"..bb.."', probably an error") end end end -- check builtins to see if they match a subgroup, because we need to remove them from builtin... local removeBuiltinItems = {} for i,v in ipairs(docRoots.builtin.items) do if docRoots[v.name] then docRoots[v.name].doc = v.doc table.insert(removeBuiltinItems, i) end end for i = #removeBuiltinItems, 1, -1 do table.remove(docRoots.builtin.items, removeBuiltinItems[i]) end -- flatten so it matches the expected doc format. local documentFormatArray -- comment out for debugging purposes documentFormatArray = {} for _,v in pairs(docRoots) do table.insert(documentFormatArray, v) end -- Sort, because hs.doc is stupid about overwriting previously created subtables. -- I know, I know... I ported/modified the %^$^%$& thing myself to make it work with Hammerspoon, -- so I've no one to blame but, well, myself... I'll get around to it. table.sort(documentFormatArray, function(m,n) return m.name < n.name end) local f = io.open(destinationDocFile,"w") f:write(json.encode(documentFormatArray)) f:close() print("++ Lua manual saved as "..destinationDocFile) end):start()
mit
LuaDist/sputnik_tickets
lua/sputnik/node_defaults/icons/edit-faded.lua
1
1292
----------------------------------------------------------------------------- -- An icon for editing the node (a faded version). -- -- Image (c) Mark James (http://famfamfam.com), 2008 -- Creative Commons Attribution 2.5 License. ----------------------------------------------------------------------------- module(..., package.seeall) NODE = { prototype = "@Binary_File", file_name = "faded_edit.png", copyright = "Mark James (http://famfamfam.com)", title = "Faded Edit Icon", actions = [[png = "binaryfile.mimetype"]], file_type = "image/png", } NODE.content = [[ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/ wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9gHBAMwDNtNuyQAAAGKSURBVHjapZ M7SxxhFIaf8407rqurjFcCMSxEiyCxEnFtgmAqCwVJEUgVK7tUpsv2Vjb5B0mRJmlSBBQvYGKIBBW NyBauOoUTnbizshd1nf0sxG0k8oGnfp/3XDivaK25T9WYCtcXp+skdPZLhbAlrGglKrcXjdQMGhvo 0ClaViM9yQFEhI3vXxJBtvBeTFZYX5zWDxPD1MYclLrueVk+Y/vXXEWZwI97X6BshZtepZg7opg7A kCUdXHnBDewlhKBt41ULP66WerjDoHvkRydFGUCZ71NLs59ok4zDXGbwvE+ydFJAVAmcPk8S1P7E/ 5lXPLHPn1jb+RGe8tg9lPKGL5l8O3jO9039MoYBhCtNR9mphKtbdFMT/84h+4mHQ8iRnD1E0NLZwa ev8aO2PxZOSAfQMejbnbXtjg7zfPs5Vv537GrK0SUxeHWEp2tTZS9HDvLP/E9/064OsGuG5D+PU9n 91PqNfilCpfBCSMTKTEO09eFH3Sld2iMRbHjsc8jE6lxk4zIfeN8BbUFz278GInXAAAAAElFTkSuQ mCC ]]
mit
devilrap97/alirap97
plugins/en-sticker.lua
5
1612
--[[ ▀▄ ▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀ ▀▄ ▄▀ ▀▄ ▄▀ ▀▄ ▄▀ BY SAJJAD NOORI ▀▄ ▄▀ ▀▄ ▄▀ BY SAJAD NOORI (@SAJJADNOORI) ▀▄ ▄▀ ▀▄ ▄▀ JUST WRITED BY SAJJAD NOORI ▀▄ ▄▀ ▀▄ ▄▀ sticker : تحويل ملصق ▀▄ ▄▀ ▀▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀ --]] local function tosticker(msg, success, result) local receiver = get_receiver(msg) if success then local file = 'sticker'..msg.from.id..'.webp' print('File downloaded to:', result) os.rename(result, file) print('File moved to:', file) send_document(get_receiver(msg), file, ok_cb, false) redis:del("photo:sticker") else print('Error downloading: '..msg.id) send_large_msg(receiver, 'Failed, please try again!', ok_cb, false) end end local function run(msg,matches) local receiver = get_receiver(msg) local group = msg.to.id if msg.reply_id then if msg.to.type == 'photo' and redis:get("photo:sticker") then if redis:set("photo:sticker", "waiting") then end end if matches[1] == "sticker" then redis:get("photo:sticker") load_photo(msg.reply_id, tosticker, msg) end end end return { patterns = { "^(sticker)$", "%[(photo)%]", }, run = run, }
gpl-2.0
fkaa/iceball
pkg/iceball/mapedit/main_client.lua
2
15781
--[[ This file is part of Ice Lua Components. Ice Lua Components is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Ice Lua Components is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Ice Lua Components. If not, see <http://www.gnu.org/licenses/>. ]] print("Starting map editor...") screen_width, screen_height = client.screen_get_dims() map_loaded = nil fname = nil do args = {...} if #args == 3 or #args == 4 then xlen, ylen, zlen = 0+args[1], 0+args[2], 0+args[3] fname = args[4] or "clsave/vol/newmap.icemap" map_loaded = common.map_new(xlen, ylen, zlen) elseif #args == 1 or #args == 2 then fname = args[1] map_loaded = common.map_load(fname) fname = args[2] or fname elseif #args == 0 then menu_main = {title="Main Menu", sel=2, "New Map", "Load Map"} menu_select = {title="Select Save Slot", sel=1, 0,1,2,3,4,5,6,7,8,9} menu_size_xlen = {title="Select Horiz Length", sel=3, 128, 256, 512} menu_size_zlen = {title="Select Vert Length", sel=3, 128, 256, 512} menu_size_ylen = {title="Select Height", sel=8, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128} menu_current = nil local function set_menu(menu) menu_current = menu menu_current.sel = menu_current.sel or 1 end local function handle_menu() local menu = menu_current if menu == menu_main then set_menu(menu_select) elseif menu == menu_select then fname = "clsave/vol/save"..menu_select[menu_select.sel]..".icemap" if menu_main.sel == 1 then set_menu(menu_size_xlen) else map_loaded = common.map_load(fname) initiate_everything() end elseif menu == menu_size_xlen then set_menu(menu_size_zlen) elseif menu == menu_size_zlen then set_menu(menu_size_ylen) elseif menu == menu_size_ylen then xlen = menu_size_xlen[menu_size_xlen.sel] ylen = menu_size_ylen[menu_size_ylen.sel] zlen = menu_size_zlen[menu_size_zlen.sel] map_loaded = common.map_new(xlen, ylen, zlen) initiate_everything() else error("menu doesn't have a handler!") end end set_menu(menu_main) function client.hook_tick(sec_current, sec_delta) return 0.001 end function client.hook_render() local i, s s = menu_current.title font_mini.print(math.floor((screen_width-6*#s)/2), math.floor(screen_height/2-12), 0xFF000000, s) for i=1,#menu_current do s = ""..menu_current[i] if menu_current.sel == i then s = "> "..s.." <" end font_mini.print(math.floor((screen_width-6*#s)/2), math.floor(screen_height/2+(i-1)*6), 0xFF000000, s) end end function client.hook_key(key, state, modif) if state then if key == SDLK_UP then menu_current.sel = menu_current.sel - 1 if menu_current.sel < 1 then menu_current.sel = #menu_current end elseif key == SDLK_DOWN then menu_current.sel = menu_current.sel + 1 if menu_current.sel > #menu_current then menu_current.sel = 1 end elseif key == SDLK_RETURN then handle_menu() end else if key == SDLK_ESCAPE then client.hook_tick = nil end end end else print("usage:") print(" iceball -l pkg/iceball/mapedit loadmap.vxl/icemap savemap.icemap") print(" iceball -l pkg/iceball/mapedit loadandsavemap.icemap") print(" iceball -l pkg/iceball/mapedit xlen ylen zlen savemap.icemap") error("check stdout for usage!") end end dofile("pkg/base/preconf.lua") dofile("pkg/base/lib_bits.lua") dofile("pkg/base/lib_gui.lua") dofile("pkg/base/lib_sdlkey.lua") dofile("pkg/base/lib_map.lua") dofile("pkg/base/lib_util.lua") dofile("pkg/base/lib_vector.lua") function initiate_everything() -- *** START INITIATION FUNCTION *** -- common.map_set(map_loaded) client.map_fog_set(192, 238, 255, 1000) xlen, ylen, zlen = common.map_get_dims() mdl_test = client.model_load_pmf("pkg/base/pmf/test.pmf") mdl_test_bone = client.model_bone_find(mdl_test, "test") ev_mf = false ev_mb = false ev_ml = false ev_mr = false ev_mu = false ev_md = false ev_spd = false ev_snk = false TOOL_MCPAIR = 1 TOOL_SELECT = 2 TOOL_PAINT = 3 lastmx,lastmy = 0,0 camx, camy, camz = xlen/2+0.5, 0.5, zlen/2+0.5 camrx, camry = 0, 0 colr, colg, colb = 128, 128, 128 colt = 1 -- TODO: not hardcode the width/height cpstartx, cpstarty = math.floor((800-768)/2), math.floor((600-512)/2) selx1,sely1,selz1 = nil,nil,nil selx2,sely2,selz2 = nil,nil,nil tool = TOOL_MCPAIR released = false cpick = false cpaint = false client.mouse_lock_set(true) client.mouse_visible_set(false) function color_pick(x,y) local r = math.floor(255*(math.sin(x*math.pi/384)+1)/2) local g = math.floor(255*(math.sin(x*math.pi/384+2*math.pi/3)+1)/2) local b = math.floor(255*(math.sin(x*math.pi/384+4*math.pi/3)+1)/2) if y < 256 then local h = (255-y)/255 return math.floor(r*(1-h)+255*h), math.floor(g*(1-h)+255*h), math.floor(b*(1-h)+255*h) else local h = (255-(y-256))/255 return math.floor(r*h), math.floor(g*h), math.floor(b*h) end end function tool_getname() if tool == TOOL_MCPAIR then return "Minecraft" elseif tool == TOOL_SELECT then return "Select" elseif tool == TOOL_PAINT then return "Paint" else return "???" end end function cam_calc_fw() local sya = math.sin(camry) local cya = math.cos(camry) local sxa = math.sin(camrx) local cxa = math.cos(camrx) return sya*cxa, sxa, cya*cxa end function client.hook_key(key, state, modif) if key == SDLK_w and bit_and(modif,KMOD_LALT) == 0 then ev_mf = state elseif key == SDLK_s and bit_and(modif,KMOD_LALT) == 0 then ev_mb = state elseif key == SDLK_a and bit_and(modif,KMOD_LALT) == 0 then ev_ml = state elseif key == SDLK_d and bit_and(modif,KMOD_LALT) == 0 then ev_mr = state elseif key == SDLK_SPACE then ev_mu = state elseif key == SDLK_LCTRL then ev_md = state elseif key == SDLK_LSHIFT then ev_spd = state elseif key == SDLK_v and bit_and(modif,KMOD_LALT) == 0 then ev_snk = state elseif key == SDLK_1 then tool = TOOL_MCPAIR elseif key == SDLK_2 then tool = TOOL_SELECT elseif key == SDLK_3 then tool = TOOL_PAINT elseif state then if key == SDLK_F5 then released = true client.mouse_lock_set(false) client.mouse_visible_set(true) elseif key == SDLK_TAB then cpick = true released = true client.mouse_lock_set(false) client.mouse_visible_set(true) elseif key == SDLK_LEFTBRACKET then colt = colt - 1 if colt < 1 then colt = 1 end elseif key == SDLK_RIGHTBRACKET then colt = colt + 1 if colt > 255 then colt = 255 end elseif key == SDLK_INSERT then if selx1 and selx2 then local x,y,z for x=math.min(selx1,selx2),math.max(selx1,selx2) do for y=math.min(sely1,sely2),math.max(sely1,sely2) do for z=math.min(selz1,selz2),math.max(selz1,selz2) do map_block_set(x,y,z,colt,colr,colg,colb) end end end end elseif key == SDLK_DELETE then if selx1 and selx2 then local x,y,z for x=math.min(selx1,selx2),math.max(selx1,selx2) do for y=math.min(sely1,sely2),math.max(sely1,sely2) do for z=math.min(selz1,selz2),math.max(selz1,selz2) do map_block_delete(x,y,z) end end end end elseif key == SDLK_p and bit_and(modif,KMOD_LALT) == 0 then if selx1 and selx2 then local x,y,z for x=math.min(selx1,selx2),math.max(selx1,selx2) do for y=math.min(sely1,sely2),math.max(sely1,sely2) do for z=math.min(selz1,selz2),math.max(selz1,selz2) do if map_block_get(x,y,z) then map_block_paint(x,y,z,colt,colr,colg,colb) end end end end end elseif bit_and(modif,KMOD_LALT) ~= 0 then if not(selx1 and selx2) then ---------------- -- do nothing -- ---------------- elseif key == SDLK_s then local cpx,cpy,cpz cpx,cpy,cpz = cam_calc_fw() local gx,gy,gz gx, gy, gz = 0, 0, 0 if math.abs(cpx) > math.abs(cpy) and math.abs(cpx) > math.abs(cpz) then gx = (cpx < 0 and -1) or 1 elseif math.abs(cpy) > math.abs(cpx) and math.abs(cpy) > math.abs(cpz) then gy = (cpy < 0 and -1) or 1 else gz = (cpz < 0 and -1) or 1 end gx = gx * (math.abs(selx1-selx2)+1) gy = gy * (math.abs(sely1-sely2)+1) gz = gz * (math.abs(selz1-selz2)+1) local x,y,z for x=math.min(selx1,selx2),math.max(selx1,selx2) do for y=math.min(sely1,sely2),math.max(sely1,sely2) do for z=math.min(selz1,selz2),math.max(selz1,selz2) do local l = map_block_get(x,y,z) if l then map_block_set(x+gx,y+gy,z+gz,l[1],l[2],l[3],l[4]) elseif l == false then map_block_aerate(x+gx,y+gy,z+gz) else map_block_delete(x+gx,y+gy,z+gz) end end end end selx1 = selx1 + gx sely1 = sely1 + gy selz1 = selz1 + gz selx2 = selx2 + gx sely2 = sely2 + gy selz2 = selz2 + gz elseif key == SDLK_a then local cpx,cpy,cpz cpx,cpy,cpz = cam_calc_fw() local gx,gy,gz gx, gy, gz = 0, 0, 0 if math.abs(cpx) > math.abs(cpy) and math.abs(cpx) > math.abs(cpz) then gx = (cpx < 0 and -1) or 1 elseif math.abs(cpy) > math.abs(cpx) and math.abs(cpy) > math.abs(cpz) then gy = (cpy < 0 and -1) or 1 else gz = (cpz < 0 and -1) or 1 end gx = gx * (math.abs(selx1-selx2)+1) gy = gy * (math.abs(sely1-sely2)+1) gz = gz * (math.abs(selz1-selz2)+1) local x,y,z for x=math.min(selx1,selx2),math.max(selx1,selx2) do for y=math.min(sely1,sely2),math.max(sely1,sely2) do for z=math.min(selz1,selz2),math.max(selz1,selz2) do local l = map_block_get(x,y,z) if l then map_block_set(x+gx,y+gy,z+gz,l[1],l[2],l[3],l[4]) elseif l == false then map_block_aerate(x+gx,y+gy,z+gz) end end end end selx1 = selx1 + gx sely1 = sely1 + gy selz1 = selz1 + gz selx2 = selx2 + gx sely2 = sely2 + gy selz2 = selz2 + gz end end else if key == SDLK_ESCAPE then if cpick then client.mouse_lock_set(true) client.mouse_visible_set(false) released = false cpick = false else client.hook_tick = nil end elseif key == SDLK_F10 then common.map_save(map_loaded, fname) print("map saved to: "..fname) end end end function client.hook_mouse_button(button, state) if released then if not state then client.mouse_lock_set(true) client.mouse_visible_set(false) released = false cpick = false elseif cpick then cpick = 2 end return end if state then if button == 1 and tool == TOOL_MCPAIR then -- Minecraft tool: LMB - BREAK if trx2 then map_block_delete(trx2,try2,trz2) end elseif button == 1 and tool == TOOL_SELECT then -- Select tool: LMB - corner 1 if trx2 then selx1,sely1,selz1 = trx2,try2,trz2 end elseif button == 3 and tool == TOOL_MCPAIR then -- Minecraft tool: RMB - BUILD if trx1 then -- TODO: allow setting the type map_block_set(trx1,try1,trz1,colt,colr,colg,colb) end elseif button == 3 and tool == TOOL_PAINT then -- Paint tool: RMB - PAINT if trx2 then map_block_paint(trx2,try2,trz2,colt,colr,colg,colb) end paintx,painty,paintz = trx2,try2,trz2 cpaint = true elseif button == 3 and tool == TOOL_SELECT then -- Select tool: LMB - corner 2 if trx2 then selx2,sely2,selz2 = trx2,try2,trz2 end elseif button == 2 and (tool == TOOL_MCPAIR or tool == TOOL_PAINT) then -- Minecraft / Paint tool: MMB - PICK if trx2 then -- TODO: allow setting the type local l = map_block_get(trx2,try2,trz2) colr,colg,colb = l[2],l[3],l[4] colt = l[1] end end else if button == 3 and tool == TOOL_PAINT then -- Paint tool: RMB - PAINT cpaint = false end end end function client.hook_mouse_motion(x, y, dx, dy) if released then if cpick == 2 then if x >= cpstartx and y >= cpstarty and x < cpstartx+768 and y < cpstarty+512 then colr, colg, colb = color_pick(x-cpstartx,y-cpstarty) end end return end camry = camry - dx*math.pi/200.0 camrx = camrx + dy*math.pi/200.0 end trx1,try1,trz1 = nil, nil, nil trx2,try2,trz2 = nil, nil, nil trd = nil function client.hook_tick(sec_current, sec_delta) -- update camera if camrx > math.pi*0.499 then camrx = math.pi*0.499 elseif camrx < -math.pi*0.499 then camrx = -math.pi*0.499 end local cvx,cvy,cvz cvx,cvy,cvz = 0,0,0 if ev_mf then cvz = cvz + 1 end if ev_mb then cvz = cvz - 1 end if ev_ml then cvx = cvx - 1 end if ev_mr then cvx = cvx + 1 end if ev_mu then cvy = cvy - 1 end if ev_md then cvy = cvy + 1 end local cpx,cpy,cpz local cd2 cpx,cpy,cpz = cam_calc_fw() cd2 = math.sqrt(cpx*cpx+cpz*cpz) cvx = cvx / cd2 local cspd = sec_delta * 10.0 if ev_spd then cspd = cspd * 3 end if ev_snk then cspd = cspd / 3 end camx = camx + cspd*(cvz*cpx-cvx*cpz) camz = camz + cspd*(cvz*cpz+cvx*cpx) camy = camy + cspd*(cvz*cpy+cvy) camx = math.min(math.max(0.5, camx), xlen-0.5) camy = math.min(camy, ylen-0.5) camz = math.min(math.max(0.5, camz), zlen-0.5) client.camera_point(cpx,cpy,cpz) client.camera_move_to(camx,camy,camz) -- do a trace trd, trx1,try1,trz1, trx2,try2,trz2 = trace_map_ray_dist(camx,camy,camz, cpx,cpy,cpz, 10) -- paint if necessary if cpaint and trx2 then if paintx ~= trx2 or painty ~= try2 or paintz ~= trz2 then map_block_paint(trx2,try2,trz2,colt,colr,colg,colb) paintx,painty,paintz = trx2,try2,trz2 end end return 0.001 end function client.hook_render() local sw,sh sw,sh = client.screen_get_dims() local s s = string.format("EDITOR: %d %d %d - tool = %s" ,camx,camy,camz ,tool_getname()) font_mini.print(3, 3, 0xFF000000, s) font_mini.print(2, 2, 0xFFFFFFFF, s) s = string.format("COLOUR %d %d %d (#%02X%02X%02X)" ,colr,colg,colb ,colr,colg,colb) font_mini.print(sw-(2+6*#s), 2, argb_split_to_merged(colr, colg, colb, 255), s) s = string.format("Select: %d %d %d -> %d %d %d" ,selx1 or -1,sely1 or -1,selz1 or -1 ,selx2 or -1,sely2 or -1,selz2 or -1) font_mini.print(sw-(2+6*#s)+1, 19, 0xFF000000, s) font_mini.print(sw-(2+6*#s), 18, 0xFFFFFFFF, s) s = string.format("Type = %d (%02X)" ,colt,colt) font_mini.print(sw-(2+6*#s)+1, 11, 0xFF000000, s) font_mini.print(sw-(2+6*#s), 10, 0xFFFFFFFF, s) if trx2 then s = string.format("point %d %d %d" ,trx2,try2,trz2) font_mini.print(3, 11, 0xFF000000, s) font_mini.print(2, 10, 0xFFFFFFFF, s) end if trx1 then client.model_render_bone_global(mdl_test, mdl_test_bone , trx1+0.5, try1+0.5, trz1+0.5 , 0, 0, 0, 0.3) end if tool == TOOL_SELECT then if selx1 then client.model_render_bone_global(mdl_test, mdl_test_bone , selx1+0.5, sely1+0.5, selz1+0.5 , 0, 0, 0, 1) end if selx2 then client.model_render_bone_global(mdl_test, mdl_test_bone , selx2+0.5, sely2+0.5, selz2+0.5 , 0, 0, 0, 1) end end if cpick then client.img_blit(img_palette, cpstartx, cpstarty) end end img_palette = common.img_new(768,512) do local x,y print("Generating colour pick image") for x=0,767 do for y=0,511 do local h = (255-y)/255 local r,g,b r,g,b = color_pick(x,y) common.img_pixel_set(img_palette, x, y, argb_split_to_merged(r, g, b, 255)) end end print("Done") end -- *** END INITIATION FUNCTION *** -- end if map_loaded then initiate_everything() end print("Loaded map editor.")
gpl-3.0
TheAnswer/FirstTest
bin/scripts/items/objects/weapons/polearm/staffWoodS1Polearm.lua
1
2468
--Copyright (C) 2007 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. staffWoodS1Polearm = Weapon:new{ objectName = "Wooden Staff", templateName = "object/weapon/melee/polearm/shared_lance_staff_wood_s1.iff", objectCRC = 1200142292, objectType = POLEARM, damageType = WEAPON_KINETIC, certification = "cert_lance_staff_wood_s1", --"cert_lance_staff_wood_s2", attackSpeed = 4.75, minDamage = 35, maxDamage = 80 }
lgpl-3.0
Modified-MW-DF/modified-MDF
MWDF Project/Dwarf Fortress/hack/scripts/masterwork/base/on-time.lua
2
4614
--base/on-time.lua v1.0 local persistTable = require 'persist-table' roses = persistTable.GlobalTable.roses if not roses then return end yearly = {} season = {} monthly = {} weekly = {} daily = {} -- CivilizationTable Checks if roses.CivilizationTable and roses.EntityTable then for _,id in pairs(roses.EntityTable._children) do entityTable = roses.EntityTable[id] if entityTable.Civilization then method = entityTable.Civilization.CurrentMethod if method == 'YEARLY' then yearly[id] = 'CIVILZATION' elseif method == 'SEASON' then season[id] = 'CIVILZATION' elseif method == 'MONTHLY' then monthly[id] = 'CIVILZATION' elseif method == 'WEEKLY' then weekly[id] = 'CIVILZATION' elseif method == 'DAILY' then daily[id] = 'CIVILZATION' else season[id] = 'CIVILIZATION' end end end end -- EventTable Checks if roses.EventTable then for _,id in pairs(roses.EventTable._children) do event = roses.EventTable[id] method = event.Check if method == 'YEARLY' then yearly[id] = 'EVENT' elseif method == 'SEASON' then season[id] = 'EVENT' elseif method == 'MONTHLY' then monthly[id] = 'EVENT' elseif method == 'WEEKLY' then weekly[id] = 'EVENT' elseif method == 'DAILY' then daily[id] = 'EVENT' else season[id] = 'EVENT' end end end for id,Type in pairs(yearly) do curtick = df.global.cur_year_tick ticks = 1200*28*3*4-curtick if ticks <= 0 then ticks = 1200*28*3*4 end if Type == 'CIVILIZATION' then dfhack.timeout(ticks+1,'ticks',function () dfhack.script_environment('functions/civilization').checkEntity(id,'YEARLY',true) end ) elseif Type == 'EVENT' then dfhack.timeout(ticks+1,'ticks',function () dfhack.script_environment('functions/event').checkEvent(id,'YEARLY',true) end ) end end for id,Type in pairs(season) do curtick = df.global.cur_season_tick*10 ticks = 1200*28*3-curtick if ticks <= 0 then ticks = 1200*28*3 end if Type == 'CIVILIZATION' then dfhack.timeout(ticks+1,'ticks',function () dfhack.script_environment('functions/civilization').checkEntity(id,'SEASON',true) end ) elseif Type == 'EVENT' then dfhack.timeout(ticks+1,'ticks',function () dfhack.script_environment('functions/event').checkEvent(id,'SEASON',true) end ) end end for id,Type in pairs(monthly) do curtick = df.global.cur_year_tick moy = curtick/(1200*28) ticks = math.ceil(moy)*1200*28 - curtick if Type == 'CIVILIZATION' then dfhack.timeout(ticks+1,'ticks',function () dfhack.script_environment('functions/civilization').checkEntity(id,'MONTHLY',true) end ) elseif Type == 'EVENT' then dfhack.timeout(ticks+1,'ticks',function () dfhack.script_environment('functions/event').checkEvent(id,'MONTHLY',true) end ) end end for id,Type in pairs(weekly) do curtick = df.global.cur_year_tick woy = curtick/(1200*7) ticks = math.ceil(woy)*1200*7 - curtick if Type == 'CIVILIZATION' then dfhack.timeout(ticks+1,'ticks',function () dfhack.script_environment('functions/civilization').checkEntity(id,'WEEKLY',true) end ) elseif Type == 'EVENT' then dfhack.timeout(ticks+1,'ticks',function () dfhack.script_environment('functions/event').checkEvent(id,'WEEKLY',true) end ) end end for id,Type in pairs(daily) do curtick = df.global.cur_year_tick doy = curtick/1200 ticks = math.ceil(doy)*1200 - curtick if Type == 'CIVILIZATION' then dfhack.timeout(ticks+1,'ticks',function () dfhack.script_environment('functions/civilization').checkEntity(id,'DAILY',true) end ) elseif Type == 'EVENT' then dfhack.timeout(ticks+1,'ticks',function () dfhack.script_environment('functions/event').checkEvent(id,'DAILY',true) end ) end end
mit
TheAnswer/FirstTest
bin/scripts/creatures/objects/naboo/creatures/fleshEatingChuba.lua
1
4638
--Copyright (C) 2008 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. fleshEatingChuba = Creature:new { objectName = "fleshEatingChuba", -- Lua Object Name creatureType = "ANIMAL", gender = "", speciesName = "flesh_eating_chuba", stfName = "mob/creature_names", objectCRC = 3129123954, socialGroup = "self", level = 6, combatFlags = ATTACKABLE_FLAG, healthMax = 220, healthMin = 180, strength = 500, constitution = 500, actionMax = 220, actionMin = 180, quickness = 500, stamina = 500, mindMax = 220, mindMin = 180, focus = 500, willpower = 500, height = 1, -- Size of creature armor = 0, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy kinetic = 0, energy = 0, electricity = 0, stun = -1, blast = 0, heat = 0, cold = 0, acid = 0, lightsaber = 0, accuracy = 200, healer = 0, pack = 0, herd = 0, stalker = 0, killer = 0, ferocity = 0, aggressive = 0, invincible = 0, meleeDefense = 1, rangedDefense = 1, attackCreatureOnSight = "", -- Enter socialGroups weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance' weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance' weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon' weaponEquipped = 0, weaponMinDamage = 50, weaponMaxDamage = 55, weaponAttackSpeed = 2, weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx alternateWeaponName = "", -- Name ex. 'a Vibrolance' alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance' alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon' alternateWeaponEquipped = 0, alternateWeaponMinDamage = 0, alternateWeaponMaxDamage = 0, alternateWeaponAttackSpeed = 0, alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's lootGroup = "0", -- Group it belongs to for loot tame = 0.25, -- Likely hood to be tamed datapadItemCRC = 2478782544, mountCRC = 0, mountSpeed = 0, mountAcceleration = 0, milk = 0, boneType = "", boneMax = 20, hideType = "hide_leathery_naboo", hideMax = 3, meatType = "meat_carnivore_naboo", meatMax = 4, skills = { "chubaAttack1" }, respawnTimer = 60, behaviorScript = "", -- Link to the behavior script for this object } Creatures:addCreature(fleshEatingChuba, 3129123954) -- Add to Global Table
lgpl-3.0
weiDDD/WSSParticleSystem
cocos2d/cocos/scripting/lua-bindings/auto/api/MenuItemToggle.lua
1
2157
-------------------------------- -- @module MenuItemToggle -- @extend MenuItem -- @parent_module cc -------------------------------- -- Sets the array that contains the subitems. -- @function [parent=#MenuItemToggle] setSubItems -- @param self -- @param #array_table items -- @return MenuItemToggle#MenuItemToggle self (return value: cc.MenuItemToggle) -------------------------------- -- Gets the index of the selected item. -- @function [parent=#MenuItemToggle] getSelectedIndex -- @param self -- @return unsigned int#unsigned int ret (return value: unsigned int) -------------------------------- -- Add more menu item. -- @function [parent=#MenuItemToggle] addSubItem -- @param self -- @param #cc.MenuItem item -- @return MenuItemToggle#MenuItemToggle self (return value: cc.MenuItemToggle) -------------------------------- -- Return the selected item. -- @function [parent=#MenuItemToggle] getSelectedItem -- @param self -- @return MenuItem#MenuItem ret (return value: cc.MenuItem) -------------------------------- -- Sets the index of the selected item. -- @function [parent=#MenuItemToggle] setSelectedIndex -- @param self -- @param #unsigned int index -- @return MenuItemToggle#MenuItemToggle self (return value: cc.MenuItemToggle) -------------------------------- -- -- @function [parent=#MenuItemToggle] setEnabled -- @param self -- @param #bool var -- @return MenuItemToggle#MenuItemToggle self (return value: cc.MenuItemToggle) -------------------------------- -- -- @function [parent=#MenuItemToggle] activate -- @param self -- @return MenuItemToggle#MenuItemToggle self (return value: cc.MenuItemToggle) -------------------------------- -- -- @function [parent=#MenuItemToggle] unselected -- @param self -- @return MenuItemToggle#MenuItemToggle self (return value: cc.MenuItemToggle) -------------------------------- -- -- @function [parent=#MenuItemToggle] selected -- @param self -- @return MenuItemToggle#MenuItemToggle self (return value: cc.MenuItemToggle) return nil
apache-2.0
GeekWithALife/love-bone
lovebone/skeleton.lua
2
4097
--[[ Skeleton A simple containment data structure for bones, animations, and skins. Actors hold a reference to a skeleton, which defines what animations and skins it can use. --]] local util = RequireLibPart("util"); local newBone = RequireLibPart("bone"); local SKELETON_ROOT_NAME = util.SKELETON_ROOT_NAME; local MSkeleton = util.Meta.Skeleton; MSkeleton.__index = MSkeleton; local function newSkeleton() local skeleton = setmetatable({}, MSkeleton); skeleton.BoneNames = {}; skeleton.Bones = {}; skeleton.Bones[SKELETON_ROOT_NAME] = newBone(); skeleton.RenderOrder = {}; skeleton.Valid = true; return skeleton; end function MSkeleton:IsValid() return self.Valid; end -- Checks all bones to see if parents are valid, and populates children lists. function MSkeleton:Validate() self.Valid = true; for boneName, bone in pairs(self.Bones) do local parentName = bone:GetParent(); if (parentName) then if (not self.Bones[parentName]) then print("Validation failed: Could not find parent '" .. parentName .. "' for bone '" .. boneName .. "'"); self.Valid = false; break; else if (parentName == boneName) then print("Validation failed: Bone '" .. parentName .. "' cannot be its own parent"); self.Valid = false; break; end local parent = self.Bones[parentName]; parent.Children = parent.Children or {}; print("Adding child",boneName,"to",parentName); table.insert(parent.Children, boneName); end elseif (boneName ~= SKELETON_ROOT_NAME) then print("Validation failed: No parent found for bone '" .. boneName .. "'"); self.Valid = false; break; end end if (self.Valid) then self:BuildRenderOrder(); end return self.Valid; end -- Adds a bone to the skeleton. function MSkeleton:SetBone(boneName, boneObj) if (not boneName or type(boneName) ~= "string") then error(util.errorArgs("BadArg", 1, "SetBone", "string", type(boneName))); elseif (not boneObj or not util.isType(boneObj, "Bone")) then error(util.errorArgs("BadMeta", 2, "SetBone", "Bone", tostring(util.Meta.Bone), tostring(getmetatable(boneObj)))); end if (not boneObj:GetParent() and boneName ~= SKELETON_ROOT_NAME) then boneObj:SetParent(SKELETON_ROOT_NAME); end self.Bones[boneName] = boneObj; self.Valid = false; end -- Rebuilds the rendering order of bones based on their current layer. function MSkeleton:BuildRenderOrder() if (not self:IsValid()) then print("Warning: Could not build render order for invalid skeleton!"); return; end self.RenderOrder = {}; for boneName, bone in pairs(self.Bones) do local i = 1; for _, v in pairs(self.RenderOrder) do if (self.Bones[v]:GetLayer() <= bone:GetLayer()) then i = i + 1; end end table.insert(self.RenderOrder, i, boneName); end end -- Get a bone object. function MSkeleton:GetBone(boneName) return self.Bones[boneName]; end -- Returns a list of bones that belong to the skeleton, starting from the optional rootName. function MSkeleton:GetBoneList(rootName, t) if (not self:IsValid()) then print("Warning: Could not get bone tree for invalid skeleton!"); return; end rootName = rootName or SKELETON_ROOT_NAME; t = t or {}; table.insert(t, rootName); local children = self:GetBone(rootName).Children; if (not children or #children == 0) then return t; end for i = 1, #children do self:GetBoneList(children[i], t); end return t; end -- Returns the skeleton bind pose. function MSkeleton:GetBindPose() if (not self:IsValid()) then print("Warning: Could not get bind pose for invalid skeleton!"); return; end -- TODO: Validate? -- TODO: Cache this? local pose = {}; for boneName, bone in pairs(self.Bones) do local keyframe = {}; keyframe.time = 0; keyframe.rotation = bone:GetDefaultRotation(); keyframe.translation = {bone:GetDefaultTranslation()}; keyframe.scale = {bone:GetDefaultScale()}; --print("BindPos:".. boneName ..":",keyframe.time, keyframe.rotation, "[" .. keyframe.translation[1] .. "," .. keyframe.translation[2] .. "]"); pose[boneName] = keyframe; end return pose; end return newSkeleton;
mit
TheAnswer/FirstTest
bin/scripts/items/objects/clothing/wookiee/wookieeSkirt2.lua
1
2339
--Copyright (C) 2007 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. wookieeSkirt2 = Clothing:new { objectName = "Sigiled Waist Wrap", templateName = "object/tangible/wearables/wookiee/shared_wke_skirt_so2", objectCRC = "1970108336", objectType = WOOKIEGARB, equipped = "0", itemMask = WOOKIEES }
lgpl-3.0
Entware/openwrt-packages
net/luci-app-squid/files/squid-cbi.lua
95
1822
--[[ LuCI Squid module Copyright (C) 2015, OpenWrt.org Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Author: Marko Ratkaj <marko.ratkaj@sartura.hr> ]]-- local fs = require "nixio.fs" local sys = require "luci.sys" require "ubus" m = Map("squid", translate("Squid")) m.on_after_commit = function() luci.sys.call("/etc/init.d/squid restart") end s = m:section(TypedSection, "squid") s.anonymous = true s.addremove = false s:tab("general", translate("General Settings")) http_port = s:taboption("general", Value, "http_port", translate("Port")) http_port.datatype = "portrange" http_port.placeholder = "0-65535" visible_hostname = s:taboption("general", Value, "visible_hostname", translate("Visible Hostname")) visible_hostname.datatype="string" visible_hostname.placeholder = "OpenWrt" coredump_dir = s:taboption("general", Value, "coredump_dir", translate("Coredump files directory")) coredump_dir.datatype="string" coredump_dir.placeholder = "/tmp/squid" s:tab("advanced", translate("Advanced Settings")) squid_config_file = s:taboption("advanced", TextValue, "_data", "") squid_config_file.wrap = "off" squid_config_file.rows = 25 squid_config_file.rmempty = false function squid_config_file.cfgvalue() local uci = require "luci.model.uci".cursor_state() local file = uci:get("squid", "squid", "config_file") if file then return fs.readfile(file) or "" else return "" end end function squid_config_file.write(self, section, value) if value then local uci = require "luci.model.uci".cursor_state() local file = uci:get("squid", "squid", "config_file") fs.writefile(file, value:gsub("\r\n", "\n")) end end return m
gpl-2.0
ludi1991/skynet
gamelogic/generateNPC/npcfactory.lua
1
3535
local NpcGen = require "npcgen" local dump = require "dump" local distribution = require "distribution" local NpcFactory = {} ------------------------------------------------------------------ -- API: -- require this file and call NpcFactory:Run() -- it will return a npcList (table) which contains all npcs, indexed from 1 to npcCount -- modify the config block below to change the distribution of npcs ------------------------------------------------------------------ ----------------------------------------- -- config -- -- modify this block to change the distribution of npcs ----------------------------------------- -- how many npcs are we going to produce local npcCount = 15 -- a function which generates a level from npc's index -- (index: how many npcs we have already produced) local levelDistribution = function(npcIndex) return math.floor(distribution.uniform(2, 30)) -- lv 1 ~ 30 with uniform distribution --fewer low level or high level, more mediocore players --return math.floor(distribution.threePoints({x = 2, y = 0.1}, {x = 10, y = 0.8}, {x = 30, y = 0.1})) end -- a function which generates an iq local iqDistribution = function(npcIndex) return distribution.uniform(0.5, 0.9) -- iq = 0.5 ~ 0.9 with uniform distribution --fewer low iq or high iq, more mediocore players --return math.floor(distribution.threePoints({x = 0.5, y = 0.1}, {x = 0.75, y = 0.8}, {x = 0.9, y = 0.1})) end -- a function which generates random ids for npcs local idGen = function(npcIndex) return npcIndex + 10000 end -- a function which generates nicknames for npcs local nameGen = function(npcIndex) return "Lu Di's girlfriend No."..tostring(npcIndex) end local writeNpcListToFile = true local writeNpcListToScreen = false --------------------------------------------- -- methods -- -- usually you don't need to change this --------------------------------------------- -- the overall wrap function function NpcFactory:Run() NpcFactory:Init() NpcFactory:Produce() NpcFactory:Output() return self.npcList end function NpcFactory:Init() self.npcCount = npcCount self.levelDistribution = levelDistribution self.iqDistribution = iqDistribution self.idGen = idGen self.nameGen = nameGen self.npcList = {} -- to store the npc results end function NpcFactory:Produce() -- start generating for npcIndex = 1, npcCount do local level = self.levelDistribution(npcIndex) local iq = self.iqDistribution(npcIndex) local id = self.idGen(npcIndex) local name = self.nameGen(npcIndex) assert(level >= 1, "level < 1!! please check your level distribution function") assert(iq > 0 and iq <= 1, "iq not in range (0, 1]!!! please check your iq distribution function") assert(id >= 0, "id < 0!!! please check your id generator") assert(name, "name is invalid!! please check your name generator") local npc = NpcGen:GenerateNpc(level, iq, id, name) assert(npc, "we get a nil npc!!! npcGen error") table.insert(self.npcList, npc) end return npcList end function NpcFactory:Output() assert(self.npcList) local npcListStr if writeNpcListToScreen then npcListStr = dump(self.npcList) print(npcListStr) end if writeNpcListToFile then npcListStr = dump(self.npcList) fileOutput = io.open("output_npclist.lua", "w+") fileOutput:write(npcListStr) io.close(fileOutput) end end NpcFactory:Run() return NpcFactory
mit
TheAnswer/FirstTest
bin/scripts/crafting/objects/draftschematics/artisan/engineeringITinkering/starshipCraftingTool.lua
1
3817
--Copyright (C) 2009 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. starshipCraftingTool = Object:new { objectName = "Starship Crafting Tool", stfName = "space_tool_name", stfFile = "crafting", objectCRC = 245803278, groupName = "craftArtisanToolGroupA", -- Group schematic is awarded in (See skills table) craftingToolTab = 524288, -- (See DraftSchemticImplementation.h) complexity = 11, size = 1, xpType = "crafting_general", xp = 65, assemblySkill = "general_assembly", experimentingSkill = "general_experimentation", ingredientTemplateNames = "craft_item_ingredients_n, craft_item_ingredients_n, craft_item_ingredients_n", ingredientTitleNames = "assembly_enclosure, thermal_shielding, electronic_control_unit", ingredientSlotType = "0, 0, 0", resourceTypes = "metal, mineral, chemical", resourceQuantities = "16, 8, 10", combineTypes = "0, 0, 0", contribution = "100, 100, 100", numberExperimentalProperties = "1, 1, 1, 1", experimentalProperties = "XX, XX, XX, CD", experimentalWeights = "1, 1, 1, 1", experimentalGroupTitles = "null, null, null, exp_effectiveness", experimentalSubGroupTitles = "null, null, hitpoints, usemodifier", experimentalMin = "0, 0, 1000, -15", experimentalMax = "0, 0, 1000, 15", experimentalPrecision = "0, 0, 0, 0", tanoAttributes = "objecttype=32769:objectcrc=2903391664:stfFile=crafting:stfName=space_tool_name:stfDetail=:itemmask=65535::", blueFrogAttributes = "", blueFrogEnabled = False, customizationOptions = "", customizationDefaults = "", customizationSkill = "clothing_customization" } DraftSchematics:addDraftSchematic(starshipCraftingTool, 245803278)--- Add to global DraftSchematics table
lgpl-3.0
praveenjha527/Algorithm-Implementations
Roman_Numerals/Lua/Yonaba/roman_test.lua
26
1056
-- Tests for roman.lua local roman = require 'roman' local total, pass = 0, 0 local function dec(str, len) return #str < len and str .. (('.'):rep(len-#str)) or str:sub(1,len) end local function run(message, f) total = total + 1 local ok, err = pcall(f) if ok then pass = pass + 1 end local status = ok and 'PASSED' or 'FAILED' print(('%02d. %68s: %s'):format(total, dec(message,68), status)) end run('Roman encoding', function() assert(roman.encode(2) == 'II') assert(roman.encode(12) == 'XII') assert(roman.encode(327) == 'CCCXXVII') assert(roman.encode(1970) == 'MCMLXX') assert(roman.encode(2014) == 'MMXIV') end) run('Roman decoding', function() assert(roman.decode('II') == 2) assert(roman.decode('XII') == 12) assert(roman.decode('CCCXXVII') == 327) assert(roman.decode('MCMLXX') == 1970) assert(roman.decode('MMXIV') == 2014) end) print(('-'):rep(80)) print(('Total : %02d: Pass: %02d - Failed : %02d - Success: %.2f %%') :format(total, pass, total-pass, (pass*100/total)))
mit
mynameis123/uzzbot
plugins/yoda.lua
642
1199
local ltn12 = require "ltn12" local https = require "ssl.https" -- Edit data/mashape.lua with your Mashape API key -- http://docs.mashape.com/api-keys local mashape = load_from_file('data/mashape.lua', { api_key = '' }) local function request(text) local api = "https://yoda.p.mashape.com/yoda?" text = string.gsub(text, " ", "+") local parameters = "sentence="..(text or "") local url = api..parameters local api_key = mashape.api_key if api_key:isempty() then return 'Configure your Mashape API Key' end local headers = { ["X-Mashape-Key"] = api_key, ["Accept"] = "text/plain" } local respbody = {} local body, code = https.request{ url = url, method = "GET", headers = headers, sink = ltn12.sink.table(respbody), protocol = "tlsv1" } if code ~= 200 then return code end local body = table.concat(respbody) return body end local function run(msg, matches) return request(matches[1]) end return { description = "Listen to Yoda and learn from his words!", usage = "!yoda You will learn how to speak like me someday.", patterns = { "^![y|Y]oda (.*)$" }, run = run }
gpl-2.0
ArashFaceBook/Virus
plugins/yoda.lua
642
1199
local ltn12 = require "ltn12" local https = require "ssl.https" -- Edit data/mashape.lua with your Mashape API key -- http://docs.mashape.com/api-keys local mashape = load_from_file('data/mashape.lua', { api_key = '' }) local function request(text) local api = "https://yoda.p.mashape.com/yoda?" text = string.gsub(text, " ", "+") local parameters = "sentence="..(text or "") local url = api..parameters local api_key = mashape.api_key if api_key:isempty() then return 'Configure your Mashape API Key' end local headers = { ["X-Mashape-Key"] = api_key, ["Accept"] = "text/plain" } local respbody = {} local body, code = https.request{ url = url, method = "GET", headers = headers, sink = ltn12.sink.table(respbody), protocol = "tlsv1" } if code ~= 200 then return code end local body = table.concat(respbody) return body end local function run(msg, matches) return request(matches[1]) end return { description = "Listen to Yoda and learn from his words!", usage = "!yoda You will learn how to speak like me someday.", patterns = { "^![y|Y]oda (.*)$" }, run = run }
gpl-2.0
Lunovox/minetest_nibirus_game
mods/base/default/craftitems.lua
5
9063
-- mods/default/craftitems.lua minetest.register_craftitem("default:stick", { description = "Stick", inventory_image = "default_stick.png", groups = {stick = 1, flammable = 2}, }) minetest.register_craftitem("default:paper", { description = "Paper", inventory_image = "default_paper.png", groups = {flammable = 3}, }) local lpp = 14 -- Lines per book's page local function book_on_use(itemstack, user) local player_name = user:get_player_name() local meta = itemstack:get_meta() local title, text, owner = "", "", player_name local page, page_max, lines, string = 1, 1, {}, "" -- Backwards compatibility local old_data = minetest.deserialize(itemstack:get_metadata()) if old_data then meta:from_table({ fields = old_data }) end local data = meta:to_table().fields if data.owner then title = data.title text = data.text owner = data.owner for str in (text .. "\n"):gmatch("([^\n]*)[\n]") do lines[#lines+1] = str end if data.page then page = data.page page_max = data.page_max for i = ((lpp * page) - lpp) + 1, lpp * page do if not lines[i] then break end string = string .. lines[i] .. "\n" end end end local formspec if owner == player_name then formspec = "size[8,8]" .. default.gui_bg .. default.gui_bg_img .. "field[0.5,1;7.5,0;title;Title:;" .. minetest.formspec_escape(title) .. "]" .. "textarea[0.5,1.5;7.5,7;text;Contents:;" .. minetest.formspec_escape(text) .. "]" .. "button_exit[2.5,7.5;3,1;save;Save]" else formspec = "size[8,8]" .. default.gui_bg .. default.gui_bg_img .. "label[0.5,0.5;by " .. owner .. "]" .. "tablecolumns[color;text]" .. "tableoptions[background=#00000000;highlight=#00000000;border=false]" .. "table[0.4,0;7,0.5;title;#FFFF00," .. minetest.formspec_escape(title) .. "]" .. "textarea[0.5,1.5;7.5,7;;" .. minetest.formspec_escape(string ~= "" and string or text) .. ";]" .. "button[2.4,7.6;0.8,0.8;book_prev;<]" .. "label[3.2,7.7;Page " .. page .. " of " .. page_max .. "]" .. "button[4.9,7.6;0.8,0.8;book_next;>]" end minetest.show_formspec(player_name, "default:book", formspec) return itemstack end minetest.register_on_player_receive_fields(function(player, formname, fields) if formname ~= "default:book" then return end local inv = player:get_inventory() local stack = player:get_wielded_item() if fields.save and fields.title ~= "" and fields.text ~= "" then local new_stack, data if stack:get_name() ~= "default:book_written" then local count = stack:get_count() if count == 1 then stack:set_name("default:book_written") else stack:set_count(count - 1) new_stack = ItemStack("default:book_written") end else data = stack:get_meta():to_table().fields end if data and data.owner and data.owner ~= player:get_player_name() then return end if not data then data = {} end data.title = fields.title data.owner = player:get_player_name() data.description = "\""..fields.title.."\" by "..data.owner data.text = fields.text data.text_len = #data.text data.page = 1 data.page_max = math.ceil((#data.text:gsub("[^\n]", "") + 1) / lpp) if new_stack then new_stack:get_meta():from_table({ fields = data }) if inv:room_for_item("main", new_stack) then inv:add_item("main", new_stack) else minetest.add_item(player:getpos(), new_stack) end else stack:get_meta():from_table({ fields = data }) end elseif fields.book_next or fields.book_prev then local data = stack:get_meta():to_table().fields if not data or not data.page then return end data.page = tonumber(data.page) data.page_max = tonumber(data.page_max) if fields.book_next then data.page = data.page + 1 if data.page > data.page_max then data.page = 1 end else data.page = data.page - 1 if data.page == 0 then data.page = data.page_max end end stack:get_meta():from_table({fields = data}) stack = book_on_use(stack, player) end -- Update stack player:set_wielded_item(stack) end) minetest.register_craftitem("default:book", { description = "Book", inventory_image = "default_book.png", groups = {book = 1, flammable = 3}, on_use = book_on_use, }) minetest.register_craftitem("default:book_written", { description = "Book With Text", inventory_image = "default_book_written.png", groups = {book = 1, not_in_creative_inventory = 1, flammable = 3}, stack_max = 1, on_use = book_on_use, }) minetest.register_craft({ type = "shapeless", output = "default:book_written", recipe = {"default:book", "default:book_written"} }) minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) if itemstack:get_name() ~= "default:book_written" then return end local original local index for i = 1, player:get_inventory():get_size("craft") do if old_craft_grid[i]:get_name() == "default:book_written" then original = old_craft_grid[i] index = i end end if not original then return end local copymeta = original:get_meta():to_table() -- copy of the book held by player's mouse cursor itemstack:get_meta():from_table(copymeta) -- put the book with metadata back in the craft grid craft_inv:set_stack("craft", index, original) end) minetest.register_craftitem("default:skeleton_key", { description = "Skeleton Key", inventory_image = "default_key_skeleton.png", groups = {key = 1}, on_use = function(itemstack, user, pointed_thing) if pointed_thing.type ~= "node" then return itemstack end local pos = pointed_thing.under local node = minetest.get_node(pos) if not node then return itemstack end local on_skeleton_key_use = minetest.registered_nodes[node.name].on_skeleton_key_use if not on_skeleton_key_use then return itemstack end -- make a new key secret in case the node callback needs it local random = math.random local newsecret = string.format( "%04x%04x%04x%04x", random(2^16) - 1, random(2^16) - 1, random(2^16) - 1, random(2^16) - 1) local secret, _, _ = on_skeleton_key_use(pos, user, newsecret) if secret then local inv = minetest.get_inventory({type="player", name=user:get_player_name()}) -- update original itemstack itemstack:take_item() -- finish and return the new key local new_stack = ItemStack("default:key") local meta = new_stack:get_meta() meta:set_string("secret", secret) meta:set_string("description", "Key to "..user:get_player_name().."'s " ..minetest.registered_nodes[node.name].description) if itemstack:get_count() == 0 then itemstack = new_stack else if inv:add_item("main", new_stack):get_count() > 0 then minetest.add_item(user:getpos(), new_stack) end -- else: added to inventory successfully end return itemstack end end }) minetest.register_craftitem("default:coal_lump", { description = "Coal Lump", inventory_image = "default_coal_lump.png", groups = {coal = 1, flammable = 1} }) minetest.register_craftitem("default:iron_lump", { description = "Iron Lump", inventory_image = "default_iron_lump.png", }) minetest.register_craftitem("default:copper_lump", { description = "Copper Lump", inventory_image = "default_copper_lump.png", }) minetest.register_craftitem("default:tin_lump", { description = "Tin Lump", inventory_image = "default_tin_lump.png", }) minetest.register_craftitem("default:mese_crystal", { description = "Mese Crystal", inventory_image = "default_mese_crystal.png", }) minetest.register_craftitem("default:gold_lump", { description = "Gold Lump", inventory_image = "default_gold_lump.png", }) minetest.register_craftitem("default:diamond", { description = "Diamond", inventory_image = "default_diamond.png", }) minetest.register_craftitem("default:clay_lump", { description = "Clay Lump", inventory_image = "default_clay_lump.png", }) minetest.register_craftitem("default:steel_ingot", { description = "Steel Ingot", inventory_image = "default_steel_ingot.png", }) minetest.register_craftitem("default:copper_ingot", { description = "Copper Ingot", inventory_image = "default_copper_ingot.png", }) minetest.register_craftitem("default:tin_ingot", { description = "Tin Ingot", inventory_image = "default_tin_ingot.png", }) minetest.register_craftitem("default:bronze_ingot", { description = "Bronze Ingot", inventory_image = "default_bronze_ingot.png", }) minetest.register_craftitem("default:gold_ingot", { description = "Gold Ingot", inventory_image = "default_gold_ingot.png" }) minetest.register_craftitem("default:mese_crystal_fragment", { description = "Mese Crystal Fragment", inventory_image = "default_mese_crystal_fragment.png", }) minetest.register_craftitem("default:clay_brick", { description = "Clay Brick", inventory_image = "default_clay_brick.png", }) minetest.register_craftitem("default:obsidian_shard", { description = "Obsidian Shard", inventory_image = "default_obsidian_shard.png", }) minetest.register_craftitem("default:flint", { description = "Flint", inventory_image = "default_flint.png" })
agpl-3.0
TheAnswer/FirstTest
bin/scripts/slashcommands/generic/waypoint.lua
1
2430
--Copyright (C) 2007 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. --true = 1, false = 0 WaypointSlashCommand = { name = "waypoint", alternativeNames = "", animation = "", invalidStateMask = 2097152, --glowingJedi, invalidPostures = "", target = 0, targeType = 0, disabled = 0, maxRangeToTarget = 0, --adminLevel = 0, addToCombatQueue = 1, } AddWaypointSlashCommand(WaypointSlashCommand)
lgpl-3.0
TheAnswer/FirstTest
bin/scripts/crafting/objects/draftschematics/weaponsmith/advancedFirearmsCrafting/tuskenRifle.lua
1
4843
--Copyright (C) 2009 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. tuskenRifle = Object:new { objectName = "Tusken Rifle", stfName = "rifle_tusken", stfFile = "weapon_name", objectCRC = 112067557, groupName = "craftWeaponRangedGroupC", -- Group schematic is awarded in (See skills table) craftingToolTab = 1, -- (See DraftSchemticImplementation.h) complexity = 16, size = 3, xpType = "crafting_weapons_general", xp = 110, assemblySkill = "weapon_assembly", experimentingSkill = "weapon_experimentation", ingredientTemplateNames = "craft_weapon_ingredients_n, craft_weapon_ingredients_n, craft_weapon_ingredients_n, craft_weapon_ingredients_n, craft_weapon_ingredients_n, craft_weapon_ingredients_n, craft_weapon_ingredients_n", ingredientTitleNames = "frame_assembly, receiver_assembly, grip_assembly, feed_unit, barrel, scope, stock", ingredientSlotType = "0, 0, 0, 2, 2, 4, 4", resourceTypes = "iron, metal_ferrous, metal, object/tangible/component/weapon/shared_projectile_feed_mechanism.iff, object/tangible/component/weapon/shared_projectile_rifle_barrel.iff, object/tangible/component/weapon/shared_scope_weapon.iff, object/tangible/component/weapon/shared_stock.iff", resourceQuantities = "35, 14, 7, 1, 1, 1, 1", combineTypes = "0, 0, 0, 1, 1, 1, 1", contribution = "100, 100, 100, 100, 100, 100, 100", numberExperimentalProperties = "1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2", experimentalProperties = "XX, XX, CD, OQ, CD, OQ, CD, OQ, CD, OQ, CD, OQ, CD, OQ, XX, XX, XX, CD, OQ, CD, OQ, CD, OQ, CD, OQ", experimentalWeights = "1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1", experimentalGroupTitles = "null, null, expDamage, expDamage, expDamage, expDamage, expEffeciency, exp_durability, null, null, null, expRange, expEffeciency, expEffeciency, expEffeciency", experimentalSubGroupTitles = "null, null, mindamage, maxdamage, attackspeed, woundchance, roundsused, hitpoints, zerorangemod, maxrangemod, midrange, midrangemod, attackhealthcost, attackactioncost, attackmindcost", experimentalMin = "0, 0, 70, 105, 9.1, 6, 30, 750, -60, -50, 60, 14, 13, 23, 55", experimentalMax = "0, 0, 130, 195, 6.3, 12, 65, 1500, -60, -50, 60, 26, 7, 13, 30", experimentalPrecision = "0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0", tanoAttributes = "objecttype=131084:objectcrc=2874182418:stfFile=weapon_name:stfName=rifle_tusken:stfDetail=:itemmask=65535:customattributes=damagetype=1;:", blueFrogAttributes = "", blueFrogEnabled = False, customizationOptions = "", customizationDefaults = "", customizationSkill = "weapon_customization" } DraftSchematics:addDraftSchematic(tuskenRifle, 112067557)--- Add to global DraftSchematics table
lgpl-3.0
Andrettin/Wyrmsun
scripts/terrain_features_earth.lua
1
4990
-- _________ __ __ -- / _____// |_____________ _/ |______ ____ __ __ ______ -- \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ -- / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ -- /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > -- \/ \/ \//_____/ \/ -- ______________________ ______________________ -- T H E W A R B E G I N S -- Stratagus - A free fantasy real time strategy game engine -- -- (c) Copyright 2016-2022 by Andrettin -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- DefineTerrainFeature("achelos-river", { -- Source: William R. Shepherd, "Historical Atlas", 1911, p. 4. Name = "Achelos River", TerrainType = "shallow-water" }) DefineTerrainFeature("alpheus-river", { -- Source: William R. Shepherd, "Historical Atlas", 1911, p. 4. Name = "Alpheus River", TerrainType = "shallow-water" }) DefineTerrainFeature("atlantic-ocean", { -- Source: "Limits of Oceans and Seas", 1953, p. 12. (see corrections as well) Name = "Atlantic Ocean", TerrainType = "shallow-water", Color = {48, 176, 176} }) DefineTerrainFeature("carpathians", { Name = "Carpathians", TerrainType = "rock" -- mountains }) DefineTerrainFeature("dnieper-river", { Name = "Dnieper River", TerrainType = "shallow-water", Color = {32, 128, 176}, CulturalNames = { "latin", "Borysthenes River" -- Source: William R. Shepherd, "Historical Atlas", 1911, pp. 34-35. } }) DefineTerrainFeature("don-river", { Name = "Don River", TerrainType = "shallow-water", Color = {16, 128, 176}, CulturalNames = { "celt", "Vanaquisl River", -- so that the river's name will appear correctly if it is Vana territory "germanic", "Vanaquisl River", -- the Tanais river is said to have been called Vanaquisl or Tanaquisl in the time of the Vana/Asa conflict in the Ynglinga saga; Source: Snorri Sturlson, "Heimskringla", 1844, vol. 1, p. 217. "greek", "Tanais River", "latin", "Tanais River", -- Source: William R. Shepherd, "Historical Atlas", 1911, pp. 34-35. "norse", "Tanais River" -- Source: Snorri Sturlson, "Heimskringla", 1844, vol. 1, p. 217. } }) DefineTerrainFeature("eurotas-river", { -- Source: William R. Shepherd, "Historical Atlas", 1911, p. 4. Name = "Eurotas River", TerrainType = "shallow-water", Color = {0, 144, 144}, CulturalNames = { "greek", "Eurotas River" } }) DefineTerrainFeature("garonne-river", { Name = "Garonne River", TerrainType = "shallow-water" }) DefineTerrainFeature("lake-neusiedl", { Name = "Lake Neusiedl", TerrainType = "shallow-water", Color = {0, 128, 176} }) DefineTerrainFeature("march-river", { Name = "March River", TerrainType = "shallow-water", Color = {0, 144, 128} }) DefineTerrainFeature("narova-river", { Name = "Narova River", TerrainType = "shallow-water" }) DefineTerrainFeature("neva-river", { Name = "Neva River", TerrainType = "shallow-water" }) DefineTerrainFeature("peneus-river", { -- Source: William R. Shepherd, "Historical Atlas", 1911, p. 4. Name = "Peneus River", TerrainType = "shallow-water" }) DefineTerrainFeature("sado-river", { Name = "Sado River", TerrainType = "shallow-water" }) DefineTerrainFeature("seine-river", { -- Source: William R. Shepherd, "Historical Atlas", 1911, pp. 146-147. Name = "Seine River", TerrainType = "shallow-water" }) DefineTerrainFeature("strait-of-gibraltar", { Name = "Strait of Gibraltar", TerrainType = "shallow-water", Color = {0, 104, 144}, CulturalNames = { "norse", "Niorvasund" -- the Straits of Gibraltar were known as "Niorvasund" to the Norse; Source: Snorri Sturlson, "Heimskringla", 1844, vol. 1, p. 216. } }) DefineTerrainFeature("ural-mountains", { Name = "Ural Mountains", TerrainType = "rock" -- mountains }) DefineTerrainFeature("volga-river", { Name = "Volga River", TerrainType = "shallow-water", CulturalNames = { "latin", "Rha River" -- Source: William R. Shepherd, "Historical Atlas", 1911, pp. 34-35. } }) DefineTerrainFeature("wicklow-mountains", { -- Source: "Philip's International School Atlas", 2006, p. 64. Name = "Wicklow Mountains", TerrainType = "rock" -- mountains })
gpl-2.0
thkhxm/TGame
Assets/StreamingAssets/lua/UnityEngine/Vector3.lua
8
12219
-------------------------------------------------------------------------------- -- Copyright (c) 2015 , 蒙占志(topameng) topameng@gmail.com -- All rights reserved. -- Use, modification and distribution are subject to the "MIT License" -------------------------------------------------------------------------------- local math = math local acos = math.acos local sqrt = math.sqrt local max = math.max local min = math.min local clamp = Mathf.Clamp local cos = math.cos local sin = math.sin local abs = math.abs local sign = Mathf.Sign local setmetatable = setmetatable local rawset = rawset local rawget = rawget local type = type local rad2Deg = Mathf.Rad2Deg local deg2Rad = Mathf.Deg2Rad local Vector3 = {} local get = tolua.initget(Vector3) Vector3.__index = function(t,k) local var = rawget(Vector3, k) if var == nil then var = rawget(get, k) if var ~= nil then return var(t) end end return var end function Vector3.New(x, y, z) local v = {x = x or 0, y = y or 0, z = z or 0} setmetatable(v, Vector3) return v end local _new = Vector3.New Vector3.__call = function(t,x,y,z) return _new(x,y,z) end function Vector3:Set(x,y,z) self.x = x or 0 self.y = y or 0 self.z = z or 0 end function Vector3:Get() return self.x, self.y, self.z end function Vector3:Clone() return _new(self.x, self.y, self.z) end function Vector3.Distance(va, vb) return sqrt((va.x - vb.x)^2 + (va.y - vb.y)^2 + (va.z - vb.z)^2) end function Vector3.Dot(lhs, rhs) return lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z end function Vector3.Lerp(from, to, t) t = clamp(t, 0, 1) return _new(from.x + (to.x - from.x) * t, from.y + (to.y - from.y) * t, from.z + (to.z - from.z) * t) end function Vector3:Magnitude() return sqrt(self.x * self.x + self.y * self.y + self.z * self.z) end function Vector3.Max(lhs, rhs) return _new(max(lhs.x, rhs.x), max(lhs.y, rhs.y), max(lhs.z, rhs.z)) end function Vector3.Min(lhs, rhs) return _new(min(lhs.x, rhs.x), min(lhs.y, rhs.y), min(lhs.z, rhs.z)) end function Vector3.Normalize(v) local x,y,z = v.x, v.y, v.z local num = sqrt(x * x + y * y + z * z) if num > 1e-5 then return _new(x/num, y/num, z/num) end return _new(0, 0, 0) end function Vector3:SetNormalize() local num = sqrt(self.x * self.x + self.y * self.y + self.z * self.z) if num > 1e-5 then self.x = self.x / num self.y = self.y / num self.z = self.z /num else self.x = 0 self.y = 0 self.z = 0 end return self end function Vector3:SqrMagnitude() return self.x * self.x + self.y * self.y + self.z * self.z end local dot = Vector3.Dot function Vector3.Angle(from, to) return acos(clamp(dot(from:Normalize(), to:Normalize()), -1, 1)) * rad2Deg end function Vector3:ClampMagnitude(maxLength) if self:SqrMagnitude() > (maxLength * maxLength) then self:SetNormalize() self:Mul(maxLength) end return self end function Vector3.OrthoNormalize(va, vb, vc) va:SetNormalize() vb:Sub(vb:Project(va)) vb:SetNormalize() if vc == nil then return va, vb end vc:Sub(vc:Project(va)) vc:Sub(vc:Project(vb)) vc:SetNormalize() return va, vb, vc end --[[function Vector3.RotateTowards2(from, to, maxRadiansDelta, maxMagnitudeDelta) local v2 = to:Clone() local v1 = from:Clone() local len2 = to:Magnitude() local len1 = from:Magnitude() v2:Div(len2) v1:Div(len1) local dota = dot(v1, v2) local angle = acos(dota) local theta = min(angle, maxRadiansDelta) local len = 0 if len1 < len2 then len = min(len2, len1 + maxMagnitudeDelta) elseif len1 == len2 then len = len1 else len = max(len2, len1 - maxMagnitudeDelta) end v2:Sub(v1 * dota) v2:SetNormalize() v2:Mul(sin(theta)) v1:Mul(cos(theta)) v2:Add(v1) v2:SetNormalize() v2:Mul(len) return v2 end function Vector3.RotateTowards1(from, to, maxRadiansDelta, maxMagnitudeDelta) local omega, sinom, scale0, scale1, len, theta local v2 = to:Clone() local v1 = from:Clone() local len2 = to:Magnitude() local len1 = from:Magnitude() v2:Div(len2) v1:Div(len1) local cosom = dot(v1, v2) if len1 < len2 then len = min(len2, len1 + maxMagnitudeDelta) elseif len1 == len2 then len = len1 else len = max(len2, len1 - maxMagnitudeDelta) end if 1 - cosom > 1e-6 then omega = acos(cosom) theta = min(omega, maxRadiansDelta) sinom = sin(omega) scale0 = sin(omega - theta) / sinom scale1 = sin(theta) / sinom v1:Mul(scale0) v2:Mul(scale1) v2:Add(v1) v2:Mul(len) return v2 else v1:Mul(len) return v1 end end]] function Vector3.MoveTowards(current, target, maxDistanceDelta) local delta = target - current local sqrDelta = delta:SqrMagnitude() local sqrDistance = maxDistanceDelta * maxDistanceDelta if sqrDelta > sqrDistance then local magnitude = sqrt(sqrDelta) if magnitude > 1e-6 then delta:Mul(maxDistanceDelta / magnitude) delta:Add(current) return delta else return current:Clone() end end return target:Clone() end function ClampedMove(lhs, rhs, clampedDelta) local delta = rhs - lhs if delta > 0 then return lhs + min(delta, clampedDelta) else return lhs - min(-delta, clampedDelta) end end local overSqrt2 = 0.7071067811865475244008443621048490 local function OrthoNormalVector(vec) local res = _new() if abs(vec.z) > overSqrt2 then local a = vec.y * vec.y + vec.z * vec.z local k = 1 / sqrt (a) res.x = 0 res.y = -vec.z * k res.z = vec.y * k else local a = vec.x * vec.x + vec.y * vec.y local k = 1 / sqrt (a) res.x = -vec.y * k res.y = vec.x * k res.z = 0 end return res end function Vector3.RotateTowards(current, target, maxRadiansDelta, maxMagnitudeDelta) local len1 = current:Magnitude() local len2 = target:Magnitude() if len1 > 1e-6 and len2 > 1e-6 then local from = current / len1 local to = target / len2 local cosom = dot(from, to) if cosom > 1 - 1e-6 then return Vector3.MoveTowards (current, target, maxMagnitudeDelta) elseif cosom < -1 + 1e-6 then local axis = OrthoNormalVector(from) local q = Quaternion.AngleAxis(maxRadiansDelta * rad2Deg, axis) local rotated = q:MulVec3(from) local delta = ClampedMove(len1, len2, maxMagnitudeDelta) rotated:Mul(delta) return rotated else local angle = acos(cosom) local axis = Vector3.Cross(from, to) axis:SetNormalize () local q = Quaternion.AngleAxis(min(maxRadiansDelta, angle) * rad2Deg, axis) local rotated = q:MulVec3(from) local delta = ClampedMove(len1, len2, maxMagnitudeDelta) rotated:Mul(delta) return rotated end end return Vector3.MoveTowards(current, target, maxMagnitudeDelta) end function Vector3.SmoothDamp(current, target, currentVelocity, smoothTime) local maxSpeed = Mathf.Infinity local deltaTime = Time.deltaTime smoothTime = max(0.0001, smoothTime) local num = 2 / smoothTime local num2 = num * deltaTime local num3 = 1 / (1 + num2 + 0.48 * num2 * num2 + 0.235 * num2 * num2 * num2) local vector2 = target:Clone() local maxLength = maxSpeed * smoothTime local vector = current - target vector:ClampMagnitude(maxLength) target = current - vector local vec3 = (currentVelocity + (vector * num)) * deltaTime currentVelocity = (currentVelocity - (vec3 * num)) * num3 local vector4 = target + (vector + vec3) * num3 if Vector3.Dot(vector2 - current, vector4 - vector2) > 0 then vector4 = vector2 currentVelocity:Set(0,0,0) end return vector4, currentVelocity end function Vector3.Scale(a, b) local x = a.x * b.x local y = a.y * b.y local z = a.z * b.z return _new(x, y, z) end function Vector3.Cross(lhs, rhs) local x = lhs.y * rhs.z - lhs.z * rhs.y local y = lhs.z * rhs.x - lhs.x * rhs.z local z = lhs.x * rhs.y - lhs.y * rhs.x return _new(x,y,z) end function Vector3:Equals(other) return self.x == other.x and self.y == other.y and self.z == other.z end function Vector3.Reflect(inDirection, inNormal) local num = -2 * dot(inNormal, inDirection) inNormal = inNormal * num inNormal:Add(inDirection) return inNormal end function Vector3.Project(vector, onNormal) local num = onNormal:SqrMagnitude() if num < 1.175494e-38 then return _new(0,0,0) end local num2 = dot(vector, onNormal) local v3 = onNormal:Clone() v3:Mul(num2/num) return v3 end function Vector3.ProjectOnPlane(vector, planeNormal) local v3 = Vector3.Project(vector, planeNormal) v3:Mul(-1) v3:Add(vector) return v3 end function Vector3.Slerp(from, to, t) local omega, sinom, scale0, scale1 if t <= 0 then return from:Clone() elseif t >= 1 then return to:Clone() end local v2 = to:Clone() local v1 = from:Clone() local len2 = to:Magnitude() local len1 = from:Magnitude() v2:Div(len2) v1:Div(len1) local len = (len2 - len1) * t + len1 local cosom = dot(v1, v2) if cosom > 1 - 1e-6 then scale0 = 1 - t scale1 = t elseif cosom < -1 + 1e-6 then local axis = OrthoNormalVector(from) local q = Quaternion.AngleAxis(180.0 * t, axis) local v = q:MulVec3(from) v:Mul(len) return v else omega = acos(cosom) sinom = sin(omega) scale0 = sin((1 - t) * omega) / sinom scale1 = sin(t * omega) / sinom end v1:Mul(scale0) v2:Mul(scale1) v2:Add(v1) v2:Mul(len) return v2 end function Vector3:Mul(q) if type(q) == "number" then self.x = self.x * q self.y = self.y * q self.z = self.z * q else self:MulQuat(q) end return self end function Vector3:Div(d) self.x = self.x / d self.y = self.y / d self.z = self.z / d return self end function Vector3:Add(vb) self.x = self.x + vb.x self.y = self.y + vb.y self.z = self.z + vb.z return self end function Vector3:Sub(vb) self.x = self.x - vb.x self.y = self.y - vb.y self.z = self.z - vb.z return self end function Vector3:MulQuat(quat) local num = quat.x * 2 local num2 = quat.y * 2 local num3 = quat.z * 2 local num4 = quat.x * num local num5 = quat.y * num2 local num6 = quat.z * num3 local num7 = quat.x * num2 local num8 = quat.x * num3 local num9 = quat.y * num3 local num10 = quat.w * num local num11 = quat.w * num2 local num12 = quat.w * num3 local x = (((1 - (num5 + num6)) * self.x) + ((num7 - num12) * self.y)) + ((num8 + num11) * self.z) local y = (((num7 + num12) * self.x) + ((1 - (num4 + num6)) * self.y)) + ((num9 - num10) * self.z) local z = (((num8 - num11) * self.x) + ((num9 + num10) * self.y)) + ((1 - (num4 + num5)) * self.z) self:Set(x, y, z) return self end function Vector3.AngleAroundAxis (from, to, axis) from = from - Vector3.Project(from, axis) to = to - Vector3.Project(to, axis) local angle = Vector3.Angle (from, to) return angle * (Vector3.Dot (axis, Vector3.Cross (from, to)) < 0 and -1 or 1) end Vector3.__tostring = function(self) return "["..self.x..","..self.y..","..self.z.."]" end Vector3.__div = function(va, d) return _new(va.x / d, va.y / d, va.z / d) end Vector3.__mul = function(va, d) if type(d) == "number" then return _new(va.x * d, va.y * d, va.z * d) else local vec = va:Clone() vec:MulQuat(d) return vec end end Vector3.__add = function(va, vb) return _new(va.x + vb.x, va.y + vb.y, va.z + vb.z) end Vector3.__sub = function(va, vb) return _new(va.x - vb.x, va.y - vb.y, va.z - vb.z) end Vector3.__unm = function(va) return _new(-va.x, -va.y, -va.z) end Vector3.__eq = function(a,b) local v = a - b local delta = v:SqrMagnitude() return delta < 1e-10 end get.up = function() return _new(0,1,0) end get.down = function() return _new(0,-1,0) end get.right = function() return _new(1,0,0) end get.left = function() return _new(-1,0,0) end get.forward = function() return _new(0,0,1) end get.back = function() return _new(0,0,-1) end get.zero = function() return _new(0,0,0) end get.one = function() return _new(1,1,1) end get.magnitude = Vector3.Magnitude get.normalized = Vector3.Normalize get.sqrMagnitude= Vector3.SqrMagnitude UnityEngine.Vector3 = Vector3 setmetatable(Vector3, Vector3) return Vector3
apache-2.0
praveenjha527/Algorithm-Implementations
Cocktail_Sort/Lua/Yonaba/cocktail_sort_test.lua
26
2230
-- Tests for cocktail_sort.lua local cocktail_sort = require 'cocktail_sort' local total, pass = 0, 0 local function dec(str, len) return #str < len and str .. (('.'):rep(len-#str)) or str:sub(1,len) end local function run(message, f) total = total + 1 local ok, err = pcall(f) if ok then pass = pass + 1 end local status = ok and 'PASSED' or 'FAILED' print(('%02d. %68s: %s'):format(total, dec(message,68), status)) end -- Wrap for Lua's table sort so that it returns -- the passed-in table local function sort(t, comp) table.sort(t, comp) return t end -- Returns a copy of a an array local function clone(t) local _t = {} for k,v in ipairs(t) do _t[k] = v end return _t end -- Checks if t1 and t2 arrays are the same local function same(t1, t2) for k,v in ipairs(t1) do if t2[k] ~= v then return false end end return true end -- Generates an array of n values in random order local function gen(n) local t = {} for i = 1, n do t[i] = math.random(n) end return t end -- Note: Let's add a bit of randomness math.randomseed(os.time()) run('Empty arrays', function() local t = {} assert(same(sort(clone(t)),cocktail_sort(t))) end) run('Sorted array', function() local t = {1, 2, 3, 4, 5} assert(same(sort(clone(t)),cocktail_sort(t))) end) run('Array sorted in reverse', function() local t = {5, 4, 3, 2, 1} assert(same(sort(clone(t)),cocktail_sort(t))) local t = {5, 4, 3, 2, 1} local comp = function(a,b) return a>b end assert(same(sort(clone(t), comp),cocktail_sort(t, comp))) end) run('Array containing multiple occurences of the same value', function() local t = {4, 4, 8, 2, 2} local comp = function(a,b) return a <= b end assert(same(sort(clone(t)),cocktail_sort(t, comp))) local t = {0, 0, 0, 0, 0} local comp = function(a,b) return a <= b end assert(same(sort(clone(t)),cocktail_sort(t, comp))) end) run('Large array of random values (1e3 values)', function() local t = gen(1e3) local comp = function(a,b) return a <= b end assert(same(sort(clone(t)),cocktail_sort(t, comp))) end) print(('-'):rep(80)) print(('Total : %02d: Pass: %02d - Failed : %02d - Success: %.2f %%') :format(total, pass, total-pass, (pass*100/total)))
mit
TheAnswer/FirstTest
bin/scripts/object/tangible/lair/corellian_slice_hound/objects.lua
1
6253
--Copyright (C) 2009 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. object_tangible_lair_corellian_slice_hound_shared_lair_corellian_slice_hound = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/poi_all_lair_cave_small.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 25, clientDataFile = "clientdata/client_shared_lair_small.cdf", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@lair_d:corellian_slice_hound", gameObjectType = 4, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 64, objectName = "@lair_n:corellian_slice_hound", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_lair_corellian_slice_hound_shared_lair_corellian_slice_hound, 866782264) object_tangible_lair_corellian_slice_hound_shared_lair_corellian_slice_hound_forest = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/poi_all_lair_cave_small.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 25, clientDataFile = "clientdata/client_shared_lair_small.cdf", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@lair_d:corellian_slice_hound_forest", gameObjectType = 4, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 64, objectName = "@lair_n:corellian_slice_hound_forest", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_lair_corellian_slice_hound_shared_lair_corellian_slice_hound_forest, 2443001594) object_tangible_lair_corellian_slice_hound_shared_lair_corellian_slice_hound_grassland = SharedTangibleObjectTemplate:new { appearanceFilename = "appearance/poi_all_lair_cave_small.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 25, clientDataFile = "clientdata/client_shared_lair_small.cdf", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 0, containerVolumeLimit = 1, customizationVariableMapping = {}, detailedDescription = "@lair_d:corellian_slice_hound_grassland", gameObjectType = 4, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 64, objectName = "@lair_n:corellian_slice_hound_grassland", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "", surfaceType = 0, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_tangible_lair_corellian_slice_hound_shared_lair_corellian_slice_hound_grassland, 3854748687)
lgpl-3.0
TheAnswer/FirstTest
bin/scripts/crafting/objects/draftschematics/artisan/engineeringIiHardwareDesign/type10Firework.lua
1
3837
--Copyright (C) 2009 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. type10Firework = Object:new { objectName = "Type 10 Firework", stfName = "firework_s10", stfFile = "firework_n", objectCRC = 1345222985, groupName = "craftArtisanEngineeringGroupB", -- Group schematic is awarded in (See skills table) craftingToolTab = 524288, -- (See DraftSchemticImplementation.h) complexity = 11, size = 1, xpType = "crafting_general", xp = 28, assemblySkill = "general_assembly", experimentingSkill = "general_experimentation", ingredientTemplateNames = "craft_item_ingredients_n, craft_item_ingredients_n, craft_item_ingredients_n, craft_item_ingredients_n", ingredientTitleNames = "canister, booster_charge, burster_charge, effect_generator", ingredientSlotType = "0, 0, 0, 0", resourceTypes = "mineral, chemical, chemical, gas", resourceQuantities = "6, 4, 2, 2", combineTypes = "0, 0, 0, 0", contribution = "100, 100, 100, 100", numberExperimentalProperties = "1, 1, 1, 1", experimentalProperties = "XX, XX, XX, OQ", experimentalWeights = "1, 1, 1, 1", experimentalGroupTitles = "null, null, null, exp_effectiveness", experimentalSubGroupTitles = "null, null, hitpoints, charges", experimentalMin = "0, 0, 1000, 2", experimentalMax = "0, 0, 1000, 10", experimentalPrecision = "0, 0, 0, 0", tanoAttributes = "objecttype=:objectcrc=1200128784:stfFile=firework_n:stfName=firework_s10:stfDetail=:itemmask=65535::", blueFrogAttributes = "", blueFrogEnabled = False, customizationOptions = "", customizationDefaults = "", customizationSkill = "clothing_customization" } DraftSchematics:addDraftSchematic(type10Firework, 1345222985)--- Add to global DraftSchematics table
lgpl-3.0
TheAnswer/FirstTest
bin/scripts/object/installation/faction_perk/turret/objects.lua
1
13441
--Copyright (C) 2009 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. object_installation_faction_perk_turret_shared_block_lg = SharedInstallationObjectTemplate:new { appearanceFilename = "appearance/ins_all_def_turret_lg_s01.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 15, clientDataFile = "clientdata/installation/client_shared_turret_block_large.cdf", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 2, containerVolumeLimit = 20, customizationVariableMapping = {}, detailedDescription = "@turret_n:base", gameObjectType = 4100, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 32, objectName = "@turret_n:block_large", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "abstract/slot/descriptor/tangible.iff", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "footprint/faction_perk/turret/turret_base.sfp", surfaceType = 1, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_installation_faction_perk_turret_shared_block_lg, 2286796965) object_installation_faction_perk_turret_shared_block_med = SharedInstallationObjectTemplate:new { appearanceFilename = "appearance/ins_all_def_turret_m_s01.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 15, clientDataFile = "clientdata/installation/client_shared_turret_block_med.cdf", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 2, containerVolumeLimit = 20, customizationVariableMapping = {}, detailedDescription = "@turret_n:base", gameObjectType = 4100, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 32, objectName = "@turret_n:block_medium", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "abstract/slot/descriptor/tangible.iff", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "footprint/faction_perk/turret/turret_base.sfp", surfaceType = 1, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_installation_faction_perk_turret_shared_block_med, 1869715208) object_installation_faction_perk_turret_shared_block_sm = SharedInstallationObjectTemplate:new { appearanceFilename = "appearance/ins_all_def_turret_sm_s01.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 15, clientDataFile = "clientdata/installation/client_shared_turret_block_small.cdf", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 2, containerVolumeLimit = 20, customizationVariableMapping = {}, detailedDescription = "@turret_n:base", gameObjectType = 4100, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 32, objectName = "@turret_n:block_small", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "abstract/slot/descriptor/tangible.iff", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "footprint/faction_perk/turret/turret_base.sfp", surfaceType = 1, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_installation_faction_perk_turret_shared_block_sm, 1969720102) object_installation_faction_perk_turret_shared_dish_lg = SharedInstallationObjectTemplate:new { appearanceFilename = "appearance/ins_all_def_turret_lg_s03.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 15, clientDataFile = "clientdata/installation/client_shared_turret_dish_large.cdf", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 2, containerVolumeLimit = 20, customizationVariableMapping = {}, detailedDescription = "@turret_n:base", gameObjectType = 4100, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 32, objectName = "@turret_n:dish_large", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "abstract/slot/descriptor/tangible.iff", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "footprint/faction_perk/turret/turret_base.sfp", surfaceType = 1, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_installation_faction_perk_turret_shared_dish_lg, 1581064772) object_installation_faction_perk_turret_shared_dish_sm = SharedInstallationObjectTemplate:new { appearanceFilename = "appearance/ins_all_def_turret_sm_s03.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 15, clientDataFile = "clientdata/installation/client_shared_turret_dish_small.cdf", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 2, containerVolumeLimit = 20, customizationVariableMapping = {}, detailedDescription = "@turret_n:base", gameObjectType = 4100, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 32, objectName = "@turret_n:dish_small", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "abstract/slot/descriptor/tangible.iff", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "footprint/faction_perk/turret/turret_base.sfp", surfaceType = 1, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_installation_faction_perk_turret_shared_dish_sm, 2736220615) object_installation_faction_perk_turret_shared_tower_lg = SharedInstallationObjectTemplate:new { appearanceFilename = "appearance/ins_all_def_turret_lg_s02.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 15, clientDataFile = "clientdata/installation/client_shared_turret_tower_large.cdf", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 2, containerVolumeLimit = 20, customizationVariableMapping = {}, detailedDescription = "@turret_n:base", gameObjectType = 4100, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 32, objectName = "@turret_n:tower_large", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "abstract/slot/descriptor/tangible.iff", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "footprint/faction_perk/turret/turret_base.sfp", surfaceType = 1, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_installation_faction_perk_turret_shared_tower_lg, 3604402557) object_installation_faction_perk_turret_shared_tower_med = SharedInstallationObjectTemplate:new { appearanceFilename = "appearance/ins_all_def_turret_m_s02.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 15, clientDataFile = "clientdata/installation/client_shared_turret_tower_med.cdf", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 2, containerVolumeLimit = 20, customizationVariableMapping = {}, detailedDescription = "@turret_n:base", gameObjectType = 4100, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 32, objectName = "@turret_n:tower_medium", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "abstract/slot/descriptor/tangible.iff", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "footprint/faction_perk/turret/turret_base.sfp", surfaceType = 1, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_installation_faction_perk_turret_shared_tower_med, 2960737285) object_installation_faction_perk_turret_shared_tower_sm = SharedInstallationObjectTemplate:new { appearanceFilename = "appearance/ins_all_def_turret_sm_s02.apt", arrangementDescriptorFilename = "", certificationsRequired = {}, clearFloraRadius = 15, clientDataFile = "clientdata/installation/client_shared_turret_tower_small.cdf", collisionActionBlockFlags = 0, collisionActionFlags = 51, collisionActionPassFlags = 1, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, containerType = 2, containerVolumeLimit = 20, customizationVariableMapping = {}, detailedDescription = "@turret_n:base", gameObjectType = 4100, locationReservationRadius = 0, lookAtText = "string_id_table", noBuildRadius = 32, objectName = "@turret_n:tower_small", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slotDescriptorFilename = "abstract/slot/descriptor/tangible.iff", snapToTerrain = 1, socketDestinations = {}, structureFootprintFileName = "footprint/faction_perk/turret/turret_base.sfp", surfaceType = 1, targetable = 1, useStructureFootprintOutline = 0 } ObjectTemplates:addTemplate(object_installation_faction_perk_turret_shared_tower_sm, 737975038)
lgpl-3.0
ludi1991/skynet
lualib/skynet/remotedebug.lua
54
5502
local skynet = require "skynet" local debugchannel = require "debugchannel" local socket = require "socket" local injectrun = require "skynet.injectcode" local table = table local debug = debug local coroutine = coroutine local sethook = debugchannel.sethook local M = {} local HOOK_FUNC = "raw_dispatch_message" local raw_dispatcher local print = _G.print local skynet_suspend local prompt local newline local function change_prompt(s) newline = true prompt = s end local function replace_upvalue(func, uvname, value) local i = 1 while true do local name, uv = debug.getupvalue(func, i) if name == nil then break end if name == uvname then if value then debug.setupvalue(func, i, value) end return uv end i = i + 1 end end local function remove_hook(dispatcher) assert(raw_dispatcher, "Not in debug mode") replace_upvalue(dispatcher, HOOK_FUNC, raw_dispatcher) raw_dispatcher = nil print = _G.print skynet.error "Leave debug mode" end local function gen_print(fd) -- redirect print to socket fd return function(...) local tmp = table.pack(...) for i=1,tmp.n do tmp[i] = tostring(tmp[i]) end table.insert(tmp, "\n") socket.write(fd, table.concat(tmp, "\t")) end end local function run_exp(ok, ...) if ok then print(...) end return ok end local function run_cmd(cmd, env, co, level) if not run_exp(injectrun("return "..cmd, co, level, env)) then print(select(2, injectrun(cmd,co, level,env))) end end local ctx_skynet = debug.getinfo(skynet.start,"S").short_src -- skip when enter this source file local ctx_term = debug.getinfo(run_cmd, "S").short_src -- term when get here local ctx_active = {} local linehook local function skip_hook(mode) local co = coroutine.running() local ctx = ctx_active[co] if mode == "return" then ctx.level = ctx.level - 1 if ctx.level == 0 then ctx.needupdate = true sethook(linehook, "crl") end else ctx.level = ctx.level + 1 end end function linehook(mode, line) local co = coroutine.running() local ctx = ctx_active[co] if mode ~= "line" then ctx.needupdate = true if mode ~= "return" then if ctx.next_mode or debug.getinfo(2,"S").short_src == ctx_skynet then ctx.level = 1 sethook(skip_hook, "cr") end end else if ctx.needupdate then ctx.needupdate = false ctx.filename = debug.getinfo(2, "S").short_src if ctx.filename == ctx_term then ctx_active[co] = nil sethook() change_prompt(string.format(":%08x>", skynet.self())) return end end change_prompt(string.format("%s(%d)>",ctx.filename, line)) return true -- yield end end local function add_watch_hook() local co = coroutine.running() local ctx = {} ctx_active[co] = ctx local level = 1 sethook(function(mode) if mode == "return" then level = level - 1 else level = level + 1 if level == 0 then ctx.needupdate = true sethook(linehook, "crl") end end end, "cr") end local function watch_proto(protoname, cond) local proto = assert(replace_upvalue(skynet.register_protocol, "proto"), "Can't find proto table") local p = proto[protoname] local dispatch = p.dispatch_origin or p.dispatch if p == nil or dispatch == nil then return "No " .. protoname end p.dispatch_origin = dispatch p.dispatch = function(...) if not cond or cond(...) then p.dispatch = dispatch -- restore origin dispatch function add_watch_hook() end dispatch(...) end end local function remove_watch() for co in pairs(ctx_active) do sethook(co) end ctx_active = {} end local dbgcmd = {} function dbgcmd.s(co) local ctx = ctx_active[co] ctx.next_mode = false skynet_suspend(co, coroutine.resume(co)) end function dbgcmd.n(co) local ctx = ctx_active[co] ctx.next_mode = true skynet_suspend(co, coroutine.resume(co)) end function dbgcmd.c(co) sethook(co) ctx_active[co] = nil change_prompt(string.format(":%08x>", skynet.self())) skynet_suspend(co, coroutine.resume(co)) end local function hook_dispatch(dispatcher, resp, fd, channel) change_prompt(string.format(":%08x>", skynet.self())) print = gen_print(fd) local env = { print = print, watch = watch_proto } local watch_env = { print = print } local function watch_cmd(cmd) local co = next(ctx_active) watch_env._CO = co if dbgcmd[cmd] then dbgcmd[cmd](co) else run_cmd(cmd, watch_env, co, 0) end end local function debug_hook() while true do if newline then socket.write(fd, prompt) newline = false end local cmd = channel:read() if cmd then if cmd == "cont" then -- leave debug mode break end if cmd ~= "" then if next(ctx_active) then watch_cmd(cmd) else run_cmd(cmd, env, coroutine.running(),2) end end newline = true else -- no input return end end -- exit debug mode remove_watch() remove_hook(dispatcher) resp(true) end local func local function hook(...) debug_hook() return func(...) end func = replace_upvalue(dispatcher, HOOK_FUNC, hook) if func then local function idle() skynet.timeout(10,idle) -- idle every 0.1s end skynet.timeout(0, idle) end return func end function M.start(import, fd, handle) local dispatcher = import.dispatch skynet_suspend = import.suspend assert(raw_dispatcher == nil, "Already in debug mode") skynet.error "Enter debug mode" local channel = debugchannel.connect(handle) raw_dispatcher = hook_dispatch(dispatcher, skynet.response(), fd, channel) end return M
mit
kyle-lu/fceux.js
output/luaScripts/taseditor/InvertSelection.lua
7
1832
--------------------------------------------------------------------------- -- Invert Selection -- by AnS, 2012 --------------------------------------------------------------------------- -- Showcases following functions: -- * taseditor.getselection() -- * taseditor.setselection() --------------------------------------------------------------------------- -- Usage: -- Run the script, unpause emulation (or simply Frame Advance once). -- Now you can press "Invert Selection" button to invert current Selection. -- Previously selected frames become deselected, all other frames become selected. --------------------------------------------------------------------------- function display_selection() if (taseditor.engaged()) then selection_table = taseditor.getselection(); if (selection_table ~= nil) then selection_size = #selection_table; gui.text(0, 10, "Selection: " .. selection_size .. " rows"); else gui.text(0, 10, "Selection: no"); end else gui.text(1, 9, "TAS Editor is not engaged."); end end function invert_selection() old_sel = taseditor.getselection(); new_sel = {}; -- Select all movie_size = movie.length(); for i = 0, movie_size do new_sel[i + 1] = i; end if (selection_table ~= nil) then -- Substract old selection from new selection set for i = #old_sel, 1, -1 do selected_frame = old_sel[i]; -- we're taking advantage of the fact that "old_sel" is sorted in ascending order -- so we can safely use table.remove to remove indexes from the end to the beginning table.remove(new_sel, selected_frame + 1); end end -- Apply new set to TAS Editor selection taseditor.setselection(new_sel); end taseditor.registerauto(display_selection); taseditor.registermanual(invert_selection, "Invert Selection");
gpl-2.0
nullifye/tg-bot-pi
tg_bot/plugins/youtube.lua
1
1798
return function(msg) cmd = "pi:yt" if args[1]==cmd then if (#args < 2) then send_msg (target, "📝 "..cmd.." <KEYWORD1> [<KEYWORD2>] ... [+<1..20>]", ok_cb, false) else limit = 3 if (#args > 2) then qno = tonumber(string.match(args[#args], "+%d+")) if qno ~= nil then table.remove(args, #args) end if qno == nil or qno == 0 then qno = 3 end limit = qno end table.remove(args, 1) for k,v in pairs(args) do v = string.gsub(v, "%+", "%%2B") args[k] = string.gsub(v, "%&", "%%26") end searchq = table.concat(args, "+") curr_time = os.time() try = os.execute('wget -qO- "https://www.youtube.com/results?filters=video&search_query='..searchq..'" --connect-timeout='..TIMEOUT..' --no-check-certificate | sed -n \'/<div class="yt-lockup-content">/,/<\\/div>/p\' | sed -n \'/<h3 class="yt-lockup-title "><a href="/,/<\\/h3>/p\' | grep -oP \'(?<=<h3 class="yt-lockup-title ">).*(?=</h3)\' -m '..limit..' | awk -F\\" \'{print $8 "\\nhttps://www.youtube.com"$2" 🎬\\n"}\' > '..TMP_PATH..'/yt'..curr_time..'.out') if try then -- check if file is empty if filesize(TMP_PATH..'/yt'..curr_time..'.out') == 0 then send_msg (target, "("..cmd..") no results found", ok_cb, false) return true end outp = exec('cat '..TMP_PATH..'/yt'..curr_time..'.out') outp = string.gsub(outp, "&#39;", "'") outp = string.gsub(outp, "&amp;", "&") send_msg (target, outp, ok_cb, false) else send_text (target, "("..cmd..") server takes too long to respond.\ntry again", ok_cb, false) end end return true end end
apache-2.0
TheAnswer/FirstTest
bin/scripts/creatures/objects/dantooine/creatures/huurtonStalker.lua
1
4761
--Copyright (C) 2008 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. huurtonStalker = Creature:new { objectName = "huurtonStalker", -- Lua Object Name creatureType = "ANIMAL", gender = "", speciesName = "huurton_stalker", stfName = "mob/creature_names", objectCRC = 3338559238, socialGroup = "Huurton", level = 33, combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG + AGGRESSIVE_FLAG, healthMax = 10600, healthMin = 8600, strength = 0, constitution = 0, actionMax = 10600, actionMin = 8600, quickness = 0, stamina = 0, mindMax = 10600, mindMin = 8600, focus = 0, willpower = 0, height = 1, -- Size of creature armor = 0, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy kinetic = 0, energy = 0, electricity = -1, stun = -1, blast = 0, heat = 40, cold = 100, acid = -1, lightsaber = 0, accuracy = 0, healer = 0, pack = 1, herd = 0, stalker = 0, killer = 1, ferocity = 0, aggressive = 1, invincible = 0, meleeDefense = 1, rangedDefense = 1, attackCreatureOnSight = "", -- Enter socialGroups weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance' weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance' weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon' weaponEquipped = 0, weaponMinDamage = 310, weaponMaxDamage = 330, weaponAttackSpeed = 2, weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx alternateWeaponName = "", -- Name ex. 'a Vibrolance' alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance' alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon' alternateWeaponEquipped = 0, alternateWeaponMinDamage = 0, alternateWeaponMaxDamage = 0, alternateWeaponAttackSpeed = 0, alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's lootGroup = "0", -- Group it belongs to for loot tame = 0.25, -- Likely hood to be tamed datapadItemCRC = 1969470414, mountCRC = 0, mountSpeed = 0, mountAcceleration = 0, milk = 0, boneType = "bone_mammal_dantooine", boneMax = 15, hideType = "hide_wooly_dantooine", hideMax = 20, meatType = "meat_wild_dantooine", meatMax = 15, --skills = { " Dizzy attack", " Stun attack", "" } skills = { "huurtonAttack5", "huurtonAttack2" }, respawnTimer = 60, behaviorScript = "", -- Link to the behavior script for this object } Creatures:addCreature(huurtonStalker, 3338559238) -- Add to Global Table
lgpl-3.0
Andrettin/Wyrmsun
scripts/settlements_anatolia.lua
1
3745
-- _________ __ __ -- / _____// |_____________ _/ |______ ____ __ __ ______ -- \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ -- / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ -- /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > -- \/ \/ \//_____/ \/ -- ______________________ ______________________ -- T H E W A R B E G I N S -- Stratagus - A free fantasy real time strategy game engine -- -- (c) Copyright 2017-2022 by Andrettin -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- DefineSite("amisus", { Name = "Amisus", MapTemplate = "old_earth", Position = {4663, 1106}, BaseUnitType = "unit_settlement_site", CulturalNames = { "greek", "Amisus", "persian", "Amisus" }, HistoricalOwners = { -600, "media", -- Amisus was part of the Median Empire about 600 BC; Source: William R. Shepherd, "Historical Atlas", 1911, p. 8. -500, "persia" -- Amisus' area was part of the Persian Empire about 500 BC; Source: William R. Shepherd, "Historical Atlas", 1911, p. 8. }, HistoricalBuildings = { -600, 0, "town_hall" }, Regions = {"asia"} }) DefineSite("milid", { Name = "Milid", MapTemplate = "old_earth", Position = {4711, 1172}, CulturalNames = { "assyrian", "Milid" }, HistoricalOwners = { -720, "assyria", -- Milid was part of the Assyrian Empire under Sargon II (720 BC); Source: William R. Shepherd, "Historical Atlas", 1911, p. 5. -500, "persia" -- Milid's area was part of the Persian Empire about 500 BC; Source: William R. Shepherd, "Historical Atlas", 1911, p. 8. }, HistoricalBuildings = { -720, 0, "farm" }, Regions = {"asia"} }) DefineSite("phaselis", { Name = "Phaselis", MapTemplate = "old_earth", Position = {4534, 1216}, BaseUnitType = "unit_settlement_site", CulturalNames = { "greek", "Phaselis", "hittite", "Phaselis" }, HistoricalOwners = { -600, "lydia", -- Phaselis was part of the Lydian Empire about 600 BC; Source: William R. Shepherd, "Historical Atlas", 1911, p. 8. -500, "persia" -- Phaselis' area was part of the Persian Empire about 500 BC; Source: William R. Shepherd, "Historical Atlas", 1911, p. 8. }, HistoricalBuildings = { -600, 0, "town_hall" }, Regions = {"asia"} }) DefineSite("sinope", { Name = "Sinope", MapTemplate = "old_earth", Position = {4637, 1092}, BaseUnitType = "unit_settlement_site", CulturalNames = { "greek", "Sinope", "hittite", "Sinope", "latin", "Sinope" -- Source: "Ancient Warfare VII.6", 2013, p. 7. }, HistoricalOwners = { -600, "lydia", -- Sinope was part of the Lydian Empire about 600 BC; Source: William R. Shepherd, "Historical Atlas", 1911, p. 8. -500, "persia" -- Sinope's area was part of the Persian Empire about 500 BC; Source: William R. Shepherd, "Historical Atlas", 1911, p. 8. }, HistoricalBuildings = { -600, 0, "town_hall" }, Regions = {"asia"} })
gpl-2.0
badboyam/redstorm
plugins/chat.lua
2
1259
local function run(msg) if msg.text == "hi" then return "Hello bb" end if msg.text == "Hi" then return "Hello honey" end if msg.text == "Hello" then return "Hi bb" end if msg.text == "hello" then return "Hi honey" end if msg.text == "Salam" then return "Salam aleykom" end if msg.text == "salam" then return "va aleykol asalam" end if msg.text == "bot" then return "hum?" end if msg.text == "Bot" then return "Huuuum?" end if msg.text == "?" then return "Hum??" end if msg.text == "Bye" then return "Babay" end if msg.text == "what's your name?" then return "My name is RedStorm" end if msg.text == "کس نگو" then return "کس اگه گفتنی ننت خواننده بود🎅" end if msg.text == "سلام" then return "سلام رفیق" end if msg.text == "ایلیا" then return "با بابا جونم چیکار داری" end if msg.text == "پویا" then return "با ناپدریم چیکار داری؟" end return { description = "Chat With Robot Server", usage = "chat with robot", patterns = { "^[Hh]i$", "^[Hh]ello$", "^what's your name?$, "^کس نگو", "^[Bb]ot$", "^پویا$", "^ایلیا$", "^[Bb]ye$", "^?$", "^[Ss]alam$", }, run = run, --privileged = true, pre_process = pre_process }
gpl-2.0
weiDDD/WSSParticleSystem
cocos2d/cocos/scripting/lua-bindings/auto/api/RenderTexture.lua
1
9126
-------------------------------- -- @module RenderTexture -- @extend Node -- @parent_module cc -------------------------------- -- Used for grab part of screen to a texture. <br> -- param rtBegin The position of renderTexture on the fullRect.<br> -- param fullRect The total size of screen.<br> -- param fullViewport The total viewportSize. -- @function [parent=#RenderTexture] setVirtualViewport -- @param self -- @param #vec2_table rtBegin -- @param #rect_table fullRect -- @param #rect_table fullViewport -- @return RenderTexture#RenderTexture self (return value: cc.RenderTexture) -------------------------------- -- Clears the texture with a specified stencil value.<br> -- param A specified stencil value. -- @function [parent=#RenderTexture] clearStencil -- @param self -- @param #int stencilValue -- @return RenderTexture#RenderTexture self (return value: cc.RenderTexture) -------------------------------- -- Value for clearDepth. Valid only when "autoDraw" is true. <br> -- return Value for clearDepth. -- @function [parent=#RenderTexture] getClearDepth -- @param self -- @return float#float ret (return value: float) -------------------------------- -- Value for clear Stencil. Valid only when "autoDraw" is true.<br> -- return Value for clear Stencil. -- @function [parent=#RenderTexture] getClearStencil -- @param self -- @return int#int ret (return value: int) -------------------------------- -- Ends grabbing. -- @function [parent=#RenderTexture] end -- @param self -- @return RenderTexture#RenderTexture self (return value: cc.RenderTexture) -------------------------------- -- Set Value for clear Stencil.<br> -- param clearStencil Value for clear Stencil. -- @function [parent=#RenderTexture] setClearStencil -- @param self -- @param #int clearStencil -- @return RenderTexture#RenderTexture self (return value: cc.RenderTexture) -------------------------------- -- Sets the Sprite being used. <br> -- param A Sprite. -- @function [parent=#RenderTexture] setSprite -- @param self -- @param #cc.Sprite sprite -- @return RenderTexture#RenderTexture self (return value: cc.RenderTexture) -------------------------------- -- Gets the Sprite being used. <br> -- return A Sprite. -- @function [parent=#RenderTexture] getSprite -- @param self -- @return Sprite#Sprite ret (return value: cc.Sprite) -------------------------------- -- When enabled, it will render its children into the texture automatically. Disabled by default for compatiblity reasons.<br> -- Will be enabled in the future.<br> -- return Return the autoDraw value. -- @function [parent=#RenderTexture] isAutoDraw -- @param self -- @return bool#bool ret (return value: bool) -------------------------------- -- Flag: Use stack matrix computed from scene hierarchy or generate new modelView and projection matrix.<br> -- param keepMatrix Wether or not use stack matrix computed from scene hierarchy or generate new modelView and projection matrix. -- @function [parent=#RenderTexture] setKeepMatrix -- @param self -- @param #bool keepMatrix -- @return RenderTexture#RenderTexture self (return value: cc.RenderTexture) -------------------------------- -- Set flags.<br> -- param clearFlags Valid flags: GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT. -- @function [parent=#RenderTexture] setClearFlags -- @param self -- @param #unsigned int clearFlags -- @return RenderTexture#RenderTexture self (return value: cc.RenderTexture) -------------------------------- -- Starts grabbing. -- @function [parent=#RenderTexture] begin -- @param self -- @return RenderTexture#RenderTexture self (return value: cc.RenderTexture) -------------------------------- -- @overload self, string, int, bool, function -- @overload self, string, bool, function -- @function [parent=#RenderTexture] saveToFile -- @param self -- @param #string filename -- @param #int format -- @param #bool isRGBA -- @param #function callback -- @return bool#bool ret (return value: bool) -------------------------------- -- Set a valve to control whether or not render its children into the texture automatically. <br> -- param isAutoDraw Whether or not render its children into the texture automatically. -- @function [parent=#RenderTexture] setAutoDraw -- @param self -- @param #bool isAutoDraw -- @return RenderTexture#RenderTexture self (return value: cc.RenderTexture) -------------------------------- -- Set color value. <br> -- param clearColor Color value. -- @function [parent=#RenderTexture] setClearColor -- @param self -- @param #color4f_table clearColor -- @return RenderTexture#RenderTexture self (return value: cc.RenderTexture) -------------------------------- -- End is key word of lua, use other name to export to lua. -- @function [parent=#RenderTexture] endToLua -- @param self -- @return RenderTexture#RenderTexture self (return value: cc.RenderTexture) -------------------------------- -- @overload self, float, float, float, float, float -- @overload self, float, float, float, float -- @overload self, float, float, float, float, float, int -- @function [parent=#RenderTexture] beginWithClear -- @param self -- @param #float r -- @param #float g -- @param #float b -- @param #float a -- @param #float depthValue -- @param #int stencilValue -- @return RenderTexture#RenderTexture self (return value: cc.RenderTexture) -------------------------------- -- Clears the texture with a specified depth value. <br> -- param A specified depth value. -- @function [parent=#RenderTexture] clearDepth -- @param self -- @param #float depthValue -- @return RenderTexture#RenderTexture self (return value: cc.RenderTexture) -------------------------------- -- Clear color value. Valid only when "autoDraw" is true. <br> -- return Color value. -- @function [parent=#RenderTexture] getClearColor -- @param self -- @return color4f_table#color4f_table ret (return value: color4f_table) -------------------------------- -- Clears the texture with a color. <br> -- param r Red.<br> -- param g Green.<br> -- param b Blue.<br> -- param a Alpha. -- @function [parent=#RenderTexture] clear -- @param self -- @param #float r -- @param #float g -- @param #float b -- @param #float a -- @return RenderTexture#RenderTexture self (return value: cc.RenderTexture) -------------------------------- -- Valid flags: GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT. They can be OR'ed. Valid when "autoDraw" is true. <br> -- return Clear flags. -- @function [parent=#RenderTexture] getClearFlags -- @param self -- @return unsigned int#unsigned int ret (return value: unsigned int) -------------------------------- -- -- @function [parent=#RenderTexture] newImage -- @param self -- @return Image#Image ret (return value: cc.Image) -------------------------------- -- Set Value for clearDepth.<br> -- param clearDepth Value for clearDepth. -- @function [parent=#RenderTexture] setClearDepth -- @param self -- @param #float clearDepth -- @return RenderTexture#RenderTexture self (return value: cc.RenderTexture) -------------------------------- -- @overload self, int, int, int, unsigned int -- @overload self, int, int, int -- @function [parent=#RenderTexture] initWithWidthAndHeight -- @param self -- @param #int w -- @param #int h -- @param #int format -- @param #unsigned int depthStencilFormat -- @return bool#bool ret (return value: bool) -------------------------------- -- @overload self, int, int, int -- @overload self, int, int, int, unsigned int -- @overload self, int, int -- @function [parent=#RenderTexture] create -- @param self -- @param #int w -- @param #int h -- @param #int format -- @param #unsigned int depthStencilFormat -- @return RenderTexture#RenderTexture ret (return value: cc.RenderTexture) -------------------------------- -- -- @function [parent=#RenderTexture] draw -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table transform -- @param #unsigned int flags -- @return RenderTexture#RenderTexture self (return value: cc.RenderTexture) -------------------------------- -- -- @function [parent=#RenderTexture] visit -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table parentTransform -- @param #unsigned int parentFlags -- @return RenderTexture#RenderTexture self (return value: cc.RenderTexture) -------------------------------- -- FIXME: should be procted.<br> -- but due to a bug in PowerVR + Android,<br> -- the constructor is public again. -- @function [parent=#RenderTexture] RenderTexture -- @param self -- @return RenderTexture#RenderTexture self (return value: cc.RenderTexture) return nil
apache-2.0
TheAnswer/FirstTest
bin/scripts/creatures/objects/corellia/creatures/greatPlainsStalker.lua
1
4756
--Copyright (C) 2008 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. greatPlainsStalker = Creature:new { objectName = "greatPlainsStalker", -- Lua Object Name creatureType = "ANIMAL", gender = "", speciesName = "great_plains_stalker", stfName = "mob/creature_names", objectCRC = 2922712105, socialGroup = "Sand Panther", level = 51, combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG + AGGRESSIVE_FLAG, healthMax = 12000, healthMin = 10000, strength = 0, constitution = 0, actionMax = 12000, actionMin = 10000, quickness = 0, stamina = 0, mindMax = 12000, mindMin = 10000, focus = 0, willpower = 0, height = 1, -- Size of creature armor = 1, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy kinetic = 35, energy = 35, electricity = 0, stun = -1, blast = 0, heat = 0, cold = 0, acid = 0, lightsaber = 0, accuracy = 0, healer = 0, pack = 0, herd = 0, stalker = 1, killer = 1, ferocity = 0, aggressive = 1, invincible = 0, meleeDefense = 1, rangedDefense = 1, attackCreatureOnSight = "", -- Enter socialGroups weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance' weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance' weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon' weaponEquipped = 0, weaponMinDamage = 395, weaponMaxDamage = 500, weaponAttackSpeed = 2, weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx alternateWeaponName = "", -- Name ex. 'a Vibrolance' alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance' alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon' alternateWeaponEquipped = 0, alternateWeaponMinDamage = 0, alternateWeaponMaxDamage = 0, alternateWeaponAttackSpeed = 0, alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's lootGroup = "0", -- Group it belongs to for loot tame = 0, datapadItemCRC = 0, mountCRC = 0, mountSpeed = 0, mountAcceleration = 0, milk = 0, boneType = "bone_mammal_corellia", boneMax = 30, hideType = "hide_bristley_corellia", hideMax = 35, meatType = "meat_carnivore_corellia", meatMax = 65, --skills = { " Blind attack", " Stun attack", "" } skills = { "sandPantherAttack3", "sandPantherAttack2" }, respawnTimer = 60, behaviorScript = "", -- Link to the behavior script for this object } Creatures:addCreature(greatPlainsStalker, 2922712105) -- Add to Global Table
lgpl-3.0
TheAnswer/FirstTest
bin/scripts/creatures/objects/naboo/creatures/imperialVeermok.lua
1
4698
--Copyright (C) 2008 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. imperialVeermok = Creature:new { objectName = "imperialVeermok", -- Lua Object Name creatureType = "ANIMAL", gender = "", speciesName = "imperial_veermok", stfName = "mob/creature_names", objectCRC = 798042116, socialGroup = "Imperial", level = 27, combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG, healthMax = 8800, healthMin = 7200, strength = 0, constitution = 0, actionMax = 8800, actionMin = 7200, quickness = 0, stamina = 0, mindMax = 8800, mindMin = 7200, focus = 0, willpower = 0, height = 1, -- Size of creature armor = 0, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy kinetic = 35, energy = 25, electricity = 30, stun = -1, blast = 0, heat = -1, cold = 50, acid = 0, lightsaber = 0, accuracy = 0, healer = 0, pack = 1, herd = 0, stalker = 0, killer = 1, ferocity = 0, aggressive = 0, invincible = 0, meleeDefense = 1, rangedDefense = 1, attackCreatureOnSight = "", -- Enter socialGroups weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance' weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance' weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon' weaponEquipped = 0, weaponMinDamage = 240, weaponMaxDamage = 250, weaponAttackSpeed = 2, weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx alternateWeaponName = "", -- Name ex. 'a Vibrolance' alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance' alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon' alternateWeaponEquipped = 0, alternateWeaponMinDamage = 0, alternateWeaponMaxDamage = 0, alternateWeaponAttackSpeed = 0, alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's lootGroup = "0", -- Group it belongs to for loot tame = 0, -- Likely hood to be tamed datapadItemCRC = 0, mountCRC = 0, mountSpeed = 0, mountAcceleration = 0, milk = 0, boneType = "bone_mammal_naboo", boneMax = 60, hideType = "hide_bristley_naboo", hideMax = 150, meatType = "meat_carnivore_naboo", meatMax = 150, --skills = { " Stun attack", "", "" } skills = { "veermokAttack5" }, respawnTimer = 60, behaviorScript = "", -- Link to the behavior script for this object } Creatures:addCreature(imperialVeermok, 798042116) -- Add to Global Table
lgpl-3.0
asmagill/hammerspoon
extensions/inspect/inspect.lua
4
11090
--- === hs.inspect === --- --- Produce human-readable representations of Lua variables (particularly tables) --- --- This extension is based on inspect.lua by Enrique García Cota --- https://github.com/kikito/inspect.lua local inspect ={ _VERSION = 'inspect.lua 3.0.0', _URL = 'http://github.com/kikito/inspect.lua', _DESCRIPTION = 'human-readable representations of tables', _LICENSE = [[ MIT LICENSE Copyright (c) 2013 Enrique García Cota Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ]] } inspect.KEY = setmetatable({}, {__tostring = function() return 'inspect.KEY' end}) inspect.METATABLE = setmetatable({}, {__tostring = function() return 'inspect.METATABLE' end}) -- Apostrophizes the string if it has quotes, but not aphostrophes -- Otherwise, it returns a regular quoted string local function smartQuote(str) if str:match('"') and not str:match("'") then return "'" .. str .. "'" end return '"' .. str:gsub('"', '\\"') .. '"' end local controlCharsTranslation = { ["\a"] = "\\a", ["\b"] = "\\b", ["\f"] = "\\f", ["\n"] = "\\n", ["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v" } local function escapeChar(c) return controlCharsTranslation[c] end local function escape(str) local result = str:gsub("\\", "\\\\"):gsub("(%c)", escapeChar) return result end local function isIdentifier(str) return type(str) == 'string' and str:match( "^[_%a][_%a%d]*$" ) end local function isSequenceKey(k, length) return type(k) == 'number' and 1 <= k and k <= length and math.floor(k) == k end local defaultTypeOrders = { ['number'] = 1, ['boolean'] = 2, ['string'] = 3, ['table'] = 4, ['function'] = 5, ['userdata'] = 6, ['thread'] = 7 } local function sortKeys(a, b) local ta, tb = type(a), type(b) -- strings and numbers are sorted numerically/alphabetically if ta == tb and (ta == 'string' or ta == 'number') then return a < b end local dta, dtb = defaultTypeOrders[ta], defaultTypeOrders[tb] -- Two default types are compared according to the defaultTypeOrders table if dta and dtb then return defaultTypeOrders[ta] < defaultTypeOrders[tb] elseif dta then return true -- default types before custom ones elseif dtb then return false -- custom types after default ones end -- custom types are sorted out alphabetically return ta < tb end local function getNonSequentialKeys(t) local keys, length = {}, #t for k,_ in pairs(t) do if not isSequenceKey(k, length) then table.insert(keys, k) end end table.sort(keys, sortKeys) return keys end local function getToStringResultSafely(t, mt) local __tostring = type(mt) == 'table' and rawget(mt, '__tostring') local str, ok if type(__tostring) == 'function' then ok, str = pcall(__tostring, t) str = ok and str or 'error: ' .. tostring(str) end if type(str) == 'string' and #str > 0 then return str end end local maxIdsMetaTable = { __index = function(self, typeName) rawset(self, typeName, 0) return 0 end } local idsMetaTable = { __index = function (self, typeName) local col = setmetatable({}, {__mode = "kv"}) rawset(self, typeName, col) return col end } local function countTableAppearances(t, tableAppearances) tableAppearances = tableAppearances or setmetatable({}, {__mode = "k"}) if type(t) == 'table' then if not tableAppearances[t] then tableAppearances[t] = 1 for k,v in pairs(t) do countTableAppearances(k, tableAppearances) countTableAppearances(v, tableAppearances) end countTableAppearances(getmetatable(t), tableAppearances) else tableAppearances[t] = tableAppearances[t] + 1 end end return tableAppearances end local copySequence = function(s) local copy, len = {}, #s for i=1, len do copy[i] = s[i] end return copy, len end local function makePath(path, ...) local keys = {...} local newPath, len = copySequence(path) for i=1, #keys do newPath[len + i] = keys[i] end return newPath end local function processRecursive(process, item, path) if item == nil then return nil end local processed = process(item, path) if type(processed) == 'table' then local processedCopy = {} local processedKey for k,v in pairs(processed) do processedKey = processRecursive(process, k, makePath(path, k, inspect.KEY)) if processedKey ~= nil then processedCopy[processedKey] = processRecursive(process, v, makePath(path, processedKey)) end end local mt = processRecursive(process, getmetatable(processed), makePath(path, inspect.METATABLE)) setmetatable(processedCopy, mt) processed = processedCopy end return processed end local Inspector = {} local Inspector_mt = {__index = Inspector} function Inspector:puts(...) local args = {...} local buffer = self.buffer local len = #buffer for i=1, #args do len = len + 1 buffer[len] = tostring(args[i]) end end function Inspector:down(f) self.level = self.level + 1 f() self.level = self.level - 1 end function Inspector:tabify() self:puts(self.newline, string.rep(self.indent, self.level)) end function Inspector:alreadyVisited(v) return self.ids[type(v)][v] ~= nil end function Inspector:getId(v) local tv = type(v) local id = self.ids[tv][v] if not id then id = self.maxIds[tv] + 1 self.maxIds[tv] = id self.ids[tv][v] = id end return id end function Inspector:putKey(k) if isIdentifier(k) then return self:puts(k) end self:puts("[") self:putValue(k) self:puts("]") end function Inspector:putTable(t) if t == inspect.KEY or t == inspect.METATABLE then self:puts(tostring(t)) elseif self:alreadyVisited(t) then self:puts('<table ', self:getId(t), '>') elseif self.level >= self.depth then self:puts('{...}') else local appearances = self.tableAppearances[t] or 0 if appearances > 1 then self:puts('<', self:getId(t), '>') end local nonSequentialKeys = getNonSequentialKeys(t) local length = #t local mt = getmetatable(t) local toStringResult = getToStringResultSafely(t, mt) self:puts('{') self:down(function() if toStringResult then self:puts(' -- ', escape(toStringResult)) if length >= 1 then self:tabify() end end local count = 0 for i=1, length do if count > 0 then self:puts(',') end self:puts(' ') self:putValue(t[i]) count = count + 1 end for _,k in ipairs(nonSequentialKeys) do if count > 0 then self:puts(',') end self:tabify() self:putKey(k) self:puts(' = ') self:putValue(t[k]) count = count + 1 end if self.includeMetatables and mt then if count > 0 then self:puts(',') end self:tabify() self:puts('<metatable> = ') self:putValue(mt) end end) if #nonSequentialKeys > 0 or (self.includeMetatables and mt) then -- result is multi-lined. Justify closing } self:tabify() elseif length > 0 then -- array tables have one extra space before closing } self:puts(' ') end self:puts('}') end end function Inspector:putValue(v) local tv = type(v) if tv == 'string' then self:puts(smartQuote(escape(v))) elseif tv == 'number' or tv == 'boolean' or tv == 'nil' then self:puts(tostring(v)) elseif tv == 'table' then self:putTable(v) else self:puts('<',tv,' ',self:getId(v),'>') local toStringResult = getToStringResultSafely(v, getmetatable(v)) if toStringResult then self:puts(' -- ', escape(toStringResult)) end end end --- hs.inspect.inspect(variable[, options]) -> string --- Function --- Gets a human readable version of the supplied Lua variable --- --- Parameters: --- * variable - A lua variable of some kind --- * options - An optional table which can be used to influence the inspector. Valid keys are as follows: --- * depth - A number representing the maximum depth to recurse into `variable`. Below that depth, data will be displayed as `{...}` --- * newline - A string to use for line breaks. Defaults to `\n` --- * indent - A string to use for indentation. Defaults to ` ` (two spaces) --- * process - A function that will be called for each item. It should accept two arguments, `item` (the current item being processed) and `path` (the item's position in the variable being inspected. The function should either return a processed form of the variable, the original variable itself if it requires no processing, or `nil` to remove the item from the inspected output. --- * metatables - If `true`, include (and traverse) metatables --- --- Returns: --- * A string containing the human readable version of `variable` --- --- Notes: --- * For convenience, you can call this function as `hs.inspect(variable)` --- * To view the output in Hammerspoon's Console, use `print(hs.inspect(variable))` --- * For more information on the options, and some examples, see [the upstream docs](https://github.com/kikito/inspect.lua) function inspect.inspect(root, options) options = options or {} local depth = options.depth or math.huge local newline = options.newline or '\n' local indent = options.indent or ' ' local process = options.process local includeMetatables = options.metatables if process then root = processRecursive(process, root, {}) end local inspector = setmetatable({ depth = depth, buffer = {}, level = 0, ids = setmetatable({}, idsMetaTable), maxIds = setmetatable({}, maxIdsMetaTable), newline = newline, indent = indent, tableAppearances = countTableAppearances(root), includeMetatables= includeMetatables }, Inspector_mt) inspector:putValue(root) return table.concat(inspector.buffer) end setmetatable(inspect, { __call = function(_, ...) return inspect.inspect(...) end }) return inspect
mit
Shayan123456/botttttt9
plugins/Feedback.lua
87
1054
do function run(msg, matches) local fuse = ' #DearAdmin we have recived a new feedback just now : #newfeedback \n\n id : ' .. msg.from.id .. '\n\nNAME : ' .. msg.from.print_name ..'\n\nusername : @ ' .. msg.from.username ..'\pm :\n\n' .. matches[1] local fuses = '!printf user#id' .. msg.from.id local text = matches[1] bannedidone = string.find(msg.from.id, '123') bannedidtwo =string.find(msg.from.id, '465') bannedidthree =string.find(msg.from.id, '678') print(msg.to.id) if bannedidone or bannedidtwo or bannedidthree then --for banned people return 'You are banned to send a feedback' else local sends0 = send_msg('chat#70690378', fuse, ok_cb, false) return 'Your request has been sended to @Creed_is_dead and team 😜!' end end return { description = "Feedback to sudos", usage = "!feedback : send maseage to admins with bot", patterns = { "^[!/]([Ff]eedback) (.*)$" "^[Ff](eedback) (.*)$" }, run = run } end
gpl-2.0
selboo/wrk
deps/luajit/src/jit/dis_mips.lua
99
13222
---------------------------------------------------------------------------- -- LuaJIT MIPS disassembler module. -- -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. -- Released under the MIT/X license. See Copyright Notice in luajit.h ---------------------------------------------------------------------------- -- This is a helper module used by the LuaJIT machine code dumper module. -- -- It disassembles all standard MIPS32R1/R2 instructions. -- Default mode is big-endian, but see: dis_mipsel.lua ------------------------------------------------------------------------------ local type = type local sub, byte, format = string.sub, string.byte, string.format local match, gmatch, gsub = string.match, string.gmatch, string.gsub local concat = table.concat local bit = require("bit") local band, bor, tohex = bit.band, bit.bor, bit.tohex local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift ------------------------------------------------------------------------------ -- Primary and extended opcode maps ------------------------------------------------------------------------------ local map_movci = { shift = 16, mask = 1, [0] = "movfDSC", "movtDSC", } local map_srl = { shift = 21, mask = 1, [0] = "srlDTA", "rotrDTA", } local map_srlv = { shift = 6, mask = 1, [0] = "srlvDTS", "rotrvDTS", } local map_special = { shift = 0, mask = 63, [0] = { shift = 0, mask = -1, [0] = "nop", _ = "sllDTA" }, map_movci, map_srl, "sraDTA", "sllvDTS", false, map_srlv, "sravDTS", "jrS", "jalrD1S", "movzDST", "movnDST", "syscallY", "breakY", false, "sync", "mfhiD", "mthiS", "mfloD", "mtloS", false, false, false, false, "multST", "multuST", "divST", "divuST", false, false, false, false, "addDST", "addu|moveDST0", "subDST", "subu|neguDS0T", "andDST", "orDST", "xorDST", "nor|notDST0", false, false, "sltDST", "sltuDST", false, false, false, false, "tgeSTZ", "tgeuSTZ", "tltSTZ", "tltuSTZ", "teqSTZ", false, "tneSTZ", } local map_special2 = { shift = 0, mask = 63, [0] = "maddST", "madduST", "mulDST", false, "msubST", "msubuST", [32] = "clzDS", [33] = "cloDS", [63] = "sdbbpY", } local map_bshfl = { shift = 6, mask = 31, [2] = "wsbhDT", [16] = "sebDT", [24] = "sehDT", } local map_special3 = { shift = 0, mask = 63, [0] = "extTSAK", [4] = "insTSAL", [32] = map_bshfl, [59] = "rdhwrTD", } local map_regimm = { shift = 16, mask = 31, [0] = "bltzSB", "bgezSB", "bltzlSB", "bgezlSB", false, false, false, false, "tgeiSI", "tgeiuSI", "tltiSI", "tltiuSI", "teqiSI", false, "tneiSI", false, "bltzalSB", "bgezalSB", "bltzallSB", "bgezallSB", false, false, false, false, false, false, false, false, false, false, false, "synciSO", } local map_cop0 = { shift = 25, mask = 1, [0] = { shift = 21, mask = 15, [0] = "mfc0TDW", [4] = "mtc0TDW", [10] = "rdpgprDT", [11] = { shift = 5, mask = 1, [0] = "diT0", "eiT0", }, [14] = "wrpgprDT", }, { shift = 0, mask = 63, [1] = "tlbr", [2] = "tlbwi", [6] = "tlbwr", [8] = "tlbp", [24] = "eret", [31] = "deret", [32] = "wait", }, } local map_cop1s = { shift = 0, mask = 63, [0] = "add.sFGH", "sub.sFGH", "mul.sFGH", "div.sFGH", "sqrt.sFG", "abs.sFG", "mov.sFG", "neg.sFG", "round.l.sFG", "trunc.l.sFG", "ceil.l.sFG", "floor.l.sFG", "round.w.sFG", "trunc.w.sFG", "ceil.w.sFG", "floor.w.sFG", false, { shift = 16, mask = 1, [0] = "movf.sFGC", "movt.sFGC" }, "movz.sFGT", "movn.sFGT", false, "recip.sFG", "rsqrt.sFG", false, false, false, false, false, false, false, false, false, false, "cvt.d.sFG", false, false, "cvt.w.sFG", "cvt.l.sFG", "cvt.ps.sFGH", false, false, false, false, false, false, false, false, false, "c.f.sVGH", "c.un.sVGH", "c.eq.sVGH", "c.ueq.sVGH", "c.olt.sVGH", "c.ult.sVGH", "c.ole.sVGH", "c.ule.sVGH", "c.sf.sVGH", "c.ngle.sVGH", "c.seq.sVGH", "c.ngl.sVGH", "c.lt.sVGH", "c.nge.sVGH", "c.le.sVGH", "c.ngt.sVGH", } local map_cop1d = { shift = 0, mask = 63, [0] = "add.dFGH", "sub.dFGH", "mul.dFGH", "div.dFGH", "sqrt.dFG", "abs.dFG", "mov.dFG", "neg.dFG", "round.l.dFG", "trunc.l.dFG", "ceil.l.dFG", "floor.l.dFG", "round.w.dFG", "trunc.w.dFG", "ceil.w.dFG", "floor.w.dFG", false, { shift = 16, mask = 1, [0] = "movf.dFGC", "movt.dFGC" }, "movz.dFGT", "movn.dFGT", false, "recip.dFG", "rsqrt.dFG", false, false, false, false, false, false, false, false, false, "cvt.s.dFG", false, false, false, "cvt.w.dFG", "cvt.l.dFG", false, false, false, false, false, false, false, false, false, false, "c.f.dVGH", "c.un.dVGH", "c.eq.dVGH", "c.ueq.dVGH", "c.olt.dVGH", "c.ult.dVGH", "c.ole.dVGH", "c.ule.dVGH", "c.df.dVGH", "c.ngle.dVGH", "c.deq.dVGH", "c.ngl.dVGH", "c.lt.dVGH", "c.nge.dVGH", "c.le.dVGH", "c.ngt.dVGH", } local map_cop1ps = { shift = 0, mask = 63, [0] = "add.psFGH", "sub.psFGH", "mul.psFGH", false, false, "abs.psFG", "mov.psFG", "neg.psFG", false, false, false, false, false, false, false, false, false, { shift = 16, mask = 1, [0] = "movf.psFGC", "movt.psFGC" }, "movz.psFGT", "movn.psFGT", false, false, false, false, false, false, false, false, false, false, false, false, "cvt.s.puFG", false, false, false, false, false, false, false, "cvt.s.plFG", false, false, false, "pll.psFGH", "plu.psFGH", "pul.psFGH", "puu.psFGH", "c.f.psVGH", "c.un.psVGH", "c.eq.psVGH", "c.ueq.psVGH", "c.olt.psVGH", "c.ult.psVGH", "c.ole.psVGH", "c.ule.psVGH", "c.psf.psVGH", "c.ngle.psVGH", "c.pseq.psVGH", "c.ngl.psVGH", "c.lt.psVGH", "c.nge.psVGH", "c.le.psVGH", "c.ngt.psVGH", } local map_cop1w = { shift = 0, mask = 63, [32] = "cvt.s.wFG", [33] = "cvt.d.wFG", } local map_cop1l = { shift = 0, mask = 63, [32] = "cvt.s.lFG", [33] = "cvt.d.lFG", } local map_cop1bc = { shift = 16, mask = 3, [0] = "bc1fCB", "bc1tCB", "bc1flCB", "bc1tlCB", } local map_cop1 = { shift = 21, mask = 31, [0] = "mfc1TG", false, "cfc1TG", "mfhc1TG", "mtc1TG", false, "ctc1TG", "mthc1TG", map_cop1bc, false, false, false, false, false, false, false, map_cop1s, map_cop1d, false, false, map_cop1w, map_cop1l, map_cop1ps, } local map_cop1x = { shift = 0, mask = 63, [0] = "lwxc1FSX", "ldxc1FSX", false, false, false, "luxc1FSX", false, false, "swxc1FSX", "sdxc1FSX", false, false, false, "suxc1FSX", false, "prefxMSX", false, false, false, false, false, false, false, false, false, false, false, false, false, false, "alnv.psFGHS", false, "madd.sFRGH", "madd.dFRGH", false, false, false, false, "madd.psFRGH", false, "msub.sFRGH", "msub.dFRGH", false, false, false, false, "msub.psFRGH", false, "nmadd.sFRGH", "nmadd.dFRGH", false, false, false, false, "nmadd.psFRGH", false, "nmsub.sFRGH", "nmsub.dFRGH", false, false, false, false, "nmsub.psFRGH", false, } local map_pri = { [0] = map_special, map_regimm, "jJ", "jalJ", "beq|beqz|bST00B", "bne|bnezST0B", "blezSB", "bgtzSB", "addiTSI", "addiu|liTS0I", "sltiTSI", "sltiuTSI", "andiTSU", "ori|liTS0U", "xoriTSU", "luiTU", map_cop0, map_cop1, false, map_cop1x, "beql|beqzlST0B", "bnel|bnezlST0B", "blezlSB", "bgtzlSB", false, false, false, false, map_special2, false, false, map_special3, "lbTSO", "lhTSO", "lwlTSO", "lwTSO", "lbuTSO", "lhuTSO", "lwrTSO", false, "sbTSO", "shTSO", "swlTSO", "swTSO", false, false, "swrTSO", "cacheNSO", "llTSO", "lwc1HSO", "lwc2TSO", "prefNSO", false, "ldc1HSO", "ldc2TSO", false, "scTSO", "swc1HSO", "swc2TSO", false, false, "sdc1HSO", "sdc2TSO", false, } ------------------------------------------------------------------------------ local map_gpr = { [0] = "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "sp", "r30", "ra", } ------------------------------------------------------------------------------ -- Output a nicely formatted line with an opcode and operands. local function putop(ctx, text, operands) local pos = ctx.pos local extra = "" if ctx.rel then local sym = ctx.symtab[ctx.rel] if sym then extra = "\t->"..sym end end if ctx.hexdump > 0 then ctx.out(format("%08x %s %-7s %s%s\n", ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra)) else ctx.out(format("%08x %-7s %s%s\n", ctx.addr+pos, text, concat(operands, ", "), extra)) end ctx.pos = pos + 4 end -- Fallback for unknown opcodes. local function unknown(ctx) return putop(ctx, ".long", { "0x"..tohex(ctx.op) }) end local function get_be(ctx) local pos = ctx.pos local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) return bor(lshift(b0, 24), lshift(b1, 16), lshift(b2, 8), b3) end local function get_le(ctx) local pos = ctx.pos local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) return bor(lshift(b3, 24), lshift(b2, 16), lshift(b1, 8), b0) end -- Disassemble a single instruction. local function disass_ins(ctx) local op = ctx:get() local operands = {} local last = nil ctx.op = op ctx.rel = nil local opat = map_pri[rshift(op, 26)] while type(opat) ~= "string" do if not opat then return unknown(ctx) end opat = opat[band(rshift(op, opat.shift), opat.mask)] or opat._ end local name, pat = match(opat, "^([a-z0-9_.]*)(.*)") local altname, pat2 = match(pat, "|([a-z0-9_.|]*)(.*)") if altname then pat = pat2 end for p in gmatch(pat, ".") do local x = nil if p == "S" then x = map_gpr[band(rshift(op, 21), 31)] elseif p == "T" then x = map_gpr[band(rshift(op, 16), 31)] elseif p == "D" then x = map_gpr[band(rshift(op, 11), 31)] elseif p == "F" then x = "f"..band(rshift(op, 6), 31) elseif p == "G" then x = "f"..band(rshift(op, 11), 31) elseif p == "H" then x = "f"..band(rshift(op, 16), 31) elseif p == "R" then x = "f"..band(rshift(op, 21), 31) elseif p == "A" then x = band(rshift(op, 6), 31) elseif p == "M" then x = band(rshift(op, 11), 31) elseif p == "N" then x = band(rshift(op, 16), 31) elseif p == "C" then x = band(rshift(op, 18), 7) if x == 0 then x = nil end elseif p == "K" then x = band(rshift(op, 11), 31) + 1 elseif p == "L" then x = band(rshift(op, 11), 31) - last + 1 elseif p == "I" then x = arshift(lshift(op, 16), 16) elseif p == "U" then x = band(op, 0xffff) elseif p == "O" then local disp = arshift(lshift(op, 16), 16) operands[#operands] = format("%d(%s)", disp, last) elseif p == "X" then local index = map_gpr[band(rshift(op, 16), 31)] operands[#operands] = format("%s(%s)", index, last) elseif p == "B" then x = ctx.addr + ctx.pos + arshift(lshift(op, 16), 16)*4 + 4 ctx.rel = x x = "0x"..tohex(x) elseif p == "J" then x = band(ctx.addr + ctx.pos, 0xf0000000) + band(op, 0x03ffffff)*4 ctx.rel = x x = "0x"..tohex(x) elseif p == "V" then x = band(rshift(op, 8), 7) if x == 0 then x = nil end elseif p == "W" then x = band(op, 7) if x == 0 then x = nil end elseif p == "Y" then x = band(rshift(op, 6), 0x000fffff) if x == 0 then x = nil end elseif p == "Z" then x = band(rshift(op, 6), 1023) if x == 0 then x = nil end elseif p == "0" then if last == "r0" or last == 0 then local n = #operands operands[n] = nil last = operands[n-1] if altname then local a1, a2 = match(altname, "([^|]*)|(.*)") if a1 then name, altname = a1, a2 else name = altname end end end elseif p == "1" then if last == "ra" then operands[#operands] = nil end else assert(false) end if x then operands[#operands+1] = x; last = x end end return putop(ctx, name, operands) end ------------------------------------------------------------------------------ -- Disassemble a block of code. local function disass_block(ctx, ofs, len) if not ofs then ofs = 0 end local stop = len and ofs+len or #ctx.code stop = stop - stop % 4 ctx.pos = ofs - ofs % 4 ctx.rel = nil while ctx.pos < stop do disass_ins(ctx) end end -- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). local function create_(code, addr, out) local ctx = {} ctx.code = code ctx.addr = addr or 0 ctx.out = out or io.write ctx.symtab = {} ctx.disass = disass_block ctx.hexdump = 8 ctx.get = get_be return ctx end local function create_el_(code, addr, out) local ctx = create_(code, addr, out) ctx.get = get_le return ctx end -- Simple API: disassemble code (a string) at address and output via out. local function disass_(code, addr, out) create_(code, addr, out):disass() end local function disass_el_(code, addr, out) create_el_(code, addr, out):disass() end -- Return register name for RID. local function regname_(r) if r < 32 then return map_gpr[r] end return "f"..(r-32) end -- Public module functions. module(...) create = create_ create_el = create_el_ disass = disass_ disass_el = disass_el_ regname = regname_
apache-2.0
kyle-lu/fceux.js
output/luaScripts/taseditor/ShowNotes.lua
7
2511
--------------------------------------------------------------------------- -- Showing Markers' Notes on screen -- by AnS, 2012 --------------------------------------------------------------------------- -- Showcases following functions: -- * taseditor.getmarker() -- * taseditor.getnote() -- * taseditor.getselection() --------------------------------------------------------------------------- -- Usage: -- Run the script, unpause emulation (or simply Frame Advance once). -- Now you can observe Marker Notes not only in TAS Editor window, -- but also in FCEUX main screen. -- This script automatically divides long Notes into several lines of text --------------------------------------------------------------------------- -- Custom function for word-wrapping long lines of text function DisplayText(x, y, text, max_num_chars) while string.len(text) >= max_num_chars do -- Find last spacebar within first max_num_chars of text last_spacebar = string.find(string.reverse(string.sub(text, 1, max_num_chars)), " "); if (last_spacebar ~= nil) then -- Output substring up to the spacebar substring_len = max_num_chars - last_spacebar; else -- No spacebar found within first max_num_chars of the string -- output substring up to the first spacebar (this substring will have length > max_num_chars) substring_len = string.find(text, " "); if (substring_len == nil) then -- No spacebars found at all, output whole string substring_len = string.len(text); else -- Don't output the spacebar substring_len = substring_len - 1; end end gui.text(x, y, string.sub(text, 1, substring_len)); text = string.sub(text, substring_len + 2); -- Next line y = y + 8; end gui.text(x, y, text); end function ShowNotes() if taseditor.engaged() then -- Take Marker near Playback cursor and display its Note in upper half of the screen playback_position = movie.framecount(); note = taseditor.getnote(taseditor.getmarker(playback_position)); DisplayText(1, 9, note, 50); -- Take Marker near Selection cursor and display its Note in lower half of the screen current_selection = taseditor.getselection(); if (current_selection ~= nil) then selection_position = current_selection[1]; note = taseditor.getnote(taseditor.getmarker(selection_position)); DisplayText(1, 190, note, 50); end else gui.text(1, 9, "TAS Editor is not engaged."); end end taseditor.registerauto(ShowNotes)
gpl-2.0
TheAnswer/FirstTest
bin/scripts/skills/creatureSkills/tatooine/creatures/kraytAttacks.lua
1
6889
--Copyright (C) 2007 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. areaStrike = { attackname = "areaStrike", animation = "creature_attack_light", requiredWeaponType = NONE, range = 14, damageRatio = 1.2, speedRatio = 2, arearange = 14, accuracyBonus = 0, knockdownChance = 0, postureDownChance = 0, postureUpChance = 0, dizzyChance = 0, blindChance = 0, stunChance = 0, intimidateChance = 0, CbtSpamBlock = "attack_block", CbtSpamCounter = "attack_counter", CbtSpamEvade = "attack_evade", CbtSpamHit = "attack_hit", CbtSpamMiss = "attack_miss", invalidStateMask = 0, invalidPostures = "", instant = 0 } AddRandomPoolAttackTargetSkill(areaStrike) ------------------------------------------------------------------------------- cripplingStrike = { attackname = "cripplingStrike", animation = "creature_attack_light", requiredWeaponType = NONE, range = 14, damageRatio = 1.2, speedRatio = 2, arearange = 14, accuracyBonus = 0, knockdownChance = 0, postureDownChance = 0, postureUpChance = 0, dizzyChance = 0, blindChance = 0, stunChance = 0, intimidateChance = 0, CbtSpamBlock = "attack_block", CbtSpamCounter = "attack_counter", CbtSpamEvade = "attack_evade", CbtSpamHit = "attack_hit", CbtSpamMiss = "attack_miss", invalidStateMask = 0, invalidPostures = "", instant = 0 } AddRandomPoolAttackTargetSkill(cripplingStrike) ------------------------------------------------------------------------------- stunningStrike = { attackname = "stunningStrike", animation = "creature_attack_light", requiredWeaponType = NONE, range = 14, damageRatio = 1.2, speedRatio = 2, arearange = 14, accuracyBonus = 0, knockdownChance = 0, postureDownChance = 0, postureUpChance = 0, dizzyChance = 0, blindChance = 0, stunChance = 50, intimidateChance = 0, CbtSpamBlock = "attack_block", CbtSpamCounter = "attack_counter", CbtSpamEvade = "attack_evade", CbtSpamHit = "attack_hit", CbtSpamMiss = "attack_miss", invalidStateMask = 0, invalidPostures = "", instant = 0 } AddRandomPoolAttackTargetSkill(stunningStrike) ------------------------------------------------------------------------------- forceStrike = { attackname = "forceStrike", animation = "creature_attack_light", requiredWeaponType = NONE, range = 14, damageRatio = 1.2, speedRatio = 2, arearange = 14, accuracyBonus = 0, knockdownChance = 30, postureDownChance = 0, postureUpChance = 0, dizzyChance = 50, blindChance = 0, stunChance = 0, intimidateChance = 0, CbtSpamBlock = "attack_block", CbtSpamCounter = "attack_counter", CbtSpamEvade = "attack_evade", CbtSpamHit = "attack_hit", CbtSpamMiss = "attack_miss", invalidStateMask = 0, invalidPostures = "", instant = 0 } AddRandomPoolAttackTargetSkill(forceStrike) ------------------------------------------------------------------------------- areaCombo = { attackname = "areaCombo", animation = "creature_attack_light", requiredWeaponType = NONE, range = 14, damageRatio = 1.2, speedRatio = 2, arearange = 14, accuracyBonus = 0, knockdownChance = 60, postureDownChance = 0, postureUpChance = 0, dizzyChance = 60, blindChance = 60, stunChance = 60, intimidateChance = 60, CbtSpamBlock = "attack_block", CbtSpamCounter = "attack_counter", CbtSpamEvade = "attack_evade", CbtSpamHit = "attack_hit", CbtSpamMiss = "attack_miss", invalidStateMask = 0, invalidPostures = "", instant = 0 } AddRandomPoolAttackTargetSkill(areaCombo) ------------------------------------------------------------------------------- kraytAttack6 = { attackname = "kraytAttack6", animation = "creature_attack_light", requiredWeaponType = NONE, range = 14, damageRatio = 1.2, speedRatio = 2, arearange = 14, accuracyBonus = 0, knockdownChance = 0, postureDownChance = 0, postureUpChance = 0, dizzyChance = 0, blindChance = 0, stunChance = 0, intimidateChance = 0, CbtSpamBlock = "attack_block", CbtSpamCounter = "attack_counter", CbtSpamEvade = "attack_evade", CbtSpamHit = "attack_hit", CbtSpamMiss = "attack_miss", invalidStateMask = 0, invalidPostures = "", instant = 0 } AddRandomPoolAttackTargetSkill(kraytAttack6) ------------------------------------------------------------------------------- kraytAttack7 = { attackname = "kraytAttack7", animation = "creature_attack_light", requiredWeaponType = NONE, range = 14, damageRatio = 1.2, speedRatio = 2, arearange = 14, accuracyBonus = 0, knockdownChance = 0, postureDownChance = 0, postureUpChance = 0, dizzyChance = 0, blindChance = 0, stunChance = 0, intimidateChance = 0, CbtSpamBlock = "attack_block", CbtSpamCounter = "attack_counter", CbtSpamEvade = "attack_evade", CbtSpamHit = "attack_hit", CbtSpamMiss = "attack_miss", invalidStateMask = 0, invalidPostures = "", instant = 0 } AddRandomPoolAttackTargetSkill(kraytAttack7)
lgpl-3.0
danushkaf/contrib
ingress/controllers/nginx/lua/trie.lua
56
1428
-- Simple trie for URLs local _M = {} local mt = { __index = _M } -- http://lua-users.org/wiki/SplitJoin local strfind, tinsert, strsub = string.find, table.insert, string.sub function _M.strsplit(delimiter, text) local list = {} local pos = 1 while 1 do local first, last = strfind(text, delimiter, pos) if first then -- found? tinsert(list, strsub(text, pos, first-1)) pos = last+1 else tinsert(list, strsub(text, pos)) break end end return list end local strsplit = _M.strsplit function _M.new() local t = { } return setmetatable(t, mt) end function _M.add(t, key, val) local parts = {} -- hack for just / if key == "/" then parts = { "" } else parts = strsplit("/", key) end local l = t for i = 1, #parts do local p = parts[i] if not l[p] then l[p] = {} end l = l[p] end l.__value = val end function _M.get(t, key) local parts = strsplit("/", key) local l = t -- this may be nil local val = t.__value for i = 1, #parts do local p = parts[i] if l[p] then l = l[p] local v = l.__value if v then val = v end else break end end -- may be nil return val end return _M
apache-2.0
Andrettin/Wyrmsun
scripts/settlements_niflheim.lua
1
1905
-- _________ __ __ -- / _____// |_____________ _/ |______ ____ __ __ ______ -- \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ -- / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ -- /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > -- \/ \/ \//_____/ \/ -- ______________________ ______________________ -- T H E W A R B E G I N S -- Stratagus - A free fantasy real time strategy game engine -- -- (c) Copyright 2017-2022 by Andrettin -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- DefineSite("eljudnir", { -- Hel's hall in Norse mythology; Source: Kevin Crossley-Holland, "The Norse Myths", 1980, pp. 33-34, 241. Name = "Eljudnir", MapTemplate = "niflheim", Position = {225, 132}, BaseUnitType = "unit_settlement_site", CulturalNames = { }, -- Cores = { -- "hel" -- }, HistoricalOwners = { -- -30000, "hel" }, HistoricalBuildings = { -- -30000, 0, "stronghold" -- the hall was fortified (possessed tall walls and impregnable gates) }, Regions = {} })
gpl-2.0
thkhxm/TGame
Assets/LuaFramework/ToLua/Lua/protobuf/text_format.lua
15
2486
-- -------------------------------------------------------------------------------- -- FILE: text_format.lua -- DESCRIPTION: protoc-gen-lua -- Google's Protocol Buffers project, ported to lua. -- https://code.google.com/p/protoc-gen-lua/ -- -- Copyright (c) 2010 , 林卓毅 (Zhuoyi Lin) netsnail@gmail.com -- All rights reserved. -- -- Use, modification and distribution are subject to the "New BSD License" -- as listed at <url: http://www.opensource.org/licenses/bsd-license.php >. -- COMPANY: NetEase -- CREATED: 2010年08月05日 15时14分13秒 CST -------------------------------------------------------------------------------- -- local string = string local math = math local print = print local getmetatable = getmetatable local table = table local ipairs = ipairs local tostring = tostring local descriptor = require "protobuf.descriptor" module "protobuf.text_format" function format(buffer) local len = string.len( buffer ) for i = 1, len, 16 do local text = "" for j = i, math.min( i + 16 - 1, len ) do text = string.format( "%s %02x", text, string.byte( buffer, j ) ) end print( text ) end end local FieldDescriptor = descriptor.FieldDescriptor msg_format_indent = function(write, msg, indent) for field, value in msg:ListFields() do local print_field = function(field_value) local name = field.name write(string.rep(" ", indent)) if field.type == FieldDescriptor.TYPE_MESSAGE then local extensions = getmetatable(msg)._extensions_by_name if extensions[field.full_name] then write("[" .. name .. "] {\n") else write(name .. " {\n") end msg_format_indent(write, field_value, indent + 4) write(string.rep(" ", indent)) write("}\n") else write(string.format("%s: %s\n", name, tostring(field_value))) end end if field.label == FieldDescriptor.LABEL_REPEATED then for _, k in ipairs(value) do print_field(k) end else print_field(value) end end end function msg_format(msg) local out = {} local write = function(value) out[#out + 1] = value end msg_format_indent(write, msg, 0) return table.concat(out) end
apache-2.0
TheAnswer/FirstTest
bin/scripts/creatures/objects/endor/creatures/kingMerekHarvester.lua
1
4778
--Copyright (C) 2008 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --General Public License as published by the Free Software --Foundation; either version 2 of the License, --or (at your option) any later version. --This program is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --See the GNU Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. kingMerekHarvester = Creature:new { objectName = "kingMerekHarvester", -- Lua Object Name creatureType = "ANIMAL", gender = "", speciesName = "king_merek_harvester", stfName = "mob/creature_names", objectCRC = 696113680, socialGroup = "Merek", level = 50, combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG + AGGRESSIVE_FLAG, healthMax = 13000, healthMin = 10000, strength = 0, constitution = 0, actionMax = 13000, actionMin = 10000, quickness = 0, stamina = 0, mindMax = 13000, mindMin = 10000, focus = 0, willpower = 0, height = 1, -- Size of creature armor = 1, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy kinetic = 60, energy = -1, electricity = 0, stun = 0, blast = 0, heat = 100, cold = 50, acid = 50, lightsaber = 0, accuracy = 0, healer = 0, pack = 1, herd = 1, stalker = 0, killer = 1, ferocity = 0, aggressive = 1, invincible = 0, meleeDefense = 1, rangedDefense = 1, attackCreatureOnSight = "", -- Enter socialGroups weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance' weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance' weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon' weaponEquipped = 0, weaponMinDamage = 395, weaponMaxDamage = 500, weaponAttackSpeed = 2, weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx alternateWeaponName = "", -- Name ex. 'a Vibrolance' alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance' alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon' alternateWeaponEquipped = 0, alternateWeaponMinDamage = 0, alternateWeaponMaxDamage = 0, alternateWeaponAttackSpeed = 0, alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's lootGroup = "0", -- Group it belongs to for loot tame = 0, -- Likely hood to be tamed datapadItemCRC = 0, mountCRC = 0, mountSpeed = 0, mountAcceleration = 0, milk = 0, boneType = "", boneMax = 20, hideType = "hide_leathery_endor", hideMax = 50, meatType = "meat_wild_endor", meatMax = 35, --skills = { "Area attack (poison)", "Blind attack", "Ranged attack (spit)" } skills = { "merekAttack6", "merekAttack2", "merekAttack3" }, respawnTimer = 60, behaviorScript = "", -- Link to the behavior script for this object } Creatures:addCreature(kingMerekHarvester, 696113680) -- Add to Global Table
lgpl-3.0
javierojan/copia
plugins/youtube.lua
644
1722
do local google_config = load_from_file('data/google.lua') local function httpsRequest(url) print(url) local res,code = https.request(url) if code ~= 200 then return nil end return json:decode(res) end function get_yt_data (yt_code) local url = 'https://www.googleapis.com/youtube/v3/videos?' url = url .. 'id=' .. URL.escape(yt_code) .. '&part=snippet' if google_config.api_keys then local i = math.random(#google_config.api_keys) local api_key = google_config.api_keys[i] if api_key then url = url.."&key="..api_key end end return httpsRequest(url) end function send_youtube_data(data, receiver) local title = data.title local description = data.description local uploader = data.channelTitle local text = title..' ('..uploader..')\n'..description local image_url = data.thumbnails.high.url or data.thumbnails.default.url local cb_extra = { receiver = receiver, url = image_url } send_msg(receiver, text, send_photo_from_url_callback, cb_extra) end function run(msg, matches) local yt_code = matches[1] local data = get_yt_data(yt_code) if data == nil or #data.items == 0 then return "I didn't find info about that video." end local senddata = data.items[1].snippet local receiver = get_receiver(msg) send_youtube_data(senddata, receiver) end return { description = "Sends YouTube info and image.", usage = "", patterns = { "youtu.be/([_A-Za-z0-9-]+)", "youtube.com/watch%?v=([_A-Za-z0-9-]+)", }, run = run } end
gpl-2.0
praveenjha527/Algorithm-Implementations
Iterative_Deepening_Depth_First_Search/Lua/Yonaba/handlers/gridmap_handler.lua
182
2356
-- A grid map handler -- Supports 4-directions and 8-directions moves -- This handler is devised for 2d bounded grid where nodes are indexed -- with a pair of (x, y) coordinates. It features straight (4-directions) -- and diagonal (8-directions) moves. local PATH = (...):gsub('handlers.gridmap_handler$','') local Node = require (PATH .. '.utils.node') -- Implements Node class (from node.lua) function Node:initialize(x, y) self.x, self.y = x, y end function Node:toString() return ('Node: x = %d, y = %d'):format(self.x, self.y) end function Node:isEqualTo(n) return self.x == n.x and self.y == n.y end -- Direction vectors for straight moves local orthogonal = { {x = 0, y = -1}, {x = -1, y = 0}, {x = 1, y = 0}, {x = 0, y = 1}, } -- Direction vectors for diagonal moves local diagonal = { {x = -1, y = -1}, {x = 1, y = -1}, {x = -1, y = 1}, {x = 1, y = 1} } -- Checks of a given location is walkable on the grid. -- Assumes 0 is walkable, any other value is unwalkable. local function isWalkable(map, x, y) return map[y] and map[y][x] and map[y][x] == 0 end local nodes = {} -- Handler implementation local handler = {} -- Inits the search space function handler.init(map) handler.map = map nodes = {} for y, line in ipairs(map) do for x in ipairs(line) do table.insert(nodes, Node(x, y)) end end end -- Returns an array of all nodes in the graph function handler.getAllNodes() return nodes end -- Returns a Node function handler.getNode(x, y) local h, w = #handler.map, #handler.map[1] local k = (y - 1) * w + (x%w == 0 and w or x) return nodes[k] end -- Returns manhattan distance between node a and node b function handler.distance(a, b) local dx, dy = a.x - b.x, a.y - b.y return math.abs(dx) + math.abs(dy) end -- Returns an array of neighbors of node n function handler.getNeighbors(n) local neighbors = {} for _, axis in ipairs(orthogonal) do local x, y = n.x + axis.x, n.y + axis.y if isWalkable(handler.map, x, y) then table.insert(neighbors, handler.getNode(x, y)) end end if handler.diagonal then for _, axis in ipairs(diagonal) do local x, y = n.x + axis.x, n.y + axis.y if isWalkable(handler.map, x, y) then table.insert(neighbors, handler.getNode(x,y)) end end end return neighbors end return handler
mit