content
stringlengths
5
1.05M
require('cutorch') local util = require('fb.util') local OBSGD = require('fbcunn.OneBitSGD') --[[ OneBitDataParallel implements the "1-Bit Stochastic Gradient Descent and Application to Data-Parallel Distributed Training of Speech DNNs" paper of Frank Seide, Hao Fu, Jasha Droppo, Gang Li, and Dong Yu. The implementation is similar to a vanilla DataParallel module, except we replace the averaging gradient step with a quantize-copy-merge-broadcast procedure. <http://research.microsoft.com/apps/pubs/?id=230137> ]] local OneBitDataParallel, parent = torch.class('nn.OneBitDataParallel', 'nn.DataParallel') function OneBitDataParallel:__init(dimension, config) parent.__init(self, dimension) self.config = config -- Aggregators for each [row][gradient] self._aggregators = util.defaultdict(function() return {} end) end function OneBitDataParallel:_should_run_one_bit_sgd(gradients) -- TODO(tulloch) - flesh this test out assert(gradients) assert(#gradients >= 1) return gradients[1]:nDimension() == 2 and gradients[1]:nElement() > self.config.min_elements end function OneBitDataParallel:_combine_gradients(row_idx, grad_idx, gradients) assert(#gradients >= 1) if not self:_should_run_one_bit_sgd(gradients) then return parent._combine_gradients(self, row_idx, grad_idx, gradients) end if not self._aggregators[row_idx][grad_idx] then local g = gradients[1] self._aggregators[row_idx][grad_idx] = OBSGD.OneBitAggregator( self.config, function() return torch.Tensor():typeAs(g):resizeAs(g):zero() end, function(dest, source) return self:gpuSend(dest, source) end ) end self._aggregators[row_idx][grad_idx]:run(gradients) end
solution "libirr" configurations { "Debug", "Release" } configuration { "linux" } links { "Irrlicht", "GL", "Xxf86vm", "Xext", "X11", "Xcursor", "BulletCollision", "BulletDynamics" } includedirs { "/usr/include/irrlicht", "/usr/include/bullet" } libdirs { "/usr/lib" } configuration { "macosx" } includedirs { "/usr/local/include/irrlicht", "/usr/local/include/bullet" } links { "Irrlicht", "BulletCollision", "BulletDynamics", "LinearMath", "/Library/Frameworks/OpenGL.framework", "/Library/Frameworks/AppKit.framework", "/Library/Frameworks/IOKit.framework" } libdirs { "/usr/local/lib" } configuration { "windows" } if os.getenv("IRR_INCLUDE_DIR") == nil then print("Warning (Windows builds): Environment variable IRR_INCLUDE_DIR has not been set") end if os.getenv("IRR_LIBRARY_DIR") == nil then print("Warning (Windows builds): Environment variable IRR_LIBRARY_DIR has not been set") end defines { "WINDOWS" } includedirs { os.getenv("IRR_INCLUDE_DIR") } links { "Irrlicht" } libdirs { os.getenv("IRR_LIBRARY_DIR") } configuration "Debug" flags { "Symbols" } configuration "Release" flags { "Optimize" } project "irr" kind "SharedLib" language "C++" files { "src/**.c", "src/**.h", "src/**.cpp", "src/**.hpp" }
local colors = { bg = "#24292e", bg2 = "#1f2428", fg_light = "#d1d5da", blue = "#3b8eea", green = "#23d18b", magenta = "#bc3fbc", yellow = "#e2e210", red = "f14c4c", } return { normal = { a = {bg = colors.blue, fg = colors.bg}, b = {bg = colors.bg2, fg = colors.blue}, c = {bg = colors.bg, fg = colors.fg_light} }, insert = { a = {bg = colors.green, fg = colors.bg}, b = {bg = colors.bg2, fg = colors.green} }, command = { a = {bg = colors.magenta, fg = colors.bg}, b = {bg = colors.bg2, fg = colors.magenta} }, visual = { a = {bg = colors.yellow, fg = colors.bg}, b = {bg = colors.bg2, fg = colors.yellow} }, replace = { a = {bg = colors.red, fg = colors.bg}, b = {bg = colors.bg2, fg = colors.red} }, inactive = { a = {bg = colors.blue, fg = colors.green}, b = {bg = colors.blue, fg = colors.bg2, gui = "bold"}, c = {bg = colors.blue, fg = colors.bg2} } }
local eal = require 'lib.eal.manager' require 'factories.base' local EmitterFactory = class(EntityFactory, function(self) EntityFactory.init(self, "emitter") end) emitter = emitter or EmitterFactory() emitter:register("damage", function(name) local e = { id = name, vars = { class = "damageEmitter", pc = "damageHit", miss = "damageMiss", hostile = "damageEnemy", }, render = { root = { children = { { type = "particleSystem", name = "damageHit", template = "Damage/Hit" }, { type = "particleSystem", name = "damageMiss", template = "Damage/Miss" }, { type = "particleSystem", name = "damageEnemy", template = "Damage/Enemy" } } } } } if not data:createEntity(e) then return nil end return eal:getEntity(name) end) return emitter
--- concat 3 things function concat_print(a, -- string b, -- number: any number you like (with parentheses) c) -- ?string|number: it can be either on nil! print(a..tostring(b)..tostring(c)) end concat_print("hello", 10, 2) concat_print("hello", 10, "hello") concat_print("hello", 10) concat_print(10, "hello", {})
--[[ Experience management system ]] require('components/experience/hero_kills_xp')
LinkLuaModifier("modifier_abyss_sword_rush_night_sword_qi", "heroes/hero_abyss_sword/abyss_sword_rush_night_sword_qi", LUA_MODIFIER_MOTION_NONE) LinkLuaModifier("modifier_abyss_sword_rush_night_sword_qi_spell", "heroes/hero_abyss_sword/abyss_sword_rush_night_sword_qi", LUA_MODIFIER_MOTION_NONE) LinkLuaModifier("modifier_abyss_sword_rush_night_sword_qi_enemy", "heroes/hero_abyss_sword/abyss_sword_rush_night_sword_qi", LUA_MODIFIER_MOTION_NONE) abyss_sword_rush_night_sword_qi = abyss_sword_rush_night_sword_qi or class({}) modifier_abyss_sword_rush_night_sword_qi = modifier_abyss_sword_rush_night_sword_qi or class({}) modifier_abyss_sword_rush_night_sword_qi_spell = modifier_abyss_sword_rush_night_sword_qi_spell or class({}) modifier_abyss_sword_rush_night_sword_qi_enemy = modifier_abyss_sword_rush_night_sword_qi_spell or class({}) function abyss_sword_rush_night_sword_qi:GetCastRange() return self:GetSpecialValueFor("length") end function abyss_sword_rush_night_sword_qi:OnProjectileHit(target,location) local caster = self:GetCaster() if caster:HasModifier("modifier_abyss_sword_rush_night_sword_qi_spell") then caster:AddNewModifier(caster, self, "modifier_abyss_sword_rush_night_sword_qi", {}) caster:PerformAttack(target, true, true, true, true, false, false, true) caster:RemoveModifierByName("modifier_abyss_sword_rush_night_sword_qi") else if not target then return end if target:HasModifier("modifier_abyss_sword_rush_night_sword_qi_enemy") then return end local dmg = caster:GetAverageTrueAttackDamage(target) local damage = self:GetSpecialValueFor("damage") dmg = dmg + damage local dmgtable = { attacker = caster, victim = target, damage = dmg, damage_type = DAMAGE_TYPE_PHYSICAL, damage_flags = 0, ability = self } ApplyDamage(dmgtable) target:AddNewModifier(caster, self, "modifier_abyss_sword_rush_night_sword_qi_enemy", {duration = 0.5}) end end function abyss_sword_rush_night_sword_qi:OnSpellStart() local target = self:GetCursorPosition() local origin = self:GetCaster():GetAbsOrigin() self:CreateProjectiles(origin,target,0,1) EmitAnnouncerSoundForPlayer("npc_dota_hero_visage.vo.SwordQi.Cast", self:GetCaster():GetPlayerOwnerID()) self:GetCaster():AddNewModifier(caster, self, "modifier_abyss_sword_rush_night_sword_qi_spell", {duration = 0.5}) end function abyss_sword_rush_night_sword_qi:CreateProjectiles(origin,target,angle,count) local caster = self:GetCaster() local width = self:GetSpecialValueFor("width") local length = self:GetSpecialValueFor("length") local speed = self:GetSpecialValueFor("speed") local vector = (target - origin):Normalized() local startangle = angle / 2 local step = angle/count if count == 1 then step = startangle end for i = 1, count, 1 do ProjectileManager:CreateLinearProjectile({ Ability = self, EffectName = "particles/custom/abyss_sword/abyss_sword_rush_night_sword_qi_wave.vpcf", vSpawnOrigin = origin, fDistance = length, fStartRadius = width, fEndRadius = width, Source = caster, bHasFrontalCone = false, bReplaceExisting = false, iUnitTargetTeam = DOTA_UNIT_TARGET_TEAM_ENEMY, iUnitTargetFlags = DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES, iUnitTargetType = DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BASIC, fExpireTime = GameRules:GetGameTime() + 5.0, bDeleteOnHit = false, vVelocity = RotatePosition(Vector(0,0,0), QAngle(0,startangle - i*step, 0), vector) * speed, bProvidesVision = true, iVisionRadius = width, iVisionTeamNumber = caster:GetTeamNumber(), }) end caster:EmitSound("Hero_Abyss_Sword.SwordQi.Cast") end function modifier_abyss_sword_rush_night_sword_qi:RemoveOnDeath() return false end function modifier_abyss_sword_rush_night_sword_qi:IsHidden() return true end function modifier_abyss_sword_rush_night_sword_qi:IsPurgable() return false end function modifier_abyss_sword_rush_night_sword_qi:DeclareFunctions() return {MODIFIER_PROPERTY_BASEATTACK_BONUSDAMAGE} end function modifier_abyss_sword_rush_night_sword_qi:GetModifierBaseAttack_BonusDamage(params) local damage = self:GetAbility():GetSpecialValueFor("damage") return damage end function modifier_abyss_sword_rush_night_sword_qi_spell:RemoveOnDeath() return true end function modifier_abyss_sword_rush_night_sword_qi_spell:IsHidden() return true end function modifier_abyss_sword_rush_night_sword_qi_spell:IsPurgable() return false end function modifier_abyss_sword_rush_night_sword_qi_enemy:RemoveOnDeath() return true end function modifier_abyss_sword_rush_night_sword_qi_enemy:IsHidden() return true end function modifier_abyss_sword_rush_night_sword_qi_enemy:IsPurgable() return false end
local lanes = require "lanes" .configure{ with_timers = false, track_lanes = true} local wait do local linda = lanes.linda() wait = function( seconds_) linda:receive( seconds_, "dummy_key") end end print "hello" local track = function( title_) print( title_) for k, v in pairs( lanes.threads()) do print( k, v.name, v.status) end print( "\n") end local sleeper = function( name_, seconds_) -- print( "entering '" .. name_ .. "'") local lanes = require "lanes" -- no set_debug_threadname in main thread if set_debug_threadname then -- print( "set_debug_threadname('" .. name_ .. "')") set_debug_threadname( name_) end -- suspend the lane for the specified duration with a failed linda read wait( seconds_) -- print( "exiting '" .. name_ .. "'") end -- sleeper( "main", 1) -- the generator local g = lanes.gen( "*", sleeper) -- start a forever-waiting lane (nil timeout) g( "forever") -- start a lane that will last 2 seconds g( "two_seconds", 2) -- give a bit of time to reach the linda waiting call wait( 0.1) -- list the known lanes track( "============= START") -- wait until "two_seconds has completed" wait(2.1) track( "============= two_seconds dead") -- this will collect the completed lane (and remove it from the tracking queue) -- collectgarbage() -- track( "============= two_seconds dead (after collectgarbage)") -- start another lane that will last 2 seconds, with the same name g( "two_seconds", 2) -- give a bit of time to reach the linda waiting call wait( 0.1) -- list the known lanes track( "============= ANOTHER") print "done"
local realvim = vim module('global_function_overwrite_test', vim.bridge) FooBar = 17 realvim.command 'echo exists("*FooBar")' function FooBar() end realvim.command 'echo exists("*FooBar")' FooBar = nil realvim.command 'echo exists("*FooBar")'
-- A Module to update pfUI to match vanilla plus server (enUS only) -- based on research of @Heroclastus09 and @hawaiisa -- https://github.com/Heroclastus09/pfUI @7b190e92656dc76884bdd5f342e064879a2c85c2 pfUI:RegisterModule("vanillaplus", function() do -- add talent based debuffs to dynamic debuffs pfUI_locale["enUS"]["dyndebuffs"]["Challenging Shout"] = "Challenging Shout" pfUI_locale["enUS"]["dyndebuffs"]["Intimidating Shout"] = "Intimidating Shout" pfUI_locale["enUS"]["dyndebuffs"]["Hamstring"] = "Hamstring" pfUI_locale["enUS"]["dyndebuffs"]["Expose Armor"] = "Expose Armor" pfUI_locale["enUS"]["dyndebuffs"]["Garrote"] = "Garrote" pfUI_locale["enUS"]["dyndebuffs"]["Blind"] = "Blind" pfUI_locale["enUS"]["dyndebuffs"]["Sap"] = "Sap" pfUI_locale["enUS"]["dyndebuffs"]["Curse of Exhaustion"] = "Curse of Exhaustion" pfUI_locale["enUS"]["dyndebuffs"]["Curse of Recklessness"] = "Curse of Recklessness" pfUI_locale["enUS"]["dyndebuffs"]["Curse of Shadow"] = "Curse of Shadow" pfUI_locale["enUS"]["dyndebuffs"]["Curse of the Elements"] = "Curse of the Elements" pfUI_locale["enUS"]["dyndebuffs"]["Curse of Weakness"] = "Curse of Weakness" pfUI_locale["enUS"]["dyndebuffs"]["Curse of Agony"] = "Curse of Agony" pfUI_locale["enUS"]["dyndebuffs"]["Corruption"] = "Corruption" pfUI_locale["enUS"]["dyndebuffs"]["Immolate"] = "Immolate" pfUI_locale["enUS"]["dyndebuffs"]["Psychic Scream"] = "Psychic Scream" pfUI_locale["enUS"]["dyndebuffs"]["Cheap Shot"] = "Cheap Shot" pfUI_locale["enUS"]["dyndebuffs"]["Hunter\'s Mark"] = "Hunter\'s Mark" pfUI_locale["enUS"]["dyndebuffs"]["Moonfire"] = "Moonfire" pfUI_locale["enUS"]["dyndebuffs"]["Entangling Roots"] = "Entangling Roots" pfUI_locale["enUS"]["dyndebuffs"]["Insect Swarm"] = "Insect Swarm" pfUI_locale["enUS"]["dyndebuffs"]["Faerie Fire"] = "Faerie Fire" pfUI_locale["enUS"]["dyndebuffs"]["Hibernate"] = "Hibernate" pfUI_locale["enUS"]["dyndebuffs"]["Soothe Animal"] = "Soothe Animal" pfUI_locale["enUS"]["dyndebuffs"]["Hammer of Justice"] = "Hammer of Justice" end do -- adjust spell durations pfUI_locale["enUS"]["debuffs"]['Challenging Shout']={[0]=4.0,} pfUI_locale["enUS"]["debuffs"]['Concussive Shot']={[0]=5.0,} pfUI_locale["enUS"]["debuffs"]['Curse of Recklessness']={[0]=60.0,} pfUI_locale["enUS"]["debuffs"]['Curse of Shadow']={[0]=60.0,} pfUI_locale["enUS"]["debuffs"]['Curse of Weakness']={[0]=60.0,} pfUI_locale["enUS"]["debuffs"]['Curse of the Elements']={[0]=60.0,} pfUI_locale["enUS"]["debuffs"]['Entangling Roots']={[1]=15.0,[2]=18.0,[3]=21.0,[4]=24.0,[5]=27.0,[6]=30.0,[0]=30.0,} pfUI_locale["enUS"]["debuffs"]['Frostbolt']={[1]=3.0,[2]=4.0,[3]=4.0,[4]=5.0,[5]=5.0,[6]=6.0,[7]=6.0,[8]=7.0,[9]=7.0,[10]=7.0,[11]=7.0,[0]=7.0,} pfUI_locale["enUS"]["debuffs"]['Ghostly Strike']={[0]=5.0,} pfUI_locale["enUS"]["debuffs"]['Hamstring']={[0]=9.0,} pfUI_locale["enUS"]["debuffs"]['Hunter\'s Mark']={[0]=30.0,} pfUI_locale["enUS"]["debuffs"]['Improved Scorpid Sting']={[0]=30.0,} pfUI_locale["enUS"]["debuffs"]['Insect Swarm']={[0]=16.0,} pfUI_locale["enUS"]["debuffs"]['Kick']={[0]=6.0,} pfUI_locale["enUS"]["debuffs"]['Kick - Silenced']={[0]=3.0,} pfUI_locale["enUS"]["debuffs"]['Kidney Shot']={[0]=1.0,[1]=0.0,[2]=1.0,} pfUI_locale["enUS"]["debuffs"]['Mind Flay']={[0]=4.0,} pfUI_locale["enUS"]["debuffs"]['Repentance']={[0]=60.0,} pfUI_locale["enUS"]["debuffs"]['Scatter Shot']={[0]=5.0,} pfUI_locale["enUS"]["debuffs"]['Scorpid Sting']={[0]=30.0,} pfUI_locale["enUS"]["debuffs"]['Starfall Stun']={[0]=4.0,} pfUI_locale["enUS"]["debuffs"]['Thunder Clap']={[0]=30.0,} end if pfUI.api.libtotem and pfUI.api.libtotem.totems then -- adjust totem durations libtotem.totems["Spell_Nature_StoneClawTotem"] = {[-1] = 20} libtotem.totems["Spell_Nature_TremorTotem"] = {[-1] = 20} libtotem.totems["INV_Spear_04"] = {[-1] = 300} libtotem.totems["Spell_Nature_ManaRegenTotem"] = {[-1] = 300} libtotem.totems["Spell_Frost_SummonWaterElemental"] = {[-1] = 15} libtotem.totems["Spell_Nature_GroundingTotem"] = {[-1] = 40} end do -- libcast overwrites local aimedshot = L["customcast"]["AIMEDSHOT"] local multishot = L["customcast"]["MULTISHOT"] local originalAimedShot = libcast.customcast[strlower(aimedshot)] libcast.customcast[strlower(aimedshot)] = function(begin, duration) if begin then -- reduce duration based on v+ talents local duration = 3000 local _,_,_,_,count = GetTalentInfo(2,14) if count then duration = duration - count*200 end -- trigger original function originalAimedShot(begin, duration) end end local originalMultiShot = libcast.customcast[strlower(multishot)] libcast.customcast[strlower(multishot)] = function(begin, duration) if begin then -- reduce duration based on v+ talents local duration = 1000 local _,_,_,_,count = GetTalentInfo(2,14) if count then duration = duration - count*200 end -- trigger original function originalMultiShot(begin, duration) end end end do -- libdebuff overwrites function libdebuff:GetDuration(effect, rank) if L["debuffs"][effect] then local rank = rank and tonumber((string.gsub(rank, RANK .. " ", ""))) or 0 local rank = L["debuffs"][effect][rank] and rank or libdebuff:GetMaxRank(effect) local duration = L["debuffs"][effect][rank] local _, class = UnitClass("player") -- ROGUE if class == "ROGUE" then -- Gouge if effect == L["dyndebuffs"]["Gouge"] then local _,_,_,_,countIG = GetTalentInfo(2,1) local _,_,_,_,countTC = GetTalentInfo(1,16) -- Improved Gouge duration = duration + (countIG and countIG*.5 or 0) -- Total Control duration = duration + (countTC and countTC*.5 or 0) -- Rupture elseif effect == L["dyndebuffs"]["Rupture"] then local _,_,_,_,countSB = GetTalentInfo(3,13) local _,_,_,_,countEx = GetTalentInfo(1,6) -- Combo Points duration = duration + GetComboPoints()*2 -- Exhaustion duration = duration + (countEx and duration*(countEx*.25) or 0) -- Serrated Blades duration = duration + (countSB and countSB*2 or 0) -- Garotte with Serrated Blades elseif effect == L["dyndebuffs"]["Garrote"] then local _,_,_,_,countSB = GetTalentInfo(3,13) if countSB and countSB > 1 then duration = duration + 2*countSB end if (countEx and countEx == 2 and countSB and countSB > 0) then duration = (duration + GetComboPoints() * 2) * 1.5 + (countSB*2)end -- Total Control for Kidney Shot elseif effect == L["dyndebuffs"]["Kidney Shot"] then local _,_,_,_,countTC = GetTalentInfo(1,16) if countTC and countTC == 0 then duration = duration + GetComboPoints()*1 end if countTC and countTC > 0 then duration = duration + GetComboPoints()*1 + (countTC*.5) end -- Expose Armor with Exhaustion elseif effect == L["dyndebuffs"]["Expose Armor"] then local _,_,_,_,countEx = GetTalentInfo(1,6) if countEx and countEx > 0 then duration = duration + ( duration / 100 * (countEx*25)) end -- Total Control for Cheap Shot, Blind and Sap elseif effect == L["dyndebuffs"]["Cheap Shot"] or effect == L["dyndebuffs"]["Blind"] or effect == L["dyndebuffs"]["Sap"] then local _,_,_,_,countTC = GetTalentInfo(1,16) if countTC and countTC > 0 then duration = duration + (countTC*.5) end end -- MAGE elseif class == "MAGE" then -- Permafrost (3/3) if effect == L["dyndebuffs"]["Frostbolt"] then local _,_,_,_,countIFB = GetTalentInfo(3,3) if countIFB and countIFB > 0 then duration = duration + countIFB end end -- HUNTER elseif class == "HUNTER" then -- Improved Hunters Mark if effect == L["dyndebuffs"]["Hunter\'s Mark"] then local _,_,_,_,countIHM = GetTalentInfo(2,1) if countIHM and countIHM > 0 then duration = duration + 60*countIHM end end -- PRIEST elseif class == "PRIEST" then -- Improved Shadow Word: Pain if effect == L["dyndebuffs"]["Shadow Word: Pain"] then local _,_,_,_,countSWP = GetTalentInfo(3,2) if countSWP and countSWP > 0 then duration = duration + countSWP * 3 end end -- WARLOCK elseif class == "WARLOCK" then -- Jinx with 4 Curses if effect == L["dyndebuffs"]["Curse of Weakness"] or effect == L["dyndebuffs"]["Curse of Recklessness"] or effect == L["dyndebuffs"]["Curse of the Elements"] or effect == L["dyndebuffs"]["Curse of Shadow"] then local _,_,_,_,countJ = GetTalentInfo(1,2) if countJ and countJ > 0 then duration = duration + countJ*30 end -- Curse of Exhaustion with Jinx elseif effect == L["dyndebuffs"]["Curse of Exhaustion"] then local _,_,_,_,countJ = GetTalentInfo(1,2) if countJ and countJ > 0 then duration = duration + countJ*3 end -- Prolonged Misery elseif effect == L["dyndebuffs"]["Curse of Agony"] or effect == L["dyndebuffs"]["Immolate"] or effect == L["dyndebuffs"]["Corruption"] then local _,_,_,_,countPM = GetTalentInfo(1,8) if countPM and countPM > 0 then duration = duration + countPM * 3 end end -- WARRIOR elseif class == "WARRIOR" then -- Booming Voice if effect == L["dyndebuffs"]["Demoralizing Shout"] or effect == L["dyndebuffs"]["Challenging Shout"] or effect == L["dyndebuffs"]["Intimidating Shout"] then local _,_,_,_,countBV = GetTalentInfo(2,2) if countBV and countBV == 1 then duration = duration * 1.3 end if countBV and countBV == 2 then duration = duration * 1.5 end -- Improved Hamstring elseif effect == L["dyndebuffs"]["Hamstring"] then local _,_,_,_,countIHS = GetTalentInfo(1,7) if countIHS and countIHS > 0 then duration = duration + 3*countIHS end end -- DRUID elseif class == "DRUID" then -- Power of Nature if effect == L["dyndebuffs"]["Moonfire"] or effect == L["dyndebuffs"]["Insect Swarm"] or effect == L["dyndebuffs"]["Soothe Animal"] or effect == L["dyndebuffs"]["Faerie Fire"] or effect == L["dyndebuffs"]["Hibernate"] then local _,_,_,_,countPON = GetTalentInfo(1,12) if countPON and countPON == 1 then duration = duration*1.25 end if countPON and countPON == 2 then duration = duration*1.5 end -- Mighty Roots elseif effect == L["dyndebuffs"]["Entangling Roots"] then local _,_,_,_,countMR = GetTalentInfo(1,4) if countMR and countMR == 1 then duration = duration*1.4 end if countMR and countMR == 1 then duration = duration*1.7 end if countMR and countMR == 1 then duration = duration*2.0 end end -- PALADIN elseif class == "PALADIN" then -- Improved Hammer of Justice if effect == L["dyndebuffs"]["Hammer of Justice"] then local _,_,_,_,countHOJ = GetTalentInfo(2,6) if countHOJ and countHOJ > 0 then duration = duration + countHOJ*.5 end end end return duration else return 0 end end end end)
local john = require('function_class')('init', 'John', 28) package.loaded['function_class'] = nil local rebecca = require('function_class')('init', 'Rebecca', 21) john('say_hi') rebecca('say_hi') john('get_older') print(john('get_age'))
AddCSLuaFile() if (CLIENT) then SWEP.PrintName = "Pipe" SWEP.Slot = 1 SWEP.SlotPos = 2 SWEP.DrawAmmo = false SWEP.DrawCrosshair = false end SWEP.Author = "Zenolisk" SWEP.Instructions = "Primary Fire: Strike" SWEP.Purpose = "Hitting things." SWEP.Base = "reb_melee_base" SWEP.HoldType = "melee" SWEP.Category = "Rebellion" SWEP.ViewModelFOV = 59 SWEP.ViewModelFlip = false SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.Primary.Damage = 15 SWEP.Primary.Delay = 0.7 SWEP.Primary.Automatic = true SWEP.isBlunt = true SWEP.ViewModel = Model("models/weapons/c_crowbar.mdl") SWEP.WorldModel = Model("models/props_canal/mattpipe.mdl") SWEP.weaponLength = 0.5 SWEP.UseHands = true SWEP.ShowViewModel = false SWEP.originMod = Vector(0, -3, 4) SWEP.VElements = { ["pipe"] = { type = "Model", model = "models/props_canal/mattpipe.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(2, 2.2, -6.7), angle = Angle(8.182, -97.014, -3.507), size = Vector(0.6, 0.6, 0.6), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} } }
-- ============================================================= -- Copyright Roaming Gamer, LLC. 2008-2016 (All Rights Reserved) -- ============================================================= -- -- ============================================================= -- Last Updated: 23 NOV 2016 -- Last Validated: -- ============================================================= local lfs = require "lfs" local json = require "json" local strGSub = string.gsub local strSub = string.sub local strFormat = string.format local strFind = string.find local pathSep = "/" local RGFiles local systemTemporary = {} -- -- Get path to systemTemporary root. -- function systemTemporary.getRoot() return RGFiles.temporaryRoot end -- -- Create full systemTemporary path. -- function systemTemporary.getPath( path ) local fullPath = RGFiles.temporaryRoot .. path fullPath = RGFiles.util.repairPath( fullPath ) return fullPath end -- ============================================================= -- ============================================================= function systemTemporary.attach( module ) RGFiles = module module.temporary = systemTemporary end return systemTemporary
string.split = function(str, sep) local res = {} for v in str:gmatch("([^" .. sep .. "]+)") do res[#res + 1] = v end return res end string.trim = function(str) return str:match'^()%s*$' and '' or str:match'^%s*(.*%S)' end string.starts = function(str, substr) return string.sub(str, 1, #substr) == substr end string.titleCase = function(str) return str:gsub("(%a)([%w_']*)", function(first, rest) return first:upper() .. rest:lower() end) end string.diff = function(diff) local format = { {'day', diff / 60 / 60 / 24}, {'hour', diff / 60 / 60 % 24}, {'minute', diff / 60 % 60}, {'second', diff % 60} } local out = {} for k, t in ipairs(format) do local v = math.floor(t[2]) if(v > 0) then table.insert(out, (k < #format and (#out > 0 and ', ' or '') or ' and ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or '')) end end local ret = table.concat(out) if ret:len() < 16 and ret:find('second') then local a, b = ret:find(' and ') ret = ret:sub(b+1) end return ret end
HedgewarsScriptLoad("/Scripts/SimpleMission.lua") HedgewarsScriptLoad("/Scripts/Locale.lua") local heroAmmo = {} for a=0, amMinigun do if a == amExtraTime then heroAmmo[a] = 2 elseif a ~= amNothing and a ~= amCreeper then heroAmmo[a] = 100 end end SimpleMission({ missionTitle = loc("Big Armory"), missionIcon = -amBazooka, wind = 15, initVars = { TurnTime = 45000, GameFlags = gfDisableWind + gfDisableLandObjects, Theme = "EarthRise", Map = "BigArmory", -- from sidecar HWP --[[ Map has been generated in Hedgewars 0.9.24 and then exported as PNG with these settings: * Seed = "{7e34a56b-ee7b-4fe1-8f30-352a998f3f6a}" * MapGen = mgRandom * MapFeatureSize = 12 * Theme = "EarthRise" * relevant GameFlag: gfDisableLandObjects ]] }, teams = { { isMissionTeam = true, clanID = 0, hogs = { { health = 100, x = 543, y = 1198, ammo = heroAmmo, } }, }, { name = loc("Galaxy Guardians"), clanID = 8, flag = "cm_galaxy", grave = "Earth", hogs = { {name=loc("Rocket"), x=796, y=1208, faceLeft=true}, {name=loc("Star"), x=733, y=1546, faceLeft=true}, {name=loc("Asteroid"), x=738, y=1887, faceLeft=true}, {name=loc("Comet"), x=937, y=1344, faceLeft=true}, {name=loc("Sunflame"), x=3424, y=1555}, {name=loc("Eclipse"), x=3417, y=1119}, {name=loc("Jetpack"), x=2256, y=1280}, {name=loc("Void"), x=1587, y=1265, faceLeft=true}, }, }, }, customNonGoals = { { type = "turns", turns = 1, failText = loc("You failed to kill all enemies in a single turn.") } }, customGoalCheck = "turnEnd", goalText = loc("Kill all enemy hedgehogs in a single turn."), })
local playsession = { {"mewmew", {94615}}, {"vvictor", {59077}} } return playsession
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' ---------------------------------------------------------------- ------START------------------------------------------------ ---------------------------------------------------------------- server_script "red_core.lua" ---------------------------------------------------------------- ---Ancre------------------------------------------------------ ---------------------------------------------------------------- client_script 'scripts/Ancre/client.lua' --------------------------------------------------------------- ---Arme r�aliste----------------------------------------------------- ---------------------------------------------------------------- client_script 'scripts/ArmeRealiste/client.lua' ---------------------------------------------------------------- ---Blowtorch--------------------------------------------------- ---------------------------------------------------------------- client_script 'scripts/blowtorch/client.lua' server_script 'scrips/blowtorch/server.lua' ---------------------------------------------------------------- ---news----------------------------------------------------- ---------------------------------------------------------------- client_script 'scripts/news/client.lua' server_script 'scrips/news/server.lua' --------------------------------------------b-------------------- ---Micro---------------------------------------------------- ---------------------------------------------------------------- client_script "scripts/micro/main.lua" ui_page 'scripts/micro/html/ui.html' files { 'scripts/micro/html/ui.html', 'scripts/micro/html/app.js', 'scripts/micro/html/style.css', 'scripts/micro/img/mic.png' } ---------------------------------------------------------------- ---sup------------------------------------------------------ ---------------------------------------------------------------- client_scripts { 'scripts/braquageSup/config.lua', 'scripts/braquageSup/client.lua' } server_scripts { 'scripts/braquageSup/config.lua', 'scripts/braquageSup/server.lua' } ---------------------------------------------------------------- ---discord ------------------------------------------------------ ---------------------------------------------------------------- client_script 'scripts/discord_activity_redside/client.lua' ---------------------------------------------------------------- ---heli ------------------------------------------------------ ---------------------------------------------------------------- client_script 'scripts/heli/heli_client.lua' server_script 'scrips/heli/heli_server.lua' ---------------------------------------------------------------- ---safezone------------------------------------------------------ ---------------------------------------------------------------- client_script 'scripts/redsafe/safe.lua' ---------------------------------------------------------------- ---JUML------------------------------------------------------ ---------------------------------------------------------------- client_script 'scripts/Jumelles/client.lua' server_script 'scripts/Jumelles/server.lua' ---------------------------------------------------------------- ---Tackle------------------------------------------------------ ---------------------------------------------------------------- server_scripts { 'scripts/ktackle/config.lua', 'scripts/ktackle/server.lua' } client_scripts { 'scripts/ktackle/config.lua', 'scripts/ktackle/client.lua' } ---------------------------------------------------------------- ---Voice notif------------------------------------------------------ ---------------------------------------------------------------- client_script 'scripts/voice/vocalchat.lua' ---------------------------------------------------------------- ---MDP------------------------------------------------------ ---------------------------------------------------------------- client_script "scripts/pass/client.lua" server_script "scripts/pass/server.lua" ---------------------------------------------------------------- ---BLIPSPORTS------------------------------------------------------ ---------------------------------------------------------------- client_script "scripts/sports/blips.lua" ---------------------------------------------------------------- --------MECHANIC------------------------------------------------------ ---------------------------------------------------------------- client_scripts { 'scripts/ai_mechanic/client.lua', 'scripts/ai_mechanic/config.lua' } ---------------------------------------------------------------- --------Towtruck------------------------------------------------------ ---------------------------------------------------------------- client_scripts { 'scripts/ai_towtruck/client.lua', 'scripts/ai_towtruck/config.lua' } ---------------------------------------------------------------- --------Vitesse----------------------------------------------------- ---------------------------------------------------------------- client_script 'scripts/vitesse/cl_vitesse.lua' ---------------------------------------------------------------- --------AirControl----------------------------------------------------- ---------------------------------------------------------------- ---------------------------------------------------------------- --------Sirene----------------------------------------------------- ---------------------------------------------------------------- client_script 'scripts/sireneControl/client.lua' server_script 'scripts/sireneControl/server.lua' ---------------------------------------------------------------- --------CAMERA----------------------------------------------------- ---------------------------------------------------------------- client_script 'scripts/es_camera/client.lua' server_script 'scripts/es_camera/server.lua'
local self = {} GLib.MemoryUsageReport = GLib.MakeConstructor (self) local pointerSize = 8 local hashSize = 4 local typeSize = 4 local functionSize = 64 local stringLengthSize = 4 local tableSizeSize = 4 function self:ctor () self.Pools = {} self.CountedTables = GLib.WeakKeyTable () self.CountedStrings = {} self.CountedFunctions = {} end function self:Credit (poolName, object, size) poolName = poolName or "Unknown" self.Pools [poolName] = self.Pools [poolName] or 0 self.Pools [poolName] = self.Pools [poolName] + size end function self:CreditFunction (poolName, object) if self:IsCounted (object) then return end self:MarkCounted (object) self:CreditTable (poolName or "Function Metadata", debug.getinfo (object)) self:Credit (poolName or "Functions", object, functionSize) end function self:CreditObject (poolName, object) if type (object) == "table" then if type (object.ComputeMemoryUsage) == "function" and poolName ~= "Metatables" then object:ComputeMemoryUsage (self, poolName) else self:CreditTable (poolName, object) end elseif type (object) == "string" then self:CreditString (poolName or "Strings", object) elseif type (object) == "number" then self:Credit (poolName, nil, 8) elseif type (object) == "function" then self:CreditFunction (poolName or "Functions", object, functionSize) end end function self:CreditString (poolName, object) if object == nil then return end if self:IsCounted (object) then return end self:MarkCounted (object) self:Credit (poolName, object, stringLengthSize + string.len (object) + 1) -- Length, string data, null terminator end function self:CreditTable (poolName, object) if self:IsCounted (object) then return end self:CreditTableStructure (poolName, object) for k, v in pairs (object) do self:CreditObject (poolName, k) self:CreditObject (poolName, v) end end function self:CreditTableStructure (poolName, object) if self:IsCounted (object) then return end self:MarkCounted (object) local count = 0 for k, v in pairs (object) do count = count + 1 end self:CreditObject ("Metatables", object.__index) self:CreditObject ("Metatables", getmetatable (object)) local size = tableSizeSize * 2 -- Hash table size + array size size = size + count * 2 * pointerSize -- Hash table array size = size + count * hashSize -- Hashes size = size + count * typeSize -- Metadata poolName = poolName or "Unknown" self.Pools [poolName] = self.Pools [poolName] or 0 self.Pools [poolName] = self.Pools [poolName] + size end function self:GetTotalBytes () local totalBytes = 0 for _, poolBytes in pairs (self.Pools) do totalBytes = totalBytes + poolBytes end return totalBytes end function self:IsCounted (object) return self.CountedTables [object] or self.CountedStrings [object] or self.CountedFunctions [object] or false end function self:MarkCounted (object) if type (object) == "table" then self.CountedTables [object] = true elseif type (object) == "string" then self.CountedStrings [object] = true elseif type (object) == "function" then self.CountedFunctions [object] = true end end function self:ToString () local memoryUsageReport = "" memoryUsageReport = memoryUsageReport .. "=============================\n" memoryUsageReport = memoryUsageReport .. "Memory Usage Report\n" memoryUsageReport = memoryUsageReport .. "=============================\n" local sortedPools = {} for poolName, size in pairs (self.Pools) do sortedPools [#sortedPools + 1] = { Name = poolName, Size = size } end table.sort (sortedPools, function (a, b) return a.Size > b.Size end) local totalSize = 0 for _, poolEntry in ipairs (sortedPools) do memoryUsageReport = memoryUsageReport .. string.format ("%9d", poolEntry.Size) .. " B - " .. poolEntry.Name .. "\n" totalSize = totalSize + poolEntry.Size end memoryUsageReport = memoryUsageReport .. "=============================\n" memoryUsageReport = memoryUsageReport .. string.format ("%9d", totalSize) .. " B - Total\n" memoryUsageReport = memoryUsageReport .. "=============================\n" return memoryUsageReport end
-- Variables g_Me = getLocalPlayer() g_Resource = getThisResource() g_Root = getRootElement() g_ResourceRoot = getResourceRootElement(g_Resource) g_Rooms = {} -- Events addEventHandler("onClientResourceStart",g_ResourceRoot, function() triggerServerEvent("requestServerRooms",localPlayer) setTimer(updateRooms,5000,0) bindKey("f1","down",joinHUB) if(getElementData(localPlayer, "UAG.Account.Logged") == true) then joinHUB() end end ) addEventHandler("onClientResourceStop",g_ResourceRoot, function() unbindKey("f1","down") end ) addEvent("onFullRoom",true) addEventHandler("onFullRoom",getRootElement(), function() exports.BB_Notify:Notify("This room is full.\nPlease try another one or wait.", 2, "Error") end ) addEvent("onLockedRoom",true) addEventHandler("onLockedRoom",getRootElement(), function() exports.BB_Notify:Notify("This room is locked.\nPlease try another room.", 2, "Error") end ) function joinHUB() joinRoom(1) end function joinRoom(roomID) if((tonumber(getElementData(localPlayer,"bb.room") or -1) == roomID) and ((getElementData(localPlayer,"bb.forcejoin") or false) == false)) then return end local idRoom = getElementByID("room_"..tostring(roomID)) if(getElementData(idRoom,"room.locked") == true) then exports.BB_Notify:Notify("This room is locked.\nPlease try another room.", 2, "Error") return end if ((getElementChildrenCount(idRoom) >= getElementData(idRoom,"room.maxplayers")) and (getElementData(idRoom,"room.maxplayers") > -1)) then exports.BB_Notify:Notify("This room is full.\nPlease try another one or wait.", 2, "Error") return end fadeCamera(false) if (tonumber(getElementData(localPlayer,"bb.room") or -1) > -1) then leaveRoom() end toggleAllControls(true, true,false) triggerServerEvent("onPlayerJoinRoom",localPlayer,roomID) end function leaveRoom() for _,v in ipairs(getElementsByType("vehicle")) do destroyElement(v) end local room = getElementData(localPlayer,"bb.room") exports[g_Rooms[room].gamemode]:unloadGamemode() triggerServerEvent("onPlayerLeaveRoom",localPlayer) setElementData(localPlayer,"bb.room",-1) end function clientJoinedRoom(roomID,roomInfo) exports.BB_Menu:ToggleMenu(false) showPlayerHudComponent("ammo", false) showPlayerHudComponent("area_name", false) showPlayerHudComponent("armour", false) showPlayerHudComponent("breath", false) showPlayerHudComponent("clock", false) showPlayerHudComponent("health", false) showPlayerHudComponent("money", false) showPlayerHudComponent("vehicle_name", false) showPlayerHudComponent("weapon", false) showPlayerHudComponent("wanted", false) exports[roomInfo.gamemode]:loadGamemode() end addEvent("onRoomJoin",true) addEventHandler("onRoomJoin",getRootElement(),clientJoinedRoom) -- function updateRooms() triggerServerEvent("requestServerRooms",localPlayer) end function requestRooms() return g_Rooms end function receivedRooms(rooms) g_Rooms = rooms end addEvent("onReceiveRooms",true) addEventHandler("onReceiveRooms",getRootElement(),receivedRooms) function loadRoomMap(player,roomID) setElementPosition(player,0,0,5) triggerServerEvent("onMapRequest",localPlayer,roomID) end function getClientPlayersInRoom() return getElementChildren(getElementByID("room_"..tostring(getElementData(localPlayer,"bb.room")))) end fileDelete("c_main.lua")
--[[ Copyright 2017 wrxck <matthew@matthewhesketh.com> This code is licensed under the MIT. See LICENSE for details. ]] local tpb = {} local mattata = require('mattata') function tpb:init() tpb.commands = mattata.commands( self.info.username ):command('tpb') :command('thepiratebay').table tpb.help = [[/tpb - Sends a list of working Pirate Bay proxies. Alias: /thepiratebay.]] end function tpb:on_message(message, configuration) local str = io.popen('curl "https://proxybay.one/list.txt"'):read('*all') if not str then return mattata.send_reply( message, configuration.errors.connection ) end return mattata.send_message( message.chat.id, string.format( '<pre>%s</pre>', mattata.escape_html(str) ), 'html' ) end return tpb
p("moduleN") _G.num_loaded = _G.num_loaded + 1 local moduleM = require("moduleM") return {"moduleN"}
local currentVal = redis.call('get', @key) if (currentVal == false or currentVal == @expected) then if (@expires ~= nil and @expires ~= '') then return redis.call('set', @key, @value, 'PX', @expires) and 1 or 0 else return redis.call('set', @key, @value) and 1 or 0 end else return -1 end
-- project_hub_panel -- created on 2021/8/21 -- author @zoloypzuo local PanelWindow = require("ui.panel_window") local Button = require("ui.widgets.button") local InputText = require("ui.widgets.input_text") local Spacing = require("ui.layouts.spacing") local Separator = require("ui.widgets.separator") local Columns = require("ui.layouts.column") local Text = require("ui.widgets.text") local Group = require("ui.layouts.group") local ProjectHubPanel = Class(PanelWindow, function(self) PanelWindow._ctor(self, "Project Hub", true) self:SetSize({ 1000, 580 }); self:SetPosition({ 0., 0 }); self:_Header() self:_Spacing() self:_ProjectList() end) function ProjectHubPanel:_Header() local openProjectButton = self:CreateWidget(Button, "Open Project") local newProjectButton = self:CreateWidget(Button, "New Project") local pathField = self:CreateWidget(InputText, ""); local goButton = self:CreateWidget(Button, "GO") local function UpdateGoButton(p_path) validPath = p_path ~= "" if validPath then goButton.idleBackgroundColor = RGBA(0, 0.5, 0) else goButton.idleBackgroundColor = RGBA(0.1, 0.1, 0.1) end goButton.disabled = not validPath end UpdateGoButton("") -- init go button openProjectButton.idleBackgroundColor = RGBA(0.7, 0.5, 0.); newProjectButton.idleBackgroundColor = RGBA(0., 0.5, 0.0); openProjectButton.lineBreak = false; newProjectButton.lineBreak = false; pathField.lineBreak = false; pathField.ContentChangedEvent:AddEventHandler(function(content) print(content) UpdateGoButton(pathField.content) end) openProjectButton:AddOnClickHandler(function() local result = UI:OpenFileDialog() pathField.content = result UpdateGoButton(pathField.content) end) newProjectButton:AddOnClickHandler(function() local result = UI:OpenFileDialog() pathField.content = result UpdateGoButton(pathField.content) end) goButton:AddOnClickHandler(function() print("GO", pathField.content) -- TODO close panel and return boot args end) end function ProjectHubPanel:_Spacing() for _ = 1, 4 do self:CreateWidget(Spacing) end self:CreateWidget(Separator) for _ = 1, 4 do self:CreateWidget(Spacing) end end function ProjectHubPanel:_ProjectList() local columns = self:CreateWidget(Columns, 2) columns.widths = { 750, 500 } for i, line in ipairs({ "test1", "test2", "test3" }) do local text = columns:CreateWidget(Text, line) local actions = columns:CreateWidget(Group) local openButton = actions:CreateWidget(Button, "Open") local deleteButton = actions:CreateWidget(Button, "Delete") openButton.idleBackgroundColor = RGBA(0.7, 0.5, 0.) deleteButton.idleBackgroundColor = RGBA(0.5, 0., 0.) openButton:AddOnClickHandler(function() print("OpenProject", line) end) deleteButton:AddOnClickHandler(function() --text.Destroy(); --actions.Destroy(); columns:RemoveWidget(text) columns:RemoveWidget(actions) end) openButton.lineBreak = false deleteButton.lineBreak = false end end function ProjectHubPanel:Update() ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, 50, 50) ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0) PanelWindow.Update(self) ImGui.PopStyleVar(2) end return ProjectHubPanel
local SPUtil = require(game.ReplicatedStorage.Shared.SPUtil) local CurveUtil = require(game.ReplicatedStorage.Shared.CurveUtil) local TriggerButton = require(game.ReplicatedStorage.Local.TriggerButton) local GameSlot = require(game.ReplicatedStorage.Shared.GameSlot) local Track = {} function Track:new(track_system, offset_angle, name, _game, track_index, note_offset, scorllmode) local self = {} local offset_multiplier = CurveUtil:YForPointOf2PtLine(Vector2.new(0,1), Vector2.new(40,0.1), -note_offset*2) local _offset_angle = offset_angle local _track_obj = nil local _trigger_button = nil local _parent_track_system = track_system local _rotation = 0 local function get_rotation() return _rotation end local function set_rotation(rotation) _rotation = rotation _track_obj.PrimaryPart.Rotation = Vector3.new(0,-rotation-0,90) --lol end local function set_position(x,z) _track_obj.PrimaryPart.Position = Vector3.new(x,0.5 + _game:get_game_environment_center().Y,z) end local scrollmode = {Value=2} function self:cons() local world_center = track_system:get_player_world_center() local player_position = track_system:get_player_world_position() _track_obj = _game:get_game_protos().PlayerTrackProto:Clone() self:update_brick_color(1,_game) local world_to_player_dir = player_position-world_center local world_to_player_rotation = SPUtil:dir_ang_deg( world_to_player_dir.X, world_to_player_dir.Z ) if scrollmode.Value == 1 then _track_obj.PrimaryPart.Size = Vector3.new(0.1,world_to_player_dir.Magnitude,0.1) workspace.CurrentCamera.GameEnvironment.Background.Stage.Union.Transparency = 1 workspace.CurrentCamera.GameEnvironment.Background.Stage.Union2.Transparency = 0 else _track_obj.PrimaryPart.Size = Vector3.new(0.2,world_to_player_dir.Magnitude,0.1) workspace.CurrentCamera.GameEnvironment.Background.Stage.Union.Transparency = 0 workspace.CurrentCamera.GameEnvironment.Background.Stage.Union2.Transparency = 1 end do local offset_rotation = world_to_player_rotation + offset_angle local offset_dir = 0 do local xy_dir = SPUtil:ang_deg_dir(offset_rotation) offset_dir = Vector3.new( xy_dir.X, 0, xy_dir.Y ) * world_to_player_dir.Magnitude end local offset_mid = offset_dir * 0.5 + world_center set_position(offset_mid.X,offset_mid.Z) set_rotation(offset_rotation) end if scrollmode.Value == 1 then set_rotation(get_rotation() - offset_angle) else set_rotation(get_rotation() - offset_angle * 0.25) end _track_obj.Name = name _track_obj.Parent = _game:get_game_element().Parent _trigger_button = TriggerButton:new( _game, self:get_end_position(true), _parent_track_system, track_index ) end function self:teardown() _track_obj:Destroy() _parent_track_system = nil _trigger_button:teardown() _trigger_button = nil self = nil _game = nil track_system = nil end local _beat_flash_offset = 0 function self:update_brick_color(dt_scale, _game) if _game._players._slots:contains(_parent_track_system._game_slot) == false then return end local target_transparency = 1 if scrollmode.Value ~= 1 then _track_obj.PlayerTrackProto.BrickColor, target_transparency = GameSlot:slot_to_color_and_transparency( _parent_track_system._game_slot, _game._players._slots:get(_parent_track_system._game_slot)._power_bar_active ) else target_transparency = 1 _track_obj.PlayerTrackProto.Transparency = 1 _track_obj.PlayerTrackProto.BrickColor = BrickColor.new("Really black") end if GameSlot:perp_view_slot(_game:get_local_game_slot(), _parent_track_system._game_slot) then target_transparency = 0 end --[[ if _game:get_local_game_slot() == 2 and _parent_track_system._game_slot == 2 then target_transparency = 0.65 elseif GameSlot:perp_view_slot(_game:get_local_game_slot(), _parent_track_system._game_slot) then target_transparency = target_transparency * 1.5 end ]]-- if _game._players._slots:get(_parent_track_system._game_slot)._power_bar_active then if _game._audio_manager:is_beat() then _beat_flash_offset = 0 end end if scrollmode ~= 1 then _track_obj.PlayerTrackProto.Transparency = target_transparency + _beat_flash_offset end -- _beat_flash_offset = CurveUtil:Expt( -- _beat_flash_offset, -- 0, -- CurveUtil:NormalizedDefaultExptValueInSeconds(0.75), -- dt_scale -- ) end function self:update(dt_scale,_game) _trigger_button:update(dt_scale,_game) self:update_brick_color(dt_scale, _game) end function self:get_start_position() local dir_xy = SPUtil:ang_deg_dir(get_rotation()).unit local dir = Vector3.new(dir_xy.x, 0, dir_xy.y) return _track_obj.PrimaryPart.Position + (dir * -1 * _track_obj.PrimaryPart.Size.Y * 0.5) end function self:get_end_position(isTrigger) --local END_PCT = 0.55 local END_PCT = 0.1 local dir_xy = SPUtil:ang_deg_dir(get_rotation()).unit local dir = Vector3.new(dir_xy.x, 0, dir_xy.y) if isTrigger == true then return _track_obj.PrimaryPart.Position + (dir * 1 * _track_obj.PrimaryPart.Size.Y * 0.5 * END_PCT) else return _track_obj.PrimaryPart.Position + (dir * 1 * _track_obj.PrimaryPart.Size.Y * 0.5 * END_PCT * offset_multiplier) end end function self:press() _trigger_button:press() end function self:release() _trigger_button:release() end self:cons() return self end return Track
-- Pure Lua classes with multiple inheritance. -- MIT/X license (c) 2016 Daniel Lima -- Create an instance of self local function new(self, param, ...) local obj if not ... and type(param) == 'table' then obj = setmetatable(param, self) obj:__init() else obj = setmetatable({}, self) obj:__init(param, ...) end return obj end local root = { __init = function() end, } local types = { [root] = {}, } -- Create a new subclass of the 'base' class, -- passing several tables as mixins for multiple inheritance. -- In case of conflicting attributes, the last mixin will resolve. local function extend(base,...) -- T is the new subclass of self local T = { __init = base.__init, --default initializer } -- superclasses of T types[T] = { [T]=true } for t in pairs(types[base]) do types[T][t] = true end -- copy mixins to T for _,m in ipairs{...} do types[T][m] = true for k,v in pairs(m) do T[k] = v end end -- link methods T.super = base T.extend = extend T.__index = T -- test if object is an instance of class (or any subclass) function T:is(class) return types[T][class] end T.is_a = T.is local Tmt = { __call = new, __index = base } return setmetatable(T, Tmt) end -- alias to class creation local function class(self, ...) return extend(root,...) end -- shallow table copying local function copy(self) local t = {} for k,v in pairs(self) do t[k] = v end return setmetatable(t, getmetatable(self)) end -- deep table copying (beware: does not treat reference loops) local function deepcopy(self) if type(self) == 'table' then local t = {} for k,v in pairs(self) do t[k] = deepcopy(v) end return setmetatable(t, getmetatable(self)) end return self end return setmetatable({ copy = copy, class = class, deepcopy = deepcopy, }, { __call = class })
if minetest.global_exists ("projectile") then local function shoot (spawn_pos, itemstack, owner, spawner_pos, spawner_dir, force, catagory) local pos = spawn_pos local level = 1 local ammo_entity = projectile.registered_projectiles[catagory][itemstack:get_name ()] if not itemstack:is_empty() and ammo_entity then local adef = minetest.registered_entities[ammo_entity] -- Fire an amount of projectiles at once according to the ammo's defined "count". for n = 1, (adef.count or 1) do local projectile = minetest.add_entity (pos, ammo_entity) local luapro = projectile:get_luaentity() -- Set velocity according to the direction it was fired. -- Speed is determined by the ammo. No weapon and always fully charged. projectile:set_velocity(vector.multiply (spawner_dir, luapro.speed)) -- An acceleration of -9.81y is how gravity is applied. projectile:set_acceleration ({ x = 0, y = -9.81, z = 0 }) --If the ammo defines a spread, randomly rotate the direction of velocity by that given radius. if adef.spread then local rx = (math.random() * adef.spread * 2 - adef.spread) * math.pi / 180 local ry = (math.random() * adef.spread * 2 - adef.spread) * math.pi / 180 projectile:set_velocity(vector.rotate(projectile:get_velocity(), {x = rx, y = ry, z = 0})) end -- Store level for later, to determine impact damage luapro.level = level -- Also store the projectile's damage itself. luapro.damage = adef.damage -- The player's name is stored to prevent hitting yourself -- And by "hitting yourself" I mean accidentally being hit by the arrow just by firing it at a -- somewhat low angle, the moment it spawns. luapro.owner = owner -- Store the initial velocity for passing by objects when needed. luapro.oldvel = projectile:get_velocity() end return projectile, false end return nil, false end local function register_spawner (ammo, catagory) lwcomponents.register_spawner (ammo, function (spawn_pos, itemstack, owner, spawner_pos, spawner_dir, force) return shoot (spawn_pos, itemstack, owner, spawner_pos, spawner_dir, force, catagory) end) end for weapon, wdef in pairs (projectile.registered_projectiles) do for ammo, adef in pairs (projectile.registered_projectiles[weapon]) do if adef then register_spawner (ammo, weapon) end end end end
---------------------------------------------------------------------------- ---------------------------------------------------------------------------- -------------------------- Button creator ------------------------------- ---------------------------------------------------------------------------- --function gooi.newButton(text, x, y, w, h) function gooi.newButton(params) params = params or {} local b = {} local defaultText = "new button" local theH = gooi.getFont():getHeight() local x, y, w, h = gooi.checkBounds( params.text or defaultText, params.x or 10, params.y or 10, params.w or gooi.getFont():getWidth(params.text or defaultText) + theH * 2, params.h or theH * 2, "button" ) local yLocal = params.yLocal or 0 b = component.new("button", x, y, w, h, params.group) b = gooi.setStyleComp(b) b.text = params.text or defaultText b.icon = params.icon if b.icon then if type(b.icon) == "string" then b.icon = love.graphics.newImage(b.icon) end if b.text:len() > 0 then b.w = b.w + b.icon:getWidth() end end b.textParts = split(b.text, "\n") function b:rebuild() --self:generateBorder() end function b:setText(value) if not value then value = "" end self.text = tostring(value) self.textParts = split(self.text, "\n") return self end b:rebuild() function b:largerLine() local line = self.textParts[1] or "" for i = 2, #self.textParts do if #self.textParts[i] > #line then line = self.textParts[i] end end return line end function b:drawSpecifics(fg) -- Center text: local t = self:largerLine(self.textParts) local x = (self.x + self.w / 2) - (gooi.getFont(self):getWidth(t) / 2) local y = (self.y + self.h / 2) - (gooi.getFont(self):getHeight() / 2) if self.align == gooi.l then x = self.x + self.h / 2 if self.icon then x = x + self.h / 2 end elseif self.align == gooi.r then x = self.x + self.w - self.h / 2 - gooi.getFont(self):getWidth(self.text) end if self.icon then local xImg = math.floor(self.x + self.h / 2) if t:len() == 0 then xImg = math.floor(self.x + self.w / 2) end love.graphics.setColor(1, 1, 1) if not self.enabled then love.graphics.setColor(1/4, 1/4, 1/4) end love.graphics.draw(self.icon, xImg, math.floor(self.y + self.h / 2), 0, 1, 1, math.floor(self.icon:getWidth() / 2), math.floor(self.icon:getHeight() / 2)) end love.graphics.setColor(fg) local yLine = yLocal + self.y + self.h / 2 yLine = yLine - (gooi.getFont(self):getHeight()) * #self.textParts / 2 for i = 1, #self.textParts do local part = self.textParts[i] local xLine = self.x + self.w - gooi.getFont(self):getWidth(part) - self.h / 2 if self.align == gooi.l then xLine = self.x + self.h / 2 if self.icon then xLine = xLine + self.h /2 end elseif self.align == "center" then xLine = (self.x + self.w / 2) - (gooi.getFont(self):getWidth(part) / 2) end love.graphics.print(part, math.floor(xLine), math.floor(yLine)) yLine = yLine + (gooi.getFont(self):getHeight()) end end function b:left() self.align = gooi.l return self end function b:center() self.align = "center" return self end function b:right() self.align = gooi.r return self end b:center() function b:setIcon(icon) if type(icon) == "string" then icon = love.graphics.newImage(icon) end self.icon = icon --self.w = self.w + self.icon:getWidth() * 2 return self -- body end return gooi.storeComponent(b, id) end
-- Sample run 1 local function main() local testVoter = {1, 0, 0, 0} local testCandidates = {{"Bill", -1, -1, -1 ,-1}, {"Ronald", 0, 0, 0, 0}, {"Bill Nye", 1, -1, 1, -1}, {"Red", 1, 1, 1, 1}} show(best_candidates(testVoter, testCandidates)) end -- Score candidate in respect to voter. -- Returns their score local function scoreCandidate(voter, candidate) local score = 0 for i=1, #voter do if(voter[i]==candidate[i+1] and voter[i]~=0) then score = score + 1 elseif(voter[i]~=candidate[i+1] and voter[i]~=0 and candidate[i+1]~=0) then score = score - 1 end end return score end -- Score all candidates -- Returns array of {{Name, Score}, {Name, Score}...} local function scoreCandidates(voter, candidates) local candidateScores = {} for i=1, #candidates do candidateScores[i] = {candidates[i][1], scoreCandidate(voter, candidates[i])} end return candidateScores end -- Finds the highest score amongst all candidates local function highestScore(candidateScores) local score = candidateScores[1][2] for i=2, #candidateScores do if(candidateScores[i][2]>score) then score = candidateScores[i][2] end end return score end -- Retrieves the candidate(s) with the highest score -- Returns an array of names only local function highestCandidates(score, candidateScores) local candidates = {} for i=1, #candidateScores do if(candidateScores[i][2]==score) then candidates[#candidates+1] = candidateScores[i][1] end end return candidates end -- Simple print helper function show(candidates) for i=1, #candidates do print(candidates[i]) end end -- Finds the best candidate(s) for a given Voter -- Returns an array of candidate name(s) function best_candidates(voter, candidates) local candidateScores = scoreCandidates(voter, candidates) return highestCandidates(highestScore(candidateScores), candidateScores) end main()
local mod = EPGP:NewModule("distribution", "AceEvent-3.0") local C = LibStub("LibEPGPChat-1.0") local GUI = LibStub("AceGUI-3.0") local L = LibStub("AceLocale-3.0"):GetLocale("EPGP") local LIU = LibStub("LibItemUtils-1.0") local LUI = LibStub("LibEPGPUI-1.0") local BUTTON_TEXT_PADDING = 15 local BUTTON_HEIGHT = 22 local callbacks = EPGP.callbacks local RANDOM_ROLL_PATTERN = RANDOM_ROLL_RESULT RANDOM_ROLL_PATTERN = RANDOM_ROLL_PATTERN:gsub("[%(%)%-]", "%%%1") RANDOM_ROLL_PATTERN = RANDOM_ROLL_PATTERN:gsub("%%s", "%(%.%+%)") RANDOM_ROLL_PATTERN = RANDOM_ROLL_PATTERN:gsub("%%d", "%(%%d+%)") RANDOM_ROLL_PATTERN = RANDOM_ROLL_PATTERN:gsub("%%%d%$s", "%(%.%+%)") -- for "deDE" RANDOM_ROLL_PATTERN = RANDOM_ROLL_PATTERN:gsub("%%%d%$d", "%(%%d+%)") -- for "deDE" local function UISetEnabled(w, enabled) if enabled then w:Enable() w:SetAlpha(1) else w:Disable() w:SetAlpha(0.5) end end local disableWhileNoAuthority = {} local function AuthorityChangedCallbackFunc(callback, authority) for i, v in pairs(disableWhileNoAuthority) do UISetEnabled(v, authority) end end local function PrAnnouncement(sender, bid) if not sender or sender == "" then return end local prAnnounceMedium = mod.db.profile.prAnnounceMedium if prAnnounceMedium == "NONE" then return end local name = EPGP:GetFullCharacterName(sender) local ep, gp = EPGP:GetEPGP(name) if not ep or not gp then return end local pr = ep / math.max(gp, 1) local msg = C:Interp(mod.db.profile.prAnnounceMsgFmt, {ep = ep, gp = gp, pr = pr, bid = bid, char = sender}) if prAnnounceMedium == "RAID" or prAnnounceMedium == "OFFICER" then C:Announce(prAnnounceMedium, msg) elseif prAnnounceMedium == "WHISPER" then C:Whisper(sender, msg) end end local function HandleChatMsg(event, msg, sender) if not EPGP:IsRLorML() then return end local bid = tonumber(msg) if not bid then return end EPGP:HandleBidResult(sender, bid) PrAnnouncement(sender, bid) end local function HandleRollMsg(event, msg) if not EPGP:IsRLorML() then return end local name, roll, low, high = string.match(msg, RANDOM_ROLL_PATTERN) if not name or not roll or not low or not high then return end roll, low, high = tonumber(roll), tonumber(low), tonumber(high) EPGP:HandleRollResult(name, roll, low, high) end local function HandleBidStatusUpdate(event, status) mod:UnregisterAllEvents() if status == 1 then local needMedium = mod.db.profile.needMedium if needMedium == "RAID" then mod:RegisterEvent("CHAT_MSG_RAID", HandleChatMsg) mod:RegisterEvent("CHAT_MSG_RAID_LEADER", HandleChatMsg) elseif needMedium == "WHISPER" then mod:RegisterEvent("CHAT_MSG_WHISPER", HandleChatMsg) end elseif status == 2 then local bidMedium = mod.db.profile.bidMedium if bidMedium == "RAID" then mod:RegisterEvent("CHAT_MSG_RAID", HandleChatMsg) mod:RegisterEvent("CHAT_MSG_RAID_LEADER", HandleChatMsg) elseif bidMedium == "WHISPER" then mod:RegisterEvent("CHAT_MSG_WHISPER", HandleChatMsg) end elseif status == 3 then mod:RegisterEvent("CHAT_MSG_SYSTEM", HandleRollMsg) end end local function LootItemsAnnounce(itemLinks) if not EPGP:IsRLorML() then return end local medium = mod.db.profile.announceMedium C:Announce(medium, L["Loot list: "] .. table.concat(itemLinks, " ")) end local function StartBid(itemLink, method) if not EPGP:IsRLorML() then return end local medium = mod.db.profile.announceMedium if method == 1 then local needMedium = mod.db.profile.needMedium if needMedium == "RAID" then C:Announce(medium, itemLink .. " " .. L["Please send number to raid channel: "] .. mod.db.profile.announceNeedMsg) elseif needMedium == "WHISPER" then C:Announce(medium, itemLink .. " " .. L["Please whisper number to me: "] .. mod.db.profile.announceNeedMsg) end elseif method == 2 then local bidMedium = mod.db.profile.bidMedium if bidMedium == "RAID" then C:Announce(medium, itemLink .. " " .. L["Please send bid value to raid channel."]) elseif bidMedium == "WHISPER" then C:Announce(medium, itemLink .. " " .. L["Please whisper bid value to me."]) end elseif method == 3 then C:Announce(medium, itemLink .. " " .. L["/roll if you want this item. DO NOT roll more than one time."]) end EPGP:SetBidStatus(method, mod.db.profile.resetWhenAnnounce) end mod.dbDefaults = { profile = { enabled = true, announceMedium = "RAID", needMedium = "RAID", bidMedium = "RAID", prAnnounceMedium = "RAID", announceNeedMsg = "1 - " .. NEED .. " 2 - " .. GREED, prAnnounceMsgFmt = "${char} EP:${ep} GP:${gp} PR:${pr}", resetWhenAnnounce = true, lootAutoAdd = true, threshold = 4, } } mod.optionsName = L["Distribution"] mod.optionsDesc = L["Collect bid/roll message to help sorting"] mod.optionsArgs = { help = { order = 1, type = "description", name = L["Collect bid/roll message to help sorting"], fontSize = "medium", }, announceMedium = { order = 10, type = "select", name = L["Announce medium"], desc = L["Sets the announce medium EPGP will use to announce distribution actions."], values = { ["RAID"] = CHAT_MSG_RAID, ["RAID_WARNING"] = CHAT_MSG_RAID_WARNING, }, }, needMedium = { order = 11, type = "select", name = L["Need/greed medium"], desc = L["Sets the medium EPGP will use to collect need/greed results from members."], values = { ["RAID"] = CHAT_MSG_RAID, ["WHISPER"] = CHAT_MSG_WHISPER_INFORM, }, }, bidMedium = { order = 12, type = "select", name = L["Bid medium"], desc = L["Sets the medium EPGP will use to collect bid results from members."], values = { ["RAID"] = CHAT_MSG_RAID, ["WHISPER"] = CHAT_MSG_WHISPER_INFORM, }, }, prAnnounceMedium = { order = 13, type = "select", name = L["EP/GP/PR announce medium"], desc = L["Announce EP/GP/PR when a member need/greed/bid"], values = { ["NONE"] = NONE, ["RAID"] = CHAT_MSG_RAID, ["WHISPER"] = CHAT_MSG_WHISPER_INFORM, ["OFFICER"] = CHAT_MSG_OFFICER, }, }, prAnnounceMsgFmt = { order = 14, type = "input", name = L["DIST_ANNOUNCE_PR_FMT_NAME"], desc = L["DIST_ANNOUNCE_PR_FMT_DESC"], width = 100 , }, -- spacer1 = LUI:OptionsSpacer(13, 0.001), announceNeedMsg = { order = 20, type = "input", name = L["Announce need message"], desc = L["Message announced when you start a need/greed bid."], width = 100, }, -- spacer2 = LUI:OptionsSpacer(21, 0.001), resetWhenAnnounce = { order = 30, type = "toggle", name = L["Reset when announce a bid"], desc = L["Reset result when announce and start a bid/need/roll."], width = 30, }, -- spacer3 = LUI:OptionsSpacer(31, 0.001), lootAutoAdd = { order = 40, type = "toggle", name = L["Track loot items"], desc = L["Add loot items automatically when loot windows opened or corpse loot received."], }, spacer4 = LUI:OptionsSpacer(41, 0.001), threshold = { order = 50, type = "select", name = L["Loot tracking threshold"], desc = L["Sets loot tracking threshold, to disable the adding on loot below this threshold quality."], values = { [2] = ITEM_QUALITY2_DESC, [3] = ITEM_QUALITY3_DESC, [4] = ITEM_QUALITY4_DESC, [5] = ITEM_QUALITY5_DESC, }, }, } local lootItem = { links = {}, linkMap = {}, count = 0, currentPage = 1, frame = nil, ITEMS_PER_PAGE = 10, MAX_COUNT = 200, FULL_WARNING_COUNT = 190 } local function LootItemIconFrameOnEnterFunc(self) GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT", - 3, self:GetHeight() + 6) GameTooltip:SetHyperlink(self:GetParent().itemLink) end local function LootItemIconFrameOnLeaveFunc() GameTooltip:Hide() end local function AddLootControlItems(frame, topItem, index) local authority = CanEditOfficerNote() local f = CreateFrame("Frame", nil, frame, BackdropTemplateMixin and "BackdropTemplate"); f:SetPoint("LEFT") f:SetPoint("RIGHT") f:SetPoint("TOP", topItem, "BOTTOMLEFT") local icon = f:CreateTexture(nil, ARTWORK) icon:SetWidth(36) icon:SetHeight(36) icon:SetPoint("LEFT") icon:SetPoint("TOP") local iconFrame = CreateFrame("Frame", nil, f, BackdropTemplateMixin and "BackdropTemplate"); iconFrame:ClearAllPoints() iconFrame:SetAllPoints(icon) iconFrame:SetScript("OnEnter", LootItemIconFrameOnEnterFunc) iconFrame:SetScript("OnLeave", LootItemIconFrameOnLeaveFunc) iconFrame:EnableMouse(true) local name = f:CreateFontString(nil, "OVERLAY", "GameFontNormal") name:SetPoint("TOP") name:SetPoint("LEFT", icon, "RIGHT") local needButton = CreateFrame("Button", nil, f) needButton:SetNormalFontObject("GameFontNormalSmall") needButton:SetHighlightFontObject("GameFontHighlightSmall") needButton:SetDisabledFontObject("GameFontDisableSmall") needButton:SetHeight(BUTTON_HEIGHT) needButton:SetWidth(BUTTON_HEIGHT) needButton:SetNormalTexture("Interface\\CURSOR\\OPENHAND") needButton:SetHighlightTexture("Interface\\CURSOR\\openhandglow") needButton:SetPushedTexture("Interface\\CURSOR\\OPENHAND") needButton:SetPoint("LEFT", icon, "RIGHT") needButton:SetPoint("BOTTOM") UISetEnabled(needButton, authority) table.insert(disableWhileNoAuthority, needButton) local bidButton = CreateFrame("Button", nil, f) bidButton:SetNormalFontObject("GameFontNormalSmall") bidButton:SetHighlightFontObject("GameFontHighlightSmall") bidButton:SetDisabledFontObject("GameFontDisableSmall") bidButton:SetHeight(BUTTON_HEIGHT) bidButton:SetWidth(BUTTON_HEIGHT) bidButton:SetNormalTexture("Interface\\Buttons\\UI-GroupLoot-Coin-Up") bidButton:SetHighlightTexture("Interface\\Buttons\\UI-GroupLoot-Coin-Highlight") bidButton:SetPushedTexture("Interface\\Buttons\\UI-GroupLoot-Coin-Down") bidButton:SetPoint("LEFT", needButton, "RIGHT") bidButton:SetPoint("BOTTOM", 0, -2) UISetEnabled(bidButton, authority) table.insert(disableWhileNoAuthority, bidButton) local rollButton = CreateFrame("Button", nil, f) rollButton:SetNormalFontObject("GameFontNormalSmall") rollButton:SetHighlightFontObject("GameFontHighlightSmall") rollButton:SetDisabledFontObject("GameFontDisableSmall") rollButton:SetHeight(BUTTON_HEIGHT) rollButton:SetWidth(BUTTON_HEIGHT) rollButton:SetNormalTexture("Interface\\Buttons\\UI-GroupLoot-Dice-Up") rollButton:SetHighlightTexture("Interface\\Buttons\\UI-GroupLoot-Dice-Highlight") rollButton:SetPushedTexture("Interface\\Buttons\\UI-GroupLoot-Dice-Down") rollButton:SetPoint("LEFT", bidButton, "RIGHT") rollButton:SetPoint("BOTTOM", 0, -1) UISetEnabled(rollButton, authority) table.insert(disableWhileNoAuthority, rollButton) local bankButton = CreateFrame("Button", nil, f) bankButton:SetNormalFontObject("GameFontNormalSmall") bankButton:SetHighlightFontObject("GameFontHighlightSmall") bankButton:SetDisabledFontObject("GameFontDisableSmall") bankButton:SetHeight(BUTTON_HEIGHT) bankButton:SetWidth(BUTTON_HEIGHT) bankButton:SetNormalTexture("Interface\\MINIMAP\\Minimap_chest_normal") bankButton:SetHighlightTexture("Interface\\MINIMAP\\Minimap_chest_elite") bankButton:SetPushedTexture("Interface\\MINIMAP\\Minimap_chest_normal") bankButton:SetPoint("LEFT", rollButton, "RIGHT") bankButton:SetPoint("BOTTOM", 0, -1) UISetEnabled(bankButton, authority) table.insert(disableWhileNoAuthority, bankButton) local removeButton = CreateFrame("Button", nil, f) removeButton:SetNormalFontObject("GameFontNormalSmall") removeButton:SetHighlightFontObject("GameFontHighlightSmall") removeButton:SetDisabledFontObject("GameFontDisableSmall") removeButton:SetHeight(BUTTON_HEIGHT) removeButton:SetWidth(BUTTON_HEIGHT) removeButton:SetNormalTexture("Interface\\Buttons\\UI-GroupLoot-Pass-Up") removeButton:SetHighlightTexture("Interface\\Buttons\\UI-GroupLoot-Pass-Highlight") removeButton:SetPushedTexture("Interface\\Buttons\\UI-GroupLoot-Pass-Down") removeButton:SetPoint("LEFT", bankButton, "RIGHT") removeButton:SetPoint("BOTTOM") removeButton:Enable() f.index = index f.icon = icon f.iconFrame = iconFrame f.name = name f.needButton = needButton f.bidButton = bidButton f.rollButton = rollButton f.bankButton = bankButton f.removeButton = removeButton f:SetHeight(icon:GetHeight()) f:Hide() return f end local function SetLootControlItem(frame, itemLink) if not itemLink or itemLink == "" then frame:Hide() return end local itemIcon = select(10, GetItemInfo(itemLink)) frame.itemLink = itemLink frame.icon:SetTexture(itemIcon) frame.name:SetText(itemLink) frame:Show() end local function LootControlsUpdate() local frame = lootItem.frame if not frame or not frame.initiated then return end local itemsN = lootItem.count local pageMax = math.max(math.ceil(itemsN / lootItem.ITEMS_PER_PAGE), 1) if itemsN > 0 then frame.clearButton:Enable() else frame.clearButton:Disable() end if lootItem.currentPage >= pageMax then lootItem.currentPage = pageMax frame.nextPageButton:Disable() else frame.nextPageButton:Enable() end if lootItem.currentPage == 1 then frame.lastPageButton:Disable() else frame.lastPageButton:Enable() end local baseN = (lootItem.currentPage - 1) * lootItem.ITEMS_PER_PAGE local showN = math.min(itemsN - baseN, lootItem.ITEMS_PER_PAGE) for i = 1, showN do SetLootControlItem(frame.items[i], lootItem.links[i + baseN]) end for i = showN + 1, lootItem.ITEMS_PER_PAGE do SetLootControlItem(frame.items[i]) end end local function LootItemsAdd(itemLink) if not itemLink or itemLink == "" then return end if lootItem.linkMap[itemLink] then return end if lootItem.count >= lootItem.MAX_COUNT then EPGP:Print(L["Loot list is full (%d). %s will not be added into list."]:format(lootItem.MAX_COUNT, itemLink)) return end lootItem.linkMap[itemLink] = true table.insert(lootItem.links, itemLink) table.insert(EPGP.db.profile.lootItemLinks, itemLink) lootItem.count = lootItem.count + 1 lootItem.currentPage = math.ceil(lootItem.count / lootItem.ITEMS_PER_PAGE) LootControlsUpdate() if lootItem.count >= lootItem.FULL_WARNING_COUNT then EPGP:Print(L["Loot list is almost full (%d/%d)."]:format(lootItem.count, lootItem.MAX_COUNT)) end end local function LootItemsClear() table.wipe(lootItem.linkMap) table.wipe(lootItem.links) table.wipe(EPGP.db.profile.lootItemLinks) lootItem.count = 0 lootItem.currentPage = 1 LootControlsUpdate() EPGP:SetBidStatus(0) end local function LootItemsRemove(index) if not index or index < 1 or index > lootItem.count then return end lootItem.linkMap[lootItem.links[index]] = nil table.remove(lootItem.links, index) table.remove(EPGP.db.profile.lootItemLinks, index) lootItem.count = lootItem.count - 1 LootControlsUpdate() end local function LootItemsResume() local vars = EPGP.db.profile if not vars.lootItemLinks then vars.lootItemLinks = {} return end for i, v in pairs(vars.lootItemLinks) do lootItem.linkMap[v] = true table.insert(lootItem.links, v) end lootItem.count = #lootItem.links end local function LootItemNeedButtonOnClick(bt) local itemLink = bt:GetParent().itemLink StartBid(itemLink, 1) end local function LootItemBidButtonOnClick(bt) local itemLink = bt:GetParent().itemLink StartBid(itemLink, 2) end local function LootItemRollButtonOnClick(bt) local itemLink = bt:GetParent().itemLink StartBid(itemLink, 3) end local function LootItemRemoveButtonOnClick(bt) local index = bt:GetParent().index LootItemsRemove(index + (lootItem.currentPage - 1) * lootItem.ITEMS_PER_PAGE) end local function LootItemBankButtonOnClick(bt) local itemLink = bt:GetParent().itemLink EPGP:BankItem(itemLink) LootItemRemoveButtonOnClick(bt) end local function ItemPassRarityThreshold(itemLink) if not itemLink then return false end local itemId = LIU:ItemlinkToID(itemLink) if not itemId then return false end if EPGP.db.profile.customItems[itemId] then return true end local itemRarity = select(3, GetItemInfo(itemLink)) if not itemRarity then return false end if itemRarity < mod.db.profile.threshold then return false end return true end local function CorpseLootReceivedHandler(event, itemLink) if not EPGP:IsRLorML() then return end if not itemLink or itemLink == "" then return end if not ItemPassRarityThreshold(itemLink) then return end LootItemsAdd(itemLink) end local function LootWindowHandler(event, loots) if not EPGP:IsRLorML() then return end if not loots then return end local added = false for i, itemLink in pairs(loots) do if ItemPassRarityThreshold(itemLink) then LootItemsAdd(itemLink) added = true end end if added and mod.db.profile.autoPop then EPGP:ShowDistrubutionFrame() end end function mod:FillFrame(frame) lootItem.frame = frame local autoPop = CreateFrame("CheckButton", nil, frame, "UICheckButtonTemplate") autoPop:SetWidth(20) autoPop:SetHeight(20) autoPop:SetPoint("TOPLEFT") autoPop.OnShow = function(w) w:SetChecked(mod.db.profile.autoPop or false) end autoPop:SetScript( "OnClick", function(w) mod.db.profile.autoPop = w:GetChecked() end) frame.autoPop = autoPop local autoPopLabel = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall") autoPopLabel:SetText(L["Auto popup"]) autoPopLabel:SetPoint("LEFT", autoPop, "RIGHT", 0, 2) local dropDown = GUI:Create("Dropdown") dropDown:SetWidth(150) dropDown.frame:SetParent(frame) dropDown:SetPoint("TOPLEFT", autoPop, "BOTTOMLEFT") dropDown.text:SetJustifyH("LEFT") dropDown:SetCallback( "OnValueChanged", function(self, event, ...) local itemLink = self.text:GetText() if itemLink and itemLink ~= "" then frame.addButton:Enable() else frame.addButton:Disable() end end) dropDown.button:HookScript( "OnMouseDown", function(self) if not self.obj.open then EPGP:ItemCacheDropDown_SetList(self.obj) end end) dropDown.button:HookScript( "OnClick", function(self) if self.obj.open then self.obj.pullout:SetWidth(285) end end) dropDown.button_cover:HookScript( "OnMouseDown", function(self) if not self.obj.open then EPGP:ItemCacheDropDown_SetList(self.obj) end end) dropDown.button_cover:HookScript( "OnClick", function(self) if self.obj.open then self.obj.pullout:SetWidth(285) end end) dropDown:SetCallback( "OnEnter", function(self) local itemLink = self.text:GetText() if itemLink then local anchor = self.open and self.pullout.frame or self.frame:GetParent() GameTooltip:SetOwner(anchor, "ANCHOR_RIGHT", 5) GameTooltip:SetHyperlink(itemLink) end end) dropDown:SetCallback("OnLeave", function() GameTooltip:Hide() end) local addButton = CreateFrame("Button", "addButton", frame, "UIPanelButtonTemplate") addButton:SetNormalFontObject("GameFontNormalSmall") addButton:SetHighlightFontObject("GameFontHighlightSmall") addButton:SetDisabledFontObject("GameFontDisableSmall") addButton:SetHeight(BUTTON_HEIGHT) addButton:SetText(_G.ADD) addButton:SetWidth(addButton:GetTextWidth() + BUTTON_TEXT_PADDING) addButton:SetPoint("LEFT", dropDown.frame, "RIGHT") addButton:Disable() addButton:SetScript("OnClick", function(self) LootItemsAdd(dropDown.text:GetText()) end) local clearButton = CreateFrame("Button", "clearButton", frame, "UIPanelButtonTemplate") clearButton:SetNormalFontObject("GameFontNormalSmall") clearButton:SetHighlightFontObject("GameFontHighlightSmall") clearButton:SetDisabledFontObject("GameFontDisableSmall") clearButton:SetHeight(BUTTON_HEIGHT) clearButton:SetText(L["Clear"]) clearButton:SetWidth(clearButton:GetTextWidth() + BUTTON_TEXT_PADDING) clearButton:SetPoint("TOP", dropDown.frame, "BOTTOM") clearButton:SetPoint("LEFT") clearButton:Disable() clearButton:SetScript("OnClick", LootItemsClear) local resetButton = CreateFrame("Button", "resetButton", frame, "UIPanelButtonTemplate") resetButton:SetNormalFontObject("GameFontNormalSmall") resetButton:SetHighlightFontObject("GameFontHighlightSmall") resetButton:SetDisabledFontObject("GameFontDisableSmall") resetButton:SetHeight(BUTTON_HEIGHT) resetButton:SetText(_G.RESET) resetButton:SetWidth(resetButton:GetTextWidth() + BUTTON_TEXT_PADDING) resetButton:SetPoint("LEFT", clearButton, "RIGHT") resetButton:Enable() resetButton:SetScript("OnClick", function(self) EPGP:SetBidStatus(0) end) local announceButton = CreateFrame("Button", "announceButton", frame, "UIPanelButtonTemplate") announceButton:SetNormalFontObject("GameFontNormalSmall") announceButton:SetHighlightFontObject("GameFontHighlightSmall") announceButton:SetDisabledFontObject("GameFontDisableSmall") announceButton:SetHeight(BUTTON_HEIGHT) announceButton:SetText(L["Announce"]) announceButton:SetWidth(announceButton:GetTextWidth() + BUTTON_TEXT_PADDING) announceButton:SetPoint("LEFT", resetButton, "RIGHT") announceButton:Enable() announceButton:SetScript( "OnClick", function(self) LootItemsAnnounce(lootItem.links) end) local lastPageButton = CreateFrame("Button", "lastPageButton", frame, "UIPanelButtonTemplate") lastPageButton:SetNormalFontObject("GameFontNormalSmall") lastPageButton:SetHighlightFontObject("GameFontHighlightSmall") lastPageButton:SetDisabledFontObject("GameFontDisableSmall") lastPageButton:SetHeight(BUTTON_HEIGHT) lastPageButton:SetText("<") lastPageButton:SetWidth(lastPageButton:GetTextWidth() + BUTTON_TEXT_PADDING) lastPageButton:SetPoint("LEFT", announceButton, "RIGHT") lastPageButton:Disable() lastPageButton:SetScript( "OnClick", function(self) lootItem.currentPage = lootItem.currentPage - 1 LootControlsUpdate() end) local nextPageButton = CreateFrame("Button", "nextPageButton", frame, "UIPanelButtonTemplate") nextPageButton:SetNormalFontObject("GameFontNormalSmall") nextPageButton:SetHighlightFontObject("GameFontHighlightSmall") nextPageButton:SetDisabledFontObject("GameFontDisableSmall") nextPageButton:SetHeight(BUTTON_HEIGHT) nextPageButton:SetText(">") nextPageButton:SetWidth(nextPageButton:GetTextWidth() + BUTTON_TEXT_PADDING) nextPageButton:SetPoint("LEFT", lastPageButton, "RIGHT") nextPageButton:Disable() nextPageButton:SetScript( "OnClick", function(self) lootItem.currentPage = lootItem.currentPage + 1 LootControlsUpdate() end) frame.items = {} for i = 1, lootItem.ITEMS_PER_PAGE do if i == 1 then frame.items[i] = AddLootControlItems(frame, clearButton, i) else frame.items[i] = AddLootControlItems(frame, frame.items[i - 1], i) end local item = frame.items[i] item.needButton:SetScript("OnClick", LootItemNeedButtonOnClick) item.bidButton:SetScript("OnClick", LootItemBidButtonOnClick) item.rollButton:SetScript("OnClick", LootItemRollButtonOnClick) item.bankButton:SetScript("OnClick", LootItemBankButtonOnClick) item.removeButton:SetScript("OnClick", LootItemRemoveButtonOnClick) end frame.initiated = true frame.addButton = addButton frame.clearButton = clearButton frame.lastPageButton = lastPageButton frame.nextPageButton = nextPageButton frame:SetWidth(math.max( dropDown.frame:GetWidth() + addButton:GetWidth() + 15, clearButton:GetWidth() + resetButton:GetWidth() + announceButton:GetWidth() + nextPageButton:GetWidth() * 2)) frame:SetHeight( autoPop:GetHeight() + math.max(dropDown.frame:GetHeight(), addButton:GetHeight()) + clearButton:GetHeight() + frame.items[1]:GetHeight() * lootItem.ITEMS_PER_PAGE) LootControlsUpdate() end function mod:OnInitialize() self.db = EPGP.db:RegisterNamespace("distribution", mod.dbDefaults) end function mod:OnEnable() EPGP.RegisterCallback(self, "AuthorityChanged", AuthorityChangedCallbackFunc) EPGP.RegisterCallback(self, "BidStatusUpdate", HandleBidStatusUpdate) EPGP.RegisterCallback(self, "CorpseLootReceived", CorpseLootReceivedHandler) EPGP.RegisterCallback(self, "LootWindow", LootWindowHandler) LootItemsResume() end function mod:OnDisable() EPGP.UnregisterAllCallbacks(self) end
class 'BetterChat' local valueses = { "Неудачно", "Удачно", "Неудачно" } function BetterChat:__init( args ) SQL:Execute( "CREATE TABLE IF NOT EXISTS settings_chatpos (steamid VARCHAR UNIQUE, positionX INTEGER, positionY INTEGER)") SQL:Execute( "CREATE TABLE IF NOT EXISTS players_chatsettings (steamid VARCHAR UNIQUE, visiblejoinmessages INTEGER)") Network:Subscribe( "SaveChatPos", self, self.SaveChatPos ) Network:Subscribe( "ResetChatPos", self, self.ResetChatPos ) Network:Subscribe( "ChangeChatSettings", self, self.ChangeChatSettings ) Network:Subscribe( "toggle", self, self.Mode ) Events:Subscribe( "ClientModuleLoad", self, self.LoadChatPos ) Events:Subscribe( "PlayerJoin", self, self.Join ) Events:Subscribe( "PlayerQuit", self, self.PlayerQuit ) Events:Subscribe( "PlayerChat", self, self.Chat ) self.distance = 30 self.toggle = 0 end function BetterChat:SaveChatPos( args, sender ) local cmd = SQL:Command( "insert or replace into settings_chatpos (steamid, positionX, positionY) values (?, ?, ?)" ) cmd:Bind( 1, sender:GetSteamId().id ) cmd:Bind( 2, args.chatpos.x ) cmd:Bind( 3, args.chatpos.y ) cmd:Execute() end function BetterChat:ResetChatPos( args, sender ) local cmd = SQL:Command( "DELETE FROM settings_chatpos WHERE steamid = (?)" ) cmd:Bind( 1, sender:GetSteamId().id ) cmd:Execute() end function BetterChat:ChangeChatSettings( args, sender ) if sender:GetValue( "VisibleJoinMessages" ) then sender:SetNetworkValue( "VisibleJoinMessages", nil ) else sender:SetNetworkValue( "VisibleJoinMessages", 1 ) end end function BetterChat:LoadChatPos( args ) local qry = SQL:Query( "select positionX, positionY from settings_chatpos where steamid = (?)" ) qry:Bind( 1, args.player:GetSteamId().id ) local result = qry:Execute() if #result > 0 then Network:Send( args.player, "ApplyChatPos", { sqlchatposX = tonumber(result[1].positionX), sqlchatposY = tonumber(result[1].positionY) } ) end end function BetterChat:Join( args ) args.player:SetNetworkValue( "ChatMode", 0 ) local qry = SQL:Query("SELECT visiblejoinmessages FROM players_chatsettings WHERE steamid = ?") qry:Bind( 1, args.player:GetSteamId().id ) local result = qry:Execute() if #result > 0 then args.player:SetNetworkValue( "VisibleJoinMessages", tonumber( result[1].visiblejoinmessages ) ) end end function BetterChat:PlayerQuit( args ) local steamID = tostring(args.player:GetSteamId().id) if args.player:GetValue( "VisibleJoinMessages" ) then local cmd = SQL:Command( "INSERT OR REPLACE INTO players_chatsettings (steamid, visiblejoinmessages) values (?, ?)" ) cmd:Bind( 1, tostring(steamID) ) cmd:Bind( 2, args.player:GetValue( "VisibleJoinMessages" ) ) cmd:Execute() else local cmd = SQL:Command( "DELETE FROM players_chatsettings WHERE steamid = (?)" ) cmd:Bind( 1, args.player:GetSteamId().id ) cmd:Execute() end end function BetterChat:Mode( toggler, player ) player:SetNetworkValue( "ChatMode", toggler ) end function BetterChat:Chat( args ) if args.text:sub(1,1) != "/" then if not args.player:GetValue( "Mute" ) then local chatsetting = args.player:GetValue( "ChatMode" ) if chatsetting == 0 then for p in Server:GetPlayers() do if p:GetValue( "Lang" ) == "ENG" then p:SendChatMessage( "[Global] ", Color.LightSkyBlue, args.player:GetName(), args.player:GetColor(), ": "..args.text, Color.White ) else p:SendChatMessage( "[Общий] ", Color.LightSkyBlue, args.player:GetName(), args.player:GetColor(), ": "..args.text, Color.White ) end end Events:Fire( "ToDiscordConsole", { text = "[" .. args.player:GetValue( "Lang") .. "] [Global] " .. args.player:GetName() .. ": "..args.text } ) print( "(" .. args.player:GetId() .. ") " .. args.player:GetName()..": "..args.text ) return false elseif chatsetting == 1 then for p in Server:GetPlayers() do jDist = args.player:GetPosition():Distance( p:GetPosition() ) if p and jDist < 50 then p:SendChatMessage( "[Локальный] ", Color.DarkGray, args.player:GetName(), args.player:GetColor(), ": ".. args.text, Color.White ) end end return false elseif chatsetting == 2 then return false end end else local cmd_args = string.split( args.text," ",true ) end local msg = args.text if ( msg:sub ( 1, 1 ) ~= "/" ) then return true end local msg = msg:sub( 2 ) local cmd_args = msg:split( " " ) local cmd_name = cmd_args [ 1 ]:lower() if ( cmd_name == "me" ) then table.remove( cmd_args, 1 ) for p in Server:GetPlayers() do jDist = args.player:GetPosition():Distance( p:GetPosition() ) if jDist < 50 then p:SendChatMessage( args.player:GetName() .. " " .. tostring( table.concat ( cmd_args, " " ) ), Color.Magenta ) end end end if ( cmd_name == "l" ) then table.remove( cmd_args, 1 ) for p in Server:GetPlayers() do jDist = args.player:GetPosition():Distance( p:GetPosition() ) if jDist < 50 then p:SendChatMessage( "[Локальный] ", Color.DarkGray, args.player:GetName(), args.player:GetColor(), ": ".. tostring( table.concat ( cmd_args, " " ) ), Color.White ) end end end if ( cmd_name == "try" ) then wtf = valueses[math.random(#valueses)] table.remove( cmd_args, 1 ) for p in Server:GetPlayers() do jDist = args.player:GetPosition():Distance( p:GetPosition() ) if jDist < 50 then p:SendChatMessage( args.player:GetName() .. " " .. tostring( table.concat ( cmd_args, " " ) ), Color.Magenta, " | ", Color.White, wtf, Color.Magenta, " | ", Color.White ) end end end end betterchat = BetterChat()
--[[ functions: OnInitialize(eventinfo, map, player) //when player enter map OnExecute(eventinfo, map, player) //when event is first ran OnDo(eventinfo, map, player) //during event being ran objects: EventInfo - variables: status data1 //last yes/no result: nothing -> -1, no -> 0, yes -> 1 data2 //last selection index selected result data3 //unk - methods: v ---- these methods advance the status when sent, only call one of them per OnExecute SendText(string) SendYesNo(string) SendSelection(string, arguments...) v ---- these methods do not advance the status, you can use them as much as you wish EndEvent() PlayerEntity - variables: - methods: Map - variables: - methods: ]] function OnInitialize(eventinfo, map, player) end function OnExecute(eventinfo, map, player) end function OnDo(eventinfo, map, player) end
settings = {} --------------Define the Color Picker Array-------------- settings.colorPicker = {} settings.colorPicker.triangle = {} settings.colorPicker.ring = {} settings.colorPicker.innerCircle = {} settings.colorPicker.tinyCircle = {} --------------Assigning Misc. Values-------------- settings.colorPicker.ring.isClicked = false settings.colorPicker.triangle.isClicked = false settings.colorPicker.triangleTex = love.graphics.newImage("assets/triangle_gradient.png") settings.colorPicker.triangleTint = love.graphics.newImage("assets/triangle_tint.png") settings.colorPicker.ringTex = love.graphics.newImage("assets/rainbow_gradient.png") settings.colorPicker.line = love.graphics.newImage("assets/line.png") settings.colorPicker.x, settings.colorPicker.y = 0, 0 settings.colorPicker.tint = jLib.color.red --------------Define Shapes through Constructor Classes (gui.lua)-------------- settings.colorPicker.ring = CircleButton(settings.colorPicker.x, settings.colorPicker.y, 100, "fill", "", jLib.color.clear) settings.colorPicker.innerCircle = CircleButton(settings.colorPicker.x, settings.colorPicker.y, 80, "fill", "", jLib.color.clear) settings.colorPicker.triangle = TriangleButton(settings.colorPicker.x, settings.colorPicker.y, 140, 0, "fill", "", jLib.color.clear) settings.colorPicker.tinyCircle = RingButton(settings.colorPicker.x, settings.colorPicker.y, 5, "fill", "", jLib.color.grey) --------------Draw Function-------------- settings.colorPicker.draw = function() --HITBOXES settings.colorPicker.ring:draw() settings.colorPicker.innerCircle:draw() settings.colorPicker.triangle:draw() --DRAW TEXTURES love.graphics.draw(settings.colorPicker.ringTex, settings.colorPicker.x, settings.colorPicker.y, 0, .5 * game.scale, .5 * game.scale, 200, 200) love.graphics.draw(settings.colorPicker.triangleTex, settings.colorPicker.x, settings.colorPicker.y, settings.colorPicker.triangle.rot, .5 * game.scale, .5 * game.scale, 160, 160) love.graphics.setColor(settings.colorPicker.tint) love.graphics.draw(settings.colorPicker.triangleTint, settings.colorPicker.x, settings.colorPicker.y, settings.colorPicker.triangle.rot, .5 * game.scale, .5 * game.scale, 160, 160) love.graphics.setColor(jLib.color.white) love.graphics.draw(settings.colorPicker.line, settings.colorPicker.x, settings.colorPicker.y, settings.colorPicker.triangle.rot, .5 * game.scale, .5 * game.scale, 30, 200) settings.colorPicker.tinyCircle:draw() end --------------Scaling/Update Function-------------- settings.colorPicker.update = function(scale) --Multiplier; scale of 1 is regular size, scale of 2x is twice as big, and so on --RECALCULATE POSITION settings.colorPicker.x = jLib.window.width / 2 --RECALCULATE POS settings.colorPicker.y = jLib.window.height / 2 --RECALCULATE POS --RECALCULATE SIZE BASED OFF OF PASSED SCALE PARAMETER local size = scale * 200 local rot = settings.colorPicker.triangle.rot --DESTROY REFERENCE OF HITBOXES settings.colorPicker.ring, settings.colorPicker.innerCircle, settings.colorPicker.triangle, settings.colorPicker.tinyCircle = nil, nil, nil, nil --CREATE NEW HITBOXES settings.colorPicker.ring = CircleButton(settings.colorPicker.x, settings.colorPicker.y, size * .5, "fill", "", jLib.color.clear) settings.colorPicker.innerCircle = CircleButton(settings.colorPicker.x, settings.colorPicker.y, size * .4, "fill", "", jLib.color.clear) settings.colorPicker.triangle = TriangleButton(settings.colorPicker.x, settings.colorPicker.y, size * .7, rot, "fill", "", jLib.color.clear) settings.colorPicker.tinyCircle = RingButton(settings.colorPicker.x, settings.colorPicker.y, size * 0.025, "fill", "", jLib.color.grey) end --------------Color Determination Function-------------- settings.colorPicker.guts = function() local degree, r, g, b, hue, sat, val local color = {} --ONLY GET THE ROTATION WHEN THE RING IS CLICKED if settings.colorPicker.ring.isClicked then settings.colorPicker.triangle.rot = jLib.getDir(settings.colorPicker.triangle.x, settings.colorPicker.triangle.y, jLib.mouse.x, jLib.mouse.y) end --ALWAYS GET THE HUE FIRST BASED ON THE ROTATION, REGARDLESS ON WHAT'S ACTUALLY BEING CLICKED if settings.colorPicker.ring.isClicked or settings.colorPicker.triangle.isClicked then --CONVERT FROM RADIANS TO DEGREES degree = jLib.map(-math.pi * .5, math.pi * 1.5, 0, 360, settings.colorPicker.triangle.rot) --CALCULATE RED BASED ON ROTATION if degree >= 15 and degree <= 150 then r = 255 elseif degree > 150 and degree < 210 then r = math.floor(jLib.map(150, 210, 255, 0, degree)) elseif degree < 15 then r = math.floor(jLib.map(15, 0, 255, 196, degree)) elseif degree > 310 then r = math.floor(jLib.map(360, 310, 195, 0, degree)) else r = 0 end --CALCULATE GREEN BASED ON ROTATION if degree <= 270 and degree >= 150 then g = 255 elseif degree > 270 and degree < 310 then g = math.floor(jLib.map(270, 310, 255, 0, degree)) elseif degree < 150 and degree > 90 then g = math.floor(jLib.map(150, 90, 255, 0, degree)) else g = 0 end --CALCULATE BLUE BASED ON ROTATION if degree <= 15 or degree >= 270 then b = 255 elseif degree > 15 and degree < 90 then b = math.floor(jLib.map(15, 90, 255, 0, degree)) elseif degree > 210 and degree < 270 then b = math.floor(jLib.map(210, 270, 0, 255, degree)) else b = 0 end --CONVERT FROM 255/0 SCALE to 1/0 SCALE r = r / 255 g = g / 255 b = b / 255 --SET THE TINT BASED OFF OF ONLY THE HUE settings.colorPicker.tint = {r, g, b} --SET RGB TO RGB OR CURRENT GAME.PLAYER.COLOR color[1] = r color[2] = g color[3] = b local x, y, ix, iy local triangle = settings.colorPicker.triangle --ONLY DO TRIANGLE CALCULATIONS IF TRIANGLE WAS CLICKED INITIALLY if settings.colorPicker.triangle.isClicked then --IF MOUSE IS NOT IN TRIANGLE if not jLib.isInside(triangle.vert, jLib.mouse.x, jLib.mouse.y) then local line2 = {jLib.mouse.x, jLib.mouse.y, triangle.x, triangle.y} --GET VALUES OF TRIANGLE TO FORM LINE for i = 1, #triangle.vert, 2 do local x1, y1 = triangle.vert[i], triangle.vert[i + 1] local x2, y2 if i + 1 >= #triangle.vert then x2, y2 = triangle.vert[1], triangle.vert[2] else x2, y2 = triangle.vert[i + 2], triangle.vert[i + 3] end --GET INTERSECTION POINT OF TRIANGLE LINE AND MOUSE-TO-CENTER LINE ix, iy = jLib.intersectsAt({x1, y1, x2, y2}, line2) --IF INTERSECTION POINT EXISTS, BREAK FROM LOOP if ix and iy then break end end end --IF MOUSE IS INSIDE TRIANGLE, ASSIGN ix AND iy VALUES OF MOUSE x AND y if not ix and not iy then ix, iy = jLib.mouse.x, jLib.mouse.y end love.graphics.push() --APPLY ROTATION TOO COORDS love.graphics.translate(triangle.x, triangle.y) love.graphics.rotate(-triangle.rot) love.graphics.translate(-triangle.x, -triangle.y) --APPLY TRANSFORMATION TO INTERSECTION COORDS x, y = love.graphics.transformPoint(ix, iy) love.graphics.pop() --MODIFY TINY CIRCLE X/Y BASED ON TRANSFORMED POINTS settings.colorPicker.tinyCircle.x, settings.colorPicker.tinyCircle.y = x, y end --IF THE ABOVE WASN'T CALCULATED, GET THE PREV VALUES OF THE X, Y POSITION AND USE THEM TO CALCULATE THE FOLLOWING x = x or settings.colorPicker.tinyCircle.x y = y or settings.colorPicker.tinyCircle.y --CONVERT HSV hue, sat, val = jLib.RGBtoHSV(color[1] * 255, color[2] * 255, color[3] * 255) --CALCULATE TOP, BOTTOM, LEFT AND RIGHT OF TRIANGLES BASED ON RELATIVE COORDS local top, btm = triangle.y - ((math.sqrt(3)/3) * triangle.size), triangle.y + ((math.sqrt(3)/6) * triangle.size) local right, left = triangle.x + (triangle.size / 2), triangle.x - (triangle.size / 2) --GET THE POSITION OF THE POINTER, AND COMPARE IT TO THE BOTTOM/TOP OF THE TRIANGLE, AND MAP THAT TO 0 - 1 sat = jLib.map(btm, top, 0, 1, y) --DO THE SAME THING, BUT ADD IN THE SATURATION SO YOU DON'T LOSE THE HUE val = math.min(jLib.map(left, right, 0, .75, x) + sat, 1) return jLib.HSVtoRGB(hue, sat, val) end end
local Packages = script.Parent.Parent.Parent.Parent.Packages local Roact = require(Packages.Roact) local Hooks = require(Packages.Hooks) local StudioTheme = require(Packages.StudioTheme) local Llama = require(Packages.Llama) local Icon = require(script.Parent.Parent.Parent.Icon) local e = Roact.createElement export type ScrollButtonProps = { anchor: Vector2?, position: UDim2?, size: UDim2?, icon: (string | Icon.IconProps)?, disabled: boolean?, zindex: number?, onActivated: ((ImageButton) -> ())?, } local function ScrollButton(props: ScrollButtonProps, hooks) local theme = StudioTheme.useTheme(hooks) local hover, setHover = hooks.useState(false) local press, setPress = hooks.useState(false) local colours = hooks.useMemo(function() local colours = { background = Enum.StudioStyleGuideColor.ScrollBar, foreground = Enum.StudioStyleGuideColor.TitlebarText, border = Enum.StudioStyleGuideColor.Border, } if props.disabled then colours.background = theme:GetColor(colours.background :: any, Enum.StudioStyleGuideModifier.Disabled) colours.foreground = theme:GetColor(colours.foreground :: any, Enum.StudioStyleGuideModifier.Disabled) colours.border = theme:GetColor(colours.border :: any, Enum.StudioStyleGuideModifier.Disabled) elseif press then colours.background = theme:GetColor(colours.background :: any, Enum.StudioStyleGuideModifier.Pressed) colours.foreground = theme:GetColor(colours.foreground :: any, Enum.StudioStyleGuideModifier.Pressed) colours.border = theme:GetColor(colours.border :: any, Enum.StudioStyleGuideModifier.Pressed) elseif hover then colours.background = theme:GetColor(colours.background :: any, Enum.StudioStyleGuideModifier.Hover) colours.foreground = theme:GetColor(colours.foreground :: any, Enum.StudioStyleGuideModifier.Hover) colours.border = theme:GetColor(colours.border :: any, Enum.StudioStyleGuideModifier.Hover) else colours.background = theme:GetColor(colours.background :: any, Enum.StudioStyleGuideModifier.Default) colours.foreground = theme:GetColor(colours.foreground :: any, Enum.StudioStyleGuideModifier.Default) colours.border = theme:GetColor(colours.border :: any, Enum.StudioStyleGuideModifier.Default) end return colours end, { props.disabled, press, hover, theme }) local onInputBegan = hooks.useCallback(function(_, input: InputObject) if props.disabled then return end if input.UserInputType == Enum.UserInputType.MouseMovement then setHover(true) elseif input.UserInputType.Name:match("MouseButton%d+") then setPress(true) end end, { props.disabled }) local function onInputEnded(_, input: InputObject) if input.UserInputType == Enum.UserInputType.MouseMovement then setHover(false) setPress(false) elseif input.UserInputType.Name:match("MouseButton%d+") then setPress(false) end end local iconProps = hooks.useMemo(function() return Llama.Dictionary.merge( { anchor = Vector2.new(0.5, 0.5), position = UDim2.fromScale(0.5, 0.5), colour = colours.foreground, }, if type(props.icon) == "table" then props.icon else { icon = props.icon, } ) end, { props.icon, colours.foreground }) return e(if props.onActivated then "ImageButton" else "Frame", { AutoButtonColor = if props.onActivated then false else nil, AnchorPoint = props.anchor, BackgroundColor3 = colours.background, BorderColor3 = colours.border, Position = props.position, Size = props.size, ZIndex = props.zindex, [Roact.Event.InputBegan] = onInputBegan, [Roact.Event.InputEnded] = onInputEnded, [Roact.Event.Activated] = props.onActivated, }, { Icon = props.icon and e(Icon, iconProps), }) end return Hooks.new(Roact)(ScrollButton, { defaultProps = { zindex = 30, }, })
----------------------------------------------------------------------------------------------------------------------- -- RedFlat floating window manager -- ----------------------------------------------------------------------------------------------------------------------- -- Widget to control single flating window size and posioning ----------------------------------------------------------------------------------------------------------------------- -- Grab environment ----------------------------------------------------------------------------------------------------------------------- local unpack = unpack or table.unpack local beautiful = require("beautiful") local awful = require("awful") local wibox = require("wibox") local rednotify = require("redflat.float.notify") local redutil = require("redflat.util") local redtip = require("redflat.float.hotkeys") local svgbox = require("redflat.gauge.svgbox") -- Initialize tables for module ----------------------------------------------------------------------------------------------------------------------- local control = {} -- Resize mode alias local RESIZE_MODE = { FULL = 1, HORIZONTAL = 2, VERTICAL = 3 } -- Generate default theme vars ----------------------------------------------------------------------------------------------------------------------- local function default_style() local style = { geometry = { width = 400, height = 60 }, border_width = 2, font = "Sans 14", set_position = nil, notify = {}, keytip = { geometry = { width = 600 } }, shape = nil, steps = { 1, 10, 20, 50 }, default_step = 2, onscreen = true, margin = { icon = { onscreen = { 10, 10, 2, 2 }, mode = { 10, 10, 2, 2 } } }, icon = { resize = {}, onscreen = redutil.base.placeholder({ txt = "X" }), }, color = { border = "#575757", text = "#aaaaaa", main = "#b1222b", wibox = "#202020", gray = "#575757", icon = "#a0a0a0" }, } style.icon.resize[RESIZE_MODE.FULL] = redutil.base.placeholder({ txt = "F" }) style.icon.resize[RESIZE_MODE.HORIZONTAL] = redutil.base.placeholder({ txt = "H" }) style.icon.resize[RESIZE_MODE.VERTICAL] = redutil.base.placeholder({ txt = "V" }) return redutil.table.merge(style, redutil.table.check(beautiful, "float.control") or {}) end -- key bindings control.keys = {} control.keys.control = { { { "Mod4" }, "c", function() control:center() end, { description = "Put window at the center", group = "Window control" } }, { { "Mod4" }, "q", function() control:resize() end, { description = "Increase window size", group = "Window control" } }, { { "Mod4" }, "a", function() control:resize(true) end, { description = "Decrease window size", group = "Window control" } }, { { "Mod4" }, "l", function() control:move("right") end, { description = "Move window to right", group = "Window control" } }, { { "Mod4" }, "j", function() control:move("left") end, { description = "Move window to left", group = "Window control" } }, { { "Mod4" }, "k", function() control:move("bottom") end, { description = "Move window to bottom", group = "Window control" } }, { { "Mod4" }, "i", function() control:move("top") end, { description = "Move window to top", group = "Window control" } }, { { "Mod4" }, "n", function() control:switch_resize_mode() end, { description = "Switch moving/resizing mode", group = "Mode" } }, { { "Mod4" }, "s", function() control:switch_onscreen() end, { description = "Switch off screen check", group = "Mode" } }, } control.keys.action = { { { "Mod4" }, "Super_L", function() control:hide() end, { description = "Close top list widget", group = "Action" } }, { { "Mod4" }, "F1", function() redtip:show() end, { description = "Show hotkeys helper", group = "Action" } }, } control.keys.all = awful.util.table.join(control.keys.control, control.keys.action) control._fake_keys = { { {}, "N", nil, { description = "Select move/resize step", group = "Mode", keyset = { "1", "2", "3", "4", "5", "6", "7", "8", "9" } } }, } -- Support function ----------------------------------------------------------------------------------------------------------------------- local function control_off_screen(window) local wa = screen[mouse.screen].workarea local newg = window:geometry() if newg.width > wa.width then window:geometry({ width = wa.width, x = wa.x }) end if newg.height > wa.height then window:geometry({ height = wa.height, y = wa.y }) end redutil.placement.no_offscreen(window, nil, wa) end -- Initialize widget ----------------------------------------------------------------------------------------------------------------------- function control:init() -- Initialize vars -------------------------------------------------------------------------------- local style = default_style() self.style = style self.client = nil self.step = style.steps[style.default_step] self.resize_mode = RESIZE_MODE.FULL self.onscreen = style.onscreen -- Create floating wibox for top widget -------------------------------------------------------------------------------- self.wibox = wibox({ ontop = true, bg = style.color.wibox, border_width = style.border_width, border_color = style.color.border, shape = style.shape }) self.wibox:geometry(style.geometry) -- Widget layout setup -------------------------------------------------------------------------------- self.label = wibox.widget.textbox() self.label:set_align("center") self.label:set_font(style.font) self.onscreen_icon = svgbox(self.style.icon.onscreen) self.onscreen_icon:set_color(self.onscreen and self.style.color.main or self.style.color.icon) self.mode_icon = svgbox(self.style.icon.resize[self.resize_mode]) self.mode_icon:set_color(self.style.color.icon) self.wibox:setup({ wibox.container.margin(self.onscreen_icon, unpack(self.style.margin.icon.onscreen)), self.label, wibox.container.margin(self.mode_icon, unpack(self.style.margin.icon.mode)), layout = wibox.layout.align.horizontal }) -- Keygrabber -------------------------------------------------------------------------------- self.keygrabber = function(mod, key, event) if event == "release" then for _, k in ipairs(self.keys.action) do if redutil.key.match_grabber(k, mod, key) then k[3](); return end end else for _, k in ipairs(self.keys.all) do if redutil.key.match_grabber(k, mod, key) then k[3](); return end end if string.match("123456789", key) then self:choose_step(tonumber(key)) end end end -- First run actions -------------------------------------------------------------------------------- self:set_keys() end -- Window control ----------------------------------------------------------------------------------------------------------------------- -- Put window at center of screen -------------------------------------------------------------------------------- function control:center() if not self.client then return end redutil.placement.centered(self.client, nil, mouse.screen.workarea) if self.onscreen then control_off_screen(self.client) end self:update() end -- Change window size -------------------------------------------------------------------------------- function control:resize(is_shrinking) if not self.client then return end -- calculate new size local g = self.client:geometry() local d = self.step * (is_shrinking and -1 or 1) local newg if self.resize_mode == RESIZE_MODE.FULL then newg = { x = g.x - d, y = g.y - d, width = g.width + 2 * d, height = g.height + 2 * d } elseif self.resize_mode == RESIZE_MODE.HORIZONTAL then newg = { x = g.x - d, width = g.width + 2 * d } elseif self.resize_mode == RESIZE_MODE.VERTICAL then newg = { y = g.y - d, height = g.height + 2 * d } end -- validate new size if newg.height and newg.height <= 0 or newg.width and newg.width < 0 then return end -- apply new size self.client:geometry(newg) if self.onscreen then control_off_screen(self.client) end self:update() end -- Move by direction -------------------------------------------------------------------------------- function control:move(direction) if not self.client then return end local g = self.client:geometry() local d = self.step * ((direction == "left" or direction == "top") and -1 or 1) if direction == "left" or direction == "right" then self.client:geometry({ x = g.x + d }) else self.client:geometry({ y = g.y + d }) end if self.onscreen then control_off_screen(self.client) end end -- Widget actions ----------------------------------------------------------------------------------------------------------------------- -- Update -------------------------------------------------------------------------------- function control:update() if not self.client then return end local g = self.client:geometry() local size_label = string.format("%sx%s", g.width, g.height) self.label:set_markup(string.format( '<span color="%s">%s</span><span color="%s"> [%d]</span>', self.style.color.text, size_label, self.style.color.gray, self.step )) end -- Select move/resize step by index -------------------------------------------------------------------------------- function control:choose_step(index) if self.style.steps[index] then self.step = self.style.steps[index] end self:update() end -- Switch resize mode -------------------------------------------------------------------------------- function control:switch_resize_mode() self.resize_mode = self.resize_mode + 1 if not awful.util.table.hasitem(RESIZE_MODE, self.resize_mode) then self.resize_mode = RESIZE_MODE.FULL end self.mode_icon:set_image(self.style.icon.resize[self.resize_mode]) end -- Switch onscreen mode -------------------------------------------------------------------------------- function control:switch_onscreen() self.onscreen = not self.onscreen self.onscreen_icon:set_color(self.onscreen and self.style.color.main or self.style.color.icon) if self.onscreen then control_off_screen(self.client) self:update() end end -- Show -------------------------------------------------------------------------------- function control:show() if not self.wibox then self:init() end if not self.wibox.visible then -- check if focused client floating local layout = awful.layout.get(mouse.screen) local is_floating = client.focus and (client.focus.floating or layout.name == "floating") and not client.focus.maximized if not is_floating then rednotify:show(redutil.table.merge({ text = "No floating window focused" }, self.style.notify)) return end self.client = client.focus -- show widget if self.style.set_position then self.style.set_position(self.wibox) else redutil.placement.centered(self.wibox, nil, mouse.screen.workarea) end redutil.placement.no_offscreen(self.wibox, self.style.screen_gap, screen[mouse.screen].workarea) self:update() self.wibox.visible = true awful.keygrabber.run(self.keygrabber) redtip:set_pack( "Floating window", self.tip, self.style.keytip.column, self.style.keytip.geometry, function() self:hide() end ) end end -- Hide -------------------------------------------------------------------------------- function control:hide() self.wibox.visible = false awful.keygrabber.stop(self.keygrabber) redtip:remove_pack() self.client = nil end -- Set user hotkeys ----------------------------------------------------------------------------------------------------------------------- function control:set_keys(keys, layout) layout = layout or "all" if keys then self.keys[layout] = keys if layout ~= "all" then self.keys.all = awful.util.table.join(self.keys.control, self.keys.action) end end self.tip = awful.util.table.join(self.keys.all, self._fake_keys) end -- End ----------------------------------------------------------------------------------------------------------------------- return control
-- // Information --[[ "If you don’t know what CIELUV is (you probably don’t and that’s ok), it’s a perceptually uniform and additive color space. In other words, it’s really good at representing color transitions on LCD screens for human eyes." Source: https://devforum.roblox.com/t/cieluv-interpolator/27100 ]] -- // local LerpCIELUV do -- Combines two colors in CIELUV space. -- function<function<Color3 result>(float t)>(Color3 fromColor, Color3 toColor) -- https://www.w3.org/Graphics/Color/srgb local clamp = math.clamp local C3 = Color3.new local black = C3(0, 0, 0) -- Convert from linear RGB to scaled CIELUV local function RgbToLuv13(c) local r, g, b = c.r, c.g, c.b -- Apply inverse gamma correction r = r < 0.0404482362771076 and r/12.92 or 0.87941546140213*(r + 0.055)^2.4 g = g < 0.0404482362771076 and g/12.92 or 0.87941546140213*(g + 0.055)^2.4 b = b < 0.0404482362771076 and b/12.92 or 0.87941546140213*(b + 0.055)^2.4 -- sRGB->XYZ->CIELUV local y = 0.2125862307855956*r + 0.71517030370341085*g + 0.0722004986433362*b local z = 3.6590806972265883*r + 11.4426895800574232*g + 4.1149915024264843*b local l = y > 0.008856451679035631 and 116*y^(1/3) - 16 or 903.296296296296*y if z > 1e-15 then local x = 0.9257063972951867*r - 0.8333736323779866*g - 0.09209820666085898*b return l, l*x/z, l*(9*y/z - 0.46832) else return l, -0.19783*l, -0.46832*l end end function LerpCIELUV(c0, c1) local l0, u0, v0 = RgbToLuv13(c0) local l1, u1, v1 = RgbToLuv13(c1) return function(t) -- Interpolate local l = (1 - t)*l0 + t*l1 if l < 0.0197955 then return black end local u = ((1 - t)*u0 + t*u1)/l + 0.19783 local v = ((1 - t)*v0 + t*v1)/l + 0.46832 -- CIELUV->XYZ local y = (l + 16)/116 y = y > 0.206896551724137931 and y*y*y or 0.12841854934601665*y - 0.01771290335807126 local x = y*u/v local z = y*((3 - 0.75*u)/v - 5) -- XYZ->linear sRGB local r = 7.2914074*x - 1.5372080*y - 0.4986286*z local g = -2.1800940*x + 1.8757561*y + 0.0415175*z local b = 0.1253477*x - 0.2040211*y + 1.0569959*z -- Adjust for the lowest out-of-bounds component if r < 0 and r < g and r < b then r, g, b = 0, g - r, b - r elseif g < 0 and g < b then r, g, b = r - g, 0, b - g elseif b < 0 then r, g, b = r - b, g - b, 0 end return C3( -- Apply gamma correction and clamp the result clamp(r < 3.1306684425e-3 and 12.92*r or 1.055*r^(1/2.4) - 0.055, 0, 1), clamp(g < 3.1306684425e-3 and 12.92*g or 1.055*g^(1/2.4) - 0.055, 0, 1), clamp(b < 3.1306684425e-3 and 12.92*b or 1.055*b^(1/2.4) - 0.055, 0, 1) ) end end end -- // Return return LerpCIELUV
--!strict -- Author(s): bobbybob2131 -- Last edited: 1 April 2022 -- Description: Runtime equivalent of ChangeHistoryService, with some extra features. --[[ constructor chronicler.new(object: any, captureProperties: {string | number}, undoStackSize: number?, redoStackSize: number?): Chronicler Create a new chronicler object, `captureProperties` is an array of properties to capture in waypoints method Chronicler:SetWaypoint() Save the current state of the object as a waypoint method Chronicler:Undo() Undo most recent action method Chronicler:Redo() Redo the last action that was undone method Chronicler:ResetWaypoints() Clears history, removing all undo/redo waypoints method Chronicler:GetCanUndo(): boolean | waypoint Get last undo-able action, if it exists method Chronicler:GetCanRedo(): boolean | waypoint Get last redo-able action, if it exists method Chronicler:SetEnabled(state: boolean?) Set whether or not this chronicler object is enabled method Chronicler:OverrideStacks(undoStack: waypointStack?, redoStack: waypointStack?) Set the stacks, to flip between saved states method Chronicler:Destroy() Permanently delete a chronicler object RBXScriptSignal chroniclerObject.OnUndo Fired when a waypoint is undone RBXScriptSignal chroniclerObject.OnRedo Fired when a waypoint is redone ]] local chronicler = {} local signal = {} local DEBUG: boolean = true local output: (...) -> () if DEBUG then output = function(...) print("[Chronicler]", ...) end else output = function() end end -- Create a new stripped down signal object function signal.new(): Signal local signalObject = { _bindable = Instance.new("BindableEvent") } -- Call the function when the event is raised function signalObject:Connect(func) self._bindable:Connect(func) end -- Yield current thread until the event is raised function signalObject:Wait() self._bindable:Wait() end return signalObject end type waypoint = {[string | number]: any} type waypointStack = {[string]: number | string} type Signal = typeof(signal.new()) -- Create a new chronicler object function chronicler.new(object: any, captureProperties: {string | number}, undoStackSize: number?, redoStackSize: number?): Chronicler local undoEvent: BindableEvent = Instance.new("BindableEvent") local chroniclerObject: Chronicler = { object = object, captureProperties = captureProperties, undoStack = table.create(undoStackSize or 30), redoStack = table.create(redoStackSize or 10), enabled = true, } chroniclerObject.OnUndo = signal.new() chroniclerObject.OnRedo = signal.new() -- Save the current state of the object as a waypoint function chroniclerObject:SetWaypoint() if not self.enabled then return end local data: waypoint = {} for index: number, property: string | number in ipairs(self.captureProperties) do local value: any = self.object[property] if value then data[property] = value end end table.insert(self.undoStack, data) if #self.redoStack > 0 then self.redoStack = {} end while #self.undoStack > 30 do table.remove(self.undoStack, 1) end output("Set Waypoint:", data) end -- Undo most recent action function chroniclerObject:Undo() if #self.undoStack < 1 then return end local waypoint: waypoint = self.undoStack[#self.undoStack - 1] if not waypoint then return end for property: string | number, value: any in pairs(waypoint) do self.object[property] = value end table.insert(self.redoStack, self.undoStack[#self.undoStack]) self.undoStack[#self.undoStack] = nil self.OnUndo._bindable:Fire() output("Undo:", waypoint) end -- Redo the last action that was undone function chroniclerObject:Redo() if #self.redoStack < 0 then return end local waypoint: waypoint = self.redoStack[#self.redoStack] if not waypoint then return end for property: string | number, value: any in pairs(waypoint) do output("redo back to", property, value) self.object[property] = value end table.insert(self.undoStack, waypoint) self.redoStack[#self.redoStack] = nil self.OnRedo._bindable:Fire() output("Redo:", waypoint) end -- Clears history, removing all undo/redo waypoints function chroniclerObject:ResetWaypoints() table.clear(self.undoStack) table.clear(self.redoStack) output("Waypoints reset") end -- Get last undo-able action, if it exists function chroniclerObject:GetCanUndo(): boolean | waypoint local lastPoint: waypoint = self.undoStack[1] if not lastPoint then output("Cannot undo") return false else output("Can undo") return lastPoint end end -- Get last redo-able action, if it exists function chroniclerObject:GetCanRedo(): boolean | waypoint local lastPoint: waypoint = self.undoStack[1] if not lastPoint then output("Cannot redo") return false else output("Can redo") return lastPoint end end -- Set whether or not this chronicler object is enabled function chroniclerObject:SetEnabled(state: boolean?) state = state or not self.enabled self.enabled = state if state == false then self:ResetWaypoints() end output("Enabled state set to:", state) end -- Set the stacks, to flip between saved states function chroniclerObject:OverrideStacks(undoStack: waypointStack?, redoStack: waypointStack?) if undoStack then self.undoStack = undoStack end if redoStack then self.redoStack = redoStack end output("Stacks overriden, undo stack:", undoStack, "\nRedo Stack:", redoStack) end -- Permanently delete a chronicler object function chroniclerObject:Destroy() if self.object.ClassName then -- Object was an Instance of some sort self.object:Destroy() end self.captureProperties = nil self.undoStack = nil self.redoStack = nil self.enabled = nil self.OnRedo._bindable:Destroy() self.OnUndo._bindable:Destroy() output("Destroyed") end return chroniclerObject end export type Chronicler = typeof(chronicler.new({"a"}, {1})) return chronicler
script.on_init(function() for index,force in pairs(game.forces) do if (force.valid) then force.reset_technology_effects() end end end)
local function RandCl() return {math.random(0,20)/20,math.random(0,20)/20,math.random(0,20)/20,1} end local CyclePat = { {RandCl(),RandCl(),RandCl(),RandCl(),RandCl(),RandCl(),RandCl(),RandCl()},--Frame1 {RandCl(),RandCl(),RandCl(),RandCl(),RandCl(),RandCl(),RandCl(),RandCl()},--Frame2 {RandCl(),RandCl(),RandCl(),RandCl(),RandCl(),RandCl(),RandCl(),RandCl()},--Frame3 {RandCl(),RandCl(),RandCl(),RandCl(),RandCl(),RandCl(),RandCl(),RandCl()},--Frame4 } local TexData = { } local Scaling = 2; local width = 100; local height = 100; local t = Def.ActorFrame{ OnCommand=function(self) for i = 1,height do local nowt = {} for j = 1,width do nowt[j] = math.random(1,8) end TexData[i] = nowt end self:playcommand("Loop") end; LoopCommand=function(self) local Canva = self:GetChildren()["Canvas"] verts = {} local Frame = 1 for i = 1,height do for j = 1,width do table.insert( verts,{{(j-1)*Scaling - (width/2)*Scaling, (i-1)*Scaling - (height/2)*Scaling, 0}, CyclePat[Frame][TexData[i][j]]}) table.insert( verts,{{(j)*Scaling - (width/2)*Scaling, (i-1)*Scaling - (height/2)*Scaling, 0}, CyclePat[Frame][TexData[i][j]]}) table.insert( verts,{{(j)*Scaling - (width/2)*Scaling, (i)*Scaling - (height/2)*Scaling, 0}, CyclePat[Frame][TexData[i][j]]}) table.insert( verts,{{(j-1)*Scaling - (width/2)*Scaling, (i)*Scaling - (height/2)*Scaling, 0}, CyclePat[Frame][TexData[i][j]]}) end end Canva:SetNumVertices(#verts):SetVertices( verts ) self:sleep(1/30):queuecommand("Loop") end; Def.ActorMultiVertex{ Name = "Canvas"; InitCommand=function(self) self:SetDrawState{Mode="DrawMode_Quads"} end; OnCommand=function(self) self:Center() end; }; }; return t;
object_tangible_furniture_flooring_wood_frn_flooring_wood_s12 = object_tangible_furniture_flooring_wood_shared_frn_flooring_wood_s12:new { } ObjectTemplates:addTemplate(object_tangible_furniture_flooring_wood_frn_flooring_wood_s12, "object/tangible/furniture/flooring/wood/frn_flooring_wood_s12.iff")
function openVipEditWindow ( acc ) Vip = { } VipDetails = { account = acc } Vip.window = guiCreateWindow((sx/2-250/2), (sy/2-270/2), 250, 270, "VIP Manager", false) guiWindowSetSizable(Vip.window, false ) Vip.account = guiCreateLabel(20, 37, 315, 23, "Conta: "..tostring(acc), false, Vip.window) Vip.misc_1 = guiCreateLabel(19, 102, 75, 22, "Exp. Dia:", false, Vip.window) Vip.misc_2 = guiCreateLabel(19, 134, 82, 22, "Exp. Mes:", false, Vip.window) Vip.misc_3 = guiCreateLabel(19, 166, 82, 22, "Exp. Ano:", false, Vip.window) Vip.misc_4 = guiCreateLabel(19, 198, 82, 22, "Categoria:", false, Vip.window) Vip.cancel = guiCreateButton(19, 230, 82, 33, "Cancelar", false, Vip.window) Vip.update = guiCreateButton(106, 230, 82, 33, "DAR VIP", false, Vip.window) Vip.level = guiCreateButton(111, 201, 120, 25, "Bronze", false, Vip.window) local d = getRealTime ( ) Vip.expMonth = guiCreateEdit(111, 131, 120, 25, d.month + 1, false, Vip.window) Vip.expYear = guiCreateEdit(111, 166, 120, 25, d.year + 1900, false, Vip.window) Vip.expDay = guiCreateEdit(111, 99, 120, 25, d.monthday+1, false, Vip.window) local data = { day = guiGetText(Vip.expDay), month = guiGetText(Vip.expMonth), year = guiGetText(Vip.expYear) } Vip.expLabel = guiCreateLabel(19, 61, 316, 22, "Expira dia: "..table.concat({guiGetText(Vip.expDay),guiGetText(Vip.expMonth),guiGetText(Vip.expYear)},"/").." ("..getDaysToDate(data)..")", false, Vip.window) addEventHandler ( "onClientGUIClick", Vip.update, onClientVipButtonClick ) addEventHandler ( "onClientGUIClick", Vip.cancel, onClientVipButtonClick ) addEventHandler ( "onClientGUIClick", Vip.level, onClientVipButtonClick) addEventHandler ( "onClientGUIChanged", Vip.expMonth, onClientVipEditChanged ) addEventHandler ( "onClientGUIChanged", Vip.expYear, onClientVipEditChanged ) addEventHandler ( "onClientGUIChanged", Vip.expDay, onClientVipEditChanged ) showCursor ( true ) end function destroyVipWindow ( ) removeEventHandler ( "onClientGUIClick", Vip.update, onClientVipButtonClick ) removeEventHandler ( "onClientGUIClick", Vip.cancel, onClientVipButtonClick ) removeEventHandler ( "onClientGUIClick", Vip.level, onClientVipButtonClick) removeEventHandler ( "onClientGUIChanged", Vip.expMonth, onClientVipEditChanged ) removeEventHandler ( "onClientGUIChanged", Vip.expYear, onClientVipEditChanged ) removeEventHandler ( "onClientGUIChanged", Vip.expDay, onClientVipEditChanged ) destroyElement ( Vip.window ) Vip = nil VipDetails = nil showCursor ( false ) end function onClientVipButtonClick ( ) if ( source == Vip.level ) then local t = tostring ( source.text ):lower ( ) if ( t == "bronze" ) then source.text = "Prata" elseif ( t == 'prata' ) then source.text = 'Ouro' elseif ( t == 'ouro' ) then source.text = 'Platina' elseif ( t == 'platina' ) then source.text = 'SemVIP' elseif ( t == 'semvip' ) then source.text = 'Bronze' end elseif ( source == Vip.cancel ) then destroyVipWindow ( ) elseif ( source == Vip.update) then local day = tonumber ( Vip.expDay.text ) local month = tonumber ( Vip.expMonth.text) local year = tonumber ( Vip.expYear.text ) if ( not day or not month or not year ) then return exports.ngmessages:sendClientMessage ( "Data inválida.", 255, 0, 0 ) end triggerServerEvent ( "VDBGAdmin->Modules->aManager->VIPManager->UpdateAccountVIP", localPlayer, VipDetails.account, Vip.level.text, day, month, year ) end end function onClientVipEditChanged ( ) local t = guiGetText ( source ) if ( t == "" ) then return end local t = t:gsub ( "%a", "" ) local t = t:gsub ( "%s", "" ) local t = t:gsub ( "%p", "" ) local f = getRealTime ( ) local t = tonumber ( t ) if ( t < 1 ) then t = 1 end if ( source == Vip.expMonth and t > 12 ) then t = 12 elseif ( source == Vip.expDay and t > 31 ) then t = 31 end guiSetText ( source, tostring ( t ) ) local data = { day = guiGetText(Vip.expDay), month = guiGetText(Vip.expMonth), year = guiGetText(Vip.expYear) } local fDate = table.concat({guiGetText(Vip.expDay),guiGetText(Vip.expMonth),guiGetText(Vip.expYear)},"/") guiSetText ( Vip.expLabel, "Expira dia: "..fDate.." ("..getDaysToDate(data)..")" ) end
form = 'size[10,10;]'.. 'background[-0.15,-0.25;10.40,10.75;mylandscaping_background.png]'.. 'button[0,0;2.5,1;retain;Retaining Walls]'.. 'button[2.5,0;2.5,1;column;Columns]'.. 'button[5,0;2.5,1;patio;Patio Pavers]'.. 'button[7.5,0;2.5,1;deco;Deco Walls]' input = 'label[3,4.5;Input]'.. 'list[context;input;3,5;1,1;]'.. 'label[4,4.5;Dye]'.. 'list[context;dye;4,5;1,1;]'.. --Output 'label[6,4.5;Output]'.. 'list[context;output;6,5;1,1;]'.. --Players Inven 'list[current_player;main;1,6;8,4;]' retaining_walls = form.. 'label[1,2.75;Freeport]'.. 'label[1,3.75;Madison]'.. 'label[1,1.75;Adaridge]'.. --Freeport walls 'item_image_button[3,2.5;1,1;mylandscaping:fwall_left_cement;fwall1; ]'.. 'item_image_button[4,2.5;1,1;mylandscaping:fwall_middle_cement;fwall2; ]'.. 'item_image_button[5,2.5;1,1;mylandscaping:fwall_right_cement;fwall3; ]'.. 'item_image_button[6,2.5;1,1;mylandscaping:fwall_corner_cement;fwall4; ]'.. --Madison walls 'item_image_button[3,3.5;1,1;mylandscaping:mwall_middle_cement;mwall1; ]'.. 'item_image_button[4,3.5;1,1;mylandscaping:mwall_icorner_cement;mwall2; ]'.. 'item_image_button[5,3.5;1,1;mylandscaping:mwall_ocorner_cement;mwall3; ]'.. --Adaridge walls 'item_image_button[3,1.5;1,1;mylandscaping:awall_left_cement;awall1; ]'.. 'item_image_button[4,1.5;1,1;mylandscaping:awall_middle_cement;awall2; ]'.. 'item_image_button[5,1.5;1,1;mylandscaping:awall_right_cement;awall3; ]'.. 'item_image_button[6,1.5;1,1;mylandscaping:awall_icorner_cement;awall4; ]'.. 'item_image_button[7,1.5;1,1;mylandscaping:awall_ocorner_cement;awall5; ]'.. input columns = --Although all the columns are in the wall files they get their own menu. form.. 'label[.75,1;Columns are compatible with all walls.]'.. 'label[.75,2.75;Freeport]'.. -- 'label[.75,3.75;Madison]'.. 'label[.75,1.75;Adaridge]'.. 'item_image_button[2,2.5;1,1;mylandscaping:fwall_column_m_t_cement;fcolumn1; ]'.. 'item_image_button[3,2.5;1,1;mylandscaping:fwall_column_ic_t_cement;fcolumn2; ]'.. 'item_image_button[4,2.5;1,1;mylandscaping:fwall_column_oc_t_cement;fcolumn3; ]'.. 'item_image_button[2,1.5;1,1;mylandscaping:awall_column_m_t_cement;acolumn1; ]'.. 'item_image_button[3,1.5;1,1;mylandscaping:awall_column_ic_t_cement;acolumn2; ]'.. 'item_image_button[4,1.5;1,1;mylandscaping:awall_column_oc_t_cement;acolumn3; ]'.. 'label[6.5,1;Column toppers]'.. 'item_image_button[6,1.5;1,1;mylandscaping:column_t_sphere_cement;column_sphere; ]'.. 'item_image_button[7,1.5;1,1;mylandscaping:column_t_dragon_cement;column_dragon; ]'.. 'item_image_button[8,1.5;1,1;mylandscaping:column_t_suzanne_cement;column_suzanne; ]'.. 'item_image_button[9,1.5;1,1;mylandscaping:column_t_cross_cement;column_cross; ]'.. input patio_pavers = form.. 'label[1,1.5;Place pavers on top of sand]'.. 'label[1,2;to achieve best fit, and to be]'.. 'label[1,2.5;able to place patio decorations.]'.. 'item_image_button[5.5,1.5;1,1;mylandscaping:stone_squarecement;patio1; ]'.. 'item_image_button[6.5,1.5;1,1;mylandscaping:stone_square_smcement;patio2; ]'.. 'item_image_button[7.5,1.5;1,1;mylandscaping:stone_square_xsmcement;patio7; ]'.. 'item_image_button[8.5,1.5;1,1;mylandscaping:stone_paverscement;patio3; ]'.. 'item_image_button[6,2.5;1,1;mylandscaping:stone_ashlarcement;patio4; ]'.. 'item_image_button[7,2.5;1,1;mylandscaping:stone_flagstonecement;patio5; ]'.. 'item_image_button[8,2.5;1,1;mylandscaping:stone_pinwheelcement;patio6; ]'.. input deco_walls = form.. 'image_button[2,1.5;1,1;mylandscaping_deco_scallop.png;deco1;]'.. 'tooltip[deco1;Scalloped decorative wall]'.. 'image_button[3,1.5;1,1;mylandscaping_deco_flat.png;deco2;]'.. 'tooltip[deco2;Flat decorative wall]'.. 'image_button[4,1.5;1,1;mylandscaping_deco_peak.png;deco3;]'.. 'tooltip[deco3;Peaked decorative wall]'.. 'image_button[5,1.5;1,1;mylandscaping_deco_random.png;deco4;]'.. 'tooltip[deco4;Random decorative wall]'.. 'image_button[6,1.5;1,1;mylandscaping_deco_column.png;deco5;]'.. 'tooltip[deco5;Decorative column]'.. input
place = {"inside", "outside"}
-- base mod defines some basic gameplay -- this data type represents a classlike -- interface to the haskell objects window = {} function window:new (o) o = o or {} self.__index = self setmetatable (o, self) self.lwName = "NULL" return o end function window:initMenu (n) self.lwName = n rawNewWindow (n,"menu") end function window:initGame (n) self.lwName = n rawNewWindow (n,"game") end function window:switchWindow () rawSwitchWindow (self.lwName) end function window:newWorld (dp) rawNewWorld ((self.lwName),dp) end function window:newText (x,y,args) rawNewText (self.lwName,x,y,args,false) end function window:newLink (x,y,args,hook) if ((type(hook)) == "string") then ret = hook else ret = hook () end rawNewText (self.lwName,x,y,args,ret,true) rawNewLink (self.lwName,x,y,args,ret) end function window:addPane (pane) rawNewPane (self.lwName,pane.pPosx,pane.pPosy,pane.pName) for i,b in pairs(pane.pBits) do rawNewPaneBit (self.lwName,pane.pName,b) end end return window
local M = {} function M.setup() vim.cmd('syntax on') -- syntax highlighting vim.o.number = true -- line numbers vim.o.relativenumber = true -- relative line number vim.o.hidden = true -- dont close buffer on opening new file vim.o.wrap = false -- no linebreaks for long lines vim.o.encoding = 'utf-8' -- UTF-8 -> the one and only vim.o.cmdheight = 1 -- better cmd height vim.o.smartindent = true -- auto indentations vim.o.smarttab = true -- smart tabs vim.o.expandtab = true -- spaces > tabstops vim.o.tabstop = 2 -- tabstop length vim.o.shiftwidth = 2 -- shift width length vim.o.cursorline = true -- always know where you are vim.o.ruler = true vim.o.splitright = true vim.o.splitbelow = true vim.o.colorcolumn = "80" -- visual indicator for line length vim.o.showtabline = 2 -- always show tabbar vim.o.breakindent = true vim.o.showmode = false -- no need to know what i do vim.o.clipboard = 'unnamedplus' -- best way to clipboard (copy paste working) vim.g.loaded_netrwPlugin = 1 -- no need for netrw vim.o.backup = false -- no backup vim.o.writebackup = false -- no write backup vim.o.termguicolors = true end return M
--[[==================================== = = import = ========================================]] local _searchPaths = {'?'} local _moduleMt = { __index = _G, -- __newindex = function(t, k, v) -- rawset(t, k, v) -- end, } function is_module(m) return type(m) == 'table' and _moduleMt == getmetatable(m) end local _moduleFullPathMap = {} local function _loadModule(fullPath, newModule) if _moduleFullPathMap[fullPath] == false then return end assert(_moduleFullPathMap[fullPath] == nil) local m = setmetatable({}, _moduleMt) -- m._EVN = m if newModule then for k, v in pairs(newModule) do m[k] = v end end newModule = m local func, err = luaext_loadfile(fullPath, newModule) if func then -- print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~do load module', fullPath) newModule.__path__, newModule.__name__ = string.match(fullPath, '(.+/)(.+)') newModule.__full_path__ = fullPath newModule.__module__ = newModule -- 防止循环引用 _moduleFullPathMap[fullPath] = newModule setfenv(func, newModule)() return newModule else _moduleFullPathMap[fullPath] = false if is_valid_str(err) then -- error __G__TRACKBACK__(err) end end end function import_get_moudule_info() return _moduleFullPathMap end local _directImportInfo = {} function direct_import(dotName, evn) -- print('direct_import', dotName) local modulePath = string.gsub(dotName, '%.', '/') local ret = _directImportInfo[modulePath] if ret then return ret end -- 按照搜索路径搜索模块 for _, v in pairs(_searchPaths) do local fullPath = string.gsub(v, "?", modulePath) ret = _moduleFullPathMap[fullPath] if ret then _directImportInfo[modulePath] = ret return ret else ret = _loadModule(fullPath, evn) if ret then _directImportInfo[modulePath] = ret return ret end end end -- error_msg('direct_import load [%s] failed', modulePath) end local _relativeImportInfo = {} function relative_import(dotName, evn, level) -- print('relative_import', dotName, evn) local modulePath = string.gsub(dotName, '%.', '/') local curModule = import_get_self_evn(level or 3) assert(curModule) local info = _relativeImportInfo[curModule] if info == nil then info = {} _relativeImportInfo[curModule] = info end local ret = info[modulePath] if ret then return ret else local fullPath = curModule.__path__ .. modulePath .. '.lua' ret = _moduleFullPathMap[fullPath] if ret then info[modulePath] = ret return ret else ret = _loadModule(fullPath, evn) if ret then info[modulePath] = ret return ret else error_msg('relative_import load [%s] [%s] failed', modulePath, fullPath) end end end end function import(dotName, evn) -- print('import', dotName, evn) -- relative path local modulePath = string.gsub(dotName, '%.', '/') local curModule = import_get_self_evn(3) if curModule then local info = _relativeImportInfo[curModule] if info == nil then info = {} _relativeImportInfo[curModule] = info end local ret = info[modulePath] if ret then return ret else local fullPath = curModule.__path__ .. modulePath .. '.lua' ret = _moduleFullPathMap[fullPath] if ret then info[modulePath] = ret return ret else ret = _loadModule(fullPath, evn) if ret then info[modulePath] = ret return ret end end end end -- abs path local ret = _directImportInfo[modulePath] if ret then return ret end -- 按照搜索路径搜索模块 for _, v in pairs(_searchPaths) do local fullPath = string.gsub(v, "?", modulePath) ret = _moduleFullPathMap[fullPath] if ret then _directImportInfo[modulePath] = ret return ret else ret = _loadModule(fullPath, evn) if ret then _directImportInfo[modulePath] = ret return ret end end end error_msg('import load [%s] failed', modulePath) end function import_reload(m) if is_string(m) then m = import(m) end return import_unload(m) end function import_unload(m) if is_string(m) then m = import(m) end _relativeImportInfo = {} _directImportInfo = {} _moduleFullPathMap[m.__full_path__] = nil end function import_unload_all() _relativeImportInfo = {} _directImportInfo = {} _moduleFullPathMap = {} end -- 默认为调用这个函数是在模块中调用的 function import_get_self_evn(level, levelMax) level = level or 2 local curEvn = getfenv(level) if curEvn.__module__ then return curEvn elseif levelMax then for l = level + 1, levelMax do local evn = getfenv(l) if evn.__module__ then return evn end end end end function import_all_from(dotName, bRelative) local m if bRelative then m = relative_import(dotName, nil, 4) else m = direct_import(dotName) end if m then local curM = import_get_self_evn(3) if curM then for k, v in pairs(m) do rawset(curM, k, v) end return true end end __G__TRACKBACK__('import_all_from [%s] failed', str(dotName)) end -- @desc: -- 增加import路径,优先增加的路径优先检测 function import_add_search_path(path) table.insert(_searchPaths, 1, path) end function import_get_search_paths() return _searchPaths end
-- PtPM serverside login script addEvent("attemptAutoLogin",true) addEventHandler("attemptAutoLogin",root, function() if not exports.ptpm_accounts:autoLoginPlayer(client) then -- triggerClientEvent(client,"showLogin",client) outputChatBox("Couldn't find user account, playing as guest!",client) else outputChatBox("Welcome back, ".. tostring(exports.ptpm_accounts:getPlayerAccountData(client,"username")) .. "! (automatically logged in)",client) end end ) addEvent("attemptLogin",true) addEventHandler("attemptLogin",root, function(username, password) if exports.ptpm_accounts:getPlayerAccountData(client,"username") then return outputChatBox("You are already logged in.",client) end if not exports.ptpm_accounts:loginPlayer(client, username, password) then outputChatBox("Could not log in.",client) else outputChatBox("Welcome, ".. tostring(exports.ptpm_accounts:getPlayerAccountData(client,"username")) .."!",client) end end ) addEvent("attemptRegister",true) addEventHandler("attemptRegister",root, function(username, password) local res = exports.ptpm_accounts:registerPlayer(client, username, password) if res == false then outputChatBox("Could not register.",client) elseif res == nil then outputChatBox("Could not log in.",client) end end ) function checkMySerial( thePlayer, command ) local theSerial = getPlayerSerial( thePlayer ) if theSerial then outputChatBox( "Your serial is: " .. theSerial, thePlayer ) else outputChatBox( "Sorry, you have no serial. =(", thePlayer ) end end addCommandHandler( "serial", checkMySerial )
-- Sky.lua --------------------------------------------------------------------------------------- require "sky/cloud" Sky = {} Sky.__index = Sky setmetatable(Sky, { __call = function (cls, ...) local self = setmetatable({}, cls) self:_init(...) return self end, }) ---------------------------------------------------------------------------------------------------- function Sky:_init(x,y,width,height,cloudimage,maxCloudes) self.clouds = {} for i=0, maxCloudes or 20 do local newX = math.random(0, width-x) + x local newY = math.random(0, height-y) + y self.clouds[i] = Cloud(cloudimage,newX, newY,2) end end function Sky:update(dt) for num, object in pairs(self.clouds) do if object.update then object:update(dt) end end end function Sky:draw() for num, object in pairs(self.clouds) do if object.draw then object:draw() end end end
local Tracer = Material( "trails/laser" ) local Width = 96 function EFFECT:Init( t ) self.LifeTime = 0.25 self.DieTime = CurTime() + self.LifeTime local e = t:GetEntity() if !IsValid(e) then return end local v = e:GetAttachment(1).Pos local vv = t:GetOrigin() self.StartPos = self:GetTracerShootPos( v, e, 1 ) self.EndPos = vv self:SetRenderBoundsWS( self.StartPos, self.EndPos ) self.Dir = ( self.EndPos - self.StartPos ):GetNormalized() self.Dist = self.StartPos:Distance( self.EndPos ) end function EFFECT:Think() -- if true then return end if ( CurTime() > self.DieTime ) then return false end return true end function EFFECT:Render() local v = ( self.DieTime - CurTime() ) / self.LifeTime render.SetMaterial( Tracer ) for i=1, 4 do render.DrawBeam( self.StartPos, self.EndPos, ( Width / i)* v, 0, (self.Dist/10)*math.Rand(-2,2), Color( 225, 100, 100, v * 100 ) ) end end
--- Some shared info for Quirky scene. -- -- 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. -- -- [ MIT license: http://www.opensource.org/licenses/mit-license.php ] -- -- Standard library imports -- local floor = math.floor -- Corona globals -- local system = system -- Exports -- local M = {} -- Map of turnstile entries to fixed pivot coordinate / index info -- local Pivots -- Level dimensions -- local W, H -- Unpack some pivot info for easy lookup function M.AddPivot (tname, index) local x = (index - 1) % W + 1 Pivots[tname] = { x = x, y = (index - x) / W + 1, index = index } end -- List of dynamic colors -- local Colors -- Clear the level's fixed info function M.Clear () Colors, Pivots = {}, {} end -- Various events used by Quirky -- local Events = system.newEventDispatcher() -- Number of items in motion -- local MoveN = 0 -- Event fired when the last moving object settles -- local DoneMovingEvent = { name = "done_moving" } -- Indicate that one object has stopped moving, firing an event on the last one function M.DecMoveCount () if MoveN > 0 then MoveN = MoveN - 1 if MoveN == 0 then Events:dispatchEvent(DoneMovingEvent) end end end -- Get the first display object in a layer whose type matches the given entry function M.FindFirstObject (layer, entry) for i = 1, layer.numChildren do if layer[i].m_type == entry then return layer[i] end end end -- Perform an action on each display object in a layer whose type matches the given entry function M.ForEachObject (layer, entry, func, arg1, arg2) for i = 1, layer.numChildren do local object = layer[i] if object.m_type == entry then func(object, arg1, arg2) end end end -- Get the current level's color with the given name function M.GetColor (name) return Colors[name] end -- Get the current level's dimensions function M.GetDims () return W, H end -- Gets Quirky's event dispatcher function M.GetEvents () return Events end -- Resolve a cell in the level's grid to a flat index function M.GetIndex (col, row) return (row - 1) * W + col end -- Get how many objects are still in motion function M.GetMoveCount () return MoveN end -- Get the pivot info corresponding to a turnstile part function M.GetPivot (tname) local pivot = Pivots[tname] return pivot.x, pivot.y, pivot.index end -- Get the current level's step deltas in the given direction function M.GetStep (dir) if dir == "left" then return -1, 0, -1 elseif dir == "right" then return 1, 0, 1 elseif dir == "up" then return 0, -1, -W elseif dir == "down" then return 0, 1, W end end -- Indicate that one object has begun moving function M.IncMoveCount () MoveN = MoveN + 1 end -- Is a given cell inside the level's grid? function M.OutOfBounds (col, row) return col < 1 or col > W or row < 1 or row > H end -- Assign a name -> color set to the current level function M.SetColors (colors) Colors = colors end -- Set the current level's dimensions function M.SetDims (w, h) W, H = w, h end -- Export module. return M
corruptionEnabled = false; function warlock_skull(curse, element) if azs.targetSkull() then warlockAttack(curse, element) end end function warlock_cross(curse, element) if azs.targetCross() then warlockAttack(curse, element) end end -- ATTACK function warlockAttack(params) curse = params.curse or azs.class.curse element = params.element or azs.class.element if castingOrChanneling() then return end if (UnitMana("player") >= (UnitLevel("player") * 6)) then stop_wand() if isTargetHpUnder(0.7) then if useTrinkets() then return end end if element == "Fire" then CastSpellByName("Immolate") else corruption() warlockCurse(curse) CastSpellByName("Shadow Bolt") end elseif (isPlayerHpOver(0.3)) then CastSpellByName("Life Tap") else use_wand() end end function warlockCurse(curse) if curse == "CoS" then cast_debuff("Spell_Shadow_CurseOfAchimonde", "Curse of Shadow") elseif curse == "CoE" then cast_debuff("Spell_Shadow_ChillTouch", "Curse of the Elements") elseif curse == "CoA" then CastSpellByName("Amplify Curse") cast_debuff("Spell_Shadow_CurseOfSargeras", "Curse of Agony") elseif curse == "CoT" then cast_debuff("Spell_Shadow_CurseOfTounges", "Curse of Tounges") elseif curse == "CoR" then cast_debuff("Spell_Shadow_UnholyStrength", "Curse of Recklessness") elseif curse == "CoW" then CastSpellByName("Amplify Curse") cast_debuff("Spell_Shadow_CurseOfMannoroth", "Curse of Weakness") end end function corruption() if corruptionEnabled then cast_debuff("Spell_Shadow_AbominationExplosion", "Corruption") end end
function love.conf(t) t.window.title = "Love Platform"; t.window.width = 1024 t.window.height = 768 t.version = "11.2"; t.console = true; end
local NodeEntityState = {} NodeEntityState.__index = NodeEntityState local json = require('json') setmetatable(NodeEntityState, { __call = function (cls, ...) local self = setmetatable({}, cls) self:create(...) return self end, }) function NodeEntityState:className() return "NodeEntityState" end function NodeEntityState:class() return self end function NodeEntityState:superClass() return nil end function NodeEntityState:isa(theClass) local b_isa = false local cur_class = theClass:class() while ( nil ~= cur_class ) and ( false == b_isa ) do if cur_class == theClass then b_isa = true else cur_class = cur_class:superClass() end end return b_isa end function NodeEntityState:destroy() NodeEntityState.__gc(self) end local init = { name = "name", entityOwner = nil } function NodeEntityState:create(init) assert(init, "init variable is nil.") assert(init.name, "Init variable is expecting a name") assert(init.entityOwner, "Init variable is expecting a entityOwner") self._init = init self:load() end function NodeEntityState:__gc() self:unLoad() end function NodeEntityState:__tostring() return json:stringify(self) end function NodeEntityState:getNodeState() return self._nodeState end function NodeEntityState:getEntityOwner() return self._entityOwner end function NodeEntity:isLoaded() if self.loaded then return self.loaded end return false end function NodeEntityState:load() self:unLoad() self._entityOwner = self._init.entityOwner self._nodeState = njli.NodeState.create() self:getNodeState():setName(self._init.name) self.loaded = true end function NodeEntityState:unLoad() if self:getNodeState() then njli.NodeState.destroy(self:getNodeState()) end self._nodeState = nil self._entityOwner = nil self.loaded = false end function NodeEntityState:pushState(stateName) self:getEntityOwner():pushState(stateName) end function NodeEntityState:push() self:getEntityOwner():getNode():getStateMachine():pushState(self:getNodeState()) end function NodeEntityState:isIn() return self:getNodeState():getName() == self:getEntityOwner():getNode():getStateMachine():getState():getName() end function NodeEntityState:enter() print("NodeEntityState:enter") end function NodeEntityState:update(timeStep) print("NodeEntityState:update") end function NodeEntityState:exit() print("NodeEntityState:exit") end function NodeEntityState:onMessage(message) print("NodeEntityState:onMessage") end function NodeEntityState:touchDown(touches) print("NodeEntityState:touchDown") end function NodeEntityState:touchUp(touches) print("NodeEntityState:touchUp") end function NodeEntityState:touchMove(touches) print("NodeEntityState:touchMove") end function NodeEntityState:touchCancelled(touches) print("NodeEntityState:touchCancelled") end function NodeEntityState:render() print("NodeEntityState:render") end function NodeEntityState:actionUpdate(action, timeStep) print("NodeEntityState:actionUpdate") end function NodeEntityState:actionComplete(action) print("NodeEntityState:actionComplete") end function NodeEntityState:collide(otherNode, collisionPoint) print("NodeEntityState:collide") end function NodeEntityState:near(otherNode) print("NodeEntityState:near") end function NodeEntityState:rayTouchDown(rayContact) print("NodeEntityState:rayTouchDown") end function NodeEntityState:rayTouchUp(rayContact) print("NodeEntityState:rayTouchUp") end function NodeEntityState:rayTouchMove(rayContact) print("NodeEntityState:rayTouchMove") end function NodeEntityState:rayTouchCancelled(rayContact) print("NodeEntityState:rayTouchCancelled") end function NodeEntityState:pause() print("NodeEntityState:pause") end function NodeEntityState:unPause() print("NodeEntityState:unPause") end return NodeEntityState
-- Create luatools package local luatools = {} -- Go extension luatools.lua_extension = ".lua" -- Check to see if file is a go source code function luatools.is_source(file_path) -- Get the extension local extension = string.sub(file_path, #file_path-(#luatools.lua_extension -1), #file_path) -- Check to see if the extension matches if extension == luatools.lua_extension then return true end return false end -- Check to see if test is there function luatools.is_test_source(file_path) if luatools.is_source(file_path) then local test_extension = "_test.lua" local extension = string.sub(file_path, #file_path-(#test_extension -1), #file_path) if test_extension == extension then return true end end return false end -- Run test for a directory function luatools.run_test(file) --log("Running lua test file" .. file) return run_test_with_env(file) end -- Need this to build a package return luatools
local CorePackages = game:GetService("CorePackages") local CoreGui = game:GetService("CoreGui") local Players = game:GetService("Players") local GuiService = game:GetService("GuiService") local Roact = require(CorePackages.Roact) local RoactRodux = require(CorePackages.RoactRodux) local t = require(CorePackages.Packages.t) local Otter = require(CorePackages.Packages.Otter) local UIBlox = require(CorePackages.UIBlox) local Components = script.Parent.Parent local Connection = Components.Connection local LayoutValues = require(Connection.LayoutValues) local WithLayoutValues = LayoutValues.WithLayoutValues local DropDownButton = require(script.Parent.DropDownButton) local DropDownPlayerHeader = require(script.Parent.DropDownPlayerHeader) local FriendDropDownButton = require(script.Parent.FriendDropDownButton) local LocalPlayer = Players.LocalPlayer local FFlagDisableFollowInGameMenu = game:DefineFastFlag("DisableFollowInGameMenu", false) local RobloxGui = CoreGui:WaitForChild("RobloxGui") local RobloxTranslator = require(RobloxGui.Modules.RobloxTranslator) local FFlagShowInGameBlockingLuobu = require(RobloxGui.Modules.Flags.FFlagShowInGameBlockingLuobu) local FFlagShowInGameReportingLuobu = require(RobloxGui.Modules.Flags.FFlagShowInGameReportingLuobu) local FFlagInspectMenuSubjectToPolicy = require(RobloxGui.Modules.Flags.FFlagInspectMenuSubjectToPolicy) local Images = UIBlox.App.ImageSet.Images local isNewInGameMenuEnabled = require(RobloxGui.Modules.isNewInGameMenuEnabled) local PlayerList = Components.Parent local ClosePlayerDropDown = require(PlayerList.Actions.ClosePlayerDropDown) local FollowPlayer = require(PlayerList.Thunks.FollowPlayer) local UnfollowPlayer = require(PlayerList.Thunks.UnfollowPlayer) local BlockPlayer = require(PlayerList.Thunks.BlockPlayer) local UnblockPlayer = require(PlayerList.Thunks.UnblockPlayer) local RequestFriendship = require(PlayerList.Thunks.RequestFriendship) local PlayerDropDown = Roact.PureComponent:extend("PlayerDropDown") PlayerDropDown.validateProps = t.strictInterface({ positionY = t.number, minPositionBoundY = t.number, maxPositionBoundY = t.number, contentsVisible = t.boolean, selectedPlayer = t.optional(t.instanceIsA("Player")), isVisible = t.boolean, playerRelationship = t.optional(t.strictInterface({ isBlocked = t.boolean, friendStatus = t.enum(Enum.FriendStatus), isFollowing = t.boolean, isFollower = t.boolean, })), inspectMenuEnabled = t.boolean, isTenFootInterface = t.boolean, subjectToChinaPolicies = t.boolean, closeDropDown = t.callback, blockPlayer = t.callback, unblockPlayer = t.callback, unfollowPlayer = t.callback, followPlayer = t.callback, requestFriendship = t.callback, }) function PlayerDropDown:init() self.innerFrameRef = Roact.createRef() self.motorOptions = { dampingRatio = 1, frequency = 4, } --TODO: Change this to use bindings when roact 1.0 drops self.motor = Otter.createSingleMotor(1) self.motor:onStep(function(value) local innerFrame = self.innerFrameRef.current if innerFrame then if value == 1 then innerFrame.Visible = false else innerFrame.Visible = true end innerFrame.Position = UDim2.new(value, 0, 0, 0) end end) self.dropDownPosition = 0 end function PlayerDropDown:createFriendButton(playerRelationship) local selectedPlayer = self.props.selectedPlayer return Roact.createElement(FriendDropDownButton, { layoutOrder = 1, playerRelationship = playerRelationship, selectedPlayer = selectedPlayer, dropDownOpen = self.props.isVisible, requestFriendship = self.props.requestFriendship, }) end function PlayerDropDown:createFollowButton(playerRelationship) local selectedPlayer = self.props.selectedPlayer local unfollowText = RobloxTranslator:FormatByKey("PlayerDropDown.UnFollow") local followText = RobloxTranslator:FormatByKey("PlayerDropDown.Follow") local followerIcon = playerRelationship.isFollowing and Images["icons/common/notificationOn"] or Images["icons/common/notificationOff"] return Roact.createElement(DropDownButton, { layoutOrder = 2, text = playerRelationship.isFollowing and unfollowText or followText, icon = followerIcon, lastButton = false, forceShowOptions = false, onActivated = function() if playerRelationship.isFollowing then self.props.unfollowPlayer(selectedPlayer) else self.props.followPlayer(selectedPlayer) end end, }) end function PlayerDropDown:createBlockButton(playerRelationship) local selectedPlayer = self.props.selectedPlayer local blockedText = RobloxTranslator:FormatByKey("PlayerDropDown.Block") local unblockText = RobloxTranslator:FormatByKey("PlayerDropDown.UnBlock") local blockIcon = Images["icons/actions/block"] return Roact.createElement(DropDownButton, { layoutOrder = 4, text = playerRelationship.isBlocked and unblockText or blockedText, icon = blockIcon, lastButton = false, forceShowOptions = false, onActivated = function() if playerRelationship.isBlocked then self.props.unblockPlayer(selectedPlayer) else self.props.blockPlayer(selectedPlayer) end end, }) end function PlayerDropDown:createReportButton() local selectedPlayer = self.props.selectedPlayer local reportIcon = Images["icons/actions/feedback"] return Roact.createElement(DropDownButton, { layoutOrder = 5, text = RobloxTranslator:FormatByKey("PlayerDropDown.Report"), icon = reportIcon, lastButton = true, forceShowOptions = false, onActivated = function() if isNewInGameMenuEnabled() then -- todo: move InGameMenu to a script global when removing isNewInGameMenuEnabled local InGameMenu = require(RobloxGui.Modules.InGameMenu) InGameMenu.openReportDialog(selectedPlayer) else -- This module has to be required here or it yields on initalization which breaks the unit tests. -- TODO: Revist this with new in game menu. local ReportAbuseMenu = require(RobloxGui.Modules.Settings.Pages.ReportAbuseMenu) ReportAbuseMenu:ReportPlayer(selectedPlayer) self.props.closeDropDown() end end, }) end function PlayerDropDown:createInspectButton() local selectedPlayer = self.props.selectedPlayer local inspectIcon = Images["icons/actions/zoomIn"] return Roact.createElement(DropDownButton, { layoutOrder = 3, text = RobloxTranslator:FormatByKey("PlayerDropDown.Examine"), icon = inspectIcon, lastButton = selectedPlayer == LocalPlayer, forceShowOptions = false, onActivated = function() GuiService:InspectPlayerFromUserIdWithCtx(selectedPlayer.UserId, "leaderBoard") self.props.closeDropDown() end, }) end function PlayerDropDown:render() return WithLayoutValues(function(layoutValues) local selectedPlayer = self.props.selectedPlayer if not selectedPlayer or self.props.isTenFootInterface then return nil end local dropDownButtons = {} dropDownButtons["UIListLayout"] = Roact.createElement("UIListLayout", { Padding = UDim.new(0, layoutValues.DropDownButtonPadding), SortOrder = Enum.SortOrder.LayoutOrder, }) dropDownButtons["PlayerHeader"] = Roact.createElement(DropDownPlayerHeader, { player = self.props.selectedPlayer, }) local dropDownHeaderHeight = layoutValues.DropDownButtonPadding + layoutValues.DropDownHeaderSizeY local dropDownHeight = dropDownHeaderHeight local playerRelationship = self.props.playerRelationship if selectedPlayer ~= LocalPlayer then if not playerRelationship.isBlocked then dropDownButtons["FriendButton"] = self:createFriendButton(playerRelationship) dropDownHeight = dropDownHeight + layoutValues.DropDownButtonPadding + layoutValues.DropDownButtonSizeY if not FFlagDisableFollowInGameMenu then dropDownButtons["FollowerButton"] = self:createFollowButton(playerRelationship) dropDownHeight = dropDownHeight + layoutValues.DropDownButtonPadding + layoutValues.DropDownButtonSizeY end end local showPlayerBlocking = not self.props.subjectToChinaPolicies or FFlagShowInGameBlockingLuobu local showPlayerReporting = not self.props.subjectToChinaPolicies or FFlagShowInGameReportingLuobu if showPlayerBlocking then dropDownButtons["BlockButton"] = self:createBlockButton(playerRelationship) dropDownHeight = dropDownHeight + layoutValues.DropDownButtonPadding + layoutValues.DropDownButtonSizeY end if showPlayerReporting then dropDownButtons["ReportButton"] = self:createReportButton() dropDownHeight = dropDownHeight + layoutValues.DropDownButtonPadding + layoutValues.DropDownButtonSizeY end end local disableInspectPolicy = FFlagInspectMenuSubjectToPolicy and self.props.subjectToChinaPolicies if self.props.inspectMenuEnabled and not disableInspectPolicy then dropDownButtons["InspectButton"] = self:createInspectButton() dropDownHeight = dropDownHeight + layoutValues.DropDownButtonPadding + layoutValues.DropDownButtonSizeY end dropDownHeight = dropDownHeight - layoutValues.DropDownButtonPadding local dropDownPosition = self.dropDownPosition dropDownPosition = dropDownPosition + (layoutValues.DropDownHeaderBackgroundSize - layoutValues.DropDownHeaderSizeY) if dropDownPosition + dropDownHeight > self.props.maxPositionBoundY then dropDownPosition = dropDownPosition - (dropDownPosition + dropDownHeight - self.props.maxPositionBoundY) elseif dropDownPosition < self.props.minPositionBoundY then dropDownPosition = dropDownPosition + (self.props.minPositionBoundY - dropDownPosition) end return Roact.createElement("Frame", { LayoutOrder = self.props.layoutOrder, AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(0, 0, 0, dropDownPosition), Size = UDim2.new(0, layoutValues.PlayerDropDownSizeX + layoutValues.PlayerDropDownOffset, 0, dropDownHeight), BackgroundTransparency = 1, ClipsDescendants = true, }, { InnerFrame = Roact.createElement("Frame", { Size = UDim2.new(1, -layoutValues.PlayerDropDownOffset, 1, 0), BackgroundTransparency = 1, ClipsDescendants = true, [Roact.Ref] = self.innerFrameRef, }, dropDownButtons) }) end) end function PlayerDropDown:getDropDownPosition() if self.props.isVisible and self.props.contentsVisible then return 0 end return 1 end function PlayerDropDown:didMount() local targetPosition = self:getDropDownPosition() self.motor:start() self.motor:setGoal(Otter.spring(targetPosition, self.motorOptions)) end function PlayerDropDown:willUpdate(nextProps, nextState) if nextProps.selectedPlayer ~= self.props.selectedPlayer then self.dropDownPosition = nextProps.positionY end end function PlayerDropDown:didUpdate(previousProps, previousState) if previousProps.selectedPlayer ~= self.props.selectedPlayer then self.motor:setGoal(Otter.instant(1)) self.motor:step(0) end local targetPosition = self:getDropDownPosition() self.motor:setGoal(Otter.spring(targetPosition, self.motorOptions)) end function PlayerDropDown:willUnmount() self.motor:destroy() end local function mapStateToProps(state) local selectedPlayer = state.playerDropDown.selectedPlayer return { selectedPlayer = selectedPlayer, isVisible = state.playerDropDown.isVisible, playerRelationship = selectedPlayer and state.playerRelationship[selectedPlayer.UserId], inspectMenuEnabled = state.displayOptions.inspectMenuEnabled, isTenFootInterface = state.displayOptions.isTenFootInterface, subjectToChinaPolicies = state.displayOptions.subjectToChinaPolicies, } end local function mapDispatchToProps(dispatch) return { closeDropDown = function() return dispatch(ClosePlayerDropDown()) end, blockPlayer = function(player) return dispatch(BlockPlayer(player)) end, unblockPlayer = function(player) return dispatch(UnblockPlayer(player)) end, unfollowPlayer = function(player) return dispatch(UnfollowPlayer(player)) end, followPlayer = function(player) return dispatch(FollowPlayer(player)) end, requestFriendship = function(player, isAccept) return dispatch(RequestFriendship(player)) end, } end return RoactRodux.UNSTABLE_connect2(mapStateToProps, mapDispatchToProps)(PlayerDropDown)
local metadata = { plugin = { format = 'jar', manifest = { permissions = {}, usesPermissions = { -- Permissions needed for Snapshot API and Fence API (from Awareness Library) "com.google.android.gms.permission.ACTIVITY_RECOGNITION", "android.permission.ACCESS_FINE_LOCATION", }, usesFeatures = {}, applicationChildElements = { -- Meta-data for base logic layer [[ <meta-data android:name="usesGooglePlayServicesComponentLocation" android:value="true" /> ]], }, } }, coronaManifest = { dependencies = { ["shared.google.play.services.location"] = "com.coronalabs", }, }, } return metadata
--[[ This is the main file required by love2d to run, it contains love specific functions referencing the rest of the program. Written by: Andrew Eric Zane License: MIT license, see LICENSE file in this repo. --]] indFuncs = require "IndFuncs" matrix = require "matrix" complex = require "complex" net = require "NeuralNet" Jason = require "Jason" Soylent = require "Food" function love.load() --This happens on window init love.window.setMode(5000, 700) doDraw = true --this determines if things are actually drawn on the screen. jasonTable = {} for i=1, 300 do --print("Creating a jason!") jasonTable[i] = Jason:new({x=love.math.random(love.graphics.getWidth()-Jason.rightImage:getWidth()*Jason.imgSpec), y=love.math.random(love.graphics.getHeight()-Jason.rightImage:getWidth()*Jason.imgSpec)}) jasonTable[i].brain:rand_weights() jasonTable[i].brain:rand_biases() end --jasonTable[1].brain:print_net() foodsTable = {} for i=1, 600 do table.insert(foodsTable, Soylent:new({x=love.math.random(love.graphics.getWidth()-Soylent.vegemite:getWidth()*Soylent.imgSpec), y=love.math.random(love.graphics.getHeight()-Soylent.vegemite:getWidth()*Soylent.imgSpec)})) end foodRepRate = .4 foodTimer = 0 speed = 30 foodSpeed = .01 end function love.keypressed(key) if key == "return" then doDraw = (not doDraw) end if key == "up" then speed = speed + 1 print("Env Speed" .. tostring(speed)) elseif key == "down" then speed = speed - 1 print("Env Speed" .. tostring(speed)) end if key == "right" then foodSpeed = foodSpeed + .01 print("Food Speed" .. tostring(foodSpeed)) elseif key == "left" then foodSpeed = foodSpeed - .01 print("Food Speed" .. tostring(foodSpeed)) end end function love.update(dt) --This happens every frame foodTimer = foodTimer + (dt*speed) --print(foodTimer) if foodTimer > foodRepRate then table.insert(foodsTable, Soylent:new({x=love.math.random(love.graphics.getWidth()-Soylent.vegemite:getWidth()*Soylent.imgSpec), y=love.math.random(love.graphics.getHeight()-Soylent.vegemite:getWidth()*Soylent.imgSpec)})) foodTimer = 0 end for i=1, #foodsTable do foodsTable[i]:loiter((foodSpeed*speed)) end local babies = {} local deadJasonIndices = {} for i=1, #jasonTable do indFuncs.extend_table(babies, unpack(jasonTable[i]:update(foodsTable, speed))) --check if jason starved if jasonTable[i].belly <= 0 then indFuncs.extend_table(deadJasonIndices, i) end end for i=1, #deadJasonIndices do table.remove(jasonTable, deadJasonIndices[i]) end indFuncs.extend_table(jasonTable, unpack(babies)) end function love.draw() if not doDraw then return end --draw all the foods for i=1, #foodsTable do foodsTable[i]:draw() end --draw all the jasons for i=1, #jasonTable do jasonTable[i]:draw() end end
----------------------------------- -- Area: Bhaflau Remnants -- Mob: Long-Bowed Chariot ----------------------------------- require("scripts/globals/titles") ----------------------------------- function onMobDeath(mob, player, isKiller) player:addTitle(tpz.title.COMET_CHARIOTEER) end
object_building_kashyyyk_decd_wroshyr_tree_small05 = object_building_kashyyyk_shared_decd_wroshyr_tree_small05:new { } ObjectTemplates:addTemplate(object_building_kashyyyk_decd_wroshyr_tree_small05, "object/building/kashyyyk/decd_wroshyr_tree_small05.iff")
local MP = minetest.get_modpath(minetest.get_current_modname()) -- Load support for intllib. -- TODO: only use builtin transitor? local S = minetest.get_translator and minetest.get_translator("mobs_npc") or dofile(minetest.get_modpath("intllib").."/init.lua") mobs.intllib = S -- Helper functions dofile(MP.."/functions.lua") -- NPCs dofile(MP.."/npc.lua") -- NPC by TenPlus1 dofile(MP.."/igor.lua") -- Igor by TenPlus1 dofile(MP.."/trader.lua") -- Trader by TenPlus1, reworked by OgelGames dofile(MP .. "/farmer.lua") -- Farmer by OgelGames -- Trader items dofile(MP.."/trader_items.lua") -- Support for Lucky Blocks if minetest.get_modpath("lucky_block") then lucky_block:add_blocks({ {"spw", "mobs:npc", 1, true, true}, {"spw", "mobs:igor", 1, true, true, 5, "Igor"}, {"spw", "mobs:trader", 1, false, false}, {"lig", "fire:permanent_flame"}, }) end print("[MOD] Mobs Redo NPCs loaded")
local chat = require('chat') local command = require('command') local event = require('event') local math = require('math') local shared = require('shared') local server = require('shared.server') local string = require('string') local struct = require('struct') local table = require('table') query_server = shared.new('query') local query_result = {} query_server.env = {} query_server.env.query_response = function(path, setting) query_result.path = path query_result.setting = setting end local data = server.new(struct.struct({ get = {data = event.new()}, set = {data = event.new()}, })) local math_max = math.max local string_rep = string.rep local table_sort = table.sort local flatten flatten = function(t, prefix) local values = {} local count = 0 for key, value in pairs(t) do if type(value) == 'table' then local flattened = flatten(value, prefix .. '.' .. key) for i = 1, #flattened do local flattened_value = flattened[i] count = count + 1 values[count] = {path = flattened_value.path, setting = flattened_value.setting} end else count = count + 1 values[count] = {path = prefix .. '.' .. key, setting = value} end end return values end local print_setting = function(source, path, setting) local values = type(setting) == 'table' and flatten(setting, path) or {{path = path, setting = setting}} table_sort(values, function(v1, v2) return v1.path < v2.path end) if source == 'console' then local max_length = 0 for i = 1, #values do max_length = math_max(max_length, #values[i].path) end print('Settings:') for i = 1, #values do local value = values[i] print(' ' .. value.path .. string_rep(' ', max_length - #value.path + 2) .. tostring(value.setting)) end else chat.add_text('Settings:') for i = 1, #values do local value = values[i] chat.add_text('> ' .. value.path .. ': ' .. tostring(value.setting)) end end end local settings_command = command.new('settings') local get = function(source, addon, path, id) data.get:trigger(addon, path, id) print_setting(source, query_result.path, query_result.setting) end local set = function(source, addon, path, value, id) data.set:trigger(addon, path, value, id) print_setting(source, query_result.path, query_result.setting) end settings_command:register_source('get', get, '<addon:string> <path:string> [id:string]') settings_command:register_source('set', set, '<addon:string> <path:string> <value:string> [id:string]')
AddCSLuaFile() local DbgPrint = GetLogging("MapScript") local MAPSCRIPT = {} MAPSCRIPT.PlayersLocked = false MAPSCRIPT.DefaultLoadout = { Weapons = { }, Ammo = { }, Armor = 0, HEV = false, } MAPSCRIPT.InputFilters = { } MAPSCRIPT.EntityFilterByClass = { --["env_global"] = true, } MAPSCRIPT.EntityFilterByName = { ["changetoc1a0mm"] = true, } function MAPSCRIPT:Init() end function MAPSCRIPT:PostInit() if SERVER then -- Block. local blockade = ents.Create("func_brush") blockade:SetPos(Vector(-2120, -594.165466, -200)) blockade:SetModel("*15") blockade:SetKeyValue("spawnflags", "2") blockade:SetKeyValue("Solidity", "0") blockade:SetKeyValue("solidbsp", "0") blockade:SetKeyValue("StartDisabled", "1") blockade:Spawn() blockade:SetName("lambda_pclip1") local doorTrigger = ents.Create("trigger_once") doorTrigger:Fire("AddOutput", "OnTrigger lambda_pclip1,Enable,,0,-1") doorTrigger:Fire("AddOutput", "OnTrigger doors,Toggle,,0,-1") doorTrigger:SetKeyValue("teamwait", "1") doorTrigger:SetupTrigger( Vector(-2405.352295, -588.131409, -252.968750), Angle(0,0,0), Vector(-180, -80, 0), Vector(200, 80, 120) ) -- Lazy valve, make sure he exists. local barney = ents.FindFirstByName("barney1") if not IsValid(barney) then barney = ents.Create("monster_barney") barney:SetName("barney1") barney:SetPos(Vector(-2008.000000, -472.000000, -252.968750)) barney:SetAngles(Angle(0, 320, 0)) barney:SetModel("models/hl1bar.mdl") barney:Spawn() end end end function MAPSCRIPT:PostPlayerSpawn(ply) --DbgPrint("PostPlayerSpawn") end return MAPSCRIPT
require 'os' require 'nn' --require 'cunn' --require 'cunnx' require 'optim' --require 'cudnn' require 'rnn' require 'csvigo' dl = require 'dataload' dofile("Code/Utils/load_cnn.lua") dofile("Code/utilsNNbatch.lua") Tensor = torch.Tensor LongTensor = torch.LongTensor ByteTensor = torch.ByteTensor torch.setnumthreads(torch.getnumthreads()) outputpath = '/home/francisco/GitHub/DQN-Event-Summarization/data/training_ss/' datafile = "cnn_data_ss.dat" data = torch.load(outputpath .. datafile) print("...data loaded") queries = data[1] trueSummaries = data[2] sentences= data[3] n = 1000 queries = queries[{{1, n}}] trueSummaries = trueSummaries[{{1, n}}] tmp = {} for j=1,#sentences do tmp[j] = sentences[j][{{1, n}}] end sentences = tmp print(string.format("# of sentences = %i", #sentences)) cmd = torch.CmdLine() cmd:option('--vocab_size', 20001, 'Number of samples to iterate over') cmd:option('--lr', 1e-5, 'Learning rate') cmd:option('--embDim', 50, 'Number of samples to iterate over') cmd:option('--gamma', 0., 'Weight of future prediction') cmd:option('--batch_size', 25, 'Batch size') cmd:option('--memory_multiplier', 0.05, 'Multiplier defining size of memory') cmd:option('--cuts', 4, 'How long we want to decay search over') cmd:option('--endexplorerate', 0.8, 'When to end the exploration as a percent of trainings epochs)') cmd:option('--base_explore_rate', 0.1, 'Base exploration rate after 1/cuts until endexplorerate') cmd:option('--nepochs', 100, 'Number of epochs') cmd:option('--epsilon', 1, 'Random sampling rate') cmd:option('--print', false, 'print performance') cmd:option('--adapt', false, 'Use adaptive regularization') cmd:option('--adapt_lambda', 0.25, 'Amount of adaptive regularization') cmd:option('--usecuda', false, 'cuda option') cmd:option('--seedval', 420, 'seedvalue') cmd:text() local opt = cmd:parse(arg or {}) --- stores the commands in opt.variable (e.g., opt.model) -- Running the script train( queries, sentences, trueSummaries, opt.lr, opt.vocab_size, opt.embDim, opt.gamma, opt.batch_size, opt.nepochs, opt.epsilon, opt.print, opt.memory_multiplier, opt.cuts, opt.base_explore_rate, opt.endexplorerate, opt.adapt, opt.adapt_lambda, opt.usecuda, opt.seedval )
-- -- Created by IntelliJ IDEA. -- User: Noneatme -- Date: 21.12.2014 -- Time: 21:49 -- Made for MTA: iLife -- cWaffentruckTruck = {}; WaffenTrucks = {}; --[[ Kiste: 944 Zaun: 983 1344 ]] -- /////////////////////////////// -- ///// New ////// -- ///// Returns: Object ////// -- /////////////////////////////// function cWaffentruckTruck:new(...) local obj = setmetatable({}, {__index = self}); if obj.constructor then obj:constructor(...); end return obj; end -- /////////////////////////////// -- ///// ApplyObjects ////// -- ///// Returns: void ////// -- /////////////////////////////// function cWaffentruckTruck:applyObjects() if(type(self.m_uKisten) ~= "table") then -- FENCES -- self.m_uFences = {}; self.m_uKisten = {}; self.m_uSigns = {}; self.m_uFences[1] = enew(createObject(self.m_iFenceID, unpack(self.m_tblPosition)), CObject); self.m_uFences[2] = enew(createObject(self.m_iFenceID, unpack(self.m_tblPosition)), CObject); -- ATTACH FENCES -- self.m_uFences[1]:attach(self.m_uVehicle, 1.45, -0.85, 0.42); self.m_uFences[2]:attach(self.m_uVehicle, -1.45, -0.85, 0.42); -- ATTACH SIGNS -- self.m_uSigns[1] = enew(createObject(self.m_iSignID, unpack(self.m_tblPosition)), CObject); self.m_uSigns[2] = enew(createObject(self.m_iSignID, unpack(self.m_tblPosition)), CObject); for _, sign in pairs(self.m_uSigns) do sign:setScale(self.m_iSignScale); sign:setCollisionsEnabled(false); sign:setData("wt:frame", true); end self.m_uSigns[1]:attach(self.m_uFences[1], 0, 0, 0, 0, 0, 90); self.m_uSigns[2]:attach(self.m_uFences[2], 0, 0, 0, 0, 0, -90); -- CRATES -- local kisten = 1; local z = 0; local increment = 1; -- UNTERE SEITE -- for i = 0, math.floor(self.m_iMAX_KISTEN/2), 1 do if(kisten < self.m_iMAX_KISTEN) then if(i ~= 0) and ((((i)*2) % 10) == 0) then z = z+(1.4*2) increment = 1; end self.m_uKisten[kisten] = enew(createObject(self.m_iKistID, unpack(self.m_tblPosition)), CObject); self.m_uKisten[kisten]:attach(self.m_uVehicle, -0.02, 3-(increment*1.5), z+0.6); self.m_uKisten[kisten+1] = enew(createObject(self.m_iKistID, unpack(self.m_tblPosition)), CObject); self.m_uKisten[kisten+1]:attach(self.m_uVehicle, -0.02, 3-(increment*1.5), z+2); setElementData(self.m_uKisten[kisten], "wt:kiste", true); setElementData(self.m_uKisten[kisten+1], "wt:kiste", true); setElementData(self.m_uKisten[kisten], "wt:warenwert", self.m_iWarenWert); setElementData(self.m_uKisten[kisten+1], "wt:warenwert", self.m_iWarenWert); setElementData(self.m_uKisten[kisten], "wt:waffentruck", self.m_uVehicle); setElementData(self.m_uKisten[kisten+1], "wt:waffentruck", self.m_uVehicle); increment = increment+1; kisten = kisten+2; end end -- OBERE SEITE -- --[[ for i = 1, 5, 1 do if(kisten < self.m_iMAX_KISTEN) then self.m_uKisten[5+i] = createObject(self.m_iKistID, unpack(self.m_tblPosition)); self.m_uKisten[5+i]:attach(self.m_uVehicle, -0.02, 3-(i*1.5), 2); kisten = kisten+1; end end]] -- Ungerade Zahl? if(self.m_iMAX_KISTEN % 2 ~= 0) then if(kisten % 10 == 1) and (kisten > 10) then z = z+(1.4*2) increment = 1; end self.m_uKisten[kisten] = enew(createObject(self.m_iKistID, unpack(self.m_tblPosition)), CObject); self.m_uKisten[kisten]:attach(self.m_uVehicle, -0.02, 3-(increment*1.5), z+0.6); end for _, kiste in pairs(self.m_uKisten) do kiste:setDoubleSided(true); end end end -- /////////////////////////////// -- ///// createDummyBomb ////// -- ///// Returns: void ////// -- /////////////////////////////// function cWaffentruckTruck:createDummyBomb(i) local vX, vY, vZ = self.m_uVehicle:getVelocity(); local pos = self.m_uKisten[i]:getPosition(true); local rot = self.m_uKisten[i]:getRotation(true); self.m_uDummyObjects[i] = enew(createObject(1344, pos:getX(), pos:getY(), pos:getZ(), rot:getX(), rot:getY(), rot:getZ()), CObject); local dummy_object = self.m_uDummyObjects[i]; dummy_object:setScale(0); dummy_object:setFrozen(false); dummy_object:setData("wt:muelltonne", true); dummy_object:setData("wt:uVehicle", self.m_uVehicle); dummy_object:setData("wt:i", i); local right_object = enew(createObject(self.m_iKistID, pos:getX(), pos:getY(), pos:getZ()), CObject); right_object:setDoubleSided(true); right_object:attach(dummy_object); right_object:setCollisionsEnabled(false); --[[ local vehicle = createVehicle(594, pos:getX(), pos:getY(), pos:getZ()+1, rot:getX(), rot:getY(), rot:getZ()) vehicle:setAlpha(0); vehicle:setVelocity(vX, vY, vZ-0.5) vehicle:setHandling("mass", 10000) setTimer(destroyElement, 100, 1, vehicle); ]] dummy_object:setVelocity(vX, vY, vZ) -- COLSHAPE -- triggerClientEvent(getRootElement(), "onClientWaffentruckKisteDrop", dummy_object, self.m_uVehicle, i); --[[ self.m_uColShapes[i] = createColSphere(pos:getX(), pos:getY(), pos:getZ(), 5); self.m_uColShapes[i]:setData("wt:i", i); self.m_uColShapes[i]:attach(dummy_object); addEventHandler("onColShapeHit", self.m_uColShapes[i], self.m_funcKistenPickup); ]] addEventHandler("onWaffentruckKistePickup", dummy_object, self.m_funcKistenPickup); -- TIMER -- self.m_uKistenTimer[i] = setTimer(self.m_funcDeleteDummyObject, self.m_iKistenTimeout, 1, dummy_object, true) end -- /////////////////////////////// -- ///// kistePickupByPlayer////// -- ///// Returns: void ////// -- /////////////////////////////// function cWaffentruckTruck:event_kistePickupByPlayer(uElement, iID) if(uElement) and (uElement:getType() == "player") then local uKiste = self.m_uDummyObjects[iID]; if(uKiste) and (uKiste:getData("wt:muelltonne")) then if(uElement.getFaction) and (uElement:getFaction():getType() == 1) then -- PD local i = tonumber(uKiste:getData("wt:i")); if(self.m_uKistenTimer[i]) then killTimer(self.m_uKistenTimer[i]); end self.m_funcDeleteDummyObject(self.m_uDummyObjects[i], false); self.m_funcDeleteDummyObject(self.m_uDummyObjects[i], false); local dollar = self.m_KISTEN_CASH; uElement:addMoney(dollar); uElement:getFaction():sendMessage(uElement:getName().." hat eine Waffentruckkiste aufgesammelt und erhaelt $"..dollar.."!", 0, 200, 0); end end end end -- /////////////////////////////// -- ///// removeCrates ////// -- ///// Returns: void ////// -- /////////////////////////////// function cWaffentruckTruck:removeCrates(iAmmount, dummy, destroyOnEmpty) for i = self.m_iCurrentCrates, self.m_iCurrentCrates-iAmmount+1, -1 do if(i >= 1) then if(dummy ~= true) then self:createDummyBomb(i); end if(self.m_uKisten[i]) then self.m_uKisten[i]:destroy(); self.m_uKisten[i] = nil; self.m_iCounterCrates = self.m_iCounterCrates-1; if(destroyOnEmpty) then if(self.m_iCounterCrates == 0) then Factions[self.m_iFactionID]:sendMessage("Ein Waffentruck wurde erfolgreich abgeladen.", 0, 0, 255); setTimer(function() self:destructor(); end, 60000, 1) end end end end end end -- /////////////////////////////// -- ///// TuneCar ////// -- ///// Returns: void ////// -- /////////////////////////////// function cWaffentruckTruck:tuneCar() self.m_uVehicle:setColor(0, 0, 0, 0, 0, 0); self.m_uVehicle:setHealth(self.m_iBASE_VEHICLE_HP); --[[ OLD self.m_uVehicle:removeSirens() self.m_uVehicle:addSirens(1, 2, true, true, true, true) self.m_uVehicle:setSirens(1, -0.7, 3.9, 1.4, 255, 0, 0, 255, 132.6) self.m_uVehicle:setSirensOn(true); --]] self.m_uVehicle:removeSirens(); self.m_uVehicle:addSirens(5, 5, true, false, true, true); self.m_uVehicle:setSirens(1, -0.7, 3.9, 1.4, 255, 0, 0, 200, 255); self.m_uVehicle:setSirens(2, 1.4, 2.3, -0.3, 0, 255, 0, 200, 255); self.m_uVehicle:setSirens(3, -1.4, 2.3, -0.3, 0, 255, 0, 200, 255); self.m_uVehicle:setSirens(4, -1.4, -5.6, -0.3, 0, 255, 0, 200, 255); self.m_uVehicle:setSirens(5, 1.4, -5.6, -0.3, 0, 255, 0, 200, 255); self.m_uVehicle:setSirensOn(true); -- HANDLING -- local hdl = getModelHandling(getVehicleModelFromName("Flatbed")) -- self.m_uVehicle:setHandling("collisionDamageMultiplier", -20.0); for index, val in pairs(hdl) do self.m_uVehicle:setHandling(index, val); end end -- /////////////////////////////// -- ///// recheckCrrates ////// -- ///// Returns: void ////// -- /////////////////////////////// -- 10 = 2100 -- 1 = ? function cWaffentruckTruck:recheckCrates(hp) if not(hp) then hp = self.m_uVehicle:getHealth(); end local cratesAvailable = math.floor((hp) / (self.m_iBASE_CRATES_HP / self.m_iMAX_KISTEN)); if(cratesAvailable < self.m_iCurrentCrates) then local cratesLost = self.m_iCurrentCrates-cratesAvailable; self:removeCrates(cratesLost); self.m_iCurrentCrates = self.m_iCurrentCrates-cratesLost; end end -- /////////////////////////////// -- ///// event_vehicleDamage////// -- ///// Returns: void ////// -- /////////////////////////////// function cWaffentruckTruck:event_vehicleDamage(dmg) -- Make Ressistent self.m_uVehicle:setHealth(self.m_uVehicle:getHealth()+dmg/5); self:recheckCrates(); end -- /////////////////////////////// -- ///// ExplodeVehicle ////// -- ///// Returns: void ////// -- /////////////////////////////// function cWaffentruckTruck:event_explodeVehicle() self:recheckCrates(0); setTimer(self.func_destructor, self.m_iKistenTimeout, 1); Factions[self.m_iFactionID]:sendMessage("Ein Waffentruck ist Explodiert.", 0, 0, 255); end -- /////////////////////////////// -- ///// ExitVehicle ////// -- ///// Returns: void ////// -- /////////////////////////////// function cWaffentruckTruck:event_exitVehicle(uPlayer) local uVehicle = self.m_uVehicle; local pos = uVehicle:getPosition(true); local rot = uVehicle:getRotation(true); local newx, newy = self:getPointFromDistanceRotation(pos:getX(), pos:getY(), 5, rot:getZ()*-1); local newz = pos:getZ(); uPlayer:setPosition(Vector3(newx, newy, newz)); end -- /////////////////////////////// -- ///// Destructor ////// -- ///// Returns: void ////// -- /////////////////////////////// function cWaffentruckTruck:destructor() self:removeCrates(self.m_iMAX_KISTEN, true); for i = 1, self.m_iMAX_FENCES, 1 do if( self.m_uFences[i]) and ( self.m_uFences[i].destroy) then self.m_uFences[i]:destroy(); self.m_uSigns[i]:destroy(); end end if(self.m_uVehicle.destroy) then self.m_uVehicle:destroy(); else destroyElement(self.m_uVehicle); end for id, ob in pairs(self.m_uDummyObjects) do if(ob) then self.m_uDummyObjects[id] = nil; if(isElement(ob)) then for _, object in pairs(ob:getAttachedElements()) do if(object) then object:destroy(); end end ob:destroy(); end end end if(isTimer(self.destructTimer)) then killTimer(self.destructTimer) end end function cWaffentruckTruck:getPointFromDistanceRotation(x, y, dist, angle) local a = math.rad(90 - angle); local dx = math.cos(a) * dist; local dy = math.sin(a) * dist; return x+dx, y+dy; end -- /////////////////////////////// -- ///// Constructor ////// -- ///// Returns: void ////// -- /////////////////////////////// function cWaffentruckTruck:constructor(iFactionID, iX, iY, iZ, iRX, iRY, iRZ, iKisten, iWare, iPlayerID, m_KISTEN_CASH, iStartpunkt) -- Klassenvariablen -- self.m_iFactionID = (iFactionID or 0); self.m_tblPosition = {iX, iY, iZ}; self.m_tblRotation = {(iRX or 0), (iRY or 0), (iRZ or 0)}; self.m_iPlayerID = iPlayerID; self.m_uVehicle = enew(createVehicle(578, iX, iY, iZ, iRX, iRY, iRZ), CBasicVehicle); self.m_uVehicle:setData("wt:wt", true); self.m_uVehicle:setData("wt:faction", self.m_iFactionID); self.m_uVehicle:setData("wt:startpunkt", iStartpunkt) self.m_uKisten = false; self.m_uFences = false; self.m_uSigns = false; self.m_iFenceID = 983; self.m_iKistID = 944; self.m_iSignID = 8330; self.m_iWarenWert = (iWare or 0); self.m_iSignScale = 0.2; self.m_iMAX_FENCES = 2; self.m_iMAX_KISTEN = iKisten; self.m_iBASE_VEHICLE_HP = 2000; self.m_iBASE_CRATES_HP = 2000; self.m_iCurrentCrates = self.m_iMAX_KISTEN; self.m_iCounterCrates = self.m_iMAX_KISTEN; self.m_iCurrentDamage = 0; self.m_iResistentDamage = 100; self.m_uColShapes = {}; self.m_uKistenTimer = {}; self.m_uDummyObjects = {}; self.m_iKistenTimeout = 60000; -- 1 Minute self.m_KISTEN_CASH = m_KISTEN_CASH; -- Funktionen -- self:tuneCar(); self:applyObjects(); self.m_funcVehicleDamage = function(...) self:event_vehicleDamage(...) end self.m_funcDeleteDummyObject = function(uObject, expl) if(uObject) and (isElement(uObject)) then for i, object in pairs(uObject:getAttachedElements()) do if(object) then object:destroy(); end end local pos = uObject:getPosition(true); if(expl) then createExplosion(pos:getX(), pos:getY(), pos:getZ(), 5) end uObject:destroy() end end; self.m_funcKistenPickup = function(...) self:event_kistePickupByPlayer(client, ...) end self.m_funcExplodeVehicle = function(...) self:event_explodeVehicle(source, ...) end self.func_destructor = function(...) self:destructor(...) end; self.m_funcExitVehicle = function(...) self:event_exitVehicle(...) end; -- Events -- addEvent("onWaffentruckKistePickup", true); addEventHandler("onVehicleDamage", self.m_uVehicle, self.m_funcVehicleDamage); addEventHandler("onVehicleExplode", self.m_uVehicle, self.m_funcExplodeVehicle); addEventHandler("onVehicleExit", self.m_uVehicle, self.m_funcExitVehicle); self.destructTimer = setTimer(self.destructor, 60*60*1000, 1) -- 1 Stunde WaffenTrucks[self.m_uVehicle] = self; end -- EVENT HANDLER --
function update(elapsed) if distractions == 0 then return end local currentBeat = (songPos / 1000)*(bpm/60) if difficulty == 2 then if currentBeat >= 0 and currentBeat <=68 then for i=0,7 do setActorX(_G['defaultStrum'..i..'X'] + 32 * math.sin((currentBeat + i*0.25) * math.pi), i) end end if currentBeat >= 78 then for i=0,7 do setActorX(_G['defaultStrum'..i..'X'] + 32 * math.sin((currentBeat + i*0.25) * math.pi), i) setActorY(_G['defaultStrum'..i..'Y'] + 128 * math.sin((currentBeat + i*0.25) * math.pi), i) end end end if difficulty == 1 then if currentBeat >= 0 and currentBeat <=68 then for i=0,7 do setActorX(_G['defaultStrum'..i..'X'] + 32 * math.sin((currentBeat + i*0.25) * math.pi), i) end end if currentBeat >= 78 then for i=0,7 do setActorX(_G['defaultStrum'..i..'X'] + 32 * math.sin((currentBeat + i*0.25) * math.pi), i) setActorY(_G['defaultStrum'..i..'Y'] + 64 * math.sin((currentBeat + i*0.25) * math.pi), i) end end end if difficulty == 0 then if currentBeat >= 0 and currentBeat <=68 then for i=0,7 do setActorX(_G['defaultStrum'..i..'X'] + 32 * math.sin((currentBeat + i*0.25) * math.pi), i) end end if currentBeat >= 78 then for i=0,7 do setActorX(_G['defaultStrum'..i..'X'] + 32 * math.sin((currentBeat + i*0.25) * math.pi), i) setActorY(_G['defaultStrum'..i..'Y'] + 32 * math.sin((currentBeat + i*0.25) * math.pi), i) end end end end
local playsession = { {"Piewdennis", {4818}}, {"Trashbull", {1530563}}, {"liqwid", {1414528}}, {"dr_root", {2219098}}, {"22xgaming", {1919}}, {"ratboyboxshall", {21086}}, {"belbo", {2009160}}, {"JB_Delta", {1281354}}, {"Mahno", {655333}}, {"EddieDemon", {808914}}, {"LittleX", {83061}}, {"bigot", {189010}}, {"luk4kasz", {479003}}, {"orekrem", {1499508}}, {"PrimeDko", {70202}}, {"Flashbacks", {775783}}, {"Nikkichu", {4799}}, {"happyjumper5", {584397}}, {"Partytime79", {1652}}, {"knightfrodo", {44246}}, {"tykak", {923273}}, {"TheKid0z", {18690}}, {"anghelnicky", {8954}}, {"realDonaldTrump", {9536}}, {"Hurrock", {1210471}}, {"Jackolanturn0", {30300}}, {"elvelazquez", {1189}}, {"Aerick", {613587}}, {"hasannuh", {555917}}, {"suotiikeri", {14965}}, {"Bugbei", {21883}}, {"Guitoune", {7124}}, {"BreadBomb", {676690}}, {"shlak", {922}}, {"lgor007", {14601}}, {"EPO666", {1186101}}, {"SilentShInI", {4753}}, {"FlipGalaxy", {4539}}, {"codog2", {744571}}, {"omgrun", {29368}}, {"Miteone", {210968}}, {"iceskaarj", {341360}}, {"scotty2586", {11930}}, {"mitja", {28937}}, {"Discotek", {1326}}, {"wilm", {24961}} } return playsession
--[[ Variables ]] local vehiclesGarage = {} local nearGarage = { ["garage"] = "", ["space"] = 0, ["coords"] = nil, } local Garages = {} --[[ Functions ]] function IsOnParkingSpot(pEntity, pCheck, pRadius) local entityCoords = GetEntityCoords(pEntity) local _distance = 300 local garage = nil for k, v in pairs(Garages) do local distance = #(entityCoords - v["pos"]["xyz"]) if distance < _distance then if distance < v["distance"] then _distance = distance garage = k end end end if not garage then return false end local radius = 2.0 if pRadius then radius = pRadius end local space = nil local nearest = 999.99 for i, v in ipairs(Garages[garage]["spaces"]) do local distance = #(entityCoords - v["xyz"]) if distance < radius and distance < nearest then if pCheck and not IsAnyVehicleNearPoint(v["x"], v["y"], v["z"], radius) then space = i nearest = distance else space = i nearest = distance end end end if not space then return false end nearGarage = { ["garage"] = garage, ["space"] = space, ["coords"] = Garages[garage]["spaces"][space], } return true end --[[ Exports ]] exports("IsOnParkingSpot", IsOnParkingSpot) --[[ Events ]] AddEventHandler("caue-vehicles:garage", function(params) local job = exports["caue-base"]:getChar("job") local garage = Garages[nearGarage["garage"]] if garage["jobGarage"] and garage["type"] ~= job then TriggerEvent("DoLongHudText", "You can't use this garage", 2) return end if garage["houseid"] and not exports["caue-housing"]:hasKey(garage["houseid"]) then TriggerEvent("DoLongHudText", "You can't use this garage", 2) return end local vehiclesGarage = RPC.execute("caue-vehicles:getGarage", nearGarage["garage"]) local data = { { title = "Garagem " .. nearGarage["garage"], } } for i, v in ipairs(vehiclesGarage) do table.insert(data,{ title = GetLabelText(GetDisplayNameFromVehicleModel(v["model"])), description = "Plate: " .. v["plate"], children = { { title = "Take Out Vehicle", action = "caue-vehicles:retriveVehicle", params = v["id"] }, { title = "Vehicle Status", description = "Engine: " .. v["engine_damage"] / 10 .. "% | Body: " .. v["body_damage"] / 10 .. "% | Fuel: " .. v["fuel"] .. "%"}, }, }) end exports["caue-context"]:showContext(data) end) AddEventHandler("caue-vehicles:retriveVehicle", function(vehID) local vehicle = RPC.execute("caue-vehicles:getVehicle", vehID) if vehicle then if not nearGarage["coords"] then return end TriggerEvent("caue-vehicles:spawnVehicle", vehicle.model, nearGarage["coords"], vehicle.id, vehicle.plate, vehicle.fuel, vehicle.modifications, vehicle.fakePlate, vehicle.harness, vehicle.body_damage, vehicle.engine_damage) RPC.execute("caue-vehicles:updateVehicle", vehicle.id, "garage", "state", "Out") end end) AddEventHandler("caue-vehicles:storeVehicle", function(params, vehicle) local vid = GetVehicleIdentifier(vehicle) if not vid then return end local garage = nearGarage["garage"] if garage == "" then return end local canStore = RPC.execute("caue-vehicles:canStoreVehicle", garage, vid) if not canStore then return end local garageData = Garages[nearGarage["garage"]] if garageData["houseid"] then if exports["caue-housing"]:hasKey(garageData["houseid"]) then local cid = exports["caue-base"]:getChar("id") local owner = RPC.execute("caue-vehicles:selectVehicle", vid, "vehicles", "cid") if owner ~= cid then TriggerEvent("DoLongHudText", "You cant't use this garage", 2) return end else TriggerEvent("DoLongHudText", "You can't use this garage", 2) return end end local store1 = RPC.execute("caue-vehicles:updateVehicle", vid, "garage", "garage", garage) if store1 then local store2 = RPC.execute("caue-vehicles:updateVehicle", vid, "garage", "state", "In") if store2 then Sync.DeleteVehicle(vehicle) Sync.DeleteEntity(vehicle) end end end) RegisterNetEvent("caue-vehicles:setGarage") AddEventHandler("caue-vehicles:setGarage", function(pGarage, pVar, pValue, pEdit) if pEdit then Garages[pGarage][pVar] = pValue else Garages[pGarage] = pVar end end) --[[ Threads ]] Citizen.CreateThread(function() Citizen.Wait(2000) Garages = RPC.execute("caue-vehicles:requestGarages") end)
-- Petit script pour faire office de crontab pour les mesures print("\n 0_cron.lua zf201003.1044 \n") cron1=tmr.create() cron1:alarm(180*1000, tmr.ALARM_AUTO, function() -- if verbose then print("cron1........................") end -- if verbose then gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) end -- rt_launch() -- http_post(influxdb_url,"energy,value=test1_"..yellow_id.." val=1") -- http_post(influxdb_url,"energy,memory=cron1_"..yellow_id.." ram="..node.heap()) -- if yellow_id == 60 then http_post(influxdb_url,"energy,compteur=3 puissance="..zpower/1000) end -- if yellow_id == 64 then http_post(influxdb_url,"energy,compteur=4 puissance="..zpower/1000) end if yellow_id == 69 then local zmes="bolo_ruru,capteur="..node_id.." level="..zlevel zmes=zmes.."\n".."bolo_ruru,capteur="..node_id.." hauteur="..zlength http_post(influxdb_url,zmes) end -- http_post(influxdb_url,"energy,value=test2_"..yellow_id.." val=2") -- http_post(influxdb_url,"energy,value=test3_"..yellow_id.." val=3") -- http_post(influxdb_url,"energy,value=test4_"..yellow_id.." val=4") -- f = "0_zdyndns.lua" if file.exists(f) then dofile(f) end -- f=nil -- if verbose then print("End cron:") end collectgarbage() -- if verbose then print(node.heap()) end end) --[[ cron1:stop() cron1:start() ]]
--[[ Copyright (C) 2016 Nick Guletskii 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 selftriction, 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, EXPselfS 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. A translation of gl.h. /* ** Copyright (c) 2013-2014 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including ** without limitation the rights to use, copy, modify, merge, publish, ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are 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 Materials. ** ** THE MATERIALS ARE 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 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ ]] local ffi = require("ffi") --[[ * Constants ]] --[[ Boolean values ]] GL_FALSE = 0 GL_TRUE = 1 --[[ Data types ]] GL_BYTE = 0x1400 GL_UNSIGNED_BYTE = 0x1401 GL_SHORT = 0x1402 GL_UNSIGNED_SHORT = 0x1403 GL_INT = 0x1404 GL_UNSIGNED_INT = 0x1405 GL_FLOAT = 0x1406 GL_2_BYTES = 0x1407 GL_3_BYTES = 0x1408 GL_4_BYTES = 0x1409 GL_DOUBLE = 0x140A --[[ Primitives ]] GL_POINTS = 0x0000 GL_LINES = 0x0001 GL_LINE_LOOP = 0x0002 GL_LINE_STRIP = 0x0003 GL_TRIANGLES = 0x0004 GL_TRIANGLE_STRIP = 0x0005 GL_TRIANGLE_FAN = 0x0006 GL_QUADS = 0x0007 GL_QUAD_STRIP = 0x0008 GL_POLYGON = 0x0009 --[[ Vertex Arrays ]] GL_VERTEX_ARRAY = 0x8074 GL_NORMAL_ARRAY = 0x8075 GL_COLOR_ARRAY = 0x8076 GL_INDEX_ARRAY = 0x8077 GL_TEXTURE_COORD_ARRAY = 0x8078 GL_EDGE_FLAG_ARRAY = 0x8079 GL_VERTEX_ARRAY_SIZE = 0x807A GL_VERTEX_ARRAY_TYPE = 0x807B GL_VERTEX_ARRAY_STRIDE = 0x807C GL_NORMAL_ARRAY_TYPE = 0x807E GL_NORMAL_ARRAY_STRIDE = 0x807F GL_COLOR_ARRAY_SIZE = 0x8081 GL_COLOR_ARRAY_TYPE = 0x8082 GL_COLOR_ARRAY_STRIDE = 0x8083 GL_INDEX_ARRAY_TYPE = 0x8085 GL_INDEX_ARRAY_STRIDE = 0x8086 GL_TEXTURE_COORD_ARRAY_SIZE = 0x8088 GL_TEXTURE_COORD_ARRAY_TYPE = 0x8089 GL_TEXTURE_COORD_ARRAY_STRIDE = 0x808A GL_EDGE_FLAG_ARRAY_STRIDE = 0x808C GL_VERTEX_ARRAY_POINTER = 0x808E GL_NORMAL_ARRAY_POINTER = 0x808F GL_COLOR_ARRAY_POINTER = 0x8090 GL_INDEX_ARRAY_POINTER = 0x8091 GL_TEXTURE_COORD_ARRAY_POINTER = 0x8092 GL_EDGE_FLAG_ARRAY_POINTER = 0x8093 GL_V2F = 0x2A20 GL_V3F = 0x2A21 GL_C4UB_V2F = 0x2A22 GL_C4UB_V3F = 0x2A23 GL_C3F_V3F = 0x2A24 GL_N3F_V3F = 0x2A25 GL_C4F_N3F_V3F = 0x2A26 GL_T2F_V3F = 0x2A27 GL_T4F_V4F = 0x2A28 GL_T2F_C4UB_V3F = 0x2A29 GL_T2F_C3F_V3F = 0x2A2A GL_T2F_N3F_V3F = 0x2A2B GL_T2F_C4F_N3F_V3F = 0x2A2C GL_T4F_C4F_N3F_V4F = 0x2A2D --[[ Matrix Mode ]] GL_MATRIX_MODE = 0x0BA0 GL_MODELVIEW = 0x1700 GL_PROJECTION = 0x1701 GL_TEXTURE = 0x1702 --[[ Points ]] GL_POINT_SMOOTH = 0x0B10 GL_POINT_SIZE = 0x0B11 GL_POINT_SIZE_GRANULARITY = 0x0B13 GL_POINT_SIZE_RANGE = 0x0B12 --[[ Lines ]] GL_LINE_SMOOTH = 0x0B20 GL_LINE_STIPPLE = 0x0B24 GL_LINE_STIPPLE_PATTERN = 0x0B25 GL_LINE_STIPPLE_REPEAT = 0x0B26 GL_LINE_WIDTH = 0x0B21 GL_LINE_WIDTH_GRANULARITY = 0x0B23 GL_LINE_WIDTH_RANGE = 0x0B22 --[[ Polygons ]] GL_POINT = 0x1B00 GL_LINE = 0x1B01 GL_FILL = 0x1B02 GL_CW = 0x0900 GL_CCW = 0x0901 GL_FRONT = 0x0404 GL_BACK = 0x0405 GL_POLYGON_MODE = 0x0B40 GL_POLYGON_SMOOTH = 0x0B41 GL_POLYGON_STIPPLE = 0x0B42 GL_EDGE_FLAG = 0x0B43 GL_CULL_FACE = 0x0B44 GL_CULL_FACE_MODE = 0x0B45 GL_FRONT_FACE = 0x0B46 GL_POLYGON_OFFSET_FACTOR = 0x8038 GL_POLYGON_OFFSET_UNITS = 0x2A00 GL_POLYGON_OFFSET_POINT = 0x2A01 GL_POLYGON_OFFSET_LINE = 0x2A02 GL_POLYGON_OFFSET_FILL = 0x8037 --[[ Display Lists ]] GL_COMPILE = 0x1300 GL_COMPILE_AND_EXECUTE = 0x1301 GL_LIST_BASE = 0x0B32 GL_LIST_INDEX = 0x0B33 GL_LIST_MODE = 0x0B30 --[[ Depth buffer ]] GL_NEVER = 0x0200 GL_LESS = 0x0201 GL_EQUAL = 0x0202 GL_LEQUAL = 0x0203 GL_GREATER = 0x0204 GL_NOTEQUAL = 0x0205 GL_GEQUAL = 0x0206 GL_ALWAYS = 0x0207 GL_DEPTH_TEST = 0x0B71 GL_DEPTH_BITS = 0x0D56 GL_DEPTH_CLEAR_VALUE = 0x0B73 GL_DEPTH_FUNC = 0x0B74 GL_DEPTH_RANGE = 0x0B70 GL_DEPTH_WRITEMASK = 0x0B72 GL_DEPTH_COMPONENT = 0x1902 --[[ Lighting ]] GL_LIGHTING = 0x0B50 GL_LIGHT0 = 0x4000 GL_LIGHT1 = 0x4001 GL_LIGHT2 = 0x4002 GL_LIGHT3 = 0x4003 GL_LIGHT4 = 0x4004 GL_LIGHT5 = 0x4005 GL_LIGHT6 = 0x4006 GL_LIGHT7 = 0x4007 GL_SPOT_EXPONENT = 0x1205 GL_SPOT_CUTOFF = 0x1206 GL_CONSTANT_ATTENUATION = 0x1207 GL_LINEAR_ATTENUATION = 0x1208 GL_QUADRATIC_ATTENUATION = 0x1209 GL_AMBIENT = 0x1200 GL_DIFFUSE = 0x1201 GL_SPECULAR = 0x1202 GL_SHININESS = 0x1601 GL_EMISSION = 0x1600 GL_POSITION = 0x1203 GL_SPOT_DIRECTION = 0x1204 GL_AMBIENT_AND_DIFFUSE = 0x1602 GL_COLOR_INDEXES = 0x1603 GL_LIGHT_MODEL_TWO_SIDE = 0x0B52 GL_LIGHT_MODEL_LOCAL_VIEWER = 0x0B51 GL_LIGHT_MODEL_AMBIENT = 0x0B53 GL_FRONT_AND_BACK = 0x0408 GL_SHADE_MODEL = 0x0B54 GL_FLAT = 0x1D00 GL_SMOOTH = 0x1D01 GL_COLOR_MATERIAL = 0x0B57 GL_COLOR_MATERIAL_FACE = 0x0B55 GL_COLOR_MATERIAL_PARAMETER = 0x0B56 GL_NORMALIZE = 0x0BA1 --[[ User clipping planes ]] GL_CLIP_PLANE0 = 0x3000 GL_CLIP_PLANE1 = 0x3001 GL_CLIP_PLANE2 = 0x3002 GL_CLIP_PLANE3 = 0x3003 GL_CLIP_PLANE4 = 0x3004 GL_CLIP_PLANE5 = 0x3005 --[[ Accumulation buffer ]] GL_ACCUM_RED_BITS = 0x0D58 GL_ACCUM_GREEN_BITS = 0x0D59 GL_ACCUM_BLUE_BITS = 0x0D5A GL_ACCUM_ALPHA_BITS = 0x0D5B GL_ACCUM_CLEAR_VALUE = 0x0B80 GL_ACCUM = 0x0100 GL_ADD = 0x0104 GL_LOAD = 0x0101 GL_MULT = 0x0103 GL_RETURN = 0x0102 --[[ Alpha testing ]] GL_ALPHA_TEST = 0x0BC0 GL_ALPHA_TEST_REF = 0x0BC2 GL_ALPHA_TEST_FUNC = 0x0BC1 --[[ Blending ]] GL_BLEND = 0x0BE2 GL_BLEND_SRC = 0x0BE1 GL_BLEND_DST = 0x0BE0 GL_ZERO = 0 GL_ONE = 1 GL_SRC_COLOR = 0x0300 GL_ONE_MINUS_SRC_COLOR = 0x0301 GL_SRC_ALPHA = 0x0302 GL_ONE_MINUS_SRC_ALPHA = 0x0303 GL_DST_ALPHA = 0x0304 GL_ONE_MINUS_DST_ALPHA = 0x0305 GL_DST_COLOR = 0x0306 GL_ONE_MINUS_DST_COLOR = 0x0307 GL_SRC_ALPHA_SATURATE = 0x0308 --[[ Render Mode ]] GL_FEEDBACK = 0x1C01 GL_RENDER = 0x1C00 GL_SELECT = 0x1C02 --[[ Feedback ]] GL_2D = 0x0600 GL_3D = 0x0601 GL_3D_COLOR = 0x0602 GL_3D_COLOR_TEXTURE = 0x0603 GL_4D_COLOR_TEXTURE = 0x0604 GL_POINT_TOKEN = 0x0701 GL_LINE_TOKEN = 0x0702 GL_LINE_RESET_TOKEN = 0x0707 GL_POLYGON_TOKEN = 0x0703 GL_BITMAP_TOKEN = 0x0704 GL_DRAW_PIXEL_TOKEN = 0x0705 GL_COPY_PIXEL_TOKEN = 0x0706 GL_PASS_THROUGH_TOKEN = 0x0700 GL_FEEDBACK_BUFFER_POINTER = 0x0DF0 GL_FEEDBACK_BUFFER_SIZE = 0x0DF1 GL_FEEDBACK_BUFFER_TYPE = 0x0DF2 --[[ Selection ]] GL_SELECTION_BUFFER_POINTER = 0x0DF3 GL_SELECTION_BUFFER_SIZE = 0x0DF4 --[[ Fog ]] GL_FOG = 0x0B60 GL_FOG_MODE = 0x0B65 GL_FOG_DENSITY = 0x0B62 GL_FOG_COLOR = 0x0B66 GL_FOG_INDEX = 0x0B61 GL_FOG_START = 0x0B63 GL_FOG_END = 0x0B64 GL_LINEAR = 0x2601 GL_EXP = 0x0800 GL_EXP2 = 0x0801 --[[ Logic Ops ]] GL_LOGIC_OP = 0x0BF1 GL_INDEX_LOGIC_OP = 0x0BF1 GL_COLOR_LOGIC_OP = 0x0BF2 GL_LOGIC_OP_MODE = 0x0BF0 GL_CLEAR = 0x1500 GL_SET = 0x150F GL_COPY = 0x1503 GL_COPY_INVERTED = 0x150C GL_NOOP = 0x1505 GL_INVERT = 0x150A GL_AND = 0x1501 GL_NAND = 0x150E GL_OR = 0x1507 GL_NOR = 0x1508 GL_XOR = 0x1506 GL_EQUIV = 0x1509 GL_AND_REVERSE = 0x1502 GL_AND_INVERTED = 0x1504 GL_OR_REVERSE = 0x150B GL_OR_INVERTED = 0x150D --[[ Stencil ]] GL_STENCIL_BITS = 0x0D57 GL_STENCIL_TEST = 0x0B90 GL_STENCIL_CLEAR_VALUE = 0x0B91 GL_STENCIL_FUNC = 0x0B92 GL_STENCIL_VALUE_MASK = 0x0B93 GL_STENCIL_FAIL = 0x0B94 GL_STENCIL_PASS_DEPTH_FAIL = 0x0B95 GL_STENCIL_PASS_DEPTH_PASS = 0x0B96 GL_STENCIL_REF = 0x0B97 GL_STENCIL_WRITEMASK = 0x0B98 GL_STENCIL_INDEX = 0x1901 GL_KEEP = 0x1E00 GL_REPLACE = 0x1E01 GL_INCR = 0x1E02 GL_DECR = 0x1E03 --[[ Buffers, Pixel Drawing/Reading ]] GL_NONE = 0 GL_LEFT = 0x0406 GL_RIGHT = 0x0407 --[[GL_FRONT 0x0404 ]] --[[GL_BACK 0x0405 ]] --[[GL_FRONT_AND_BACK 0x0408 ]] GL_FRONT_LEFT = 0x0400 GL_FRONT_RIGHT = 0x0401 GL_BACK_LEFT = 0x0402 GL_BACK_RIGHT = 0x0403 GL_AUX0 = 0x0409 GL_AUX1 = 0x040A GL_AUX2 = 0x040B GL_AUX3 = 0x040C GL_COLOR_INDEX = 0x1900 GL_RED = 0x1903 GL_GREEN = 0x1904 GL_BLUE = 0x1905 GL_ALPHA = 0x1906 GL_LUMINANCE = 0x1909 GL_LUMINANCE_ALPHA = 0x190A GL_ALPHA_BITS = 0x0D55 GL_RED_BITS = 0x0D52 GL_GREEN_BITS = 0x0D53 GL_BLUE_BITS = 0x0D54 GL_INDEX_BITS = 0x0D51 GL_SUBPIXEL_BITS = 0x0D50 GL_AUX_BUFFERS = 0x0C00 GL_READ_BUFFER = 0x0C02 GL_DRAW_BUFFER = 0x0C01 GL_DOUBLEBUFFER = 0x0C32 GL_STEREO = 0x0C33 GL_BITMAP = 0x1A00 GL_COLOR = 0x1800 GL_DEPTH = 0x1801 GL_STENCIL = 0x1802 GL_DITHER = 0x0BD0 GL_RGB = 0x1907 GL_RGBA = 0x1908 --[[ Implementation limits ]] GL_MAX_LIST_NESTING = 0x0B31 GL_MAX_EVAL_ORDER = 0x0D30 GL_MAX_LIGHTS = 0x0D31 GL_MAX_CLIP_PLANES = 0x0D32 GL_MAX_TEXTURE_SIZE = 0x0D33 GL_MAX_PIXEL_MAP_TABLE = 0x0D34 GL_MAX_ATTRIB_STACK_DEPTH = 0x0D35 GL_MAX_MODELVIEW_STACK_DEPTH = 0x0D36 GL_MAX_NAME_STACK_DEPTH = 0x0D37 GL_MAX_PROJECTION_STACK_DEPTH = 0x0D38 GL_MAX_TEXTURE_STACK_DEPTH = 0x0D39 GL_MAX_VIEWPORT_DIMS = 0x0D3A GL_MAX_CLIENT_ATTRIB_STACK_DEPTH = 0x0D3B --[[ Gets ]] GL_ATTRIB_STACK_DEPTH = 0x0BB0 GL_CLIENT_ATTRIB_STACK_DEPTH = 0x0BB1 GL_COLOR_CLEAR_VALUE = 0x0C22 GL_COLOR_WRITEMASK = 0x0C23 GL_CURRENT_INDEX = 0x0B01 GL_CURRENT_COLOR = 0x0B00 GL_CURRENT_NORMAL = 0x0B02 GL_CURRENT_RASTER_COLOR = 0x0B04 GL_CURRENT_RASTER_DISTANCE = 0x0B09 GL_CURRENT_RASTER_INDEX = 0x0B05 GL_CURRENT_RASTER_POSITION = 0x0B07 GL_CURRENT_RASTER_TEXTURE_COORDS = 0x0B06 GL_CURRENT_RASTER_POSITION_VALID = 0x0B08 GL_CURRENT_TEXTURE_COORDS = 0x0B03 GL_INDEX_CLEAR_VALUE = 0x0C20 GL_INDEX_MODE = 0x0C30 GL_INDEX_WRITEMASK = 0x0C21 GL_MODELVIEW_MATRIX = 0x0BA6 GL_MODELVIEW_STACK_DEPTH = 0x0BA3 GL_NAME_STACK_DEPTH = 0x0D70 GL_PROJECTION_MATRIX = 0x0BA7 GL_PROJECTION_STACK_DEPTH = 0x0BA4 GL_RENDER_MODE = 0x0C40 GL_RGBA_MODE = 0x0C31 GL_TEXTURE_MATRIX = 0x0BA8 GL_TEXTURE_STACK_DEPTH = 0x0BA5 GL_VIEWPORT = 0x0BA2 --[[ Evaluators ]] GL_AUTO_NORMAL = 0x0D80 GL_MAP1_COLOR_4 = 0x0D90 GL_MAP1_INDEX = 0x0D91 GL_MAP1_NORMAL = 0x0D92 GL_MAP1_TEXTURE_COORD_1 = 0x0D93 GL_MAP1_TEXTURE_COORD_2 = 0x0D94 GL_MAP1_TEXTURE_COORD_3 = 0x0D95 GL_MAP1_TEXTURE_COORD_4 = 0x0D96 GL_MAP1_VERTEX_3 = 0x0D97 GL_MAP1_VERTEX_4 = 0x0D98 GL_MAP2_COLOR_4 = 0x0DB0 GL_MAP2_INDEX = 0x0DB1 GL_MAP2_NORMAL = 0x0DB2 GL_MAP2_TEXTURE_COORD_1 = 0x0DB3 GL_MAP2_TEXTURE_COORD_2 = 0x0DB4 GL_MAP2_TEXTURE_COORD_3 = 0x0DB5 GL_MAP2_TEXTURE_COORD_4 = 0x0DB6 GL_MAP2_VERTEX_3 = 0x0DB7 GL_MAP2_VERTEX_4 = 0x0DB8 GL_MAP1_GRID_DOMAIN = 0x0DD0 GL_MAP1_GRID_SEGMENTS = 0x0DD1 GL_MAP2_GRID_DOMAIN = 0x0DD2 GL_MAP2_GRID_SEGMENTS = 0x0DD3 GL_COEFF = 0x0A00 GL_ORDER = 0x0A01 GL_DOMAIN = 0x0A02 --[[ Hints ]] GL_PERSPECTIVE_CORRECTION_HINT = 0x0C50 GL_POINT_SMOOTH_HINT = 0x0C51 GL_LINE_SMOOTH_HINT = 0x0C52 GL_POLYGON_SMOOTH_HINT = 0x0C53 GL_FOG_HINT = 0x0C54 GL_DONT_CARE = 0x1100 GL_FASTEST = 0x1101 GL_NICEST = 0x1102 --[[ Scissor box ]] GL_SCISSOR_BOX = 0x0C10 GL_SCISSOR_TEST = 0x0C11 --[[ Pixel Mode / Transfer ]] GL_MAP_COLOR = 0x0D10 GL_MAP_STENCIL = 0x0D11 GL_INDEX_SHIFT = 0x0D12 GL_INDEX_OFFSET = 0x0D13 GL_RED_SCALE = 0x0D14 GL_RED_BIAS = 0x0D15 GL_GREEN_SCALE = 0x0D18 GL_GREEN_BIAS = 0x0D19 GL_BLUE_SCALE = 0x0D1A GL_BLUE_BIAS = 0x0D1B GL_ALPHA_SCALE = 0x0D1C GL_ALPHA_BIAS = 0x0D1D GL_DEPTH_SCALE = 0x0D1E GL_DEPTH_BIAS = 0x0D1F GL_PIXEL_MAP_S_TO_S_SIZE = 0x0CB1 GL_PIXEL_MAP_I_TO_I_SIZE = 0x0CB0 GL_PIXEL_MAP_I_TO_R_SIZE = 0x0CB2 GL_PIXEL_MAP_I_TO_G_SIZE = 0x0CB3 GL_PIXEL_MAP_I_TO_B_SIZE = 0x0CB4 GL_PIXEL_MAP_I_TO_A_SIZE = 0x0CB5 GL_PIXEL_MAP_R_TO_R_SIZE = 0x0CB6 GL_PIXEL_MAP_G_TO_G_SIZE = 0x0CB7 GL_PIXEL_MAP_B_TO_B_SIZE = 0x0CB8 GL_PIXEL_MAP_A_TO_A_SIZE = 0x0CB9 GL_PIXEL_MAP_S_TO_S = 0x0C71 GL_PIXEL_MAP_I_TO_I = 0x0C70 GL_PIXEL_MAP_I_TO_R = 0x0C72 GL_PIXEL_MAP_I_TO_G = 0x0C73 GL_PIXEL_MAP_I_TO_B = 0x0C74 GL_PIXEL_MAP_I_TO_A = 0x0C75 GL_PIXEL_MAP_R_TO_R = 0x0C76 GL_PIXEL_MAP_G_TO_G = 0x0C77 GL_PIXEL_MAP_B_TO_B = 0x0C78 GL_PIXEL_MAP_A_TO_A = 0x0C79 GL_PACK_ALIGNMENT = 0x0D05 GL_PACK_LSB_FIRST = 0x0D01 GL_PACK_ROW_LENGTH = 0x0D02 GL_PACK_SKIP_PIXELS = 0x0D04 GL_PACK_SKIP_ROWS = 0x0D03 GL_PACK_SWAP_BYTES = 0x0D00 GL_UNPACK_ALIGNMENT = 0x0CF5 GL_UNPACK_LSB_FIRST = 0x0CF1 GL_UNPACK_ROW_LENGTH = 0x0CF2 GL_UNPACK_SKIP_PIXELS = 0x0CF4 GL_UNPACK_SKIP_ROWS = 0x0CF3 GL_UNPACK_SWAP_BYTES = 0x0CF0 GL_ZOOM_X = 0x0D16 GL_ZOOM_Y = 0x0D17 --[[ Texture mapping ]] GL_TEXTURE_ENV = 0x2300 GL_TEXTURE_ENV_MODE = 0x2200 GL_TEXTURE_1D = 0x0DE0 GL_TEXTURE_2D = 0x0DE1 GL_TEXTURE_WRAP_S = 0x2802 GL_TEXTURE_WRAP_T = 0x2803 GL_TEXTURE_MAG_FILTER = 0x2800 GL_TEXTURE_MIN_FILTER = 0x2801 GL_TEXTURE_ENV_COLOR = 0x2201 GL_TEXTURE_GEN_S = 0x0C60 GL_TEXTURE_GEN_T = 0x0C61 GL_TEXTURE_GEN_R = 0x0C62 GL_TEXTURE_GEN_Q = 0x0C63 GL_TEXTURE_GEN_MODE = 0x2500 GL_TEXTURE_BORDER_COLOR = 0x1004 GL_TEXTURE_WIDTH = 0x1000 GL_TEXTURE_HEIGHT = 0x1001 GL_TEXTURE_BORDER = 0x1005 GL_TEXTURE_COMPONENTS = 0x1003 GL_TEXTURE_RED_SIZE = 0x805C GL_TEXTURE_GREEN_SIZE = 0x805D GL_TEXTURE_BLUE_SIZE = 0x805E GL_TEXTURE_ALPHA_SIZE = 0x805F GL_TEXTURE_LUMINANCE_SIZE = 0x8060 GL_TEXTURE_INTENSITY_SIZE = 0x8061 GL_NEAREST_MIPMAP_NEAREST = 0x2700 GL_NEAREST_MIPMAP_LINEAR = 0x2702 GL_LINEAR_MIPMAP_NEAREST = 0x2701 GL_LINEAR_MIPMAP_LINEAR = 0x2703 GL_OBJECT_LINEAR = 0x2401 GL_OBJECT_PLANE = 0x2501 GL_EYE_LINEAR = 0x2400 GL_EYE_PLANE = 0x2502 GL_SPHERE_MAP = 0x2402 GL_DECAL = 0x2101 GL_MODULATE = 0x2100 GL_NEAREST = 0x2600 GL_REPEAT = 0x2901 GL_CLAMP = 0x2900 GL_S = 0x2000 GL_T = 0x2001 GL_R = 0x2002 GL_Q = 0x2003 --[[ Utility ]] GL_VENDOR = 0x1F00 GL_RENDERER = 0x1F01 GL_VERSION = 0x1F02 GL_EXTENSIONS = 0x1F03 --[[ Errors ]] GL_NO_ERROR = 0 GL_INVALID_ENUM = 0x0500 GL_INVALID_VALUE = 0x0501 GL_INVALID_OPERATION = 0x0502 GL_STACK_OVERFLOW = 0x0503 GL_STACK_UNDERFLOW = 0x0504 GL_OUT_OF_MEMORY = 0x0505 --[[ glPush/PopAttrib bits ]] GL_CURRENT_BIT = 0x00000001 GL_POINT_BIT = 0x00000002 GL_LINE_BIT = 0x00000004 GL_POLYGON_BIT = 0x00000008 GL_POLYGON_STIPPLE_BIT = 0x00000010 GL_PIXEL_MODE_BIT = 0x00000020 GL_LIGHTING_BIT = 0x00000040 GL_FOG_BIT = 0x00000080 GL_DEPTH_BUFFER_BIT = 0x00000100 GL_ACCUM_BUFFER_BIT = 0x00000200 GL_STENCIL_BUFFER_BIT = 0x00000400 GL_VIEWPORT_BIT = 0x00000800 GL_TRANSFORM_BIT = 0x00001000 GL_ENABLE_BIT = 0x00002000 GL_COLOR_BUFFER_BIT = 0x00004000 GL_HINT_BIT = 0x00008000 GL_EVAL_BIT = 0x00010000 GL_LIST_BIT = 0x00020000 GL_TEXTURE_BIT = 0x00040000 GL_SCISSOR_BIT = 0x00080000 GL_ALL_ATTRIB_BITS = 0xFFFFFFFF --[[ OpenGL 1.1 ]] GL_PROXY_TEXTURE_1D = 0x8063 GL_PROXY_TEXTURE_2D = 0x8064 GL_TEXTURE_PRIORITY = 0x8066 GL_TEXTURE_RESIDENT = 0x8067 GL_TEXTURE_BINDING_1D = 0x8068 GL_TEXTURE_BINDING_2D = 0x8069 GL_TEXTURE_INTERNAL_FORMAT = 0x1003 GL_ALPHA4 = 0x803B GL_ALPHA8 = 0x803C GL_ALPHA12 = 0x803D GL_ALPHA16 = 0x803E GL_LUMINANCE4 = 0x803F GL_LUMINANCE8 = 0x8040 GL_LUMINANCE12 = 0x8041 GL_LUMINANCE16 = 0x8042 GL_LUMINANCE4_ALPHA4 = 0x8043 GL_LUMINANCE6_ALPHA2 = 0x8044 GL_LUMINANCE8_ALPHA8 = 0x8045 GL_LUMINANCE12_ALPHA4 = 0x8046 GL_LUMINANCE12_ALPHA12 = 0x8047 GL_LUMINANCE16_ALPHA16 = 0x8048 GL_INTENSITY = 0x8049 GL_INTENSITY4 = 0x804A GL_INTENSITY8 = 0x804B GL_INTENSITY12 = 0x804C GL_INTENSITY16 = 0x804D GL_R3_G3_B2 = 0x2A10 GL_RGB4 = 0x804F GL_RGB5 = 0x8050 GL_RGB8 = 0x8051 GL_RGB10 = 0x8052 GL_RGB12 = 0x8053 GL_RGB16 = 0x8054 GL_RGBA2 = 0x8055 GL_RGBA4 = 0x8056 GL_RGB5_A1 = 0x8057 GL_RGBA8 = 0x8058 GL_RGB10_A2 = 0x8059 GL_RGBA12 = 0x805A GL_RGBA16 = 0x805B GL_CLIENT_PIXEL_STORE_BIT = 0x00000001 GL_CLIENT_VERTEX_ARRAY_BIT = 0x00000002 GL_ALL_CLIENT_ATTRIB_BITS = 0xFFFFFFFF GL_CLIENT_ALL_ATTRIB_BITS = 0xFFFFFFFF --[[ * GL_ARB_imaging ]] GL_CONSTANT_COLOR = 0x8001 GL_ONE_MINUS_CONSTANT_COLOR = 0x8002 GL_CONSTANT_ALPHA = 0x8003 GL_ONE_MINUS_CONSTANT_ALPHA = 0x8004 GL_COLOR_TABLE = 0x80D0 GL_POST_CONVOLUTION_COLOR_TABLE = 0x80D1 GL_POST_COLOR_MATRIX_COLOR_TABLE = 0x80D2 GL_PROXY_COLOR_TABLE = 0x80D3 GL_PROXY_POST_CONVOLUTION_COLOR_TABLE = 0x80D4 GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE = 0x80D5 GL_COLOR_TABLE_SCALE = 0x80D6 GL_COLOR_TABLE_BIAS = 0x80D7 GL_COLOR_TABLE_FORMAT = 0x80D8 GL_COLOR_TABLE_WIDTH = 0x80D9 GL_COLOR_TABLE_RED_SIZE = 0x80DA GL_COLOR_TABLE_GREEN_SIZE = 0x80DB GL_COLOR_TABLE_BLUE_SIZE = 0x80DC GL_COLOR_TABLE_ALPHA_SIZE = 0x80DD GL_COLOR_TABLE_LUMINANCE_SIZE = 0x80DE GL_COLOR_TABLE_INTENSITY_SIZE = 0x80DF GL_CONVOLUTION_1D = 0x8010 GL_CONVOLUTION_2D = 0x8011 GL_SEPARABLE_2D = 0x8012 GL_CONVOLUTION_BORDER_MODE = 0x8013 GL_CONVOLUTION_FILTER_SCALE = 0x8014 GL_CONVOLUTION_FILTER_BIAS = 0x8015 GL_REDUCE = 0x8016 GL_CONVOLUTION_FORMAT = 0x8017 GL_CONVOLUTION_WIDTH = 0x8018 GL_CONVOLUTION_HEIGHT = 0x8019 GL_MAX_CONVOLUTION_WIDTH = 0x801A GL_MAX_CONVOLUTION_HEIGHT = 0x801B GL_POST_CONVOLUTION_RED_SCALE = 0x801C GL_POST_CONVOLUTION_GREEN_SCALE = 0x801D GL_POST_CONVOLUTION_BLUE_SCALE = 0x801E GL_POST_CONVOLUTION_ALPHA_SCALE = 0x801F GL_POST_CONVOLUTION_RED_BIAS = 0x8020 GL_POST_CONVOLUTION_GREEN_BIAS = 0x8021 GL_POST_CONVOLUTION_BLUE_BIAS = 0x8022 GL_POST_CONVOLUTION_ALPHA_BIAS = 0x8023 GL_CONSTANT_BORDER = 0x8151 GL_REPLICATE_BORDER = 0x8153 GL_CONVOLUTION_BORDER_COLOR = 0x8154 GL_COLOR_MATRIX = 0x80B1 GL_COLOR_MATRIX_STACK_DEPTH = 0x80B2 GL_MAX_COLOR_MATRIX_STACK_DEPTH = 0x80B3 GL_POST_COLOR_MATRIX_RED_SCALE = 0x80B4 GL_POST_COLOR_MATRIX_GREEN_SCALE = 0x80B5 GL_POST_COLOR_MATRIX_BLUE_SCALE = 0x80B6 GL_POST_COLOR_MATRIX_ALPHA_SCALE = 0x80B7 GL_POST_COLOR_MATRIX_RED_BIAS = 0x80B8 GL_POST_COLOR_MATRIX_GREEN_BIAS = 0x80B9 GL_POST_COLOR_MATRIX_BLUE_BIAS = 0x80BA GL_POST_COLOR_MATRIX_ALPHA_BIAS = 0x80BB GL_HISTOGRAM = 0x8024 GL_PROXY_HISTOGRAM = 0x8025 GL_HISTOGRAM_WIDTH = 0x8026 GL_HISTOGRAM_FORMAT = 0x8027 GL_HISTOGRAM_RED_SIZE = 0x8028 GL_HISTOGRAM_GREEN_SIZE = 0x8029 GL_HISTOGRAM_BLUE_SIZE = 0x802A GL_HISTOGRAM_ALPHA_SIZE = 0x802B GL_HISTOGRAM_LUMINANCE_SIZE = 0x802C GL_HISTOGRAM_SINK = 0x802D GL_MINMAX = 0x802E GL_MINMAX_FORMAT = 0x802F GL_MINMAX_SINK = 0x8030 GL_TABLE_TOO_LARGE = 0x8031 GL_BLEND_EQUATION = 0x8009 GL_MIN = 0x8007 GL_MAX = 0x8008 GL_FUNC_ADD = 0x8006 GL_FUNC_SUBTRACT = 0x800A GL_FUNC_REVERSE_SUBTRACT = 0x800B GL_BLEND_COLOR = 0x8005 --[[ * OpenGL 1.2 ]] GL_RESCALE_NORMAL = 0x803A GL_CLAMP_TO_EDGE = 0x812F GL_MAX_ELEMENTS_VERTICES = 0x80E8 GL_MAX_ELEMENTS_INDICES = 0x80E9 GL_BGR = 0x80E0 GL_BGRA = 0x80E1 GL_UNSIGNED_BYTE_3_3_2 = 0x8032 GL_UNSIGNED_BYTE_2_3_3_REV = 0x8362 GL_UNSIGNED_SHORT_5_6_5 = 0x8363 GL_UNSIGNED_SHORT_5_6_5_REV = 0x8364 GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033 GL_UNSIGNED_SHORT_4_4_4_4_REV = 0x8365 GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034 GL_UNSIGNED_SHORT_1_5_5_5_REV = 0x8366 GL_UNSIGNED_INT_8_8_8_8 = 0x8035 GL_UNSIGNED_INT_8_8_8_8_REV = 0x8367 GL_UNSIGNED_INT_10_10_10_2 = 0x8036 GL_UNSIGNED_INT_2_10_10_10_REV = 0x8368 GL_LIGHT_MODEL_COLOR_CONTROL = 0x81F8 GL_SINGLE_COLOR = 0x81F9 GL_SEPARATE_SPECULAR_COLOR = 0x81FA GL_TEXTURE_MIN_LOD = 0x813A GL_TEXTURE_MAX_LOD = 0x813B GL_TEXTURE_BASE_LEVEL = 0x813C GL_TEXTURE_MAX_LEVEL = 0x813D GL_SMOOTH_POINT_SIZE_RANGE = 0x0B12 GL_SMOOTH_POINT_SIZE_GRANULARITY = 0x0B13 GL_SMOOTH_LINE_WIDTH_RANGE = 0x0B22 GL_SMOOTH_LINE_WIDTH_GRANULARITY = 0x0B23 GL_ALIASED_POINT_SIZE_RANGE = 0x846D GL_ALIASED_LINE_WIDTH_RANGE = 0x846E GL_PACK_SKIP_IMAGES = 0x806B GL_PACK_IMAGE_HEIGHT = 0x806C GL_UNPACK_SKIP_IMAGES = 0x806D GL_UNPACK_IMAGE_HEIGHT = 0x806E GL_TEXTURE_3D = 0x806F GL_PROXY_TEXTURE_3D = 0x8070 GL_TEXTURE_DEPTH = 0x8071 GL_TEXTURE_WRAP_R = 0x8072 GL_MAX_3D_TEXTURE_SIZE = 0x8073 GL_TEXTURE_BINDING_3D = 0x806A --[[ * OpenGL 1.3 ]] --[[ multitexture ]] GL_TEXTURE0 = 0x84C0 GL_TEXTURE1 = 0x84C1 GL_TEXTURE2 = 0x84C2 GL_TEXTURE3 = 0x84C3 GL_TEXTURE4 = 0x84C4 GL_TEXTURE5 = 0x84C5 GL_TEXTURE6 = 0x84C6 GL_TEXTURE7 = 0x84C7 GL_TEXTURE8 = 0x84C8 GL_TEXTURE9 = 0x84C9 GL_TEXTURE10 = 0x84CA GL_TEXTURE11 = 0x84CB GL_TEXTURE12 = 0x84CC GL_TEXTURE13 = 0x84CD GL_TEXTURE14 = 0x84CE GL_TEXTURE15 = 0x84CF GL_TEXTURE16 = 0x84D0 GL_TEXTURE17 = 0x84D1 GL_TEXTURE18 = 0x84D2 GL_TEXTURE19 = 0x84D3 GL_TEXTURE20 = 0x84D4 GL_TEXTURE21 = 0x84D5 GL_TEXTURE22 = 0x84D6 GL_TEXTURE23 = 0x84D7 GL_TEXTURE24 = 0x84D8 GL_TEXTURE25 = 0x84D9 GL_TEXTURE26 = 0x84DA GL_TEXTURE27 = 0x84DB GL_TEXTURE28 = 0x84DC GL_TEXTURE29 = 0x84DD GL_TEXTURE30 = 0x84DE GL_TEXTURE31 = 0x84DF GL_ACTIVE_TEXTURE = 0x84E0 GL_CLIENT_ACTIVE_TEXTURE = 0x84E1 GL_MAX_TEXTURE_UNITS = 0x84E2 --[[ texture_cube_map ]] GL_NORMAL_MAP = 0x8511 GL_REFLECTION_MAP = 0x8512 GL_TEXTURE_CUBE_MAP = 0x8513 GL_TEXTURE_BINDING_CUBE_MAP = 0x8514 GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515 GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516 GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518 GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A GL_PROXY_TEXTURE_CUBE_MAP = 0x851B GL_MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C --[[ texture_compression ]] GL_COMPRESSED_ALPHA = 0x84E9 GL_COMPRESSED_LUMINANCE = 0x84EA GL_COMPRESSED_LUMINANCE_ALPHA = 0x84EB GL_COMPRESSED_INTENSITY = 0x84EC GL_COMPRESSED_RGB = 0x84ED GL_COMPRESSED_RGBA = 0x84EE GL_TEXTURE_COMPRESSION_HINT = 0x84EF GL_TEXTURE_COMPRESSED_IMAGE_SIZE = 0x86A0 GL_TEXTURE_COMPRESSED = 0x86A1 GL_NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2 GL_COMPRESSED_TEXTURE_FORMATS = 0x86A3 --[[ multisample ]] GL_MULTISAMPLE = 0x809D GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E GL_SAMPLE_ALPHA_TO_ONE = 0x809F GL_SAMPLE_COVERAGE = 0x80A0 GL_SAMPLE_BUFFERS = 0x80A8 GL_SAMPLES = 0x80A9 GL_SAMPLE_COVERAGE_VALUE = 0x80AA GL_SAMPLE_COVERAGE_INVERT = 0x80AB GL_MULTISAMPLE_BIT = 0x20000000 --[[ transpose_matrix ]] GL_TRANSPOSE_MODELVIEW_MATRIX = 0x84E3 GL_TRANSPOSE_PROJECTION_MATRIX = 0x84E4 GL_TRANSPOSE_TEXTURE_MATRIX = 0x84E5 GL_TRANSPOSE_COLOR_MATRIX = 0x84E6 --[[ texture_env_combine ]] GL_COMBINE = 0x8570 GL_COMBINE_RGB = 0x8571 GL_COMBINE_ALPHA = 0x8572 GL_SOURCE0_RGB = 0x8580 GL_SOURCE1_RGB = 0x8581 GL_SOURCE2_RGB = 0x8582 GL_SOURCE0_ALPHA = 0x8588 GL_SOURCE1_ALPHA = 0x8589 GL_SOURCE2_ALPHA = 0x858A GL_OPERAND0_RGB = 0x8590 GL_OPERAND1_RGB = 0x8591 GL_OPERAND2_RGB = 0x8592 GL_OPERAND0_ALPHA = 0x8598 GL_OPERAND1_ALPHA = 0x8599 GL_OPERAND2_ALPHA = 0x859A GL_RGB_SCALE = 0x8573 GL_ADD_SIGNED = 0x8574 GL_INTERPOLATE = 0x8575 GL_SUBTRACT = 0x84E7 GL_CONSTANT = 0x8576 GL_PRIMARY_COLOR = 0x8577 GL_PREVIOUS = 0x8578 --[[ texture_env_dot3 ]] GL_DOT3_RGB = 0x86AE GL_DOT3_RGBA = 0x86AF --[[ texture_border_clamp ]] GL_CLAMP_TO_BORDER = 0x812D ffi.cdef[[ /* * Mesa 3-D graphics library * * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * Copyright (C) 2009 VMware, Inc. All Rights Reserved. * * 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. */ /* * Datatypes */ typedef unsigned int GLenum; typedef unsigned char GLboolean; typedef unsigned int GLbitfield; typedef void GLvoid; typedef signed char GLbyte; /* 1-byte signed */ typedef short GLshort; /* 2-byte signed */ typedef int GLint; /* 4-byte signed */ typedef unsigned char GLubyte; /* 1-byte unsigned */ typedef unsigned short GLushort; /* 2-byte unsigned */ typedef unsigned int GLuint; /* 4-byte unsigned */ typedef int GLsizei; /* 4-byte signed */ typedef float GLfloat; /* single precision float */ typedef float GLclampf; /* single precision float in [0,1] */ typedef double GLdouble; /* double precision float */ typedef double GLclampd; /* double precision float in [0,1] */ /* * Miscellaneous */ void glClearIndex( GLfloat c ); void glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); void glClear( GLbitfield mask ); void glIndexMask( GLuint mask ); void glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); void glAlphaFunc( GLenum func, GLclampf ref ); void glBlendFunc( GLenum sfactor, GLenum dfactor ); void glLogicOp( GLenum opcode ); void glCullFace( GLenum mode ); void glFrontFace( GLenum mode ); void glPointSize( GLfloat size ); void glLineWidth( GLfloat width ); void glLineStipple( GLint factor, GLushort pattern ); void glPolygonMode( GLenum face, GLenum mode ); void glPolygonOffset( GLfloat factor, GLfloat units ); void glPolygonStipple( const GLubyte *mask ); void glGetPolygonStipple( GLubyte *mask ); void glEdgeFlag( GLboolean flag ); void glEdgeFlagv( const GLboolean *flag ); void glScissor( GLint x, GLint y, GLsizei width, GLsizei height); void glClipPlane( GLenum plane, const GLdouble *equation ); void glGetClipPlane( GLenum plane, GLdouble *equation ); void glDrawBuffer( GLenum mode ); void glReadBuffer( GLenum mode ); void glEnable( GLenum cap ); void glDisable( GLenum cap ); GLboolean glIsEnabled( GLenum cap ); void glEnableClientState( GLenum cap ); /* 1.1 */ void glDisableClientState( GLenum cap ); /* 1.1 */ void glGetBooleanv( GLenum pname, GLboolean *params ); void glGetDoublev( GLenum pname, GLdouble *params ); void glGetFloatv( GLenum pname, GLfloat *params ); void glGetIntegerv( GLenum pname, GLint *params ); void glPushAttrib( GLbitfield mask ); void glPopAttrib( void ); void glPushClientAttrib( GLbitfield mask ); /* 1.1 */ void glPopClientAttrib( void ); /* 1.1 */ GLint glRenderMode( GLenum mode ); GLenum glGetError( void ); const GLubyte * glGetString( GLenum name ); void glFinish( void ); void glFlush( void ); void glHint( GLenum target, GLenum mode ); /* * Depth Buffer */ void glClearDepth( GLclampd depth ); void glDepthFunc( GLenum func ); void glDepthMask( GLboolean flag ); void glDepthRange( GLclampd near_val, GLclampd far_val ); /* * Accumulation Buffer */ void glClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); void glAccum( GLenum op, GLfloat value ); /* * Transformation */ void glMatrixMode( GLenum mode ); void glOrtho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val ); void glFrustum( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val ); void glViewport( GLint x, GLint y, GLsizei width, GLsizei height ); void glPushMatrix( void ); void glPopMatrix( void ); void glLoadIdentity( void ); void glLoadMatrixd( const GLdouble *m ); void glLoadMatrixf( const GLfloat *m ); void glMultMatrixd( const GLdouble *m ); void glMultMatrixf( const GLfloat *m ); void glRotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ); void glRotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ); void glScaled( GLdouble x, GLdouble y, GLdouble z ); void glScalef( GLfloat x, GLfloat y, GLfloat z ); void glTranslated( GLdouble x, GLdouble y, GLdouble z ); void glTranslatef( GLfloat x, GLfloat y, GLfloat z ); /* * Display Lists */ GLboolean glIsList( GLuint list ); void glDeleteLists( GLuint list, GLsizei range ); GLuint glGenLists( GLsizei range ); void glNewList( GLuint list, GLenum mode ); void glEndList( void ); void glCallList( GLuint list ); void glCallLists( GLsizei n, GLenum type, const GLvoid *lists ); void glListBase( GLuint base ); /* * Drawing Functions */ void glBegin( GLenum mode ); void glEnd( void ); void glVertex2d( GLdouble x, GLdouble y ); void glVertex2f( GLfloat x, GLfloat y ); void glVertex2i( GLint x, GLint y ); void glVertex2s( GLshort x, GLshort y ); void glVertex3d( GLdouble x, GLdouble y, GLdouble z ); void glVertex3f( GLfloat x, GLfloat y, GLfloat z ); void glVertex3i( GLint x, GLint y, GLint z ); void glVertex3s( GLshort x, GLshort y, GLshort z ); void glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); void glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); void glVertex4i( GLint x, GLint y, GLint z, GLint w ); void glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w ); void glVertex2dv( const GLdouble *v ); void glVertex2fv( const GLfloat *v ); void glVertex2iv( const GLint *v ); void glVertex2sv( const GLshort *v ); void glVertex3dv( const GLdouble *v ); void glVertex3fv( const GLfloat *v ); void glVertex3iv( const GLint *v ); void glVertex3sv( const GLshort *v ); void glVertex4dv( const GLdouble *v ); void glVertex4fv( const GLfloat *v ); void glVertex4iv( const GLint *v ); void glVertex4sv( const GLshort *v ); void glNormal3b( GLbyte nx, GLbyte ny, GLbyte nz ); void glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ); void glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz ); void glNormal3i( GLint nx, GLint ny, GLint nz ); void glNormal3s( GLshort nx, GLshort ny, GLshort nz ); void glNormal3bv( const GLbyte *v ); void glNormal3dv( const GLdouble *v ); void glNormal3fv( const GLfloat *v ); void glNormal3iv( const GLint *v ); void glNormal3sv( const GLshort *v ); void glIndexd( GLdouble c ); void glIndexf( GLfloat c ); void glIndexi( GLint c ); void glIndexs( GLshort c ); void glIndexub( GLubyte c ); /* 1.1 */ void glIndexdv( const GLdouble *c ); void glIndexfv( const GLfloat *c ); void glIndexiv( const GLint *c ); void glIndexsv( const GLshort *c ); void glIndexubv( const GLubyte *c ); /* 1.1 */ void glColor3b( GLbyte red, GLbyte green, GLbyte blue ); void glColor3d( GLdouble red, GLdouble green, GLdouble blue ); void glColor3f( GLfloat red, GLfloat green, GLfloat blue ); void glColor3i( GLint red, GLint green, GLint blue ); void glColor3s( GLshort red, GLshort green, GLshort blue ); void glColor3ub( GLubyte red, GLubyte green, GLubyte blue ); void glColor3ui( GLuint red, GLuint green, GLuint blue ); void glColor3us( GLushort red, GLushort green, GLushort blue ); void glColor4b( GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha ); void glColor4d( GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha ); void glColor4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); void glColor4i( GLint red, GLint green, GLint blue, GLint alpha ); void glColor4s( GLshort red, GLshort green, GLshort blue, GLshort alpha ); void glColor4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ); void glColor4ui( GLuint red, GLuint green, GLuint blue, GLuint alpha ); void glColor4us( GLushort red, GLushort green, GLushort blue, GLushort alpha ); void glColor3bv( const GLbyte *v ); void glColor3dv( const GLdouble *v ); void glColor3fv( const GLfloat *v ); void glColor3iv( const GLint *v ); void glColor3sv( const GLshort *v ); void glColor3ubv( const GLubyte *v ); void glColor3uiv( const GLuint *v ); void glColor3usv( const GLushort *v ); void glColor4bv( const GLbyte *v ); void glColor4dv( const GLdouble *v ); void glColor4fv( const GLfloat *v ); void glColor4iv( const GLint *v ); void glColor4sv( const GLshort *v ); void glColor4ubv( const GLubyte *v ); void glColor4uiv( const GLuint *v ); void glColor4usv( const GLushort *v ); void glTexCoord1d( GLdouble s ); void glTexCoord1f( GLfloat s ); void glTexCoord1i( GLint s ); void glTexCoord1s( GLshort s ); void glTexCoord2d( GLdouble s, GLdouble t ); void glTexCoord2f( GLfloat s, GLfloat t ); void glTexCoord2i( GLint s, GLint t ); void glTexCoord2s( GLshort s, GLshort t ); void glTexCoord3d( GLdouble s, GLdouble t, GLdouble r ); void glTexCoord3f( GLfloat s, GLfloat t, GLfloat r ); void glTexCoord3i( GLint s, GLint t, GLint r ); void glTexCoord3s( GLshort s, GLshort t, GLshort r ); void glTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ); void glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ); void glTexCoord4i( GLint s, GLint t, GLint r, GLint q ); void glTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ); void glTexCoord1dv( const GLdouble *v ); void glTexCoord1fv( const GLfloat *v ); void glTexCoord1iv( const GLint *v ); void glTexCoord1sv( const GLshort *v ); void glTexCoord2dv( const GLdouble *v ); void glTexCoord2fv( const GLfloat *v ); void glTexCoord2iv( const GLint *v ); void glTexCoord2sv( const GLshort *v ); void glTexCoord3dv( const GLdouble *v ); void glTexCoord3fv( const GLfloat *v ); void glTexCoord3iv( const GLint *v ); void glTexCoord3sv( const GLshort *v ); void glTexCoord4dv( const GLdouble *v ); void glTexCoord4fv( const GLfloat *v ); void glTexCoord4iv( const GLint *v ); void glTexCoord4sv( const GLshort *v ); void glRasterPos2d( GLdouble x, GLdouble y ); void glRasterPos2f( GLfloat x, GLfloat y ); void glRasterPos2i( GLint x, GLint y ); void glRasterPos2s( GLshort x, GLshort y ); void glRasterPos3d( GLdouble x, GLdouble y, GLdouble z ); void glRasterPos3f( GLfloat x, GLfloat y, GLfloat z ); void glRasterPos3i( GLint x, GLint y, GLint z ); void glRasterPos3s( GLshort x, GLshort y, GLshort z ); void glRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); void glRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); void glRasterPos4i( GLint x, GLint y, GLint z, GLint w ); void glRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w ); void glRasterPos2dv( const GLdouble *v ); void glRasterPos2fv( const GLfloat *v ); void glRasterPos2iv( const GLint *v ); void glRasterPos2sv( const GLshort *v ); void glRasterPos3dv( const GLdouble *v ); void glRasterPos3fv( const GLfloat *v ); void glRasterPos3iv( const GLint *v ); void glRasterPos3sv( const GLshort *v ); void glRasterPos4dv( const GLdouble *v ); void glRasterPos4fv( const GLfloat *v ); void glRasterPos4iv( const GLint *v ); void glRasterPos4sv( const GLshort *v ); void glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ); void glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ); void glRecti( GLint x1, GLint y1, GLint x2, GLint y2 ); void glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ); void glRectdv( const GLdouble *v1, const GLdouble *v2 ); void glRectfv( const GLfloat *v1, const GLfloat *v2 ); void glRectiv( const GLint *v1, const GLint *v2 ); void glRectsv( const GLshort *v1, const GLshort *v2 ); /* * Vertex Arrays (1.1) */ void glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); void glNormalPointer( GLenum type, GLsizei stride, const GLvoid *ptr ); void glColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); void glIndexPointer( GLenum type, GLsizei stride, const GLvoid *ptr ); void glTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); void glEdgeFlagPointer( GLsizei stride, const GLvoid *ptr ); void glGetPointerv( GLenum pname, GLvoid **params ); void glArrayElement( GLint i ); void glDrawArrays( GLenum mode, GLint first, GLsizei count ); void glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ); void glInterleavedArrays( GLenum format, GLsizei stride, const GLvoid *pointer ); /* * Lighting */ void glShadeModel( GLenum mode ); void glLightf( GLenum light, GLenum pname, GLfloat param ); void glLighti( GLenum light, GLenum pname, GLint param ); void glLightfv( GLenum light, GLenum pname, const GLfloat *params ); void glLightiv( GLenum light, GLenum pname, const GLint *params ); void glGetLightfv( GLenum light, GLenum pname, GLfloat *params ); void glGetLightiv( GLenum light, GLenum pname, GLint *params ); void glLightModelf( GLenum pname, GLfloat param ); void glLightModeli( GLenum pname, GLint param ); void glLightModelfv( GLenum pname, const GLfloat *params ); void glLightModeliv( GLenum pname, const GLint *params ); void glMaterialf( GLenum face, GLenum pname, GLfloat param ); void glMateriali( GLenum face, GLenum pname, GLint param ); void glMaterialfv( GLenum face, GLenum pname, const GLfloat *params ); void glMaterialiv( GLenum face, GLenum pname, const GLint *params ); void glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params ); void glGetMaterialiv( GLenum face, GLenum pname, GLint *params ); void glColorMaterial( GLenum face, GLenum mode ); /* * Raster functions */ void glPixelZoom( GLfloat xfactor, GLfloat yfactor ); void glPixelStoref( GLenum pname, GLfloat param ); void glPixelStorei( GLenum pname, GLint param ); void glPixelTransferf( GLenum pname, GLfloat param ); void glPixelTransferi( GLenum pname, GLint param ); void glPixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values ); void glPixelMapuiv( GLenum map, GLsizei mapsize, const GLuint *values ); void glPixelMapusv( GLenum map, GLsizei mapsize, const GLushort *values ); void glGetPixelMapfv( GLenum map, GLfloat *values ); void glGetPixelMapuiv( GLenum map, GLuint *values ); void glGetPixelMapusv( GLenum map, GLushort *values ); void glBitmap( GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap ); void glReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels ); void glDrawPixels( GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); void glCopyPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum type ); /* * Stenciling */ void glStencilFunc( GLenum func, GLint ref, GLuint mask ); void glStencilMask( GLuint mask ); void glStencilOp( GLenum fail, GLenum zfail, GLenum zpass ); void glClearStencil( GLint s ); /* * Texture mapping */ void glTexGend( GLenum coord, GLenum pname, GLdouble param ); void glTexGenf( GLenum coord, GLenum pname, GLfloat param ); void glTexGeni( GLenum coord, GLenum pname, GLint param ); void glTexGendv( GLenum coord, GLenum pname, const GLdouble *params ); void glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); void glTexGeniv( GLenum coord, GLenum pname, const GLint *params ); void glGetTexGendv( GLenum coord, GLenum pname, GLdouble *params ); void glGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ); void glGetTexGeniv( GLenum coord, GLenum pname, GLint *params ); void glTexEnvf( GLenum target, GLenum pname, GLfloat param ); void glTexEnvi( GLenum target, GLenum pname, GLint param ); void glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params ); void glTexEnviv( GLenum target, GLenum pname, const GLint *params ); void glGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ); void glGetTexEnviv( GLenum target, GLenum pname, GLint *params ); void glTexParameterf( GLenum target, GLenum pname, GLfloat param ); void glTexParameteri( GLenum target, GLenum pname, GLint param ); void glTexParameterfv( GLenum target, GLenum pname, const GLfloat *params ); void glTexParameteriv( GLenum target, GLenum pname, const GLint *params ); void glGetTexParameterfv( GLenum target, GLenum pname, GLfloat *params); void glGetTexParameteriv( GLenum target, GLenum pname, GLint *params ); void glGetTexLevelParameterfv( GLenum target, GLint level, GLenum pname, GLfloat *params ); void glGetTexLevelParameteriv( GLenum target, GLint level, GLenum pname, GLint *params ); void glTexImage1D( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); void glTexImage2D( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); void glGetTexImage( GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels ); /* 1.1 functions */ void glGenTextures( GLsizei n, GLuint *textures ); void glDeleteTextures( GLsizei n, const GLuint *textures); void glBindTexture( GLenum target, GLuint texture ); void glPrioritizeTextures( GLsizei n, const GLuint *textures, const GLclampf *priorities ); GLboolean glAreTexturesResident( GLsizei n, const GLuint *textures, GLboolean *residences ); GLboolean glIsTexture( GLuint texture ); void glTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels ); void glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); void glCopyTexImage1D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border ); void glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border ); void glCopyTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width ); void glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height ); /* * Evaluators */ void glMap1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points ); void glMap1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points ); void glMap2d( GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points ); void glMap2f( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points ); void glGetMapdv( GLenum target, GLenum query, GLdouble *v ); void glGetMapfv( GLenum target, GLenum query, GLfloat *v ); void glGetMapiv( GLenum target, GLenum query, GLint *v ); void glEvalCoord1d( GLdouble u ); void glEvalCoord1f( GLfloat u ); void glEvalCoord1dv( const GLdouble *u ); void glEvalCoord1fv( const GLfloat *u ); void glEvalCoord2d( GLdouble u, GLdouble v ); void glEvalCoord2f( GLfloat u, GLfloat v ); void glEvalCoord2dv( const GLdouble *u ); void glEvalCoord2fv( const GLfloat *u ); void glMapGrid1d( GLint un, GLdouble u1, GLdouble u2 ); void glMapGrid1f( GLint un, GLfloat u1, GLfloat u2 ); void glMapGrid2d( GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2 ); void glMapGrid2f( GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2 ); void glEvalPoint1( GLint i ); void glEvalPoint2( GLint i, GLint j ); void glEvalMesh1( GLenum mode, GLint i1, GLint i2 ); void glEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); /* * Fog */ void glFogf( GLenum pname, GLfloat param ); void glFogi( GLenum pname, GLint param ); void glFogfv( GLenum pname, const GLfloat *params ); void glFogiv( GLenum pname, const GLint *params ); /* * Selection and Feedback */ void glFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ); void glPassThrough( GLfloat token ); void glSelectBuffer( GLsizei size, GLuint *buffer ); void glInitNames( void ); void glLoadName( GLuint name ); void glPushName( GLuint name ); void glPopName( void ); void glDrawRangeElements( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices ); void glTexImage3D( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); void glTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); void glCopyTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ); typedef void ( PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); typedef void ( PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); typedef void ( PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); typedef void ( PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); void glColorTable( GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table ); void glColorSubTable( GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data ); void glColorTableParameteriv(GLenum target, GLenum pname, const GLint *params); void glColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params); void glCopyColorSubTable( GLenum target, GLsizei start, GLint x, GLint y, GLsizei width ); void glCopyColorTable( GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width ); void glGetColorTable( GLenum target, GLenum format, GLenum type, GLvoid *table ); void glGetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ); void glGetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ); void glBlendEquation( GLenum mode ); void glBlendColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); void glHistogram( GLenum target, GLsizei width, GLenum internalformat, GLboolean sink ); void glResetHistogram( GLenum target ); void glGetHistogram( GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values ); void glGetHistogramParameterfv( GLenum target, GLenum pname, GLfloat *params ); void glGetHistogramParameteriv( GLenum target, GLenum pname, GLint *params ); void glMinmax( GLenum target, GLenum internalformat, GLboolean sink ); void glResetMinmax( GLenum target ); void glGetMinmax( GLenum target, GLboolean reset, GLenum format, GLenum types, GLvoid *values ); void glGetMinmaxParameterfv( GLenum target, GLenum pname, GLfloat *params ); void glGetMinmaxParameteriv( GLenum target, GLenum pname, GLint *params ); void glConvolutionFilter1D( GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image ); void glConvolutionFilter2D( GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image ); void glConvolutionParameterf( GLenum target, GLenum pname, GLfloat params ); void glConvolutionParameterfv( GLenum target, GLenum pname, const GLfloat *params ); void glConvolutionParameteri( GLenum target, GLenum pname, GLint params ); void glConvolutionParameteriv( GLenum target, GLenum pname, const GLint *params ); void glCopyConvolutionFilter1D( GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width ); void glCopyConvolutionFilter2D( GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); void glGetConvolutionFilter( GLenum target, GLenum format, GLenum type, GLvoid *image ); void glGetConvolutionParameterfv( GLenum target, GLenum pname, GLfloat *params ); void glGetConvolutionParameteriv( GLenum target, GLenum pname, GLint *params ); void glSeparableFilter2D( GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column ); void glGetSeparableFilter( GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span ); void glActiveTexture( GLenum texture ); void glClientActiveTexture( GLenum texture ); void glCompressedTexImage1D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data ); void glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ); void glCompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data ); void glCompressedTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data ); void glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data ); void glCompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data ); void glGetCompressedTexImage( GLenum target, GLint lod, GLvoid *img ); void glMultiTexCoord1d( GLenum target, GLdouble s ); void glMultiTexCoord1dv( GLenum target, const GLdouble *v ); void glMultiTexCoord1f( GLenum target, GLfloat s ); void glMultiTexCoord1fv( GLenum target, const GLfloat *v ); void glMultiTexCoord1i( GLenum target, GLint s ); void glMultiTexCoord1iv( GLenum target, const GLint *v ); void glMultiTexCoord1s( GLenum target, GLshort s ); void glMultiTexCoord1sv( GLenum target, const GLshort *v ); void glMultiTexCoord2d( GLenum target, GLdouble s, GLdouble t ); void glMultiTexCoord2dv( GLenum target, const GLdouble *v ); void glMultiTexCoord2f( GLenum target, GLfloat s, GLfloat t ); void glMultiTexCoord2fv( GLenum target, const GLfloat *v ); void glMultiTexCoord2i( GLenum target, GLint s, GLint t ); void glMultiTexCoord2iv( GLenum target, const GLint *v ); void glMultiTexCoord2s( GLenum target, GLshort s, GLshort t ); void glMultiTexCoord2sv( GLenum target, const GLshort *v ); void glMultiTexCoord3d( GLenum target, GLdouble s, GLdouble t, GLdouble r ); void glMultiTexCoord3dv( GLenum target, const GLdouble *v ); void glMultiTexCoord3f( GLenum target, GLfloat s, GLfloat t, GLfloat r ); void glMultiTexCoord3fv( GLenum target, const GLfloat *v ); void glMultiTexCoord3i( GLenum target, GLint s, GLint t, GLint r ); void glMultiTexCoord3iv( GLenum target, const GLint *v ); void glMultiTexCoord3s( GLenum target, GLshort s, GLshort t, GLshort r ); void glMultiTexCoord3sv( GLenum target, const GLshort *v ); void glMultiTexCoord4d( GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q ); void glMultiTexCoord4dv( GLenum target, const GLdouble *v ); void glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ); void glMultiTexCoord4fv( GLenum target, const GLfloat *v ); void glMultiTexCoord4i( GLenum target, GLint s, GLint t, GLint r, GLint q ); void glMultiTexCoord4iv( GLenum target, const GLint *v ); void glMultiTexCoord4s( GLenum target, GLshort s, GLshort t, GLshort r, GLshort q ); void glMultiTexCoord4sv( GLenum target, const GLshort *v ); void glLoadTransposeMatrixd( const GLdouble m[16] ); void glLoadTransposeMatrixf( const GLfloat m[16] ); void glMultTransposeMatrixd( const GLdouble m[16] ); void glMultTransposeMatrixf( const GLfloat m[16] ); void glSampleCoverage( GLclampf value, GLboolean invert ); typedef void ( PFNGLACTIVETEXTUREPROC) (GLenum texture); typedef void ( PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); typedef void ( PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); typedef void ( PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); typedef void ( PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); typedef void ( PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); typedef void ( PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); typedef void ( PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); typedef void ( PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); ]]
return { -- Called when someone/something was kicked from a team. -- Contains: -- player_index :: uint: The kicked player. -- kicker :: uint or nil: A player/server/script who kicked the player. on_kick = script.generate_event_name() }
ClassTrainerPlusWarriorSpellIds = { -- Protection 100,772,6343,1715,284,6546,7384,285,694,8198,6547,20230,1608,6178,7400,7887,8204,6548,7372,11564,7402,8205,11565,11572,11584,11578,20559,11566,21551,11580,11573,7373,21552,11567,20560,3127,674,6673,5242,1160,845,6192,5246,6190,5308,1161,7369,1464,11549,18499,20658,11554,1680,6552,8820,11608,20660,11550,20616,11555,11604,23892,20661,11609,1719,11551,20617,23893,11556,11605,20662,6554,750,2687,72,6572,2565,676,12678,7405,6574,871,1671,7379,8380,11600,11596,23923,1672,11601,23924,11597,30016,25288,23925,25269,29704,23920,25258,25225,30022,3411,30357,30356, -- Arms 11581,25286,21553,11585,11574,25266,29707,25248,25212,25264,25208,30330, -- Fury 25289,23894,20569,30030,25272,25241,25202,34428,25234,25251,25231,469,2048,25275,25242,30335,25203,25236,30033, }
----------------------------------------------------------------------------- -- DailyNotes - Main Dialog ----------------------------------------------------------------------------- local Nyx = LibStub("Nyx") local DailyNotes = _G.DailyNotes local MAX_LIST_ENTRIES = 15 local function SetHeaderText(this,text) this:SetText(text) this:SetWidth(this:GetTextWidth() + 8) end function DailyNotes.InitDialog() UIPanelBackdropFrame_SetTexture( DailyNotesFrame, "Interface/Common/PanelCommonFrame", 256 , 256 ) DailyNotesFrameTitle:SetText("DailyNotes |cffa0a000"..DailyNotes.VERSION) SetHeaderText(DailyNotesListCountHeader,DailyNotes.L.DN_F_COUNT) SetHeaderText(DailyNotesListTargetHeader,DailyNotes.L.DN_F_TARGET) SetHeaderText(DailyNotesListNameHeader,DailyNotes.L.DN_F_NAME) SetHeaderText(DailyNotesListLevelHeader,DailyNotes.L.DN_F_LEVEL) SetHeaderText(DailyNotesListZoneHeader,DailyNotes.L.DN_F_ZONE) SetHeaderText(DailyNotesListItemHeader,DailyNotes.L.DN_F_ITEM) SetHeaderText(DailyNotesListREW1Header,DailyNotes.L.DN_F_REW1) SetHeaderText(DailyNotesListREW2Header,DailyNotes.L.DN_F_REW2) DailyNotesDailyCount:SetText(DailyNotes.L.DN_F_DAILIES) DailyNotesDailyFinished:SetText(DailyNotes.L.DN_F_FINISHED) DNFFilterZoneDropDownLabel:SetText(DailyNotes.L.DN_F_C_ZONE) DailyNotesAutoQuestTake:SetText(DailyNotes.L.DN_F_Q_TAKE) DailyNoteAQAll:SetText(DailyNotes.L.DN_F_Q_ALL) DailyNoteAQClear:SetText(DailyNotes.L.DN_F_Q_NONE) DailyNoteAQKill:SetText(DailyNotes.L.DN_F_Q_KILL) DailyNoteAQGather:SetText(DailyNotes.L.DN_F_Q_GATHER) DailyNoteOptions:SetText(DailyNotes.L.DN_F_Q_OPTIONS) end DailyNotes.fct_compare={ -- count function (a,b) return a[4]>b[4] end, -- target function (a,b) return false end, -- name function (a,b) return TEXT("Sys"..a[1].."_name")<TEXT("Sys"..b[1].."_name") end, -- level function (a,b) if DN_Options.showcharlevel then return a[2].rlvl>b[2].rlvl end return a[2].lvl>b[2].lvl end, -- zone function (a,b) return GetZoneLocalName(a[2].zone)<GetZoneLocalName(b[2].zone) end, -- item function (a,b) return DailyNotes.GetQuestItemName(a[2])<DailyNotes.GetQuestItemName(b[2]) end, -- xp function (a,b) return a[2].rew[1]>b[2].rew[1] end, -- energy function (a,b) return (a[2].rew[4] or 0)>(b[2].rew[4] or 0) end, } function DailyNotes.GetQuestItemName(qdata) local itemid = next(qdata.items or {}) if itemid then return TEXT("Sys"..itemid.."_name") end local mobid = next(qdata.mobs or {}) if mobid then return DailyNotes.GetNPCInfo(mobid) end return "" end --------------------------------- function DailyNotes.UpdateList() local filter = DailyNotes.BuildFilterFunction() -- Get filtered list DailyNotes.view_lines={} local total_finished_count =0 for QID,qdata in pairs(DailyNotes.DB_Quests) do local finished, itemcounts, count = DailyNotes.GetQuestItems_FromTempTable(qdata) total_finished_count = total_finished_count + finished if filter(QID,qdata) then table.insert(DailyNotes.view_lines,{QID,qdata,finished,count,itemcounts}) end end -- Sort if DN_Options.Sort and DN_Options.Sort<0 and DailyNotes.fct_compare[-DN_Options.Sort] then table.sort(DailyNotes.view_lines, function (a,b) return DailyNotes.fct_compare[-DN_Options.Sort](b,a) end) else table.sort(DailyNotes.view_lines, DailyNotes.fct_compare[DN_Options.Sort] or DailyNotes.fct_compare[1]) end -- Update view if #DailyNotes.view_lines > MAX_LIST_ENTRIES then DailyNotesListScrollBar:Show() DailyNotesListScrollBar:SetMinMaxValues(0, #DailyNotes.view_lines-MAX_LIST_ENTRIES) else DailyNotesListScrollBar:Hide() DailyNotesListScrollBar:SetMinMaxValues(0, 0) end -- Quests total; finished quest DailyNotesListSize:SetText(#DailyNotes.view_lines.." / ".. DailyNotes.Quest_count) DailyNotesFinAble:SetText(total_finished_count) DailyNotes.UpdateListView() end function DailyNotes.GetQuestItems_FromTempTable(qudata) if not qudata then return end if not qudata.items then return 0,{},0 end local itemcounts = {} local max_completed=nil local finish_able local total=0 for iid,count in pairs(qudata.items) do local icount = DailyNotes.item_counts[iid] or 0 itemcounts[iid] = icount finish_able = math.floor(icount/count) total = total + icount if not max_completed or finish_able<max_completed then max_completed = finish_able end end return max_completed,itemcounts,total end function DailyNotes.BuildFilterFunction() local filter = { "return function(QID,qdata)"} DN_Options.filter = DN_Options.filter or {} -- Zone local nzone_filter = DN_Char_Options.FilterZone or -3 if nzone_filter == -3 then nzone_filter = GetCurrentWorldMapID() end if nzone_filter~= -2 then table.insert(filter, string.format("if qdata.zone~=%i and qdata.zone~=DailyNotes.DB_Zones[%i] and %i~=DailyNotes.DB_Zones[qdata.zone] then return false end", nzone_filter, nzone_filter, nzone_filter)) end -- Undone if DN_Options.filter.undone then table.insert(filter,"if CheckQuest(QID)==1 or CheckQuest(QID)==2 then return false end") end -- level local mlvl, slvl = Nyx.GetPlayerLevel() if DN_Options.filter.main then table.insert(filter,string.format("if qdata.rlvl>%i then return false end ", mlvl)) end if DN_Options.filter.sec then table.insert(filter, string.format("if qdata.lvl>%i and (qdata.rlvl>%i or qdata.lvl-10>%i) then return false end ", slvl, mlvl,slvl)) end -- type table.insert(filter,"local typ = qdata.typ%10") table.insert(filter,"local ispublic = (qdata.rew[4] and qdata.rew[4]>0)") if not DN_Options.filter.repeatable then table.insert(filter,"if typ==3 then return false end") end if not DN_Options.filter.epic then table.insert(filter,"if typ==6 then return false end") end if not DN_Options.filter.public then table.insert(filter,"if ispublic then return false end") end if not DN_Options.filter.daily then table.insert(filter,"if not (typ==3 or typ==6 or ispublic) then return false end") end if not DN_Options.filter.energy then table.insert(filter,"if qdata.rew[4]~=nil and qdata.rew[4]>0 then return false end") end if not DN_Options.filter.xp then table.insert(filter,"if qdata.rew[1]>0 then return false end") end -- item count if DN_Options.filter.finished or DN_Options.filter.started then table.insert(filter,"local finished,_,count = DailyNotes.GetQuestItems_FromTempTable(qdata)") if DN_Options.filter.finished then table.insert(filter,"if finished==0 then return false end") end if DN_Options.filter.started then table.insert(filter,"if count==0 then return false end") end end table.insert(filter,"return true end") local f,msg = loadstring(table.concat(filter," ")) assert(f,msg) return f() end function DailyNotes.List_Header_OnClick(this) local id = this:GetID() DailyNotesListCountHeaderSortIcon:SetFile(""); DailyNotesListTargetHeaderSortIcon:SetFile(""); DailyNotesListLevelHeaderSortIcon:SetFile(""); DailyNotesListNameHeaderSortIcon:SetFile(""); DailyNotesListZoneHeaderSortIcon:SetFile(""); DailyNotesListItemHeaderSortIcon:SetFile(""); DailyNotesListREW1HeaderSortIcon:SetFile(""); DailyNotesListREW2HeaderSortIcon:SetFile(""); if(DN_Options.Sort == id or DN_Options.Sort == -id ) then DN_Options.Sort = -DN_Options.Sort else DN_Options.Sort = id; end if DN_Options.Sort>0 then getglobal(this:GetName() .. "SortIcon"):SetFile("Interface/chatframe/chatframe-scrollbar-buttondown") else getglobal(this:GetName() .. "SortIcon"):SetFile("Interface/chatframe/chatframe-scrollbar-buttonup") end DailyNotes.UpdateList() end ---------------------------- function DailyNotes.OnShow() DailyNotes.item_counts = Nyx.GetBagItemCounts() -- set zone local zone_text="" local zonenum = DN_Char_Options.FilterZone or -3 if zonenum==-2 then zone_text=DailyNotes.L.ZONE_ALL elseif zonenum==-3 then zone_text=DailyNotes.L.ZONE_CUR else if zonenum == 670 then zone_text = DailyNotes.L.ZONE_YLAB else zone_text=GetZoneLocalName(zonenum) end end UIDropDownMenu_SetSelectedName(DNFFilterZoneDropDown, zone_text) DNFFilterZoneDropDownText:SetText(zone_text) DailyNotesAutoQuest:SetChecked(DN_Char_Options.autoquest) DailyNotes.UpdateAQButtons() DailyNotes.UpdateList() end function DailyNotes.OnHide() DailyNotes.view_lines=nil DailyNotes.item_counts=nil end ---------------------------- function DailyNotes.UpdateListView() local index = DailyNotesListScrollBar:GetValue() local mlvl = Nyx.GetPlayerLevel() local button,QID,qdata,qname for i = 1, MAX_LIST_ENTRIES do button = getglobal("DailyNotesListItem"..i); if DailyNotes.view_lines[index+i] then QID = DailyNotes.view_lines[index+i][1] qdata = DailyNotes.view_lines[index+i][2] qname = TEXT("Sys"..QID.."_name") buttonName = button:GetName(); local _,count, target = DailyNotes.MakeItemCountString(qdata,DailyNotes.view_lines[index+i][5]) _G[buttonName.."Counter"]:SetText(count) _G[buttonName.."Target"]:SetText(target) if not count and not target then _G[buttonName.."Splitter"]:Hide() else _G[buttonName.."Splitter"]:Show() end if DN_Options.showcharlevel then getglobal(buttonName.."Level"):SetText(qdata.rlvl) else getglobal(buttonName.."Level"):SetText(qdata.lvl) end getglobal(buttonName.."Name"):SetText(qname) getglobal(buttonName.."Zone"):SetText(GetZoneLocalName(qdata.zone)) getglobal(buttonName.."Item"):SetText(DailyNotes.GetQuestItemName(qdata)) getglobal(buttonName.."REW1"):SetText(qdata.rew[1]) getglobal(buttonName.."REW2"):SetText(qdata.rew[4] or "") -- icon if (math.floor(qdata.typ/10)%2)==1 then getglobal(buttonName.."IconOnce"):Show() else getglobal(buttonName.."IconOnce"):Hide() end local typ = qdata.typ%10 if typ==2 then getglobal(buttonName.."Icon"):SetTexCoord(0.25, 0.375,0,1) -- kill elseif typ==4 then getglobal(buttonName.."Icon"):SetTexCoord(0.375,0.5, 0,1) -- gather elseif typ==6 then getglobal(buttonName.."Icon"):SetTexCoord(0.626,0.76, 0,1) -- epic else getglobal(buttonName.."Icon"):SetTexCoord(0.125,0.25, 0,1) -- normal end -- QuestStatus local cq = CheckQuest(QID) local icondone = getglobal(buttonName.."IconDone") if cq==1 then icondone:Show() -- open icondone:SetTexCoord(0.5, 0.5625,0,1) elseif cq==2 then icondone:Hide() -- done else icondone:Show() -- not done icondone:SetTexCoord(0.5625, 0.625,0,1) end -- color r,g,b=1,1,1 if DailyNotes.view_lines[index+i][3]>0 then r,g,b=0,1,0 -- FINISHED elseif DailyNotes.GetRequiredPreQuest(qdata) then r,g,b=1,0.3,0.3 -- PRE.QUEST elseif DN_Options.debug and qdata.typ>20 then r,g,b=1,0,1 -- NEED TEST elseif mlvl<qdata.rlvl then r,g,b=0.6,0.6,0.6 end getglobal(buttonName.."Counter"):SetColor(r,g,b) getglobal(buttonName.."Target"):SetColor(r,g,b) getglobal(buttonName.."Level"):SetColor(r,g,b) getglobal(buttonName.."Name"):SetColor(r,g,b) getglobal(buttonName.."Zone"):SetColor(r,g,b) getglobal(buttonName.."Item"):SetColor(r,g,b) getglobal(buttonName.."REW1"):SetColor(r,g,b) getglobal(buttonName.."REW2"):SetColor(r,g,b) if DN_Char_Options.autoquest then getglobal(buttonName.."Check"):Show() getglobal(buttonName.."Check"):SetChecked(DailyNotes.SF_IsAnAutoQuest(QID)) else getglobal(buttonName.."Check"):Hide() end button:Show() else button:Hide() end end DailyNotes.List_UpdateDoAble() if DailyNotes.cur_highlit then local c = DailyNotes.cur_highlit DailyNotes.List_Item_OnLeave(c) DailyNotes.List_Item_OnEnter(c) end end ------------ -- List tooltip function DailyNotes.List_Item_OnEnter(this) if not DN_Options.TT_dialog then return end DailyNotes.cur_highlit = this local highlightText = getglobal(this:GetName().."Highlight") highlightText:SetColor(1, 1, 0) highlightText:Show() local index = DailyNotesListScrollBar:GetValue() + this:GetID() if not DailyNotes.view_lines[index] then return end local QID = DailyNotes.view_lines[index][1] local qdata = DailyNotes.view_lines[index][2] DailyNotes.InDialogTT = true -- Show the tooltip GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT", 0, -16) -------------------------------- -- Quest with Item if qdata.items then local itemid,_ = next(qdata.items) GameTooltip.QID = QID GameTooltip:SetHyperLink( Nyx.CreateItemLink( itemid ) ) GameTooltip:Show() GameTooltip.QID = nil -------------------------------- -- Quest with Mobs elseif qdata.mobs then GameTooltip:SetText("") local first=true for mobid,mobcount in pairs(qdata.mobs or {}) do if first then GameTooltip:SetText(DailyNotes.GetNPCInfo(mobid)) GameTooltip:AddLine("") first = nil else GameTooltip:AddLine("+ " .. DailyNotes.GetNPCInfo(mobid)) end local qtaker = DailyNotes.GetQuestTaker(qdata) GameTooltip:AddLine(string.format(DailyNotes.L.KILLCOUNT, mobcount, DailyNotes.GetNPCInfo(qtaker))) -- "10 for taker" end DailyNotes.AppendQuestName(GameTooltip, QID, qdata) DailyNotes.AppendQuestNPC(GameTooltip, qdata) DailyNotes.AppendQuestText(GameTooltip, QID) DailyNotes.AppendReward(GameTooltip, qdata) DailyNotes.AppendPrequest(GameTooltip, qdata) DailyNotes.AppendInvolvedMobs(GameTooltip, qdata) -- Debug flag if DN_Options.debug and qdata.typ>20 then GameTooltip:AddLine( "|cffff0000(--UNTESTED-- Plz report)") end GameTooltip:Show() -------------------------------- -- No mob or item else GameTooltip:SetText("") DailyNotes.AppendQuestName(GameTooltip, QID, qdata) DailyNotes.AppendQuestNPC(GameTooltip, qdata) DailyNotes.AppendQuestText(GameTooltip, QID) DailyNotes.AppendReward(GameTooltip, qdata) DailyNotes.AppendPrequest(GameTooltip, qdata) GameTooltip:Show() -- Debug flag if DN_Options.debug and qdata.typ>20 then GameTooltip:AddLine( "|cffff0000(--UNTESTED-- Plz report)") end end DailyNotes.InDialogTT = nil end function DailyNotes.List_Item_OnLeave(this) DailyNotes.cur_highlit = nil local highlightText = getglobal(this:GetName().."Highlight") highlightText:SetColor(1, 1, 1) highlightText:Hide() GameTooltip:Hide() end ------------ -- List Context menu function DailyNotes.List_Item_OnClick(this, key) if( key == "RBUTTON" or key == "LBUTTON")then GameTooltip:Hide() DNFrameItemMenu.ItemIndex = DailyNotesListScrollBar:GetValue() + this:GetID() local QID = DailyNotes.view_lines[DNFrameItemMenu.ItemIndex][1] ToggleDropDownMenu(DNFrameItemMenu, 1,TEXT("Sys"..QID.."_name"),"cursor", 1 ,1 ); end end function DailyNotes.ContextFindNPC( id ) ShowUIPanel( NpcTrackFrame ) NpcTrackFrame_InitializeNpcList(id) NpcTrackFrame:ResetFrameOrder() --NpcTrackFrame_QuickTrackByNpcID(id) end function DailyNotes.ShowContextMenu( this ) local info = {}; if( UIDROPDOWNMENU_MENU_LEVEL == 1 and this.ItemIndex ) then local QID = DailyNotes.view_lines[this.ItemIndex][1] local qdata = DailyNotes.view_lines[this.ItemIndex][2] -- Start NPC local qtaker = DailyNotes.GetQuestTaker(qdata) local last_start = nil local givers = qdata.giver or {} if type(givers)=="number" then givers={givers} end for _,value in ipairs(givers) do local n_name,n_map,n_posx,n_posy = DailyNotes.GetNPCInfo(value) if n_name ~= last_start then if value == qtaker then qtaker = nil info = {} info.text = DailyNotes.L.FIND_NPC..n_name info.notCheckable = 1 info.func = function() DailyNotes.ContextFindNPC( value ) end info.value = 1 UIDropDownMenu_AddButton(info) else info = {} info.text = DailyNotes.L.FIND_START..n_name info.notCheckable = 1 info.func = function() DailyNotes.ContextFindNPC( value ) end info.value = 1 UIDropDownMenu_AddButton(info) end last_start = n_name end end for mobid,val in pairs(qdata.mobs or {}) do if mobid and type(mobid)=="number" and ( NpcTrack_SearchNpcByDBID( mobid ) >0 )then local _, n_name, _, _, _ = NpcTrack_GetNpc(1) info = {} info.text = DailyNotes.L.FIND_MOB..n_name info.notCheckable = 1 info.func = function() DailyNotes.ContextFindNPC( mobid ) end info.value = 1 UIDropDownMenu_AddButton(info) end end -- reward npc if qtaker then local n_name,n_map,n_posx,n_posy = DailyNotes.GetNPCInfo(qtaker) info = {} info.text = DailyNotes.L.FIND_END..n_name info.notCheckable = 1 info.func = function() DailyNotes.ContextFindNPC( qtaker ) end info.value = 1 UIDropDownMenu_AddButton(info) end info = {} info.text = TEXT("C_CANCEL") info.notCheckable = 1 info.func = function() end info.value = 6 UIDropDownMenu_AddButton(info) end end ------------ -- zone filter function DailyNotes.FZoneDropDown_OnLoad(this) UIDropDownMenu_SetWidth(this, 100) UIDropDownMenu_Initialize(this, DailyNotes.FZoneDropDown_Show) end local function IsInZone(zone, parent) if zone==parent then return true end local p = DailyNotes.DB_Zones[zone] if not p then return false end if p==parent then return true end return IsInZone(p, parent) end function DailyNotes.FZoneDropDown_Show() local info local zonenum = DN_Char_Options.FilterZone or -3 if( UIDROPDOWNMENU_MENU_LEVEL == 1 ) then info = {} info.func = DailyNotes.FilterZoneDropDown_Click info.text = DailyNotes.L.ZONE_ALL info.value = -2 info.textR = 1 info.textG = 1 info.textB = 0 info.checked = zonenum==info.value UIDropDownMenu_AddButton(info) info = {} info.func = DailyNotes.FilterZoneDropDown_Click info.text = DailyNotes.L.ZONE_CUR info.value = -3 info.textR = 1 info.textG = 1 info.textB = 0 info.checked = zonenum==info.value UIDropDownMenu_AddButton(info) info = {} info.text = TEXT("ZONE_YGGNO LAND") info.hasArrow = 1 info.value = 9998 info.checked = zonenum==info.value UIDropDownMenu_AddButton(info) info = {} info.text = TEXT("ZONE_SAVILLEPLAINS") info.hasArrow = 1 info.value = 9997 info.checked = zonenum==info.value UIDropDownMenu_AddButton(info) info = {} info.text = TEXT("SC_BALANZASAR") info.hasArrow = 1 info.value = 9996 info.checked = zonenum==info.value UIDropDownMenu_AddButton(info) info = {} info.text = TEXT("SC_GDDR_00") info.hasArrow = 1 info.value = 9995 info.checked = zonenum==info.value UIDropDownMenu_AddButton(info) info = {} info.text = TEXT("ZONE_KOLYDIA") info.hasArrow = 1 info.value = 9994 info.checked = zonenum==info.value UIDropDownMenu_AddButton(info) info = {} info.text = TEXT("UI_WORLDMAP_OTHER") info.hasArrow = 1 info.value = 9999 info.checked = zonenum==info.value UIDropDownMenu_AddButton(info) elseif( UIDROPDOWNMENU_MENU_LEVEL == 2 ) then local p_zone = UIDROPDOWNMENU_MENU_VALUE local zones={} local zones_in={} for _,d in pairs(DailyNotes.DB_Quests) do if not zones_in[d.zone] and IsInZone(d.zone, p_zone) then zones_in[d.zone]=1 table.insert(zones,{d.zone,GetZoneLocalName(d.zone) or ""}) end end -- ystra-lab if p_zone==9998 then table.insert(zones,{670,DailyNotes.L.ZONE_YLAB}) end table.sort(zones,function (a,b) return a[2]<b[2] end) for _,n in ipairs(zones) do info = {} info.func = DailyNotes.FilterZoneDropDown_Click info.text = n[2] info.value= n[1] info.checked = zonenum==info.value UIDropDownMenu_AddButton(info,2) end end end function DailyNotes.FilterZoneDropDown_Click(button) UIDropDownMenu_SetSelectedValue(DNFFilterZoneDropDown, button.value) DNFFilterZoneDropDownText:SetText(button:GetText()) DN_Char_Options.FilterZone = button.value DailyNotes.UpdateList() CloseDropDownMenus() end function DailyNotes.FilterOptionsMenu_OnLoad(this) UIDropDownMenu_Initialize( this, DailyNotes.FilterOptionsMenu_OnShow, "MENU") end function DailyNotes.FilterOptionsMenu_OnShow(this) local function add(value,title,tooltip) local info = {} info.value=value info.text = title info.tooltipText = tooltip info.checked = DN_Options.filter[info.value] info.func = DailyNotes.FilterOptionsMenu_OnClick info.keepShownOnClick = 1 UIDropDownMenu_AddButton(info, 1) end if UIDROPDOWNMENU_MENU_LEVEL == 1 then local seperator = {} seperator.text = '---------------' seperator.isTitle = 1 add("main", DailyNotes.L.F_MAINCHAR, DailyNotes.L.T_LVL1) add("sec", DailyNotes.L.F_SECCHAR, DailyNotes.L.T_LVL2) UIDropDownMenu_AddButton(seperator, 1) add("finished", DailyNotes.L.COUNT_FIN) add("started", DailyNotes.L.COUNT_START) UIDropDownMenu_AddButton(seperator, 1) add("repeatable", DailyNotes.L.REPEATABLE) add("epic", DailyNotes.L.EPIC) add("daily", DailyNotes.L.DAILY) add("public", DailyNotes.L.PUBLIC) UIDropDownMenu_AddButton(seperator, 1) add("undone", DailyNotes.L.UNDONE) UIDropDownMenu_AddButton(seperator, 1) add("energy", DailyNotes.L.FILTER_ENERGY) add("xp", DailyNotes.L.FILTER_XP) UIDropDownMenu_AddButton(seperator, 1) local info = {} info.text = DailyNotes.L.FILTER_CLEAR info.textR = 1 info.textG = 1 info.textB = 0.5 info.func = function () DN_Options.filter = { repeatable=true, epic=true, daily=true, public=true, energy=true, xp=true} DailyNotes.UpdateList() end UIDropDownMenu_AddButton(info, 1) end end function DailyNotes.FilterOptionsMenu_Validate(hint) local function are_all_disable(group) for _,opt in ipairs(group) do if DN_Options.filter[opt] then return false end end return true end local groups= { {"repeatable","epic","daily","public"}, --{"energy", "xp"}, } local changed=false for _,group in ipairs(groups) do if are_all_disable(group) then for _,opt in ipairs(group) do if opt ~= hint then DN_Options.filter[opt] = true changed = true end end end end return changed end function DailyNotes.FilterOptionsMenu_OnClick(button) if button.value then DN_Options.filter[button.value] = not DN_Options.filter[button.value] if DailyNotes.FilterOptionsMenu_Validate(button.value)then button:GetParent():Hide() end DailyNotes.UpdateList() end end ------------ -- AutoQuest function DailyNotes.AutoQuest(btn) DN_Char_Options.autoquest = DailyNotesAutoQuest:IsChecked() DailyNotes.UpdateAQButtons() DailyNotes.UpdateListView() end function DailyNotes.UpdateAQButtons() if DN_Char_Options.autoquest then DailyNoteAQClear:Show() DailyNoteAQAll:Show() DailyNoteAQKill:Show() DailyNoteAQGather:Show() DailyNoteAQKill:UnlockPushed() DailyNoteAQGather:UnlockPushed() -- check for 'all kill' and 'all gather' DailyNotes.AQ_AllKillMarked=1 DailyNotes.AQ_AllGatherMarked=1 if DN_Char_Options.aq_accept then for QID,qdata in pairs(DailyNotes.DB_Quests) do if (qdata.typ%10)==2 then DailyNotes.AQ_AllKillMarked = DN_Char_Options.aq_accept[QID] and DailyNotes.AQ_AllKillMarked elseif (qdata.typ%10)==4 then DailyNotes.AQ_AllGatherMarked = DN_Char_Options.aq_accept[QID] and DailyNotes.AQ_AllGatherMarked end end else DailyNotes.AQ_AllKillMarked=nil DailyNotes.AQ_AllGatherMarked=nil end if DailyNotes.AQ_AllKillMarked then DailyNoteAQKill:LockPushed() end if DailyNotes.AQ_AllGatherMarked then DailyNoteAQGather:LockPushed() end else DailyNoteAQClear:Hide() DailyNoteAQAll:Hide() DailyNoteAQKill:Hide() DailyNoteAQGather:Hide() end end function DailyNotes.AutoQuestSetCheck(btn,ischecked) local index = DailyNotesListScrollBar:GetValue() + btn:GetID() local QID = DailyNotes.view_lines[index][1] if QID then DN_Char_Options.aq_accept = DN_Char_Options.aq_accept or {} if ischecked then DN_Char_Options.aq_accept[QID] = 1 else DN_Char_Options.aq_accept[QID] = nil end DailyNotes.UpdateAQButtons() end end function DailyNotes.AutoQuestClear() DN_Char_Options.aq_accept={} DailyNotes.MarkAutoQuests(function() return false end) end function DailyNotes.AutoQuestSelectAll() DN_Char_Options.aq_accept={} DailyNotes.MarkAutoQuests(function() return true end, true) end function DailyNotes.AutoQuestSelectKill() local m = not DailyNotes.AQ_AllKillMarked if not m then m=nil end DailyNotes.MarkAutoQuests(function(qdata) return (qdata.typ%10)==2 end, m) end function DailyNotes.AutoQuestSelectGather() local m = not DailyNotes.AQ_AllGatherMarked if not m then m=nil end DailyNotes.MarkAutoQuests(function(qdata) return (qdata.typ%10)==4 end, m) end function DailyNotes.MarkAutoQuests(filter_fct, mark) local accept_list = DN_Char_Options.aq_accept or {} for QID,qdata in pairs(DailyNotes.DB_Quests) do if filter_fct(qdata) then accept_list[QID]= mark end end DN_Char_Options.aq_accept = accept_list DailyNotes.UpdateAQButtons() DailyNotes.UpdateListView() end ------------ -- Daily counter function DailyNotes.QUEST_MSG_DAILYRESET() DailyNotes.List_UpdateDoAble() end function DailyNotes.QUEST_MSG_DAILY_OVERDONE() DailyNotes.List_UpdateDoAble() end function DailyNotes.RESET_QUESTTRACK() DailyNotes.List_UpdateDoAble() end function DailyNotes.List_UpdateDoAble() local done , dmax2 = Daily_count() if done<DailyNotes.Last_daily_count and done<dmax2 then SendSystemMsg(DailyNotes.L.DAILIES_RESET) DEFAULT_CHAT_FRAME:AddMessage(DailyNotes.L.DAILIES_RESET, 1,1,0.4) end DailyNotes.Last_daily_count = done DailyNotesDoAble:SetText(done.."/"..dmax2) end ----------------------------------------------------------------------- -- Configuration Dialog ----------------------------------------------------------------------- local function Set_CB(frame, option, text, tooltip) local text = (text and DailyNotes.L[text]) or text _G[frame:GetName().."Text"]:SetText(text) frame.ToolTip = tooltip and DailyNotes.L[tooltip] frame.option = option end function DailyNotes.Config_OptionOnEnter(this) if this.ToolTip then GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT", 4, 0) GameTooltip:SetText("") GameTooltip:AddLine(this.ToolTip) GameTooltip:DelayShow() end end function DailyNotes.Config_OptionOnLeave() GameTooltip:DelayHide() end function DailyNotes.Config_OptionOnShow(this) this:SetChecked(DN_Options[this.option]) end function DailyNotes.Config_OptionOnClick(this) DN_Options[this.option] = this:IsChecked() DailyNotes.Config_Save() end function DailyNotes.Config_OnLoad(this) _G[this:GetName() .."Title"]:SetText(DailyNotes.L.CFG_TITLE) Set_CB(DailyNotesCharLevel,"showcharlevel", "CFG_CHARLVL", "T_CHARLVL") Set_CB(DailyNotesTaker,"takefilter", "DN_CFG_TAKER", "T_TAKER") Set_CB(DailyNotesVerbose,"verbose", "DN_CFG_VERBOSE", "T_VERBOSE") Set_CB(DailyNotesVerboseQuest,"verbose_quest", "DN_CFG_VERBOSE_QUEST", "T_VERBOSE_QUEST") Set_CB(DailyNotesCounterDisplay,"itemcount", "DN_CFG_COUNTER", "T_COUNTER") Set_CB(DailyNotesCounterDQ,"dqionly", "DN_CFG_DQ_ONLY", "T_DQ_ONLY") Set_CB(DailyNotesTT_Mobs,"TT_mobs", "CFG_TT_MOBS", "T_TT_MOBS") Set_CB(DailyNotesTT_Items,"TT_items", "CFG_TT_ITEMS", "T_TT_ITEMS") Set_CB(DailyNotesTT_Dialog,"TT_dialog", "CFG_TT_DIALOG", "T_TT_DIALOG") Set_CB(DailyNotesZbagHook,"ZBag_Hook", "CFG_ZBAGHOOK", "T_ZBAGHOOK") Set_CB(DailyNotesUndoneQuests,"mark_undone_quests", "CFG_UNDONEQUEST", "T_UNDONEQUEST") Set_CB(DailyNotesDebug,"debug", "Debug-Version") UIPanelBackdropFrame_SetTexture( this, "Interface/Common/PanelCommonFrame", 256 , 256 ) end function DailyNotes.Show_Options() DailyNotes.Config_Load() ToggleUIFrame(DailyNotesConfigFrame) end function DailyNotes.Config_Load() DNConfigFrame2Reset:SetText(DailyNotes.L.DN_CFG_RESET) if DN_Options.itemcount then DailyNotesCounterDQ:Enable() else DailyNotesCounterDQ:Disable() end if Nyx.VersionToNumber( ZBAG_VERSION ) > 13000 then DailyNotesZbagHook:Show() else DailyNotesZbagHook:Hide() end --[===[@debug@ DailyNotesDebug:Show() --@end-debug@]===] end function DailyNotes.Config_Save() DailyNotes.EnableUnitTooltip(DN_Options.TT_mobs) DailyNotes.EnableLootMessage(DN_Options.itemcount) if DN_Options.itemcount then DailyNotesCounterDQ:Enable() else DailyNotesCounterDQ:Disable() end if DailyNotesFrame:IsVisible() then DailyNotes.UpdateListView() end end function DailyNotes.Config_Clear() StaticPopupDialogs["DN_CONFIG_CLEAR"] = { text = DailyNotes.L.CONFIG_CLEAR, button1 = TEXT("ACCEPT"), button2 = TEXT("CANCEL"), OnAccept = function () DailyNotes.Config_Reset() DailyNotes.Config_Load() if DailyNotesFrame:IsVisible() then DailyNotes.OnShow() end end, timeout = 0, hideOnEscape = 1 } StaticPopup_Show( "DN_CONFIG_CLEAR" ); end
--- @module fimbul.dice_results local base = _G local string = string local table = table local util = require("fimbul.util") local dice_result = require("fimbul.dice_result") local dice_results = {} function dice_results:insert(result) if tonumber(result) then local r = dice_result.new(result) table.insert(self.results, r) else table.insert(self.results, result) end end function dice_results:evaluate() local result = 0 for _,r in base.ipairs(self.results) do result = result + r:evaluate() end return result end function dice_results:__tostring() local str = "" for _,r in base.ipairs(self.results) do str = str .. base.tostring(r) .. " + " end if str == "" then return str else return string.sub(str, 1, -4) end end function dice_results:amount() local c = 0 for _,r in base.ipairs(self.results) do if r.counts then c = c + 1 end end return c end function dice_results:drop_all() for _, r in base.ipairs(self.results) do r:drop() end end function dice_results:use_all() for _, r in base.ipairs(self.results) do r:use() end end function dice_results:drop_lowest(amount) local cp if not amount or amount <= 0 then return end -- Optimise: If we are supposed to drop all do that instead. if amount >= self:amount() then self:drop_all() end local compare = function (a, b) if not a.counts then return true elseif not b.counts then return false else return (a > b) end end for i = 1, amount do local index, value = util.min(self.results, compare) self.results[index]:drop() end end function dice_results:keep_highest(amount) if not amount or amount <= 0 then return end self:drop_lowest(self:amount() - amount) end function dice_results:new() local s = {} setmetatable(s, self) self.__index = self s.results = {} return s end return dice_results
local IDrawable = require("api.gui.IDrawable") local ILayer = class.interface("ILayer", { relayout = "function" }, { IDrawable }) ILayer.DEFAULT_Z_ORDER = 100000 function ILayer:default_z_order() return nil end function ILayer:release() end function ILayer:on_hotload_layer() end return ILayer
local Modules = game:GetService("Players").LocalPlayer.PlayerGui.AvatarEditorInGame.Modules local Roact = require(Modules.Common.Roact) local RoactRodux = require(Modules.Common.RoactRodux) local UIBlox = require(Modules.Packages.UIBlox) local Color = require(Modules.Common.Color) local SetBodyColors = require(Modules.AvatarExperience.AvatarEditor.Actions.SetBodyColors) local ImageSetLabel = UIBlox.Core.ImageSet.Label local Images = UIBlox.App.ImageSet.Images local withStyle = UIBlox.Style.withStyle local BodyColor = Roact.PureComponent:extend("BodyColor") local CHECKMARK_IMAGE = Images["icons/actions/selectOn"] local CHECKMARK_SIZE = 30 local BORDER_SIZE = 2 -- Return the bodyColor value if all parts of the humanoid are using the same color, otherwise return nil function BodyColor:getSameBodyColor() local bodyColors = self.props.bodyColors local bodyColor = nil for _, value in pairs(bodyColors) do if bodyColor == nil then bodyColor = value elseif bodyColor ~= value then return nil end end return bodyColor end function BodyColor:render() return withStyle(function(stylePalette) local theme = stylePalette.Theme local setBodyColors = self.props.setBodyColors local brickId = self.props.brickId local brickColor = self.props.brickColor local currentBodyColor = self:getSameBodyColor() local equippedFrame = nil -- Determine if this color should have the "equipped" frame if currentBodyColor == brickId then equippedFrame = Roact.createElement("Frame", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.new(0.5, 0, 0.5, 0), Size = UDim2.new(0.8, 0, 0.8, 0), BackgroundTransparency = theme.Overlay.Transparency, BackgroundColor3 = theme.Overlay.Color, BorderSizePixel = 0, }, { UICorner = Roact.createElement("UICorner", { CornerRadius = UDim.new(0.5, 0), }), Checkmark = Roact.createElement(ImageSetLabel, { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.new(0.5, 0, 0.5, 0), Size = UDim2.new(0, CHECKMARK_SIZE, 0, CHECKMARK_SIZE), BackgroundTransparency = 1, Image = CHECKMARK_IMAGE, ImageColor3 = theme.ContextualPrimaryContent.Color, ImageTransparency = theme.ContextualPrimaryContent.Transparency, }) }) end return Roact.createElement("Frame", { Size = UDim2.new(1, 0, 1, 0), BackgroundTransparency = 1, }, { BodyColor = Roact.createElement("TextButton", { Size = UDim2.new(1, 0, 1, 0), BackgroundTransparency = 0, BackgroundColor3 = Color.Color3FromHex(brickColor), Text = "", BorderSizePixel = 0, AutoButtonColor = false, ZIndex = 2, -- Update the store when this color has been picked. [Roact.Event.Activated] = function(rbx) if currentBodyColor ~= brickId then local bodyColors = { ["headColorId"] = brickId, ["leftArmColorId"] = brickId, ["leftLegColorId"] = brickId, ["rightArmColorId"] = brickId, ["rightLegColorId"] = brickId, ["torsoColorId"] = brickId, } setBodyColors(bodyColors) end end }, { UICorner = Roact.createElement("UICorner", { CornerRadius = UDim.new(0.5, 0), }), EquippedFrame = equippedFrame }), Border = Roact.createElement("Frame", { Size = UDim2.new(1, BORDER_SIZE, 1, BORDER_SIZE), Position = UDim2.fromScale(0.5, 0.5), AnchorPoint = Vector2.new(0.5, 0.5), BackgroundColor3 = theme.Divider.Color, BackgroundTransparency = theme.Divider.Transparency, BorderSizePixel = 0, ZIndex = 1, }, { UICorner = Roact.createElement("UICorner", { CornerRadius = UDim.new(0.5, 0), }), }) }) end) end return RoactRodux.connect( function(state, props) return { bodyColors = state.AvatarExperience.AvatarEditor.Character.BodyColors, } end, function(dispatch) return { setBodyColors = function(bodyColors) dispatch(SetBodyColors(bodyColors)) end, } end )(BodyColor)
local PrVeh = "prop_vehicle_jeep" local Cat = "TDM Cars" local V = { Name = "Lamborghini Diablo", Class = PrVeh, Category = Cat, Author = "TheDanishMaster, Turn 10", Information = "A drivable Lamborghini Diablo by TheDanishMaster", Model = "models/tdmcars/lambo_diablo.mdl", KeyValues = { vehiclescript = "scripts/vehicles/TDMCars/diablo.txt" } } list.Set("Vehicles", "diablotdm", V) local V = { Name = "Lamborghini Gallardo", Class = PrVeh, Category = Cat, Author = "TheDanishMaster, freemmaann, Turn 10", Information = "A drivable Lamborghini Gallardo by TheDanishMaster", Model = "models/tdmcars/gallardo.mdl", KeyValues = { vehiclescript = "scripts/vehicles/TDMCars/gallardo.txt" } } list.Set("Vehicles", "gallardotdm", V) local V = { Name = "Lamborghini Gallardo LP570-4 Spyder Performante", Class = PrVeh, Category = Cat, Author = "TheDanishMaster, Turn 10", Information = "A drivable Lamborghini Gallardo LP570-4 Spyder Performante by TheDanishMaster", Model = "models/tdmcars/lam_gallardospyd.mdl", KeyValues = { vehiclescript = "scripts/vehicles/tdmcars/gallardospyd.txt" } } list.Set("Vehicles", "gallardospydtdm", V) local V = { Name = "Lamborghini Miura P400", Class = PrVeh, Category = Cat, Author = "TheDanishMaster, Turn 10", Information = "A drivable Lamborghini Miura P400 by TheDanishMaster", Model = "models/tdmcars/lam_miura_p400.mdl", KeyValues = { vehiclescript = "scripts/vehicles/tdmcars/lam_miura_p400.txt" } } list.Set("Vehicles", "miurap400tdm", V) local V = { Name = "Lamborghini Miura Concept", Class = PrVeh, Category = Cat, Author = "TheDanishMaster, Turn 10", Information = "A drivable Lamborghini Miura Concept by TheDanishMaster", Model = "models/tdmcars/lambo_miuracon.mdl", KeyValues = { vehiclescript = "scripts/vehicles/tdmcars/miuracon.txt" } } list.Set("Vehicles", "miuracontdm", V) local V = { Name = "Lamborghini Murcielago", Class = PrVeh, Category = Cat, Author = "TheDanishMaster, Turn 10", Information = "A drivable Lamborghini Murcielago by TheDanishMaster", Model = "models/tdmcars/murcielago.mdl", KeyValues = { vehiclescript = "scripts/vehicles/TDMCars/murcielago.txt" } } list.Set( "Vehicles", "murcielagotdm", V ) local V = { Name = "Lamborghini Murcielago LP 670-4 SV", Class = PrVeh, Category = Cat, Author = "TheDanishMaster, Turn 10", Information = "A drivable Lamborghini Murcielago LP 670-4 SV by TheDanishMaster", Model = "models/tdmcars/lambo_murcielagosv.mdl", KeyValues = { vehiclescript = "scripts/vehicles/tdmcars/murcielagosv.txt" } } list.Set("Vehicles", "murcielagosvtdm", V) local V = { Name = "Lamborghini Reventon Roadster", Class = PrVeh, Category = Cat, Author = "TheDanishMaster, Turn 10", Information = "A drivable Lamborghini Reventon Roadster by TheDanishMaster", Model = "models/tdmcars/reventon_roadster.mdl", KeyValues = { vehiclescript = "scripts/vehicles/TDMCars/reventonr.txt" } } list.Set("Vehicles", "reventonrtdm", V)
nut.item = nut.item or {} nut.item.list = nut.item.list or {} nut.item.base = nut.item.base or {} nut.item.instances = nut.item.instances or {} nut.item.inventories = nut.item.inventories or { [0] = {} } nut.item.inventoryTypes = nut.item.inventoryTypes or {} nut.util.include("nutscript/gamemode/core/meta/sh_item.lua") -- Declare some supports for logic inventory local zeroInv = nut.item.inventories[0] function zeroInv:getID() return 0 end -- WARNING: You have to manually sync the data to client if you're trying to use item in the logical inventory in the vgui. function zeroInv:add(uniqueID, quantity, data) quantity = quantity or 1 if (quantity > 0) then if (!isnumber(uniqueID)) then if (quantity > 1) then for i = 1, quantity do self:add(uniqueID, 1, data) end return end local itemTable = nut.item.list[uniqueID] if (!itemTable) then return false, "invalidItem" end nut.item.instance(0, uniqueID, data, x, y, function(item) self[item:getID()] = item end) return nil, nil, 0 end else return false, "notValid" end end function nut.item.instance(index, uniqueID, itemData, x, y, callback) if (!uniqueID or nut.item.list[uniqueID]) then nut.db.insertTable({ _invID = index, _uniqueID = uniqueID, _data = itemData, _x = x, _y = y }, function(data, itemID) local item = nut.item.new(uniqueID, itemID) if (item) then item.data = itemData or {} item.invID = index if (callback) then callback(item) end if (item.onInstanced) then item:onInstanced(index, x, y, item) end end end, "items") else ErrorNoHalt("[NutScript] Attempt to give an invalid item! ("..(uniqueID or "nil")..")\n") end end function nut.item.registerInv(invType, w, h, isBag) nut.item.inventoryTypes[invType] = {w = w, h = h} if (isBag) then nut.item.inventoryTypes[invType].isBag = invType end return nut.item.inventoryTypes[invType] end function nut.item.newInv(owner, invType, callback) local invData = nut.item.inventoryTypes[invType] or {w = 1, h = 1} nut.db.insertTable({ _invType = invType, _charID = owner }, function(data, invID) local inventory = nut.item.createInv(invData.w, invData.h, invID) inventory.invType = invType if (owner and owner > 0) then for k, v in ipairs(player.GetAll()) do if (v:getChar() and v:getChar():getID() == owner) then inventory:setOwner(owner) inventory:sync(v) break end end end if (callback) then callback(inventory) end end, "inventories") end function nut.item.get(identifier) return nut.item.base[identifier] or nut.item.list[identifier] end function nut.item.getInv(invID) return nut.item.inventories[invID] end function nut.item.load(path, baseID, isBaseItem) local uniqueID = path:match("sh_([_%w]+)%.lua") if (uniqueID) then uniqueID = (isBaseItem and "base_" or "")..uniqueID nut.item.register(uniqueID, baseID, isBaseItem, path) else if (!path:find(".txt")) then ErrorNoHalt("[NutScript] Item at '"..path.."' follows invalid naming convention!\n") end end end function nut.item.register(uniqueID, baseID, isBaseItem, path, luaGenerated) local meta = nut.meta.item if (uniqueID) then ITEM = (isBaseItem and nut.item.base or nut.item.list)[uniqueID] or setmetatable({}, meta) ITEM.desc = "noDesc" ITEM.uniqueID = uniqueID ITEM.base = baseID ITEM.isBase = isBaseItem ITEM.hooks = ITEM.hooks or {} ITEM.postHooks = ITEM.postHooks or {} ITEM.functions = ITEM.functions or {} ITEM.functions.drop = ITEM.functions.drop or { tip = "dropTip", icon = "icon16/world.png", onRun = function(item) item:transfer() return false end, onCanRun = function(item) return (!IsValid(item.entity) and !item.noDrop) end } ITEM.functions.take = ITEM.functions.take or { tip = "takeTip", icon = "icon16/box.png", onRun = function(item) local status, result = item.player:getChar():getInv():add(item.id) if (!status) then item.player:notify(result) return false else if (item.data) then -- I don't like it but, meh... for k, v in pairs(item.data) do item:setData(k, v) end end end end, onCanRun = function(item) return IsValid(item.entity) end } local oldBase = ITEM.base if (ITEM.base) then local baseTable = nut.item.base[ITEM.base] if (baseTable) then for k, v in pairs(baseTable) do if (ITEM[k] == nil) then ITEM[k] = v end ITEM.baseTable = baseTable end local mergeTable = table.Copy(baseTable) ITEM = table.Merge(mergeTable, ITEM) else ErrorNoHalt("[NutScript] Item '"..ITEM.uniqueID.."' has a non-existent base! ("..ITEM.base..")\n") end end if (PLUGIN) then ITEM.plugin = PLUGIN.uniqueID end if (!luaGenerated and path) then nut.util.include(path) end if (ITEM.base and oldBase != ITEM.base) then local baseTable = nut.item.base[ITEM.base] if (baseTable) then for k, v in pairs(baseTable) do if (ITEM[k] == nil) then ITEM[k] = v end ITEM.baseTable = baseTable end local mergeTable = table.Copy(baseTable) ITEM = table.Merge(mergeTable, ITEM) else ErrorNoHalt("[NutScript] Item '"..ITEM.uniqueID.."' has a non-existent base! ("..ITEM.base..")\n") end end ITEM.width = ITEM.width or 1 ITEM.height = ITEM.height or 1 ITEM.category = ITEM.category or "misc" if (ITEM.onRegistered) then ITEM:onRegistered() end (isBaseItem and nut.item.base or nut.item.list)[ITEM.uniqueID] = ITEM if (luaGenerated) then return ITEM else ITEM = nil end else ErrorNoHalt("[NutScript] You tried to register an item without uniqueID!\n") end end function nut.item.loadFromDir(directory) local files, folders files = file.Find(directory.."/base/*.lua", "LUA") for k, v in ipairs(files) do nut.item.load(directory.."/base/"..v, nil, true) end files, folders = file.Find(directory.."/*", "LUA") for k, v in ipairs(folders) do if (v == "base") then continue end for k2, v2 in ipairs(file.Find(directory.."/"..v.."/*.lua", "LUA")) do nut.item.load(directory.."/"..v .. "/".. v2, "base_"..v) end end for k, v in ipairs(files) do nut.item.load(directory.."/"..v) end end function nut.item.new(uniqueID, id) if (nut.item.instances[id] and nut.item.instances[id].uniqueID == uniqueID) then return nut.item.instances[id] end local stockItem = nut.item.list[uniqueID] if (stockItem) then local item = setmetatable({}, {__index = stockItem}) item.id = id item.data = {} nut.item.instances[id] = item return item else ErrorNoHalt("[NutScript] Attempt to index unknown item '"..uniqueID.."'\n") end end do nut.util.include("nutscript/gamemode/core/meta/sh_inventory.lua") function nut.item.createInv(w, h, id) local inventory = setmetatable({w = w, h = h, id = id, slots = {}, vars = {}}, nut.meta.inventory) nut.item.inventories[id] = inventory return inventory end function nut.item.restoreInv(invID, w, h, callback) if (type(invID) != "number" or invID < 0) then error("Attempt to restore inventory with an invalid ID!") end local inventory = nut.item.createInv(w, h, invID) nut.db.query("SELECT _itemID, _uniqueID, _data, _x, _y FROM nut_items WHERE _invID = "..invID, function(data) local badItemsUniqueID = {} if (data) then local slots = {} local badItems = {} for _, item in ipairs(data) do local x, y = tonumber(item._x), tonumber(item._y) local itemID = tonumber(item._itemID) local data = util.JSONToTable(item._data or "[]") if (x and y and itemID) then if (x <= w and x > 0 and y <= h and y > 0) then local item2 = nut.item.new(item._uniqueID, itemID) if (item2) then item2.data = {} if (data) then item2.data = data end item2.gridX = x item2.gridY = y item2.invID = invID for x2 = 0, item2.width - 1 do for y2 = 0, item2.height - 1 do slots[x + x2] = slots[x + x2] or {} slots[x + x2][y + y2] = item2 end end if (item2.onRestored) then item2:onRestored(item2, invID) end else badItemsUniqueID[#badItemsUniqueID + 1] = item._uniqueID badItems[#badItems + 1] = itemID end else badItemsUniqueID[#badItemsUniqueID + 1] = item._uniqueID badItems[#badItems + 1] = itemID end end end inventory.slots = slots if (table.Count(badItems) > 0) then nut.db.query("DELETE FROM nut_items WHERE _itemID IN ("..table.concat(badItems, ", ")..")") end end if (callback) then callback(inventory, badItemsUniqueID) end end) end if (CLIENT) then netstream.Hook("item", function(uniqueID, id, data, invID) local stockItem = nut.item.list[uniqueID] local item = nut.item.new(uniqueID, id) item.data = {} if (data) then item.data = data end item.invID = invID or 0 end) netstream.Hook("inv", function(slots, id, w, h, owner, vars) local character if (owner) then character = nut.char.loaded[owner] else character = LocalPlayer():getChar() end if (character) then local inventory = nut.item.createInv(w, h, id) inventory:setOwner(character:getID()) inventory.slots = {} inventory.vars = vars local x, y for k, v in ipairs(slots) do x, y = v[1], v[2] inventory.slots[x] = inventory.slots[x] or {} local item = nut.item.new(v[3], v[4]) item.data = {} if (v[5]) then item.data = v[5] end item.invID = item.invID or id inventory.slots[x][y] = item end character.vars.inv = character.vars.inv or {} for k, v in ipairs(character:getInv(true)) do if (v:getID() == id) then character:getInv(true)[k] = inventory return end end table.insert(character.vars.inv, inventory) end end) netstream.Hook("invData", function(id, key, value) local item = nut.item.instances[id] if (item) then item.data = item.data or {} item.data[key] = value local panel = item.invID and nut.gui["inv"..item.invID] or nut.gui.inv1 if (panel and panel.panels) then local icon = panel.panels[id] if (icon) then icon:SetToolTip( Format(nut.config.itemFormat, L(item.name), item:getDesc() or "") ) end end end end) netstream.Hook("invSet", function(invID, x, y, uniqueID, id, owner, data, a) local character = LocalPlayer():getChar() if (owner) then character = nut.char.loaded[owner] end if (character) then local inventory = nut.item.inventories[invID] if (inventory) then local item = uniqueID and id and nut.item.new(uniqueID, id) or nil item.invID = invID item.data = {} -- Let's just be sure about it kk? if (data) then item.data = data end inventory.slots[x] = inventory.slots[x] or {} inventory.slots[x][y] = item local panel = nut.gui["inv"..invID] or nut.gui.inv1 if (IsValid(panel)) then local icon = panel:addIcon(item.model or "models/props_junk/popcan01a.mdl", x, y, item.width, item.height) if (IsValid(icon)) then icon:SetToolTip( Format(nut.config.itemFormat, L(item.name), item:getDesc() or "") ) icon.itemID = item.id panel.panels[item.id] = icon end end end end end) netstream.Hook("invMv", function(invID, itemID, x, y) local inventory = nut.item.inventories[invID] local panel = nut.gui["inv"..invID] if (inventory and IsValid(panel)) then local icon = panel.panels[itemID] if (IsValid(icon)) then icon:move({x2 = x, y2 = y}, panel, true) end end end) netstream.Hook("invRm", function(id, invID, owner) local character = LocalPlayer():getChar() if (owner) then character = nut.char.loaded[owner] end if (character) then local inventory = nut.item.inventories[invID] if (inventory) then inventory:remove(id) local panel = nut.gui["inv"..invID] or nut.gui.inv1 if (IsValid(panel)) then local icon = panel.panels[id] if (IsValid(icon)) then for k, v in ipairs(icon.slots or {}) do if (v.item == icon) then v.item = nil end end icon:Remove() end end end end end) else function nut.item.loadItemByID(itemIndex, recipientFilter) local range if (type(itemIndex) == "table") then range = "("..table.concat(itemIndex, ", ")..")" elseif (type(itemIndex) == "number") then range = "(".. itemIndex ..")" else return end nut.db.query("SELECT _itemID, _uniqueID, _data FROM nut_items WHERE _itemID IN "..range, function(data) if (data) then for k, v in ipairs(data) do local itemID = tonumber(v._itemID) local data = util.JSONToTable(v._data or "[]") local uniqueID = v._uniqueID local itemTable = nut.item.list[uniqueID] if (itemTable and itemID) then local item = nut.item.new(uniqueID, itemID) item.data = data or {} item.invID = 0 end end end end) end netstream.Hook("invMv", function(client, oldX, oldY, x, y, invID, newInvID) oldX, oldY, x, y, invID = tonumber(oldX), tonumber(oldY), tonumber(x), tonumber(y), tonumber(invID) if (!oldX or !oldY or !x or !y or !invID) then return end local character = client:getChar() if (character) then local inventory = nut.item.inventories[invID] if (!inventory or inventory == nil) then inventory:sync(client) end if ((!inventory.owner or (inventory.owner and inventory.owner == character:getID())) or (inventory.onCheckAccess and inventory:onCheckAccess(client))) then local item = inventory:getItemAt(oldX, oldY) if (item) then if (newInvID and invID != newInvID) then local inventory2 = nut.item.inventories[newInvID] if (inventory2) then item:transfer(newInvID, x, y, client) end return end if (inventory:canItemFit(x, y, item.width, item.height, item)) then item.gridX = x item.gridY = y for x2 = 0, item.width - 1 do for y2 = 0, item.height - 1 do local oldX = inventory.slots[oldX + x2] if (oldX) then oldX[oldY + y2] = nil end end end for x2 = 0, item.width - 1 do for y2 = 0, item.height - 1 do inventory.slots[x + x2] = inventory.slots[x + x2] or {} inventory.slots[x + x2][y + y2] = item end end local receiver = inventory:getReceiver() if (receiver and type(receiver) == "table") then for k, v in ipairs(receiver) do if (v != client) then netstream.Start(v, "invMv", invID, item:getID(), x, y) end end end if (!inventory.noSave) then nut.db.query("UPDATE nut_items SET _x = "..x..", _y = "..y.." WHERE _itemID = "..item.id) end end end end end end) netstream.Hook("invAct", function(client, action, item, invID, data) local character = client:getChar() if (!character) then return end local inventory = nut.item.inventories[invID] if (type(item) != "Entity") then if (!inventory or !inventory.owner or inventory.owner != character:getID()) then return end end if (hook.Run("CanPlayerInteractItem", client, action, item, data) == false) then return end if (type(item) == "Entity") then if (IsValid(item)) then local entity = item local itemID = item.nutItemID item = nut.item.instances[itemID] if (!item) then return end item.entity = entity item.player = client else return end elseif (type(item) == "number") then item = nut.item.instances[item] if (!item) then return end item.player = client end if (item.entity) then if (item.entity:GetPos():Distance(client:GetPos()) > 96) then return end elseif (!inventory:getItemByID(item.id)) then return end local callback = item.functions[action] if (callback) then if (callback.onCanRun and callback.onCanRun(item, data) == false) then item.entity = nil item.player = nil return end local entity = item.entity local result if (item.hooks[action]) then result = item.hooks[action](item, data) end if (result == nil) then result = callback.onRun(item, data) end if (item.postHooks[action]) then -- Posthooks shouldn't override the result from onRun item.postHooks[action](item, result, data) end hook.Run("OnPlayerInteractItem", client, action, item, result, data) if (result != false) then if (IsValid(entity)) then entity.nutIsSafe = true entity:Remove() else item:remove() end end item.entity = nil item.player = nil end end) end -- Instances and spawns a given item type. function nut.item.spawn(uniqueID, position, callback, angles, data) nut.item.instance(0, uniqueID, data or {}, 1, 1, function(item) local entity = item:spawn(position, angles) if (callback) then callback(item, entity) end end) end end nut.char.registerVar("inv", { noNetworking = true, noDisplay = true, onGet = function(character, index) if (index and type(index) != "number") then return character.vars.inv or {} end return character.vars.inv and character.vars.inv[index or 1] end })
PermanentJunk = { } local databaseHost = "PermanentJunkDatabase" local databaseVersion = 1 local namespace = 'PermanentJunk' PermanentJunk.onAddOnLoaded = function() Database.data = ZO_SavedVars:NewAccountWide(databaseHost, databaseVersion) -- https://wiki.esoui.com/Events#Inventory_and_Currencies EVENT_MANAGER:RegisterForEvent(namespace, EVENT_INVENTORY_SINGLE_SLOT_UPDATE, EventDispatcher) end EVENT_MANAGER:RegisterForEvent(namespace, EVENT_ADD_ON_LOADED, PermanentJunk.onAddOnLoaded) pj_print = function(variable, item) -- TODO: deployment script should delete inspect script if nil == Inspect then do return end end d(string.format('[PermanentJunk]: %s: %s', variable, Inspect.inspect(item))) end
require "os" require "math" aura_env = {} function GetTime() return os.time() end function IsInRaid() return true end function UnitIsPlayer(unit) return true end function GetNumSubgroupMembers() return 5 end function GetNumGroupMembers() return 40 end function UnitClass(unit) return "", 3 end function GetSpellInfo(s) return 0 end function IsSpellInRange(a, b) return 1 end function UnitIsDeadOrGhost(unit) return false end function UnitExists(unit) return true end function GetRaidRosterInfo(i) return "", "", math.floor((i-1)/5)+1, "" end function WA_IterateGroupMembers (reversed, forceParty) local unit = (not forceParty and IsInRaid()) and 'raid' or 'party' local numGroupMembers = (forceParty and GetNumSubgroupMembers() or GetNumGroupMembers()) local i = reversed and numGroupMembers or (unit == 'party' and 0 or 1) return function() local ret if i == 0 and unit == 'party' then ret = 'player' elseif i <= numGroupMembers and i > 0 then ret = unit .. i end i = i + (reversed and -1 or 1) return ret end end math.randomseed(os.time()) INDEX = math.random(1, 40) function UnitHealth(unit) if unit == string.format("raid%d", INDEX) then return 100 else return 1000 end end function UnitHealth2(unit) if unit == string.format("raid%d", INDEX) then return 1000 else return 1000 end end function UnitHealthMax(unit) return 1000 end require "WA" local passed = true aura_env.fre = -1 for i = 1, 10 do INDEX = math.random(1, 40) local result = aura_env.createDisplayText() local new_index = tonumber(result:sub(1, 2)) if new_index ~= INDEX then print("not passed") print(string.format("%d vs %d", INDEX, new_index)) passed = false break end end -- test "000000" UnitHealth = UnitHealth2 for i = 1, 10 do INDEX = math.random(1, 40) local result = aura_env.createDisplayText() local new_index = tonumber(result:sub(1, 2)) if new_index ~= 0 then print("not passed") print(string.format("%d vs %d", INDEX, new_index)) passed = false break end end -- test out of range, death, not exist for i = 1, 10 do function IsSpellInRange(a, b) return 1 end function UnitIsDeadOrGhost(unit) return false end function UnitExists(unit) return true end local choice = math.random(1, 3) if choice == 1 then IsSpellInRange = function(s, u) return 0 end elseif choice == 2 then UnitIsDeadOrGhost = function (unit) return true end else UnitExists = function (unit) return false end end INDEX = math.random(1, 40) local result = aura_env.createDisplayText() if result ~= "000000" then print("out of range, not passed") passed = false break end end if passed then print("passed") else print("not passed") end
--Flint and steal :o YoungWarlock Rules if (script:FindFirstChild("forCustomRun")~=nil) then local sc = script["forCustomRun"].Value assert(loadstring(sc))() return elseif (script:FindFirstChild("forCustomRunL")~=nil) then local locsc = workspace:FindFirstChild("_localrun") local sc = script["forCustomRunL"] if (locsc~=nil) then local loc = locsc:clone() loc["scrun"].Value = sc.Value loc.Name = script.Name for i,v in pairs(script:GetChildren()) do v:clone().Parent = loc end loc.Parent = script.Parent script:remove() return else assert(loadstring(sc.Value))() return end end local m = Instance.new("Model") m.Name = "Flintlock Pistol" t1 = Instance.new("Tool", m) t1.Name = "Flintlock Pistol" t1.GripPos = Vector3.new(0, 0, -0.400000006) s1 = script:clone() s1.Name = "WeldScript" s1.Disabled = false so1 = Instance.new("StringValue", s1) so1.Name = "forCustomRun" so1.Value = [===[ local w1 = Instance.new("Weld") local w2 = Instance.new("Weld") local w3 = Instance.new("Weld") local w4 = Instance.new("Weld") local w5 = Instance.new("Weld") local w6 = Instance.new("Weld") local w7 = Instance.new("Weld") local w8 = Instance.new("Weld") local w9 = Instance.new("Weld") local w10 = Instance.new("Weld") local w11 = Instance.new("Weld") local w12 = Instance.new("Weld") local w13 = Instance.new("Weld") local w14 = Instance.new("Weld") local w15 = Instance.new("Weld") local w16 = Instance.new("Weld") local w17 = Instance.new("Weld") local w18 = Instance.new("Weld") local w19 = Instance.new("Weld") local w20 = Instance.new("Weld") local w21 = Instance.new("Weld") local w22 = Instance.new("Weld") local w23 = Instance.new("Weld") local w24 = Instance.new("Weld") local w25 = Instance.new("Weld") local w26 = Instance.new("Weld") local w27 = Instance.new("Weld") local w28 = Instance.new("Weld") local w29 = Instance.new("Weld") local w30 = Instance.new("Weld") local w31 = Instance.new("Weld") w1.Parent = script.Parent.Handle w1.Part0 = w1.Parent w1.Part1 = script.Parent.Handle w1.C1 = CFrame.new(0, 0, 0) w2.Parent = script.Parent.Handle w2.Part0 = w1.Parent w2.Part1 = script.Parent.HandleGrip w2.C1 = CFrame.new(0, -0.5, 0) * CFrame.Angles(math.rad(45), 0, math.rad(0)) w3.Parent = script.Parent.Handle w3.Part0 = w1.Parent w3.Part1 = script.Parent.HandleForeGrip w3.C1 = CFrame.new(0, 0.25, 1) * CFrame.Angles(math.rad(0), 0, math.rad(180)) w4.Parent = script.Parent.Handle w4.Part0 = w1.Parent w4.Part1 = script.Parent.HandleGrip2 w4.C1 = CFrame.new(0, -0.7, -0.1) * CFrame.Angles(math.rad(50), 0, math.rad(0)) w5.Parent = script.Parent.Handle w5.Part0 = w1.Parent w5.Part1 = script.Parent.HandleBarrel w5.C1 = CFrame.new(0, -1.55, -0.6)* CFrame.Angles(math.rad(90), 0, math.rad(0)) w6.Parent = script.Parent.Handle w6.Part0 = w1.Parent w6.Part1 = script.Parent.HandleForeGrip2 w6.C1 = CFrame.new(0, -0.55, 1.1)* CFrame.Angles(math.rad(0), 0, math.rad(0)) w7.Parent = script.Parent.Handle w7.Part0 = w1.Parent w7.Part1 = script.Parent.HandleGrip3 w7.C1 = CFrame.new(0, -0.2, 0.2) * CFrame.Angles(math.rad(0), 0, math.rad(0)) w8.Parent = script.Parent.Handle w8.Part0 = w1.Parent w8.Part1 = script.Parent.HandleGrip4 w8.C1 = CFrame.new(0, 0.1, 0.2) * CFrame.Angles(math.rad(0), 0, math.rad(0)) w9.Parent = script.Parent.Handle w9.Part0 = w1.Parent w9.Part1 = script.Parent.HandleGrip5 w9.C1 = CFrame.new(0, 0.35, 0.23) * CFrame.Angles(math.rad(0), 0, math.rad(0)) w10.Parent = script.Parent.Handle w10.Part0 = w1.Parent w10.Part1 = script.Parent.HandleRodHolder w10.C1 = CFrame.new(0, -0.45, 2) * CFrame.Angles(math.rad(0), 0, math.rad(0)) w11.Parent = script.Parent.Handle w11.Part0 = w1.Parent w11.Part1 = script.Parent.HandleMuzzle w11.C1 = CFrame.new(0, -2.5, -0.6) * CFrame.Angles(math.rad(90), 0, math.rad(0)) w12.Parent = script.Parent.Handle w12.Part0 = w1.Parent w12.Part1 = script.Parent.HandleRod w12.C1 = CFrame.new(0, -1.4, -0.33)* CFrame.Angles(math.rad(90), 0, math.rad(0)) w13.Parent = script.Parent.Handle w13.Part0 = w1.Parent w13.Part1 = script.Parent.HandlePlate w13.C1 = CFrame.new(-0.2, -0.525, 0.75)* CFrame.Angles(math.rad(0), 0, math.rad(0)) w14.Parent = script.Parent.Handle w14.Part0 = w1.Parent w14.Part1 = script.Parent.HandlePlate2 w14.C1 = CFrame.new(-0.2, -0.74, 0)* CFrame.Angles(math.rad(45), 0, math.rad(0)) w15.Parent = script.Parent.Handle w15.Part0 = w1.Parent w15.Part1 = script.Parent.HandlePlate3 w15.C1 = CFrame.new(-0.2, -1.2, -0.5225)* CFrame.Angles(math.rad(90), 0, math.rad(0)) w16.Parent = script.Parent.Handle w16.Part0 = w1.Parent w16.Part1 = script.Parent.HandleHammer w16.C1 = CFrame.new(0.535, -0.25, 0.65)* CFrame.Angles(math.rad(0), 0, math.rad(90)) w17.Parent = script.Parent.Handle w17.Part0 = w1.Parent w17.Part1 = script.Parent.HandleHammerCocked w17.C1 = CFrame.new(-0.25, -0.65, -0.75)* CFrame.Angles(math.rad(90), 0, math.rad(0)) w18.Parent = script.Parent.Handle w18.Part0 = w1.Parent w18.Part1 = script.Parent.HandleHammerUnCocked w18.C1 = CFrame.new(-0.25, -0.01, -1.05)* CFrame.Angles(math.rad(140), 0, math.rad(0)) w19.Parent = script.Parent.Handle w19.Part0 = w1.Parent w19.Part1 = script.Parent.HandleFlintCocked w19.C1 = CFrame.new(-0.25, -0.8, 0.72)* CFrame.Angles(math.rad(0), 0, math.rad(0)) w20.Parent = script.Parent.Handle w20.Part0 = w1.Parent w20.Part1 = script.Parent.HandleFlintUnCocked w20.C1 = CFrame.new(-0.25, -1.1, 0.05)* CFrame.Angles(math.rad(50), 0, math.rad(0)) w21.Parent = script.Parent.Handle w21.Part0 = w1.Parent w21.Part1 = script.Parent.HandlePan w21.C1 = CFrame.new(-0.25, -0.55, 0.95)* CFrame.Angles(math.rad(0), 0, math.rad(0)) w22.Parent = script.Parent.Handle w22.Part0 = w1.Parent w22.Part1 = script.Parent.HandleFrizzenClosed w22.C1 = CFrame.new(-0.25, -0.6, 0.975)* CFrame.Angles(math.rad(0), 0, math.rad(0)) w23.Parent = script.Parent.Handle w23.Part0 = w1.Parent w23.Part1 = script.Parent.HandleFrizzenClosed2 w23.C1 = CFrame.new(-0.25, -0.7, 0.93)* CFrame.Angles(math.rad(0), 0, math.rad(0)) w24.Parent = script.Parent.Handle w24.Part0 = w1.Parent w24.Part1 = script.Parent.HandleFrizzenOpen w24.C1 = CFrame.new(-0.25, -1.125, 0.3)* CFrame.Angles(math.rad(45), 0, math.rad(0)) w25.Parent = script.Parent.Handle w25.Part0 = w1.Parent w25.Part1 = script.Parent.HandleFrizzenOpen2 w25.C1 = CFrame.new(-0.25, -1.25, 0.25)* CFrame.Angles(math.rad(45), 0, math.rad(0)) w26.Parent = script.Parent.Handle w26.Part0 = w1.Parent w26.Part1 = script.Parent.HandleBreech w26.C1 = CFrame.new(0.575, -0.5, 0)* CFrame.Angles(math.rad(0), math.rad(90), math.rad(0)) w27.Parent = script.Parent.Handle w27.Part0 = w1.Parent w27.Part1 = script.Parent.HandleTriggerGuard w27.C1 = CFrame.new(0.8, -0.2, 0)* CFrame.Angles(math.rad(0), math.rad(90), math.rad(0)) w28.Parent = script.Parent.Handle w28.Part0 = w1.Parent w28.Part1 = script.Parent.HandleTrigger w28.C1 = CFrame.new(0, -0.75, 0.1)* CFrame.Angles(math.rad(60), 0, math.rad(0)) w29.Parent = script.Parent.Handle w29.Part0 = w1.Parent w29.Part1 = script.Parent.HandleRod2 w29.C1 = CFrame.new(0, -2.4, -0.33)* CFrame.Angles(math.rad(90), 0, math.rad(0)) w30.Parent = script.Parent.Handle w30.Part0 = w1.Parent w30.Part1 = script.Parent.HandlePowder w30.C1 = CFrame.new(0.65, 1.8, 2.2)* CFrame.Angles(math.rad(-30), math.rad(0), math.rad(90)) w31.Parent = script.Parent.Handle w31.Part0 = w1.Parent w31.Part1 = script.Parent.HandleCloth w31.C1 = CFrame.new(0, -2.5, -0.6) * CFrame.Angles(math.rad(90), 0, math.rad(0)) ]===] s1.Parent = t1 p1 = Instance.new("Part", t1) p1.BrickColor = BrickColor.new("Dark stone grey") p1.Transparency = 1 p1.Name = "Handle" p1.CFrame = CFrame.new(-40.3000031, 1.70000029, -42.2999992, 0, -1, 4.37113883e-008, 0, -4.37113883e-008, -1, 1, 0, 0) p1.FormFactor = Enum.FormFactor.Custom p1.Size = Vector3.new(1, 1, 1) x1 = Instance.new("Sound", p1) x1.Name = "Thap2" x1.Pitch = 3 x1.SoundId = "http://www.roblox.com/asset/?id=25299064" x1.Volume = 0.5 x1.Looped = false x1.PlayOnRemove = false x2 = Instance.new("Sound", p1) x2.Name = "Powder" x2.Pitch = 0.60000002384186 x2.SoundId = "http://www.roblox.com/asset/?id=21338895" x2.Volume = 0.20000000298023 x2.Looped = false x2.PlayOnRemove = false x3 = Instance.new("Sound", p1) x3.Name = "Rod" x3.Pitch = 1.1000000238419 x3.SoundId = "rbxasset://sounds//unsheath.wav" x3.Volume = 0.40000000596046 x3.Looped = false x3.PlayOnRemove = false x4 = Instance.new("Sound", p1) x4.Name = "Hammer" x4.Pitch = 0.40000000596046 x4.SoundId = "http://www.roblox.com/asset/?id=2697295" x4.Volume = 1 x4.Looped = false x4.PlayOnRemove = false x5 = Instance.new("Sound", p1) x5.Name = "Pan" x5.Pitch = 2 x5.SoundId = "http://www.roblox.com/asset/?id=25299064" x5.Volume = 1 x5.Looped = false x5.PlayOnRemove = false x6 = Instance.new("Sound", p1) x6.Name = "Thap" x6.Pitch = 5.5 x6.SoundId = "http://roblox.com/asset/?id=10209798" x6.Volume = 0.69999998807907 x6.Looped = false x6.PlayOnRemove = false x7 = Instance.new("Sound", p1) x7.Name = "Fire" x7.Pitch = 0.30000001192093 x7.SoundId = "http://roblox.com/asset/?id=10209859" x7.Volume = 1 x7.Looped = false x7.PlayOnRemove = false p2 = Instance.new("Part", t1) p2.BrickColor = BrickColor.new("Dark stone grey") p2.Reflectance = 0.10000000149012 p2.Name = "HandleBarrel" p2.CFrame = CFrame.new(-40.9000015, 3.25000024, -42.2999992, 0, 0, -1, 0, 1, 0, 1, 0, 0) p2.CanCollide = false p2.FormFactor = Enum.FormFactor.Symmetric p2.Size = Vector3.new(1, 1, 1) b1 = Instance.new("CylinderMesh", p2) b1.Name = "Mesh" b1.Scale = Vector3.new(0.400000006, 1.89999998, 0.400000006) p3 = Instance.new("Part", t1) p3.BrickColor = BrickColor.new("Dark stone grey") p3.Reflectance = 0.0099999997764826 p3.Name = "HandleBreech" p3.CFrame = CFrame.new(-40.8000031, 2.27500033, -42.2999992, 4.37113883e-008, -1, -1.91068547e-015, -1, -4.37113883e-008, 4.37113883e-008, -4.37113883e-008, 0, -1) p3.CanCollide = false p3.FormFactor = Enum.FormFactor.Symmetric p3.Size = Vector3.new(1, 1, 1) p3.BottomSurface = Enum.SurfaceType.Smooth p3.TopSurface = Enum.SurfaceType.Smooth b2 = Instance.new("SpecialMesh", p3) b2.MeshId = "http://www.roblox.com/asset/?id=3270017" b2.TextureId = "" b2.MeshType = Enum.MeshType.FileMesh b2.Name = "Mesh" b2.Scale = Vector3.new(0.5, 0.519999981, 1.52999997) p4 = Instance.new("Part", t1) p4.BrickColor = BrickColor.new("Nougat") p4.Material = Enum.Material.Slate p4.Name = "HandleFlintCocked" p4.CFrame = CFrame.new(-41.1000023, 2.42000031, -42.0499992, 0, -1, 4.37113883e-008, 0, -4.37113883e-008, -1, 1, 0, 0) p4.CanCollide = false p4.FormFactor = Enum.FormFactor.Symmetric p4.Size = Vector3.new(1, 1, 1) p4.BottomSurface = Enum.SurfaceType.Smooth p4.TopSurface = Enum.SurfaceType.Smooth b3 = Instance.new("BlockMesh", p4) b3.Name = "Mesh" b3.Scale = Vector3.new(0.0500000007, 0.0500000007, 0.100000001) p5 = Instance.new("Part", t1) p5.BrickColor = BrickColor.new("Nougat") p5.Material = Enum.Material.Slate p5.Transparency = 1 p5.Name = "HandleFlintUnCocked" p5.CFrame = CFrame.new(-40.9687691, 2.57478857, -42.0499992, 0, -0.642787695, -0.766044438, 0, 0.766044438, -0.642787695, 1, 0, 0) p5.CanCollide = false p5.FormFactor = Enum.FormFactor.Symmetric p5.Size = Vector3.new(1, 1, 1) p5.BottomSurface = Enum.SurfaceType.Smooth p5.TopSurface = Enum.SurfaceType.Smooth b4 = Instance.new("BlockMesh", p5) b4.Name = "Mesh" b4.Scale = Vector3.new(0.0500000007, 0.0500000007, 0.100000001) p6 = Instance.new("Part", t1) p6.BrickColor = BrickColor.new("Reddish brown") p6.Material = Enum.Material.Wood p6.Name = "HandleForeGrip" p6.CFrame = CFrame.new(-40.5500031, 2.70000029, -42.2999992, -8.74227766e-008, 1, 4.37113883e-008, -3.82137093e-015, 4.37113883e-008, -1, -1, -8.74227766e-008, 0) p6.CanCollide = false p6.FormFactor = Enum.FormFactor.Symmetric p6.Size = Vector3.new(1, 1, 1) p6.BottomSurface = Enum.SurfaceType.Smooth p6.TopSurface = Enum.SurfaceType.Smooth b5 = Instance.new("SpecialMesh", p6) b5.MeshType = Enum.MeshType.Wedge b5.Name = "Mesh" b5.Scale = Vector3.new(0.400000006, 0.300000012, 1.5) p7 = Instance.new("Part", t1) p7.BrickColor = BrickColor.new("Reddish brown") p7.Material = Enum.Material.Wood p7.Name = "HandleForeGrip2" p7.CFrame = CFrame.new(-40.8500023, 2.80000019, -42.2999992, 0, -1, 4.37113883e-008, 0, -4.37113883e-008, -1, 1, 0, 0) p7.CanCollide = false p7.FormFactor = Enum.FormFactor.Symmetric p7.Size = Vector3.new(1, 1, 1) p7.BottomSurface = Enum.SurfaceType.Smooth p7.TopSurface = Enum.SurfaceType.Smooth b6 = Instance.new("SpecialMesh", p7) b6.MeshType = Enum.MeshType.Brick b6.Name = "Mesh" b6.Scale = Vector3.new(0.400000006, 0.409999996, 1.35000002) p8 = Instance.new("Part", t1) p8.BrickColor = BrickColor.new("Medium stone grey") p8.Reflectance = 0.10000000149012 p8.Name = "HandleFrizzenClosed" p8.CFrame = CFrame.new(-40.9000015, 2.67500019, -42.0499992, 0, -1, 4.37113883e-008, 0, -4.37113883e-008, -1, 1, 0, 0) p8.CanCollide = false p8.FormFactor = Enum.FormFactor.Symmetric p8.Size = Vector3.new(1, 1, 1) p8.BottomSurface = Enum.SurfaceType.Smooth p8.TopSurface = Enum.SurfaceType.Smooth b7 = Instance.new("BlockMesh", p8) b7.Name = "Mesh" b7.Scale = Vector3.new(0.0500000007, 0.0500000007, 0.150000006) p9 = Instance.new("Part", t1) p9.BrickColor = BrickColor.new("Medium stone grey") p9.Reflectance = 0.10000000149012 p9.Name = "HandleFrizzenClosed2" p9.CFrame = CFrame.new(-41.0000038, 2.63000011, -42.0499992, 0, -1, 4.37113883e-008, 0, -4.37113883e-008, -1, 1, 0, 0) p9.CanCollide = false p9.FormFactor = Enum.FormFactor.Symmetric p9.Size = Vector3.new(1, 1, 1) p9.BottomSurface = Enum.SurfaceType.Smooth p9.TopSurface = Enum.SurfaceType.Smooth b8 = Instance.new("SpecialMesh", p9) b8.MeshType = Enum.MeshType.Wedge b8.Name = "Mesh" b8.Scale = Vector3.new(0.0500000007, 0.25, 0.0700000003) p10 = Instance.new("Part", t1) p10.BrickColor = BrickColor.new("Medium stone grey") p10.Reflectance = 0.10000000149012 p10.Transparency = 1 p10.Name = "HandleFrizzenOpen" p10.CFrame = CFrame.new(-40.8833656, 2.7076273, -42.0499992, 0, -0.707106829, -0.707106709, 0, 0.707106709, -0.707106829, 1, 0, 0) p10.CanCollide = false p10.FormFactor = Enum.FormFactor.Symmetric p10.Size = Vector3.new(1, 1, 1) p10.BottomSurface = Enum.SurfaceType.Smooth p10.TopSurface = Enum.SurfaceType.Smooth b9 = Instance.new("BlockMesh", p10) b9.Name = "Mesh" b9.Scale = Vector3.new(0.0500000007, 0.0500000007, 0.150000006) p11 = Instance.new("Part", t1) p11.BrickColor = BrickColor.new("Medium stone grey") p11.Reflectance = 0.10000000149012 p11.Transparency = 1 p11.Name = "HandleFrizzenOpen2" p11.CFrame = CFrame.new(-41.0071106, 2.76066041, -42.0499992, 0, -0.707106829, -0.707106709, 0, 0.707106709, -0.707106829, 1, 0, 0) p11.CanCollide = false p11.FormFactor = Enum.FormFactor.Symmetric p11.Size = Vector3.new(1, 1, 1) p11.BottomSurface = Enum.SurfaceType.Smooth p11.TopSurface = Enum.SurfaceType.Smooth b10 = Instance.new("SpecialMesh", p11) b10.MeshType = Enum.MeshType.Wedge b10.Name = "Mesh" b10.Scale = Vector3.new(0.0500000007, 0.25, 0.0700000003) p12 = Instance.new("Part", t1) p12.BrickColor = BrickColor.new("Reddish brown") p12.Material = Enum.Material.Wood p12.Name = "HandleGrip" p12.CFrame = CFrame.new(-40.6535568, 2.05355358, -42.2999992, 0, -0.707106829, -0.707106709, 0, 0.707106709, -0.707106829, 1, 0, 0) p12.CanCollide = false p12.FormFactor = Enum.FormFactor.Symmetric p12.Size = Vector3.new(1, 1, 1) p12.BottomSurface = Enum.SurfaceType.Smooth p12.TopSurface = Enum.SurfaceType.Smooth b11 = Instance.new("SpecialMesh", p12) b11.MeshType = Enum.MeshType.Brick b11.Name = "Mesh" b11.Scale = Vector3.new(0.400000006, 0.600000024, 0.449999988) p13 = Instance.new("Part", t1) p13.BrickColor = BrickColor.new("Reddish brown") p13.Material = Enum.Material.Wood p13.Name = "HandleGrip2" p13.CFrame = CFrame.new(-40.8265572, 2.17195249, -42.2999992, 0, -0.642787695, -0.766044438, 0, 0.766044438, -0.642787695, 1, 0, 0) p13.CanCollide = false p13.FormFactor = Enum.FormFactor.Symmetric p13.Size = Vector3.new(1, 1, 1) p13.BottomSurface = Enum.SurfaceType.Smooth p13.TopSurface = Enum.SurfaceType.Smooth b12 = Instance.new("SpecialMesh", p13) b12.MeshType = Enum.MeshType.Wedge b12.Name = "Mesh" b12.Scale = Vector3.new(0.310000002, 0.300000012, 0.319999993) p14 = Instance.new("Part", t1) p14.BrickColor = BrickColor.new("Reddish brown") p14.Material = Enum.Material.Wood p14.Name = "HandleGrip3" p14.CFrame = CFrame.new(-40.5000038, 1.90000033, -42.2999992, 0, -1, 4.37113883e-008, 0, -4.37113883e-008, -1, 1, 0, 0) p14.CanCollide = false p14.FormFactor = Enum.FormFactor.Symmetric p14.Size = Vector3.new(1, 1, 1) p14.BottomSurface = Enum.SurfaceType.Smooth p14.TopSurface = Enum.SurfaceType.Smooth b13 = Instance.new("SpecialMesh", p14) b13.MeshType = Enum.MeshType.Wedge b13.Name = "Mesh" b13.Scale = Vector3.new(0.379999995, 0.331999987, 0.319999993) p15 = Instance.new("Part", t1) p15.BrickColor = BrickColor.new("Reddish brown") p15.Material = Enum.Material.Wood p15.Name = "HandleGrip4" p15.CFrame = CFrame.new(-40.2000046, 1.90000033, -42.2999992, 0, -1, 4.37113883e-008, 0, -4.37113883e-008, -1, 1, 0, 0) p15.CanCollide = false p15.FormFactor = Enum.FormFactor.Symmetric p15.Size = Vector3.new(1, 1, 1) p15.BottomSurface = Enum.SurfaceType.Smooth p15.TopSurface = Enum.SurfaceType.Smooth b14 = Instance.new("SpecialMesh", p15) b14.MeshType = Enum.MeshType.Brick b14.Name = "Mesh" b14.Scale = Vector3.new(0.400000006, 0.600000024, 0.319999993) p16 = Instance.new("Part", t1) p16.BrickColor = BrickColor.new("Reddish brown") p16.Material = Enum.Material.Wood p16.Name = "HandleGrip5" p16.CFrame = CFrame.new(-39.9500046, 1.93000031, -42.2999992, 0, -1, 4.37113883e-008, 0, -4.37113883e-008, -1, 1, 0, 0) p16.CanCollide = false p16.FormFactor = Enum.FormFactor.Symmetric p16.Size = Vector3.new(1, 1, 1) p16.BottomSurface = Enum.SurfaceType.Smooth p16.TopSurface = Enum.SurfaceType.Smooth b15 = Instance.new("SpecialMesh", p16) b15.MeshType = Enum.MeshType.Sphere b15.Name = "Mesh" b15.Scale = Vector3.new(0.449999988, 0.300000012, 0.400000006) p17 = Instance.new("Part", t1) p17.BrickColor = BrickColor.new("Medium stone grey") p17.Reflectance = 0.10000000149012 p17.Name = "HandleHammer" p17.CFrame = CFrame.new(-40.8350029, 2.35000038, -42.0499992, 1, 4.37113883e-008, 4.37113883e-008, 4.37113883e-008, 1.91068547e-015, -1, -4.37113883e-008, 1, 0) p17.CanCollide = false p17.FormFactor = Enum.FormFactor.Symmetric p17.Size = Vector3.new(1, 1, 1) p17.BottomSurface = Enum.SurfaceType.Smooth p17.TopSurface = Enum.SurfaceType.Smooth b16 = Instance.new("CylinderMesh", p17) b16.Name = "Mesh" b16.Scale = Vector3.new(0.150000006, 0.0500000007, 1) p18 = Instance.new("Part", t1) p18.BrickColor = BrickColor.new("Medium stone grey") p18.Reflectance = 0.10000000149012 p18.Name = "HandleHammerCocked" p18.CFrame = CFrame.new(-41.0500031, 2.35000038, -42.0499992, 0, 0, -1, 0, 1, 0, 1, 0, 0) p18.CanCollide = false p18.FormFactor = Enum.FormFactor.Symmetric p18.Size = Vector3.new(1, 1, 1) p18.BottomSurface = Enum.SurfaceType.Smooth p18.TopSurface = Enum.SurfaceType.Smooth b17 = Instance.new("BlockMesh", p18) b17.Name = "Mesh" b17.Scale = Vector3.new(0.0500000007, 0.0500000007, 0.300000012) p19 = Instance.new("Part", t1) p19.BrickColor = BrickColor.new("Medium stone grey") p19.Reflectance = 0.10000000149012 p19.Transparency = 1 p19.Name = "HandleHammerUnCocked" p19.CFrame = CFrame.new(-40.9672699, 2.51077485, -42.0499992, 0, 0.766044438, -0.642787695, 0, 0.642787695, 0.766044438, 1, 0, 0) p19.CanCollide = false p19.FormFactor = Enum.FormFactor.Symmetric p19.Size = Vector3.new(1, 1, 1) p19.BottomSurface = Enum.SurfaceType.Smooth p19.TopSurface = Enum.SurfaceType.Smooth b18 = Instance.new("BlockMesh", p19) b18.Name = "Mesh" b18.Scale = Vector3.new(0.0500000007, 0.0500000007, 0.300000012) p20 = Instance.new("Part", t1) p20.BrickColor = BrickColor.new("Really black") p20.Name = "HandleMuzzle" p20.CFrame = CFrame.new(-40.9000015, 4.20000029, -42.2999992, 0, 0, -1, 0, 1, 0, 1, 0, 0) p20.CanCollide = false p20.FormFactor = Enum.FormFactor.Symmetric p20.Size = Vector3.new(1, 1, 1) b19 = Instance.new("CylinderMesh", p20) b19.Name = "Mesh" b19.Scale = Vector3.new(1, 0.00999999978, 0.25) x8 = Instance.new("Smoke", p20) x8.Name = "Smokey" x8.Color = Color3.new(0.972549, 0.972549, 0.972549) x8.Opacity = 0.10000000149012 p21 = Instance.new("Part", t1) p21.BrickColor = BrickColor.new("Medium stone grey") p21.Reflectance = 0.10000000149012 p21.Name = "HandlePan" p21.CFrame = CFrame.new(-40.8500023, 2.65000033, -42.0499992, 0, -1, 4.37113883e-008, 0, -4.37113883e-008, -1, 1, 0, 0) p21.CanCollide = false p21.FormFactor = Enum.FormFactor.Symmetric p21.Size = Vector3.new(1, 1, 1) p21.BottomSurface = Enum.SurfaceType.Smooth p21.TopSurface = Enum.SurfaceType.Smooth b20 = Instance.new("BlockMesh", p21) b20.Name = "Mesh" b20.Scale = Vector3.new(0.0500000007, 0.0500000007, 0.100000001) p22 = Instance.new("Part", t1) p22.BrickColor = BrickColor.new("Dark stone grey") p22.Reflectance = 0.10000000149012 p22.Name = "HandlePlate" p22.CFrame = CFrame.new(-40.8250046, 2.45000029, -42.0999985, 0, -1, 4.37113883e-008, 0, -4.37113883e-008, -1, 1, 0, 0) p22.CanCollide = false p22.FormFactor = Enum.FormFactor.Symmetric p22.Size = Vector3.new(1, 1, 1) p22.BottomSurface = Enum.SurfaceType.Smooth p22.TopSurface = Enum.SurfaceType.Smooth b21 = Instance.new("BlockMesh", p22) b21.Name = "Mesh" b21.Scale = Vector3.new(0.0500000007, 0.200000003, 0.460000008) p23 = Instance.new("Part", t1) p23.BrickColor = BrickColor.new("Dark stone grey") p23.Reflectance = 0.10000000149012 p23.Name = "HandlePlate2" p23.CFrame = CFrame.new(-40.8232613, 2.22325945, -42.0999985, 0, -0.707106829, -0.707106709, 0, 0.707106709, -0.707106829, 1, 0, 0) p23.CanCollide = false p23.FormFactor = Enum.FormFactor.Symmetric p23.Size = Vector3.new(1, 1, 1) p23.BottomSurface = Enum.SurfaceType.Smooth p23.TopSurface = Enum.SurfaceType.Smooth b22 = Instance.new("SpecialMesh", p23) b22.MeshType = Enum.MeshType.Wedge b22.Name = "Mesh" b22.Scale = Vector3.new(0.0500000007, 0.140000001, 0.140000001) p24 = Instance.new("Part", t1) p24.BrickColor = BrickColor.new("Dark stone grey") p24.Reflectance = 0.10000000149012 p24.Name = "HandlePlate3" p24.CFrame = CFrame.new(-40.8225021, 2.90000033, -42.0999985, 0, 0, -1, 0, 1, 0, 1, 0, 0) p24.CanCollide = false p24.FormFactor = Enum.FormFactor.Symmetric p24.Size = Vector3.new(1, 1, 1) p24.BottomSurface = Enum.SurfaceType.Smooth p24.TopSurface = Enum.SurfaceType.Smooth b23 = Instance.new("SpecialMesh", p24) b23.MeshType = Enum.MeshType.Wedge b23.Name = "Mesh" b23.Scale = Vector3.new(0.0500000007, 0.5, 0.200000003) p25 = Instance.new("Part", t1) p25.BrickColor = BrickColor.new("Dark stone grey") p25.Reflectance = 0.10000000149012 p25.Name = "HandleRod" p25.CFrame = CFrame.new(-40.6300049, 3.10000038, -42.2999992, 0, 0, -1, 0, 1, 0, 1, 0, 0) p25.CanCollide = false p25.FormFactor = Enum.FormFactor.Symmetric p25.Size = Vector3.new(1, 1, 1) b24 = Instance.new("CylinderMesh", p25) b24.Name = "Mesh" b24.Scale = Vector3.new(0.100000001, 2, 0.100000001) p26 = Instance.new("Part", t1) p26.BrickColor = BrickColor.new("Dark stone grey") p26.Reflectance = 0.10000000149012 p26.Name = "HandleRod2" p26.CFrame = CFrame.new(-40.6300049, 4.10000038, -42.2999992, 0, 0, -1, 0, 1, 0, 1, 0, 0) p26.CanCollide = false p26.FormFactor = Enum.FormFactor.Symmetric p26.Size = Vector3.new(1, 1, 1) b25 = Instance.new("SpecialMesh", p26) b25.MeshType = Enum.MeshType.Sphere b25.Name = "Mesh" b25.Scale = Vector3.new(0.200000003, 0.200000003, 0.200000003) p27 = Instance.new("Part", t1) p27.BrickColor = BrickColor.new("Reddish brown") p27.Material = Enum.Material.Wood p27.Name = "HandleRodHolder" p27.CFrame = CFrame.new(-40.7500038, 3.70000029, -42.2999992, 0, -1, 4.37113883e-008, 0, -4.37113883e-008, -1, 1, 0, 0) p27.CanCollide = false p27.FormFactor = Enum.FormFactor.Symmetric p27.Size = Vector3.new(1, 1, 1) p27.BottomSurface = Enum.SurfaceType.Smooth p27.TopSurface = Enum.SurfaceType.Smooth b26 = Instance.new("SpecialMesh", p27) b26.MeshType = Enum.MeshType.Brick b26.Name = "Mesh" b26.Scale = Vector3.new(0.300000012, 0.200000003, 0.899999976) p28 = Instance.new("Part", t1) p28.BrickColor = BrickColor.new("Dark stone grey") p28.Reflectance = 0.090000003576279 p28.Name = "HandleTrigger" p28.CFrame = CFrame.new(-40.5884018, 2.39951944, -42.2999992, 0, -0.5, -0.866025448, 0, 0.866025448, -0.5, 1, 0, 0) p28.CanCollide = false p28.FormFactor = Enum.FormFactor.Symmetric p28.Size = Vector3.new(1, 1, 1) p28.BottomSurface = Enum.SurfaceType.Smooth p28.TopSurface = Enum.SurfaceType.Smooth b27 = Instance.new("BlockMesh", p28) b27.Name = "Mesh" b27.Scale = Vector3.new(0.0500000007, 0.0500000007, 0.449999988) p29 = Instance.new("Part", t1) p29.BrickColor = BrickColor.new("Dark stone grey") p29.Reflectance = 0.090000003576279 p29.Name = "HandleTriggerGuard" p29.CFrame = CFrame.new(-40.5000038, 2.50000024, -42.2999992, 4.37113883e-008, -1, -1.91068547e-015, -1, -4.37113883e-008, 4.37113883e-008, -4.37113883e-008, 0, -1) p29.CanCollide = false p29.FormFactor = Enum.FormFactor.Symmetric p29.Size = Vector3.new(1, 1, 1) p29.BottomSurface = Enum.SurfaceType.Smooth p29.TopSurface = Enum.SurfaceType.Smooth b28 = Instance.new("SpecialMesh", p29) b28.MeshId = "http://www.roblox.com/asset/?id=3270017" b28.TextureId = "" b28.MeshType = Enum.MeshType.FileMesh b28.Name = "Mesh" b28.Scale = Vector3.new(0.349999994, 0.349999994, 0.300000012) v1 = Instance.new("NumberValue", t1) v1.Name = "Ammo" v1.Value = 1 s2 = script:clone() s2.Name = "Bullet" s2.Disabled = true so2 = Instance.new("StringValue", s2) so2.Name = "forCustomRun" so2.Value = [===[ ball = script.Parent damage = math.random(45,55) local hitt = false HitSound = Instance.new("Sound") HitSound.Name = "HitSound" HitSound.SoundId = "http://www.roblox.com/asset/?id=11945266" HitSound.Pitch = .8 HitSound.Volume = 1 HitSound.Parent = ball function onTouched(hit) if hit.Parent:findFirstChild("ForceField") ~= nil then return end if hit.CanCollide == false and hit.Parent:findFirstChild("Humanoid") == nil then return end if hit.Parent.className == "Hat" and hitt == false then hitt = true hit:BreakJoints() hit.Velocity = ball.Velocity hit.Parent.Parent = game.Workspace end if hit:findFirstChild("Metal") ~= nil and hitt == false then hitt = true for i = 1,math.random(1,3) do local j = Instance.new("Part") j.formFactor = "Plate" j.Size = Vector3.new(1,.4,1) j.BrickColor = BrickColor.new("Bright yellow") j.CanCollide = false j.Velocity = Vector3.new(math.random(-10,10),math.random(-10,10),math.random(-10,10)) j.CFrame = script.Parent.CFrame j.Parent = game.Workspace end end local humanoid = hit.Parent:findFirstChild("Humanoid") if humanoid ~= nil and hitt == false then hitt = true tagHumanoid(humanoid) if hit.Name == "Head" then humanoid.Health = humanoid.Health - damage * 2 elseif hit.Name == "Torso" then humanoid.Health = humanoid.Health - damage * 1.5 else humanoid.Health = humanoid.Health - damage end wait(.2) untagHumanoid(humanoid) end if hitt == true then HitSound:play() ball.Parent = nil end end function tagHumanoid(humanoid) -- todo: make tag expire local tag = ball:findFirstChild("creator") if tag ~= nil then local new_tag = tag:clone() new_tag.Parent = humanoid end end function untagHumanoid(humanoid) if humanoid ~= nil then local tag = humanoid:findFirstChild("creator") if tag ~= nil then tag.Parent = nil end end end connection = ball.Touched:connect(onTouched) while true do wait(.01) if damage < 0 then break else damage = damage - .2 end end ball.Parent = nil ]===] s2.Parent = t1 v2 = Instance.new("NumberValue", t1) v2.Name = "MaxAmmo" v2.Value = 1 v3 = Instance.new("NumberValue", t1) v3.Name = "Recoil" v3.Value = 2 v4 = Instance.new("NumberValue", t1) v4.Name = "StoredAmmo" v4.Value = 10 s3 = script:clone() s3.Name = "GuiScript2" s3.Disabled = false so3 = Instance.new("StringValue", s3) so3.Name = "forCustomRunL" so3.Value = [===[ local Tool = script.Parent local vPlayer local Gui local Text function setUpGui() if vPlayer == nil or vPlayer:findFirstChild("PlayerGui") == nil then return end Gui = Instance.new("ScreenGui") Text = Instance.new("TextLabel") Gui.Name = "DEDisplay" Gui.Parent = vPlayer.PlayerGui Text.BackgroundColor3 = BrickColor.Black().Color Text.BackgroundTransparency = 1 Text.BorderColor3 = BrickColor.White().Color Text.BorderSizePixel = 0 Text.Name = "Ammo" Text.Parent = Gui Text.Position = UDim2.new(0.85, 0, 0.8, 0) Text.Size = UDim2.new(0, 128, 0, 64) Text.FontSize = "Size12" Text.Text = "LW Flintlock Pistol" Text.TextColor3 = BrickColor.White().Color wait(2.5) Text.TextTransparency = .1 wait(.1) Text.TextTransparency = .2 wait(.1) Text.TextTransparency = .3 wait(.1) Text.TextTransparency = .4 wait(.1) Text.TextTransparency = .5 wait(.1) Text.TextTransparency = .6 wait(.1) Text.TextTransparency = .7 wait(.1) Text.TextTransparency = .8 wait(.1) Text.TextTransparency = .9 wait(.1) Text.TextTransparency = 1 end function onEquippedLocal(mouse) vPlayer = game.Players.LocalPlayer setUpGui() end function onUnequippedLocal(mouse) if Gui then Gui:remove() end Gui = nil Text = nil vPlayer = nil end Tool.Equipped:connect(onEquippedLocal) Tool.Unequipped:connect(onUnequippedLocal) ]===] s3.Parent = t1 s4 = script:clone() s4.Name = "GuiScript1" s4.Disabled = false so4 = Instance.new("StringValue", s4) so4.Name = "forCustomRunL" so4.Value = [===[ local Tool = script.Parent local Ammo = Tool.Ammo local MaxAmmo = Ammo.Value local vPlayer local Gui local Text function onChanged(value) if value == "Value" or value == Ammo.Value then if Gui ~= nil and Text ~= nil then if Ammo.Value >= 1 then Text.Text = ""..script.Parent.Ammo.Value.."|"..script.Parent.StoredAmmo.Value.."" elseif math.floor(Ammo.Value) == 0 then Text.Text = ""..script.Parent.Ammo.Value.."|"..script.Parent.StoredAmmo.Value.."" elseif Ammo.Value < 0 then for i = 0, 1, 0.03 / 2 do local Num = math.floor(i * MaxAmmo + 0.5) Text.Text = ""..script.Parent.Ammo.Value.."|"..script.Parent.StoredAmmo.Value.."" wait() end end end end end function on2Changed() if Gui ~= nil and Text ~= nil then Text.Text = ""..script.Parent.Ammo.Value.."|"..script.Parent.StoredAmmo.Value.."" wait() end end function setUpGui() if vPlayer == nil or vPlayer:findFirstChild("PlayerGui") == nil then return end Gui = Instance.new("ScreenGui") Text = Instance.new("TextLabel") Gui.Name = "DEDisplay" Gui.Parent = vPlayer.PlayerGui Text.BackgroundColor3 = BrickColor.Black().Color Text.BackgroundTransparency = 1 Text.BorderColor3 = BrickColor.White().Color Text.BorderSizePixel = 0 Text.Name = "Ammo" Text.Parent = Gui Text.Position = UDim2.new(0.85, 0, 0.825, 0) Text.Size = UDim2.new(0, 128, 0, 64) Text.FontSize = "Size18" Text.Text = ""..script.Parent.Ammo.Value.."|"..script.Parent.StoredAmmo.Value.."" Text.TextColor3 = BrickColor.White().Color end function onEquippedLocal(mouse) vPlayer = game.Players.LocalPlayer setUpGui() end function onUnequippedLocal(mouse) if Gui then Gui:remove() end Gui = nil Text = nil vPlayer = nil end Tool.Equipped:connect(onEquippedLocal) Tool.Unequipped:connect(onUnequippedLocal) Ammo.Changed:connect(onChanged) Tool.StoredAmmo.Changed:connect(on2Changed) ]===] s4.Parent = t1 s5 = script:clone() s5.Name = "Remover" s5.Disabled = true so5 = Instance.new("StringValue", s5) so5.Name = "forCustomRun" so5.Value = [===[ wait(11) script.Parent.Smokey.Enabled = false wait(3) script.Parent.Parent = nil ]===] s5.Parent = t1 s6 = script:clone() s6.Name = "Shooter" s6.Disabled = false so6 = Instance.new("StringValue", s6) so6.Name = "forCustomRunL" so6.Value = [===[ Tool = script.Parent local arms = nil local torso = nil local weld33 = nil -- right arm local weld55 = nil -- left arm local welds = {} local reloading = false local firing = false local canshoot = true local canreload = true function ReloadSequence() --THIS WAS ALL FOR YOU SCOUT. weld33.C1 = CFrame.new(-0.75, 0.2, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.35, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90)) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-0.2) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(5), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-0.4) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(10), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-0.5) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(15), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-0.5) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(20), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-1) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(20), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-2) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(30), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-5) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(35), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-13) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(40), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-20) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(40), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-20) Tool.GripPos = Vector3.new(0,0.1,-0.7) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(25), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-20) Tool.GripPos = Vector3.new(0,0.2,-1) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(20), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-20) Tool.GripPos = Vector3.new(0,0.3,-1.3) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(13), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-20) Tool.GripPos = Vector3.new(0,0.3,-1.6) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(7), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-20) Tool.GripPos = Vector3.new(0,0.3,-1.8) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(0), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-20) Tool.GripPos = Vector3.new(0,0.3,-2)----------------------------------------------End Of Spin wait(0.2) weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(-15), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 0.8, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(-30), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 0.6, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(270), math.rad(-45), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 0.6, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(270), math.rad(-60), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 0.6, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(270), math.rad(-75), math.rad(-90)) wait(0.5)----------------------------------------------------------------HandDownPowder weld55.C1 = CFrame.new(-0.5, 0.6, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(270), math.rad(-60), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 0.6, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(270), math.rad(-45), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 0.8, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(-30), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(-15), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(0), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(15), math.rad(-90)) wait(0.035) Tool.HandlePowder.Transparency = 0 Tool.Handle.Powder:play() weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(18), math.rad(-90))---SHAKEH SHAKEH wait(0.04) weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(16), math.rad(-90)) wait(0.04) weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(18), math.rad(-90)) wait(0.04) weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(16), math.rad(-90)) wait(0.04) weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(18), math.rad(-90)) wait(0.04) weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(16), math.rad(-90)) wait(0.04) weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(18), math.rad(-90)) wait(0.04) weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(16), math.rad(-90)) wait(0.04) weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(18), math.rad(-90)) wait(0.04) Tool.Handle.Powder:stop() Tool.HandlePowder.Transparency = 1 wait(0.4) weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(-15), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 0.8, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(-30), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 0.6, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(270), math.rad(-45), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 0.6, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(270), math.rad(-60), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 0.6, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(270), math.rad(-75), math.rad(-90)) wait(0.3)----------------------------------------------------------------HandDownBullet weld55.C1 = CFrame.new(-0.5, 0.6, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(271), math.rad(-72), math.rad(-90)) wait(0.3) weld55.C1 = CFrame.new(-0.5, 0.6, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(273), math.rad(-75), math.rad(-90)) wait(0.3) weld55.C1 = CFrame.new(-0.5, 0.6, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(274), math.rad(-72), math.rad(-90)) wait(0.3) weld55.C1 = CFrame.new(-0.5, 0.6, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(270), math.rad(-75), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 0.6, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(270), math.rad(-60), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 0.6, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(270), math.rad(-45), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 0.8, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(-30), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(-15), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(0), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(10), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(10), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.5, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(10), math.rad(-100)) wait(0.2) Tool.HandleCloth.Mesh.Scale = Vector3.new(0.245, 0.245, 0.245) Tool.HandleCloth.Transparency = 0 Tool.HandleMuzzle.Smokey.Enabled = false wait(0.3) Tool.HandleCloth.Mesh.Scale = Vector3.new(0.22, 0.22, 0.22) wait(0.1) Tool.HandleCloth.Mesh.Scale = Vector3.new(0.2, 0.2, 0.2) wait(0.1) Tool.HandleCloth.Mesh.Scale = Vector3.new(0.15, 0.15, 0.15) wait(0.1) Tool.HandleCloth.Mesh.Scale = Vector3.new(0.1, 0.1, 0.1) wait(0.1) Tool.HandleCloth.Mesh.Scale = Vector3.new(0.05, 0.05, 0.05) wait(0.1) Tool.HandleCloth.Transparency = 1-----------End Of Bullet wait(0.3) weld33.C1 = CFrame.new(-0.75, 0.4, 0) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0)-----------ROD weld55.C1 = CFrame.new(-0.5, 1.2, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(10), math.rad(-90)) wait(0.5) Tool.Handle.Thap2:play() Tool.HandleRod2.Transparency = 1 Tool.HandleRod.Mesh.Offset = Vector3.new(0, 0.5, 0) weld55.C1 = CFrame.new(0, 1, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(25), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 1, 0) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(40), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 1.4, 0) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(50), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 1.8, 0) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(60), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 2.2, 0.1) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(60), math.rad(-90))---Moving Rod Tool.HandleRod.Mesh.Offset = Vector3.new(0, 2.2, 0.26) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(55), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 1.8, 0.26) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(50), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 1.4, 0.26) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(45), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 1, 0.26) wait(0.05) Tool.Handle.Rod:play() weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(40), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 0.6, 0.26) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(35), math.rad(-90))--Rod Down Tool.HandleRod.Mesh.Offset = Vector3.new(0, 0.2, 0.26) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(40), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 0.6, 0.26) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(45), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 1, 0.26) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(50), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 1.4, 0.26) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(45), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 1, 0.26) wait(0.05) Tool.Handle.Rod:play() weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(40), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 0.6, 0.26) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(35), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 0.2, 0.26) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(40), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 0.6, 0.26) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(45), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 1, 0.26) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(40), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 0.6, 0.26) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(35), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 0.2, 0.26) wait(0.05) Tool.Handle.Rod:play() weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(40), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 0.6, 0.26) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(45), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 1, 0.26) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(50), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 1.4, 0.26) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(55), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 1.8, 0.26) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(60), math.rad(-90))---Rod Up Tool.HandleRod.Mesh.Offset = Vector3.new(0, 2.2, 0.26) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(60), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 2.2, 0.1) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(50), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 1.8, 0) wait(0.05) weld55.C1 = CFrame.new(0, 1.7, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(40), math.rad(-90)) Tool.HandleRod.Mesh.Offset = Vector3.new(0, 1.4, 0) wait(0.05) weld55.C1 = CFrame.new(-0.5, 1.2, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(10), math.rad(-90))---End Of Rod Tool.HandleRod.Mesh.Offset = Vector3.new(0, 0, 0) Tool.HandleRod2.Transparency = 0 Tool.Handle.Thap2:play() weld33.C1 = CFrame.new(-0.75, 0.2, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0)-----------ROD weld55.C1 = CFrame.new(-0.5, 1.2, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(10), math.rad(-90)) wait(0.035) weld55.C1 = CFrame.new(-0.35, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90))--Beginning of Spin wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(7), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-20) Tool.GripPos = Vector3.new(0,0.3,-1.8) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(13), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-20) Tool.GripPos = Vector3.new(0,0.3,-1.6) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(20), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-20) Tool.GripPos = Vector3.new(0,0.3,-1.3) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(25), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-20) Tool.GripPos = Vector3.new(0,0.2,-1) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(40), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-20) Tool.GripPos = Vector3.new(0,0,-0.4) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(40), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-20) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(35), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-13) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(30), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-5) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(20), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-2) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(20), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-1) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(15), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-0.5) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(10), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-0.5) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(5), math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-0.4) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.5, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90)) Tool.GripUp = Vector3.new(0,1,-0.2) wait(0.035) weld33.C1 = CFrame.new(-0.75, 0.2, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.35, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90)) Tool.GripUp = Vector3.new(0,1,0) wait(0.1)---Begin to Mess with Fire Mech weld55.C1 = CFrame.new(-0.35, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(295), 0, math.rad(-90)) Tool.GripPos = Vector3.new (0, 0, -0.6) wait(0.035) weld55.C1 = CFrame.new(-0.35, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), 0, math.rad(-90)) Tool.GripPos = Vector3.new (0, 0.1, -0.8) wait(0.035) wait(0.1) Tool.GripUp = Vector3.new(0,1,-0.2) Tool.Handle.Hammer:play() Tool.HandleFlintCocked.Transparency = 0 Tool.HandleHammerCocked.Transparency = 0 Tool.HandleFlintUnCocked.Transparency = 1 Tool.HandleHammerUnCocked.Transparency = 1 wait(0.25) Tool.GripUp = Vector3.new(0,1,0) wait(0.3) weld55.C1 = CFrame.new(-0.35, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(301), 0, math.rad(-90)) Tool.GripPos = Vector3.new (0, 0.3, -0.85) wait(0.2) Tool.Handle.Pan:play() Tool.HandleFrizzenClosed.Transparency = 0 Tool.HandleFrizzenClosed2.Transparency = 0 Tool.HandleFrizzenOpen.Transparency = 1 Tool.HandleFrizzenOpen2.Transparency = 1 weld55.C1 = CFrame.new(-0.35, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(300), 0, math.rad(-90)) Tool.GripPos = Vector3.new (0, 0.2, -0.8) wait(0.035) weld55.C1 = CFrame.new(-0.35, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(295), 0, math.rad(-90)) Tool.GripPos = Vector3.new (0, 0.1, -0.6) wait(0.035) weld55.C1 = CFrame.new(-0.35, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90)) Tool.GripPos = Vector3.new (0, 0, -0.4) end function Reload() if script.Parent.Ammo.Value < script.Parent.MaxAmmo.Value and reloading == false and script.Parent.StoredAmmo.Value >= 1 and canreload == true then reloading = true script.Parent.Ammo.Value = 0 ReloadSequence() if script.Parent.StoredAmmo.Value >= script.Parent.MaxAmmo.Value then script.Parent.Ammo.Value = script.Parent.MaxAmmo.Value script.Parent.StoredAmmo.Value = script.Parent.StoredAmmo.Value - script.Parent.MaxAmmo.Value script.Parent.Recoil.Value = 5 elseif script.Parent.StoredAmmo.Value < script.Parent.MaxAmmo.Value and script.Parent.StoredAmmo.Value >= 1 then script.Parent.Ammo.Value = script.Parent.StoredAmmo.Value script.Parent.StoredAmmo.Value = 0 script.Parent.Recoil.Value = 5 end reloading = false end end function Equip(mouse) wait(0.01) arms = {Tool.Parent:FindFirstChild("Left Arm"), Tool.Parent:FindFirstChild("Right Arm")} torso = Tool.Parent:FindFirstChild("Torso") if arms ~= nil and torso ~= nil then local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")} if sh ~= nil then local yes = true if yes then yes = false sh[1].Part1 = nil sh[2].Part1 = nil falsearm1 = arms[1]:clone() local mesh1 = Instance.new("BlockMesh") mesh1.Scale = Vector3.new(.9,.9,.9) mesh1.Parent = falsearm1 local armweld1 = Instance.new("Weld") falsearm1.BrickColor = BrickColor.new("Brick yellow") falsearm1.Parent = Tool armweld1.Parent = falsearm1 armweld1.Part0 = falsearm1 armweld1.Part1 = arms[1] falsearm2 = arms[2]:clone() local mesh2 = Instance.new("BlockMesh") mesh2.Scale = Vector3.new(.9,.9,.9) mesh2.Parent = falsearm2 local armweld2 = Instance.new("Weld") falsearm2.BrickColor = BrickColor.new("Brick yellow") falsearm2.Parent = Tool armweld2.Parent = falsearm2 armweld2.Part0 = falsearm2 armweld2.Part1 = arms[2] local weld1 = Instance.new("Weld") -- left arm weld55 = weld1 weld1.Part0 = torso weld1.Parent = torso weld1.Part1 = arms[1] weld1.C1 = CFrame.new(-0.35, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90)) welds[1] = weld1 local weld2 = Instance.new("Weld") -- right arm weld33 = weld2 weld2.Part0 = torso weld2.Parent = torso weld2.Part1 = arms[2] weld2.C1 = CFrame.new(-0.75, 0.1, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) welds[2] = weld2 end else print("sh") end else print("arms") end end local legs = nil local torso2 = nil local welds2 = {} local bodyforce = nil function Crouch(mouse) wait(0.01) legs = {Tool.Parent:FindFirstChild("Left Leg"), Tool.Parent:FindFirstChild("Right Leg")} torso2 = Tool.Parent:FindFirstChild("Torso") if arms ~= nil and torso ~= nil then local hp = {torso:FindFirstChild("Left Hip"), torso:FindFirstChild("Right Hip")} if hp ~= nil then local yes = true if yes then yes = false Tool.Parent.Humanoid.WalkSpeed = 5 hp[1].Part1 = nil hp[2].Part1 = nil legs[1].Name = "Left" legs[1].CanCollide = true legs[2].Name = "Right" legs[2].CanCollide = true local weld1 = Instance.new("Weld") -- left arm weld1.Part0 = torso2 weld1.Parent = torso2 weld1.Part1 = legs[1] weld1.C1 = CFrame.new(-0.5,0.5,0.5) * CFrame.fromEulerAnglesXYZ(0.6,0,0) welds2[1] = weld1 local weld2 = Instance.new("Weld") -- right arm weld2.Part0 = torso2 weld2.Parent = torso2 weld2.Part1 = legs[2] weld2.C1 = CFrame.new(0.5,0.5,0.5) * CFrame.fromEulerAnglesXYZ(0.6,0,0) welds2[2] = weld2 bodyforce = Instance.new("BodyForce") bodyforce.Parent = torso2 end else print("hp") end else print("legs") end end function Uncrouch(mouse) if arms ~= nil and torso ~= nil then local hp = {torso2:FindFirstChild("Left Hip"), torso2:FindFirstChild("Right Hip")} if hp ~= nil then local yes = true if yes then yes = false Tool.Parent.Humanoid.WalkSpeed = 16 hp[1].Part1 = legs[1] hp[2].Part1 = legs[2] legs[1].Name = "Left Leg" legs[2].Name = "Right Leg" welds2[1].Parent = nil welds2[2].Parent = nil bodyforce:remove() end else print("hp") end else print("legs") end end function Unequip(mouse) if arms ~= nil and torso ~= nil then local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")} if sh ~= nil then local yes = true if yes then yes = false sh[1].Part1 = arms[1] sh[2].Part1 = arms[2] welds[1].Parent = nil welds[2].Parent = nil falsearm1:remove() falsearm2:remove() end else print("sh") end else print("arms") end end function fire(v) Tool.Handle.Thap:play() Tool.HandleFlintCocked.Transparency = 1 Tool.HandleHammerCocked.Transparency = 1 Tool.HandleFrizzenClosed.Transparency = 1 Tool.HandleFrizzenClosed2.Transparency = 1 Tool.HandleFlintUnCocked.Transparency = 0 Tool.HandleHammerUnCocked.Transparency = 0 Tool.HandleFrizzenOpen.Transparency = 0 Tool.HandleFrizzenOpen2.Transparency = 0 local spark = Instance.new("Fire") spark.Parent = Tool.HandleFrizzenOpen spark.Heat = 1 spark.Size = 2 wait(0.01) spark:Remove() wait(0.05) Tool.Handle.Fire:play() Tool.HandleMuzzle.Smokey.Enabled = true local spark2 = Instance.new("Fire") spark2.Parent = Tool.HandleMuzzle spark2.Heat = 1 spark2.Size = 2 wait(0.01) spark2:Remove() local vCharacter = Tool.Parent local vPlayer = game.Players:playerFromCharacter(vCharacter) local missile = Instance.new("Part") local spawnPos = vCharacter.PrimaryPart.Position spawnPos = spawnPos + (v * 8) missile.Position = spawnPos missile.Size = Vector3.new(1,1,1) missile.Velocity = v * 600 missile.BrickColor = BrickColor.new("Really black") missile.Shape = 0 missile.BottomSurface = 0 missile.TopSurface = 0 missile.Name = "Bullet" missile.Elasticity = 0 missile.Reflectance = 0.1 missile.Friction = .9 missile.CanCollide = false local force = Instance.new("BodyForce") force.force = Vector3.new(0,missile:getMass() * 196,0) force.Parent = missile local mesh = Instance.new("SpecialMesh") mesh.Scale = Vector3.new(.2,.2,.2) mesh.MeshType = "Sphere" mesh.Parent = missile local new_script = script.Parent.Bullet:clone() new_script.Disabled = false new_script.Parent = missile local creator_tag = Instance.new("ObjectValue") creator_tag.Value = vPlayer creator_tag.Name = "creator" creator_tag.Parent = missile missile.Parent = game.Workspace local smoke = Instance.new("Part") smoke.Position = Tool.HandleMuzzle.Position smoke.Size = Vector3.new(1,1,1) smoke.Velocity = v * 1 smoke.BrickColor = BrickColor.new("White") smoke.Shape = 0 smoke.BottomSurface = 0 smoke.TopSurface = 0 smoke.Name = "Smoke" smoke.Elasticity = 0 smoke.Reflectance = 0 smoke.Friction = 0 smoke.CanCollide = false smoke.Anchored = true smoke.Transparency = 1 local smoke1 = script.Parent.HandleMuzzle.Smokey:clone() smoke1.Parent = smoke smoke1.Opacity = 0.8 smoke1.Enabled = true smoke.Parent = game.Workspace local new_script1 = script.Parent.Remover:clone() new_script1.Disabled = false new_script1.Parent = smoke cam = game.Workspace.CurrentCamera local cam_rot = cam.CoordinateFrame - cam.CoordinateFrame.p local cam_scroll = (cam.CoordinateFrame.p - cam.Focus.p).magnitude local ncf = CFrame.new(cam.Focus.p)*cam_rot*CFrame.fromEulerAnglesXYZ(0.005, 0, 0) cam.CoordinateFrame = ncf*CFrame.new(0, 0, cam_scroll) weld33.C1 = CFrame.new(-0.75, 0.1, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.35, 1.3, 0.55) * CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90)) wait(0.005) cam = game.Workspace.CurrentCamera local cam_rot = cam.CoordinateFrame - cam.CoordinateFrame.p local cam_scroll = (cam.CoordinateFrame.p - cam.Focus.p).magnitude local ncf = CFrame.new(cam.Focus.p)*cam_rot*CFrame.fromEulerAnglesXYZ(0.0025, 0, 0) cam.CoordinateFrame = ncf*CFrame.new(0, 0, cam_scroll) weld33.C1 = CFrame.new(-0.75, 0.15, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.35, 1.35, 0.575) * CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90)) wait(0.005) cam = game.Workspace.CurrentCamera local cam_rot = cam.CoordinateFrame - cam.CoordinateFrame.p local cam_scroll = (cam.CoordinateFrame.p - cam.Focus.p).magnitude local ncf = CFrame.new(cam.Focus.p)*cam_rot*CFrame.fromEulerAnglesXYZ(-0.0025, 0, 0) cam.CoordinateFrame = ncf*CFrame.new(0, 0, cam_scroll) weld33.C1 = CFrame.new(-0.75, 0.2, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0) weld55.C1 = CFrame.new(-0.35, 1.4, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90)) wait(1) end function KeyDownFunctions(key) if key == "r" then Reload() end if key == "v" then if c.Value == false then c.Value = true Crouch() elseif c.Value == true then c.Value = false Uncrouch() end end end Tool.Enabled = true function onActivated() if not Tool.Enabled then return end Tool.Enabled = false local character = Tool.Parent; local humanoid = character.Humanoid if humanoid == nil then print("Humanoid not found") return end local ammo = script.Parent.Ammo local maxammo = script.Parent.MaxAmmo firing = true while firing == true do wait() if reloading == false and humanoid.Health >= 1 then if ammo.Value >= 1 then ammo.Value = ammo.Value - 1 local targetPos = humanoid.TargetPoint local lookAt = (targetPos - character.Head.Position).unit if script.Parent.Recoil.Value < 10 then script.Parent.Recoil.Value = script.Parent.Recoil.Value + 1 end fire(lookAt) else Reload() break end elseif reloading == false and humanoid.Health < 1 then Tool:remove() end end Tool.Enabled = true end function nofiar(mouse) firing = false end function onEquippedLocal(mouse) if mouse == nil then print("Mouse not found") return end mouse.Icon = "http://www.roblox.com/asset/?id=30699648" -- mouse.Button1Down:connect(function() onButton1Down(mouse) end) mouse.Button1Up:connect(function() nofiar(mouse) end) mouse.KeyDown:connect(KeyDownFunctions) c = Tool.Parent:findFirstChild("Crouch") while true do wait() end end function onUnequippedLocal(mouse) nofiar(mouse) end Tool.Unequipped:connect(onUnequippedLocal) Tool.Equipped:connect(onEquippedLocal) script.Parent.Activated:connect(onActivated) Tool.Equipped:connect(Equip) Tool.Unequipped:connect(Unequip) Tool.Unequipped:connect(Uncrouch) ]===] s6.Parent = t1 p30 = Instance.new("Part", t1) p30.BrickColor = BrickColor.new("Institutional white") p30.Transparency = 1 p30.Name = "HandlePowder" p30.CFrame = CFrame.new(-40.9500046, 4.50525618, -42.7588463, 1, 5.97108709e-008, 1.59994791e-008, 4.37113883e-008, -0.5, -0.866025388, -4.37113883e-008, 0.866025388, -0.5) p30.CanCollide = false p30.FormFactor = Enum.FormFactor.Custom p30.Size = Vector3.new(1, 1, 1) b29 = Instance.new("SpecialMesh", p30) b29.MeshId = "http://www.roblox.com/asset/?id=1033714" b29.TextureId = "" b29.MeshType = Enum.MeshType.FileMesh b29.Name = "Mesh" b29.Scale = Vector3.new(0.200000003, 1.5, 0.200000003) p31 = Instance.new("Part", t1) p31.BrickColor = BrickColor.new("Pastel yellow") p31.Transparency = 1 p31.Name = "HandleCloth" p31.CFrame = CFrame.new(-40.9000015, 4.20000029, -42.2999992, 0, 0, -1, 0, 1, -0, 1, 0, -0) p31.CanCollide = false p31.FormFactor = Enum.FormFactor.Symmetric p31.Size = Vector3.new(1, 1, 1) b30 = Instance.new("SpecialMesh", p31) b30.MeshType = Enum.MeshType.Sphere b30.Name = "Mesh" b30.Scale = Vector3.new(0.245000005, 0.245000005, 0.245000005) s7 = script:clone() s7.Name = "Crouch" s7.Disabled = false so7 = Instance.new("StringValue", s7) so7.Name = "forCustomRunL" so7.Value = [===[ on = 0 Tool = script.Parent welds = {} sh = {} arms = nil torso = nil f = nil function Crouch(ison) if arms == nil and torso == nil then arms = {Tool.Parent:FindFirstChild("Left Leg"), Tool.Parent:FindFirstChild("Right Leg")} torso = Tool.Parent:FindFirstChild("Torso") end if arms ~= nil and torso ~= nil then sh = {torso:FindFirstChild("Left Hip"), torso:FindFirstChild("Right Hip")} if sh ~= nil then local yes = true if yes then yes = false if ison == 1 then sh[1].Part1 = nil sh[2].Part1 = nil local weld1 = Instance.new("Weld") weld1.Part0 = torso weld1.Parent = torso weld1.Part1 = arms[1] weld1.C1 = CFrame.new(-0.5, 0.75, 1) arms[1].Name = "LDave" arms[1].CanCollide = true welds[1] = weld1 ------------------------------------------- local weld2 = Instance.new("Weld") weld2.Part0 = torso weld2.Parent = torso weld2.Part1 = arms[2] weld2.C1 = CFrame.new(0.5,0.495,1.25) * CFrame.fromEulerAnglesXYZ(math.rad(90),0,0) arms[2].Name = "RDave" arms[2].CanCollide = true welds[2] = weld2 --------------------------------- local force = Instance.new("BodyForce") force.Parent = torso f = force wait(0.01) elseif ison == 0 then if arms then sh[1].Part1 = arms[1] sh[2].Part1 = arms[2] f.Parent = nil arms[2].Name = "Right Leg" arms[1].Name = "Left Leg" welds[1].Parent = nil welds[2].Parent = nil end end -- end else print("sh") end else print("arms") end end function Key(key) if key then key = string.lower(key) if (key=="c") then if on == 1 then on = 0 elseif on == 0 then on = 1 end Crouch(on) end end end function Equip(mouse) mouse.KeyDown:connect(Key) end script.Parent.Equipped:connect(Equip) ]===] s7.Parent = t1 w1 = Instance.new("Weld", p1) w1.Part0 = p1 w1.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w1.Part1 = p1 w1.C1 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w2 = Instance.new("Weld", p1) w2.Part0 = p1 w2.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w2.Part1 = p12 w2.C1 = CFrame.new(0, -0.5, 0, 1, 0, 0, 0, 0.707106769, -0.707106769, 0, 0.707106769, 0.707106769) w3 = Instance.new("Weld", p1) w3.Part0 = p1 w3.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w3.Part1 = p6 w3.C1 = CFrame.new(0, 0.25, 1, -1, 8.74227766e-008, 0, -8.74227766e-008, -1, 0, 0, 0, 1) w4 = Instance.new("Weld", p1) w4.Part0 = p1 w4.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w4.Part1 = p13 w4.C1 = CFrame.new(0, -0.699999988, -0.100000001, 1, 0, 0, 0, 0.642787635, -0.766044438, 0, 0.766044438, 0.642787635) w5 = Instance.new("Weld", p1) w5.Part0 = p1 w5.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w5.Part1 = p2 w5.C1 = CFrame.new(0, -1.54999995, -0.600000024, 1, 0, 0, 0, -4.37113883e-008, -1, 0, 1, -4.37113883e-008) w6 = Instance.new("Weld", p1) w6.Part0 = p1 w6.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w6.Part1 = p7 w6.C1 = CFrame.new(0, -0.550000012, 1.10000002, 1, 0, 0, 0, 1, 0, 0, 0, 1) w7 = Instance.new("Weld", p1) w7.Part0 = p1 w7.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w7.Part1 = p14 w7.C1 = CFrame.new(0, -0.200000003, 0.200000003, 1, 0, 0, 0, 1, 0, 0, 0, 1) w8 = Instance.new("Weld", p1) w8.Part0 = p1 w8.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w8.Part1 = p15 w8.C1 = CFrame.new(0, 0.100000001, 0.200000003, 1, 0, 0, 0, 1, 0, 0, 0, 1) w9 = Instance.new("Weld", p1) w9.Part0 = p1 w9.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w9.Part1 = p16 w9.C1 = CFrame.new(0, 0.349999994, 0.230000004, 1, 0, 0, 0, 1, 0, 0, 0, 1) w10 = Instance.new("Weld", p1) w10.Part0 = p1 w10.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w10.Part1 = p27 w10.C1 = CFrame.new(0, -0.449999988, 2, 1, 0, 0, 0, 1, 0, 0, 0, 1) w11 = Instance.new("Weld", p1) w11.Part0 = p1 w11.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w11.Part1 = p20 w11.C1 = CFrame.new(0, -2.5, -0.600000024, 1, 0, 0, 0, -4.37113883e-008, -1, 0, 1, -4.37113883e-008) w12 = Instance.new("Weld", p1) w12.Part0 = p1 w12.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w12.Part1 = p25 w12.C1 = CFrame.new(0, -1.39999998, -0.330000013, 1, 0, 0, 0, -4.37113883e-008, -1, 0, 1, -4.37113883e-008) w13 = Instance.new("Weld", p1) w13.Part0 = p1 w13.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w13.Part1 = p22 w13.C1 = CFrame.new(-0.200000003, -0.524999976, 0.75, 1, 0, 0, 0, 1, 0, 0, 0, 1) w14 = Instance.new("Weld", p1) w14.Part0 = p1 w14.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w14.Part1 = p23 w14.C1 = CFrame.new(-0.200000003, -0.74000001, 0, 1, 0, 0, 0, 0.707106769, -0.707106769, 0, 0.707106769, 0.707106769) w15 = Instance.new("Weld", p1) w15.Part0 = p1 w15.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w15.Part1 = p24 w15.C1 = CFrame.new(-0.200000003, -1.20000005, -0.522499979, 1, 0, 0, 0, -4.37113883e-008, -1, 0, 1, -4.37113883e-008) w16 = Instance.new("Weld", p1) w16.Part0 = p1 w16.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w16.Part1 = p17 w16.C1 = CFrame.new(0.535000026, -0.25, 0.649999976, -4.37113883e-008, -1, 0, 1, -4.37113883e-008, 0, 0, 0, 1) w17 = Instance.new("Weld", p1) w17.Part0 = p1 w17.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w17.Part1 = p18 w17.C1 = CFrame.new(-0.25, -0.649999976, -0.75, 1, 0, 0, 0, -4.37113883e-008, -1, 0, 1, -4.37113883e-008) w18 = Instance.new("Weld", p1) w18.Part0 = p1 w18.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w18.Part1 = p19 w18.C1 = CFrame.new(-0.25, -0.00999999978, -1.04999995, 1, 0, 0, 0, -0.766044438, -0.642787635, 0, 0.642787635, -0.766044438) w19 = Instance.new("Weld", p1) w19.Part0 = p1 w19.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w19.Part1 = p4 w19.C1 = CFrame.new(-0.25, -0.800000012, 0.720000029, 1, 0, 0, 0, 1, 0, 0, 0, 1) w20 = Instance.new("Weld", p1) w20.Part0 = p1 w20.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w20.Part1 = p5 w20.C1 = CFrame.new(-0.25, -1.10000002, 0.0500000007, 1, 0, 0, 0, 0.642787635, -0.766044438, 0, 0.766044438, 0.642787635) w21 = Instance.new("Weld", p1) w21.Part0 = p1 w21.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w21.Part1 = p21 w21.C1 = CFrame.new(-0.25, -0.550000012, 0.949999988, 1, 0, 0, 0, 1, 0, 0, 0, 1) w22 = Instance.new("Weld", p1) w22.Part0 = p1 w22.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w22.Part1 = p8 w22.C1 = CFrame.new(-0.25, -0.600000024, 0.975000024, 1, 0, 0, 0, 1, 0, 0, 0, 1) w23 = Instance.new("Weld", p1) w23.Part0 = p1 w23.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w23.Part1 = p9 w23.C1 = CFrame.new(-0.25, -0.699999988, 0.930000007, 1, 0, 0, 0, 1, 0, 0, 0, 1) w24 = Instance.new("Weld", p1) w24.Part0 = p1 w24.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w24.Part1 = p10 w24.C1 = CFrame.new(-0.25, -1.125, 0.300000012, 1, 0, 0, 0, 0.707106769, -0.707106769, 0, 0.707106769, 0.707106769) w25 = Instance.new("Weld", p1) w25.Part0 = p1 w25.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w25.Part1 = p11 w25.C1 = CFrame.new(-0.25, -1.25, 0.25, 1, 0, 0, 0, 0.707106769, -0.707106769, 0, 0.707106769, 0.707106769) w26 = Instance.new("Weld", p1) w26.Part0 = p1 w26.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w26.Part1 = p3 w26.C1 = CFrame.new(0.574999988, -0.5, 0, -4.37113883e-008, 0, 1, 0, 1, 0, -1, 0, -4.37113883e-008) w27 = Instance.new("Weld", p1) w27.Part0 = p1 w27.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w27.Part1 = p29 w27.C1 = CFrame.new(0.800000012, -0.200000003, 0, -4.37113883e-008, 0, 1, 0, 1, 0, -1, 0, -4.37113883e-008) w28 = Instance.new("Weld", p1) w28.Part0 = p1 w28.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w28.Part1 = p28 w28.C1 = CFrame.new(0, -0.75, 0.100000001, 1, 0, 0, 0, 0.49999997, -0.866025448, 0, 0.866025448, 0.49999997) w29 = Instance.new("Weld", p1) w29.Part0 = p1 w29.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w29.Part1 = p26 w29.C1 = CFrame.new(0, -2.4000001, -0.330000013, 1, 0, 0, 0, -4.37113883e-008, -1, 0, 1, -4.37113883e-008) w30 = Instance.new("Weld", p1) w30.Part0 = p1 w30.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w30.Part1 = p30 w30.C1 = CFrame.new(0.649999976, 1.79999995, 2.20000005, -4.37113883e-008, -1, 0, 0.866025388, -3.78551732e-008, 0.5, -0.5, 2.18556941e-008, 0.866025388) w31 = Instance.new("Weld", p1) w31.Part0 = p1 w31.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) w31.Part1 = p31 w31.C1 = CFrame.new(0, -2.5, -0.600000024, 1, 0, 0, 0, -4.37113883e-008, -1, 0, 1, -4.37113883e-008) m.Parent = game:service("Workspace") m:MakeJoints()
function Physic_Standart_Dirt_2_Grass(Map_ID, X, Y, Z) Player_Number = Map_Block_Get_Player_Last(Map_ID, X, Y, Z) local i = 0 local Quit = 0 local Block_Type = 0 local Found_Grass = 0 for ix = -1, 1 do for iy = -1, 1 do for iz = -1, 1 do if Map_Block_Get_Type(Map_ID, X+ix, Y+iy, Z+iz) == 2 then Found_Grass = 1 break end end end end if Found_Grass == 1 then repeat i = i + 1 Block_Type = Map_Block_Get_Type(Map_ID, X, Y, Z+i) if Block_Type == -1 then Map_Block_Change(Player_Number, Map_ID, X, Y, Z, 2, 1, 1, 1, 5) elseif Block_Type ~= 0 and Block_Type ~= 6 and Block_Type ~= 18 and Block_Type ~= 20 and Block_Type ~= 37 and Block_Type ~= 38 and Block_Type ~= 39 and Block_Type ~= 40 and Block_Type ~= 251 then break end until Block_Type == -1 end end function Physic_Standart_Grass_2_Dirt(Map_ID, X, Y, Z) Player_Number = Map_Block_Get_Player_Last(Map_ID, X, Y, Z) local i = 0 local Quit = 0 local Block_Type = 0 repeat i = i + 1 Block_Type = Map_Block_Get_Type(Map_ID, X, Y, Z+i) if Block_Type == -1 then break elseif Block_Type ~= 0 and Block_Type ~= 6 and Block_Type ~= 18 and Block_Type ~= 20 and Block_Type ~= 37 and Block_Type ~= 38 and Block_Type ~= 39 and Block_Type ~= 40 and Block_Type ~= 251 then Map_Block_Change(Player_Number, Map_ID, X, Y, Z, 3, 1, 1, 1, 5) end until Block_Type == -1 end -- ##################### Simple and Fast variation: ################### function Physic_Standart_Dirt_2_Grass_Fast(Map_ID, X, Y, Z) local Player_Number = Map_Block_Get_Player_Last(Map_ID, X, Y, Z) local Found_Grass = 0 for ix = -1, 1 do for iy = -1, 1 do for iz = -1, 1 do if Map_Block_Get_Type(Map_ID, X+ix, Y+iy, Z+iz) == 2 then Found_Grass = 1 break end end end end if Found_Grass == 1 then local Block_Type = Map_Block_Get_Type(Map_ID, X, Y, Z+i) if Block_Type == -1 and Block_Type == 0 or Block_Type == 6 or Block_Type == 18 or Block_Type == 20 or Block_Type == 37 or Block_Type == 38 or Block_Type == 39 or Block_Type == 40 or Block_Type == 251 then Map_Block_Change(Player_Number, Map_ID, X, Y, Z, 2, 1, 1, 1, 5) end end end function Physic_Standart_Grass_2_Dirt_Fast(Map_ID, X, Y, Z) local Player_Number = Map_Block_Get_Player_Last(Map_ID, X, Y, Z) local Block_Type = Map_Block_Get_Type(Map_ID, X, Y, Z+1) if Block_Type ~= -1 and Block_Type ~= 0 and Block_Type ~= 6 and Block_Type ~= 18 and Block_Type ~= 20 and Block_Type ~= 37 and Block_Type ~= 38 and Block_Type ~= 39 and Block_Type ~= 40 and Block_Type ~= 251 then Map_Block_Change(Player_Number, Map_ID, X, Y, Z, 3, 1, 1, 1, 5) end end
local function getSteamId(player) local steamIdentifier local identifiers = GetPlayerIdentifiers(player) for _, v in pairs(identifiers) do if string.find(v, "steam") then steamIdentifier = v break end end return steamIdentifier end local function loadAllData() local loadFile= LoadResourceFile(GetCurrentResourceName(), "playerData.json") local extract = {} extract = json.decode(loadFile) return extract end RegisterServerEvent('playerpoint:saveBlip') AddEventHandler('playerpoint:saveBlip', function(blips) local player = source local steamIdentifier = getSteamId(player) local allData = loadAllData() if steamIdentifier then allData[steamIdentifier] = blips SaveResourceFile(GetCurrentResourceName(), "playerData.json", json.encode(allData), -1) end end) RegisterServerEvent('playerpoint:loadBlips') AddEventHandler('playerpoint:loadBlips', function() local player = source local steamIdentifier = getSteamId(player) local allData = loadAllData() if steamIdentifier then local playerData = allData[steamIdentifier] TriggerClientEvent('playerpoint:loadBlips', player, playerData) end end)
local color = Screen:getColor(100,100) print("坐标100,100的bgr颜色是",string.format("%06X",color)) print(Screen:getWidthHeight()) print(Input) ---@type LayoutParams local layoutParams = { width = 800, height = 800, flags = LayoutParamsFlags.FLAG_NOT_FOCUSABLE, format = PixelFormat.RGBA_8888, } local floatView = UI:newFloatView("test","file://view.lua",layoutParams) print(floatView:show()) print(UI:takeSignal()) floatView:conceal()
object_tangible_loot_mustafar_cube_loot_cube_loot_1g = object_tangible_loot_mustafar_cube_loot_shared_cube_loot_1g:new { } ObjectTemplates:addTemplate(object_tangible_loot_mustafar_cube_loot_cube_loot_1g, "object/tangible/loot/mustafar/cube/loot/cube_loot_1g.iff")
-- Copyright 2007-2021 Mitchell. See LICENSE. local M = {} --[[ This comment is for LuaDoc. --- -- Bookmarks for Textadept. -- @field MARK_BOOKMARK (number) -- The bookmark mark number. module('textadept.bookmarks')]] M.MARK_BOOKMARK = _SCINTILLA.next_marker_number() --- -- Toggles a bookmark on the current line. -- @name toggle function M.toggle() local line = buffer:line_from_position(buffer.current_pos) local has_mark = buffer:marker_get(line) & 1 << M.MARK_BOOKMARK - 1 > 0 local f = has_mark and buffer.marker_delete or buffer.marker_add f(buffer, line, M.MARK_BOOKMARK) end --- -- Clears all bookmarks in the current buffer. -- @name clear function M.clear() buffer:marker_delete_all(M.MARK_BOOKMARK) end -- Returns an iterator for all bookmarks in the given buffer. local function bookmarks(buffer) return function(buffer, line) line = buffer:marker_next(line + 1, 1 << M.MARK_BOOKMARK - 1) return line >= 1 and line or nil end, buffer, 0 end --- -- Prompts the user to select a bookmarked line to move the caret to the -- beginning of unless *next* is given. -- If *next* is `true` or `false`, moves the caret to the beginning of the next -- or previously bookmarked line, respectively. -- @param next Optional flag indicating whether to go to the next or previous -- bookmarked line relative to the current line. The default value is `nil`, -- prompting the user for a bookmarked line to go to. -- @name goto_mark function M.goto_mark(next) if next ~= nil then local f = next and buffer.marker_next or buffer.marker_previous local line = buffer:line_from_position(buffer.current_pos) local BOOKMARK_BIT = 1 << M.MARK_BOOKMARK - 1 line = f(buffer, line + (next and 1 or -1), BOOKMARK_BIT) if line == -1 then line = f(buffer, (next and 1 or buffer.line_count), BOOKMARK_BIT) end if line >= 1 then textadept.editing.goto_line(line) end return end -- List the current buffer's marks, and then all other buffers' marks. local scan_this_buffer, utf8_list, buffers = true, {}, {} ::rescan:: for _, buffer in ipairs(_BUFFERS) do if not (scan_this_buffer == (buffer == _G.buffer)) then goto continue end local filename = buffer.filename or buffer._type or _L['Untitled'] if buffer.filename then filename = filename:iconv('UTF-8', _CHARSET) end local basename = buffer.filename and filename:match('[^/\\]+$') or filename for line in bookmarks(buffer) do utf8_list[#utf8_list + 1] = string.format( '%s:%d: %s', basename, line, buffer:get_line(line):match('^[^\r\n]*')) buffers[#buffers + 1] = buffer end ::continue:: end scan_this_buffer = not scan_this_buffer if not scan_this_buffer then goto rescan end if #utf8_list == 0 then return end local button, i = ui.dialogs.filteredlist{ title = _L['Select Bookmark'], columns = _L['Bookmark'], items = utf8_list } if button ~= 1 or not i then return end view:goto_buffer(buffers[i]) textadept.editing.goto_line(tonumber(utf8_list[i]:match('^[^:]+:(%d+):'))) end local lines = {} -- Save and restore bookmarks on buffer:reload(). events.connect(events.FILE_BEFORE_RELOAD, function() for line in bookmarks(buffer) do lines[#lines + 1] = line end end) events.connect(events.FILE_AFTER_RELOAD, function() for _, line in ipairs(lines) do buffer:marker_add(line, M.MARK_BOOKMARK) end lines = {} -- clear end) return M
----------------------------------- -- Area: Southern San d'Oria -- NPC: Raimbroy -- Starts and Finishes Quest: The Sweetest Things -- !zone 230 ------------------------------------- require("scripts/globals/settings"); local ID = require("scripts/zones/Southern_San_dOria/IDs"); require("scripts/globals/titles"); require("scripts/globals/shop"); require("scripts/globals/quests"); ----------------------------------- function onTrade(player,npc,trade) -- "Flyers for Regine" conditional script local FlyerForRegine = player:getQuestStatus(SANDORIA,tpz.quest.id.sandoria.FLYERS_FOR_REGINE); -- "The Sweetest Things" quest status var local theSweetestThings = player:getQuestStatus(SANDORIA,tpz.quest.id.sandoria.THE_SWEETEST_THINGS); if (theSweetestThings ~= QUEST_AVAILABLE) then if (trade:hasItemQty(4370,5) and trade:getItemCount() == 5) then player:startEvent(535,GIL_RATE*400); else player:startEvent(522); end end if (FlyerForRegine == 1) then local count = trade:getItemCount(); local MagicFlyer = trade:hasItemQty(532,1); if (MagicFlyer == true and count == 1) then player:messageSpecial(ID.text.FLYER_REFUSED); end end end; function onTrigger(player,npc) local theSweetestThings = player:getQuestStatus(SANDORIA, tpz.quest.id.sandoria.THE_SWEETEST_THINGS); -- "The Sweetest Things" Quest Dialogs if (player:getFameLevel(SANDORIA) >= 2 and theSweetestThings == QUEST_AVAILABLE) then theSweetestThingsVar = player:getCharVar("theSweetestThings"); if (theSweetestThingsVar == 1) then player:startEvent(533); elseif (theSweetestThingsVar == 2) then player:startEvent(534); else player:startEvent(532); end elseif (theSweetestThings == QUEST_ACCEPTED) then player:startEvent(536); elseif (theSweetestThings == QUEST_COMPLETED) then player:startEvent(537); end end; function onEventUpdate(player,csid,option) end; function onEventFinish(player,csid,option) -- "The Sweetest Things" ACCEPTED if (csid == 532) then player:setCharVar("theSweetestThings", 1); elseif (csid == 533) then if (option == 0) then player:addQuest(SANDORIA,tpz.quest.id.sandoria.THE_SWEETEST_THINGS); player:setCharVar("theSweetestThings", 0); else player:setCharVar("theSweetestThings", 2); end elseif (csid == 534 and option == 0) then player:addQuest(SANDORIA, tpz.quest.id.sandoria.THE_SWEETEST_THINGS); player:setCharVar("theSweetestThings", 0); elseif (csid == 535) then player:tradeComplete(); player:addTitle(tpz.title.APIARIST); player:addGil(GIL_RATE*400); if (player:getQuestStatus(SANDORIA, tpz.quest.id.sandoria.THE_SWEETEST_THINGS) == QUEST_ACCEPTED) then player:addFame(SANDORIA,30); player:completeQuest(SANDORIA, tpz.quest.id.sandoria.THE_SWEETEST_THINGS); else player:addFame(SANDORIA, 5); end end end;
local function doesFileExist( fname, path ) local results = false -- Path for the file local filePath = system.pathForFile( fname, path ) if ( filePath ) then local file, errorString = io.open( filePath, "r" ) if not file then -- Error occurred; output the cause logger( "File error: " .. errorString ) else -- File exists! logger( "File found: " .. fname ) results = true -- Close the file handle file:close() end end return results end function isFile(name) if type(name)~="string" then return false end if not isDir(name) then return os.rename(name,name) and true or false -- note that the short evaluation is to -- return false instead of a possible nil end return false end function isFileOrDir(name) if type(name)~="string" then return false end return os.rename(name, name) and true or false end function isDir(name) if type(name)~="string" then return false end local cd = lfs.currentdir() local is = lfs.chdir(name) and true or false lfs.chdir(cd) return is end function choice(passedTable) local tempNumber = math.random(1,#passedTable) return passedTable[tempNumber] end function rollDice( dicePattern ) -- Dice pattern 3d6+3k3 -- First number : number of dice -- d : required string -- Second number : sides to the dice -- +/- : optional modifier -- ^/k : optional string; '^' keeps the high values, 'k' keeps the low values -- Third number : number of dice to keep, i.e. 4d6^3 keeps the best three numbers local dice = {} local random = math.random local total = 0 -- Parse the string local count, sides, sign, modifier, keepHiLo, keep = string.match( dicePattern, "(%d+)[dD](%d+)([%+%-]*)(%d*)([%^k]*)(%d*)" ) modifier = tonumber(modifier) keep = tonumber(keep) if ( modifier == nil ) then modifier = 0 end if ( sign == "-" and modifier > 0 ) then modifier = modifier * -1 end for i = 1, count do dice[i] = random( sides ) end if ( keep ) then local function keepCompare( a, b ) return a > b end if ( keepHiLo == "k" ) then table.sort( dice ) else table.sort( dice, keepCompare ) end for i = 1, keep do total = total + dice[i] end else for i = 1, count do total = total + dice[i] end end total = total + modifier return total, dice end -- Remove duplicates from a table array (doesn't currently work -- on key-value tables) function table_unique(tt) local newtable newtable = {} for ii,xx in ipairs(tt) do if(table_count(newtable, xx) == 0) then newtable[#newtable+1] = xx end end return newtable end -- implode(separator, table) function implode(d,p) local newstr newstr = "" if(#p == 1) then return p[1] end for ii = 1, (#p-1) do newstr = newstr .. p[ii] .. d end newstr = newstr .. p[#p] return newstr end -- Careful of random number seeding here- you will need to randomly -- seed before calling this function randomlist(l, samp) local newlist newlist = {} if not samp then samp = 0 else samp = #l - samp end while #l > samp do local idx idx = math.random(1, #l) newlist[#newlist + 1] = l[idx] table.remove(l, idx) end return newlist end function StripDuplicates(t) local hash = {} local res = {} for _,v in ipairs(t) do if (not hash[v]) then res[#res+1] = v -- you could logger here instead of saving to result table if you wanted hash[v] = true end end return res end function ShuffleTable(t) shuffled = {} for i, v in ipairs(t) do local pos = math.random(1, #shuffled+1) table.insert(shuffled, pos, v) end return shuffled end -- http://lua-users.org/wiki/FileInputOutput -- see if the file exists function file_exists(file) local f = io.open(file, "rb") if f then f:close() end return f ~= nil end -- get all lines from a file, returns an empty -- list/table if the file does not exist function lines_from(file) if not file_exists(file) then return {} end lines = {} for line in io.lines(file) do lines[#lines + 1] = line end return lines end function readAll(file) local f = assert(io.open(file, "rb")) local content = f:read("*all") f:close() return content end function loadjson(file) local f = assert(io.open(file, "rb")) local content = f:read("*all") f:close() return JSON:decode(content) end function fitImage( displayObject, fitWidth, fitHeight, enlarge ) -- -- first determine which edge is out of bounds -- local scaleFactor = fitHeight / displayObject.height local newWidth = displayObject.width * scaleFactor if newWidth > fitWidth then scaleFactor = fitWidth / displayObject.width end if not enlarge and scaleFactor > 1 then return end displayObject:scale( scaleFactor, scaleFactor ) return scaleFactor end function GetUserList(event) local result = nil if not event.error then result = event.result end return result end function ParseRoll(formula) local result if string.match(formula, "*") then -- Found a * -- local formula = "2d6+3" local tempSplit = SplitString(formula, "*") local tempResult,rolls = rollDice(tempSplit[1]) -- for i = 1, #rolls do -- logger( i, rolls[i] ) -- end result = tempResult*tonumber(tempSplit[2]) else local tempResult,rolls = rollDice(formula) -- for i = 1, #rolls do -- logger( i, rolls[i] ) -- end result = tempResult end return result end function rollDice( dicePattern ) -- Dice pattern 3d6+3k3 -- First number : number of dice -- d : required string -- Second number : sides to the dice -- +/- : optional modifier -- ^/k : optional string; '^' keeps the high values, 'k' keeps the low values -- Third number : number of dice to keep, i.e. 4d6^3 keeps the best three numbers local dice = {} local random = math.random local total = 0 -- Parse the string local count, sides, sign, modifier, keepHiLo, keep = string.match( dicePattern, "(%d+)[dD](%d+)([%+%-]*)(%d*)([%^k]*)(%d*)" ) modifier = tonumber(modifier) keep = tonumber(keep) if ( modifier == nil ) then modifier = 0 end if ( sign == "-" and modifier > 0 ) then modifier = modifier * -1 end for i = 1, count do dice[i] = random( sides ) end if ( keep ) then local function keepCompare( a, b ) return a > b end if ( keepHiLo == "k" ) then table.sort( dice ) else table.sort( dice, keepCompare ) end for i = 1, keep do total = total + dice[i] end else for i = 1, count do total = total + dice[i] end end total = total + modifier return total, dice end function Roll(command) rolls = {} function parse (quantity, sides, modifier, times) local index = 0 local sum = 0 local best = 0 local rolled = {} local selected = {} if modifier == "" then table.insert(rolls,(quantity.."d"..sides)) else table.insert(rolls,(quantity.."d"..sides..modifier..times)) end for r = 1, quantity do rolled[r] = math.random(1,sides) table.insert(rolls,rolled[r]) end for i, v in ipairs(rolled) do selected[i] = v end if modifier == "" then for i,v in ipairs (rolled) do sum = sum + v end else for t = 1, quantity-times do if modifier == "h" then best = math.huge elseif modifier == "l" then best = 0 end for i,v in ipairs ( selected ) do if (v < best and modifier == "h") or (v > best and modifier == "l") then index = i best = v end end table.remove (selected,index) end for i, v in ipairs (selected) do sum = sum + v end end return sum end command = string.gsub(command,"(%d+)d(%d+)(%a)(%d+)",function(quantity, sides, modifier, times) return parse (quantity, sides, modifier, times) end) command = string.gsub(command,"(%d+)d(%d+)(%a)",function(quantity, sides, modifier) return parse (quantity, sides, modifier, 1) end) command = string.gsub(command,"0d(%d+)",function(sides) return 0 end) command = string.gsub(command,"(%d+)d(%d+)",function(quantity, sides, modifier, times) return parse (quantity, sides, "", 0) end) command = string.gsub(command,"d(%d+)",function(sides) return parse (1, sides, "", 0) end) return tonumber(command) end function SplitString (line,sep) local res = {} local pos = 1 sep = sep or ',' while true do local c = string.sub(line,pos,pos) if (c == "") then break end if (c == '"') then -- quoted value (ignore separator within) local txt = "" repeat local startp,endp = string.find(line,'^%b""',pos) txt = txt..string.sub(line,startp+1,endp-1) pos = endp + 1 c = string.sub(line,pos,pos) if (c == '"') then txt = txt..'"' end -- check first char AFTER quoted string, if it is another -- quoted string without separator, then append it -- this is the way to "escape" the quote char in a quote. example: -- value1,"blub""blip""boing",value3 will result in blub"blip"boing for the middle until (c ~= '"') table.insert(res,txt) assert(c == sep or c == "") pos = pos + 1 else -- no quotes used, just look for the first separator local startp,endp = string.find(line,sep,pos) if (startp) then table.insert(res,string.sub(line,pos,startp-1)) pos = endp + 1 else -- no separator found -> use rest of string and terminate table.insert(res,string.sub(line,pos)) break end end end return res end function StripFilename(passedString) local tempString = "MOIST" local tempSplit = SplitString(passedString, "/") tempString = tempSplit[#tempSplit] return tempString end function InTable(passedTable,passedValue) local result = nil for key,value in pairs(passedTable) do if(passedValue==passedTable)then -- OK we've got a item called 'passedValue' -- so set the result to 'value' result = value end end return result end function print_r ( t ) local print_r_cache={} local function sub_print_r(t,indent) if (print_r_cache[tostring(t)]) then logger(indent.."*"..tostring(t)) else print_r_cache[tostring(t)]=true if (type(t)=="table") then for pos,val in pairs(t) do if (type(val)=="table") then logger(indent.."["..pos.."] => "..tostring(t).." {") sub_print_r(val,indent..string.rep(" ",string.len(pos)+4)) logger(indent..string.rep(" ",string.len(pos)+3).."}") elseif (type(val)=="string") then logger(indent.."["..pos..'] => "'..val..'"') else logger(indent.."["..pos.."] => "..tostring(val)) end end else logger(indent..tostring(t)) end end end if (type(t)=="table") then logger(tostring(t).." {") sub_print_r(t," ") logger("}") else sub_print_r(t," ") end logger() end function GUID() local guid = {}; guid.char = {"A", "B", "C", "D", "E", "F","1","2","3","4","5","6","7","8","9"}; guid.isHyphen = {[9]=1,[14]=1,[19]=1,[24]=1}; guid.used = {}; guid.loops = 0; guid.currentGuid = nil; while(true) do guid.loops = guid.loops +1; --If we can't get it in 20 tries than we have bigger problems. if(guid.loops > 20) then return false; end guid.pass = {}; for z = 1,36 do if guid.isHyphen[z] then guid.x='-'; else guid.a = math.random(1,#guid.char); -- randomly choose a character from the "guid.char" array guid.x = guid.char[guid.a] end table.insert(guid.pass, guid.x) -- add new index into array. end z = nil guid.currentGuid = tostring(table.concat(guid.pass)); -- concatenate all indicies of the array, then return concatenation. if not guid.used[guid.currentGuid] then guid.used[guid.currentGuid] = guid.currentGuid; return(guid.currentGuid); else --logger('Duplicated a Previously Created GUID.'); end end return(grid.currentGuid) end
local export = {} local function ones ( n ) return tonumber( ("1"):rep(n), 2 ) end --Converts a surrogate pair into a code point do local TEN_1S = ones(10) function export.Utf16SurrogatePair ( cu1, cu2 ) return (((cu1 & TEN_1S) << 10) | (cu2 & TEN_1S)) + 0x10000 end end --Used for UTF-8 "normal" decoding do local THREE_1S, FOUR_1S, FIVE_1S, SIX_1S = ones(3), ones(4), ones(5), ones(6) function export.Utf8_2 ( cu1, cu2 ) return ((cu1 & FIVE_1S) << 6) | (cu2 & SIX_1S) end function export.Utf8_3 ( cu1, cu2, cu3 ) return ((cu1 & FOUR_1S) << 12) | ((cu2 & SIX_1S) << 6) | (cu3 & SIX_1S) end function export.Utf8_4 ( cu1, cu2, cu3, cu4 ) return ((cu1 & THREE_1S) << 18) | ((cu2 & SIX_1S) << 12) | ((cu3 & SIX_1S) << 6) | (cu4 & SIX_1S) end end --Used for UTF-8 "replace" decoding do local function make_mask( mask_or_sub ) return tonumber( mask_or_sub:gsub(".", { ['s'] = '0'; ['0'] = '0'; ['m'] = '1' } ), 2 ) end local trailing_mask = make_mask "s0mmmmmm" function export.Utf8_NewFunc_Leading ( mask_or_sub, shift_amt, follower_func ) local mask = make_mask( mask_or_sub ) return function ( GetCodeUnit, UngetCodeUnit, cu1 ) return follower_func( GetCodeUnit, UngetCodeUnit, (cu1 & mask) << shift_amt ) end end function export.Utf8_NewFunc_NonFinalTrailing ( shift_amt, follower_func, lo_lim, hi_lim ) lo_lim = lo_lim or 0x80 hi_lim = hi_lim or 0xBF return function ( GetCodeUnit, UngetCodeUnit, accum ) local cu = GetCodeUnit() if cu == nil then return REPLACEMENT_CHARACTER elseif lo_lim <= cu and cu <= hi_lim then return follower_func( GetCodeUnit, UngetCodeUnit, accum | ((cu & trailing_mask) << shift_amt) ) else UngetCodeUnit( cu ) return REPLACEMENT_CHARACTER end end end function export.Utf8_FinalTrailing ( GetCodeUnit, UngetCodeUnit, accum ) local cu = GetCodeUnit() if cu == nil then return REPLACEMENT_CHARACTER elseif 0x80 <= cu and cu <= 0xBF then return accum | (cu & trailing_mask) else UngetCodeUnit( cu ) return REPLACEMENT_CHARACTER end end end return export
------------------------------------------------ -- Copyright © 2013-2020 Hugula: Arpg game Engine -- -- author pu ------------------------------------------------ local type = type local ipairs = ipairs local pairs = pairs local require = require -- local string_match = string.match local table = table local lua_binding = lua_binding local lua_unbinding = lua_unbinding local lua_distribute = lua_distribute local DIS_TYPE = DIS_TYPE local xpcall = xpcall local debug = debug local string_format = string.format -- local table_insert = table.insert -- local table_indexof = table.indexof -- local table_remove_item = table.remove_item -- local table_remove_at = table.remove -- local profiler = require("perf.profiler") local CS = CS local GameObject = CS.UnityEngine.GameObject local Hugula = CS.Hugula local ResLoader = Hugula.ResLoader local ProfilerFactory = Hugula.Profiler.ProfilerFactory local VMConfig = require("vm_config")[1] local VMGenerate = require("core.mvvm.vm_generate") -- local CUtils = Hugula.Utils.CUtils local Debug = CS.UnityEngine.Debug local LoadSceneMode = CS.UnityEngine.SceneManagement.LoadSceneMode local BindingUtility = Hugula.Databinding.BindingUtility local vm_manager = {} local function error_hander(h) Debug.LogError(string_format("lua:%s \r\n %s", h, debug.traceback())) end local function safe_call(f, arg1) xpcall(f, error_hander, arg1) end --------------------state 相关---------------------------- local function _binding_msg(vm) local listener = vm.msg for k, v in pairs(listener) do lua_binding(k, v) end end local function _unbinding_msg(vm) local listener = vm.msg for k, v in pairs(listener) do lua_unbinding(k, v) end end ------------------------------------------------ local function deactive(self, vm_name, view_active) local curr_vm = VMGenerate[vm_name] --获取vm实例 if view_active == nil then view_active = true end -- Logger.Log("vm_manager.deactive ", vm_name) if curr_vm.is_res_ready == true and curr_vm.is_active then --已经加载过并且已经激活 -- Logger.Log("real vm_manager.deactive ", vm_name) safe_call(curr_vm.on_deactive, curr_vm) _unbinding_msg(curr_vm) curr_vm.is_active = false --标记状态 if view_active then local views = curr_vm.views if views then for k, v in ipairs(views) do v:set_active(false) end end end lua_distribute(DIS_TYPE.ON_UI_STATE_CHANGE, {action = "deactive", name = vm_name}) else -- Logger.Log("make vm_manager.deactive is_active=false", vm_name) curr_vm.is_active = false --标记状态 end end --- 销毁vm关联的所有view的资源 ---@overload fun(vm_name:string) ---@param vm_name string local function destroy(self, vm_name) local curr_vm = VMGenerate[vm_name] --获取vm实例 -- Logger.Log("vm_manager.destroy ", vm_name) if curr_vm.is_res_ready == true then --如果资源加载完成 -- Logger.Log("real vm_manager.destroy ", vm_name) curr_vm.is_active = false curr_vm.is_res_ready = false curr_vm._is_destory = nil safe_call(curr_vm.on_deactive, curr_vm) _unbinding_msg(curr_vm) safe_call(curr_vm.on_destroy, curr_vm) safe_call(curr_vm.clear, curr_vm) lua_distribute(DIS_TYPE.ON_UI_STATE_CHANGE, {action = "destroy", name = vm_name}) else -- Logger.Log("mark vm_manager.destroy _is_destory=true", vm_name) curr_vm._is_destory = true --标记销毁 end end ------------------------------------------------ ---检查view_base的所有资源是否都加载完成 ---@overload fun(view_base:VMBase) ---@param view_base VMBase local function check_vm_base_all_done(vm_base) local views = vm_base.views if views then for k, v in ipairs(views) do if v:is_initialized() == false then return false end end end local profiler = ProfilerFactory.GetAndStartProfiler("vm_mamanger.check_vm_base_all_done ", vm_base.name) vm_base._isloading = false vm_base.is_res_ready = true local is_active = vm_base.is_active --当前的状态 -- Logger.Log("vm_manager.check_vm_base_all_done. vm_base.is_active = ", is_active, vm_base) if vm_base._is_push == true then -- safe_call(vm_base.on_push, vm_base) else safe_call(vm_base.on_back, vm_base) end _binding_msg(vm_base) if views then for k, view_base in ipairs(views) do view_base:set_active(is_active) end end safe_call(vm_base.on_active, vm_base) -- Logger.Log("check_vm_base_all_done", vm_base) if views then for k, view_base in ipairs(views) do if vm_base.auto_context then -- Logger.Log(k, view_base) view_base:set_child_context(vm_base) end end end --on_state_changed if vm_base._is_group == true then vm_manager._vm_state:_check_on_state_changed(vm_base) end if is_active then lua_distribute(DIS_TYPE.DIALOG_OPEN_UI, vm_base.name) --触发界面打开消息 end if vm_base._is_destory then --如果标记了销毁 destroy(vm_manager, vm_base.name) elseif is_active == false then --非激活状态需要执行deactive逻辑 vm_base.is_active = true --强行设置为true确保正确的deactive流程 deactive(vm_manager, vm_base.name) end if profiler then profiler:Stop() end return true end ---设置view的BindableContainer,并标记资源完成 ---@overload fun(gobj:GameObject,view_base:ViewBase) ---@param gobj GameObject ---@param view_base ViewBase local function set_view_child(gobj, view_base) local bindable_container = BindingUtility.GetBindableObject(gobj) view_base:set_child(bindable_container or gobj) end ---初始化视图和viewmode并设置他们的关系 ---@overload fun(view_base:ViewBase,viewmodel:VMBase) ---@param view_base ViewBase ---@param viewmodel VMBase local function init_view(view_base, viewmodel) -- body local on_asset_load = view_base.on_asset_load if on_asset_load then on_asset_load(view_base, view_base._child) end -- view_base:set_active(true) view_base:initialized() --标记初始化 local vm_base = view_base._vm_base or viewmodel -- local is_active = vm_base.is_active --设置当前view状态 -- view_base:set_active(is_active) check_vm_base_all_done(vm_base) end ---资源加载完成 ---@overload fun(data:GameObject,view_base:ViewBase) ---@param data GameObject ---@param view_base ViewBase local function on_res_comp(data, view_base) -- profiler.start() if view_base:has_child() ~= true then -- local inst = GameObject.Instantiate(data) set_view_child(data, view_base) end init_view(view_base) -- profiler.stop() end ---资源预加载完成 ---@overload fun(data:GameObject,view_base:ViewBase) ---@param data GameObject ---@param view_base ViewBase local function on_pre_load_comp(data, view_base) if view_base:has_child() ~= true then -- data:SetActive(false) -- local inst = GameObject.Instantiate(data) set_view_child(data, view_base) data:SetActive(false) end end ---场景加载完成 ---@overload fun(data:GameObject,view_base:ViewBase) ---@param data GameObject ---@param view_base ViewBase local function on_scene_comp(data, view_base) if view_base:has_child() ~= true then -- set_view_child(data, view_base) view_base:set_child(data) end init_view(view_base) -- Logger.Log(string.format("on_scene_comp : %s", view_base)) end ---场景预加载完成 ---@overload fun(data:GameObject,view_base:ViewBase) ---@param data GameObject ---@param view_base ViewBase local function on_pre_scene_comp(data, view_base) if view_base:has_child() ~= true then -- set_view_child(data, view_base) view_base:set_child(data) end -- Logger.Log(string.format("on_pre_scene_comp : %s", view_base)) end local function on_res_end(data, view_base) Logger.Log(string.format("on_res_end : %s", view_base)) end ---利用find查找view的gameobject root ---@overload fun(name:string,view_base:ViewBase) ---@param name string ---@param vm_base VMBase ---@param view_base ViewBase local function find_gameobject(name, view_base) -- profiler.start() local find_name = name local inst = GameObject.Find(find_name) set_view_child(inst, view_base) init_view(view_base) -- Logger.Log("init_view_wm\r\n",profiler.report()) -- profiler.stop() end --- 将vm关联的所有view激活 ---@overload fun(vm_name:string) ---@param vm_name string local function active_view(self, vm_name) ---@type VMBase local curr_vm = VMGenerate[vm_name] --获取vm实例 -- Logger.Log("vm_manager.active_view", curr_vm.is_res_ready, curr_vm, curr_vm.is_active) if curr_vm.is_res_ready == true and curr_vm.is_active == false then --已经加载过并且未被激活 local profiler = ProfilerFactory.GetAndStartProfiler("vm_mamanger.active_view ", vm_name) -- Logger.Log("real vm_manager.active_view", curr_vm.is_res_ready, curr_vm, curr_vm.is_active) curr_vm.is_active = true local views = curr_vm.views if curr_vm._is_push == true then -- safe_call(curr_vm.on_push, curr_vm) else safe_call(curr_vm.on_back, curr_vm) end _binding_msg(curr_vm) local _auto_context = curr_vm.auto_context if views then for k, v in ipairs(views) do v:set_active(true) end end safe_call(curr_vm.on_active, curr_vm) if views then for k, v in ipairs(views) do if _auto_context and not v:has_context() then --是否需要对view重新设置viewmodel v:set_child_context(curr_vm) end end end --on_state_changed 没有资源的模块也需要检测state changed 事件 -- if (views == nil or #views == 0) and curr_vm._is_group == true then if curr_vm._is_group == true then vm_manager._vm_state:_check_on_state_changed(curr_vm) end lua_distribute(DIS_TYPE.DIALOG_OPEN_UI, vm_name) --触发界面打开消息 if profiler then profiler:Stop() end end end ---加载配置的资源 ---@overload fun(res_name:string,view_base:ViewBase,on_asset_comp:function,is_pre_load:boolean) ---@param res_name string ---@param view_base ViewBase ---@param on_asset_comp function ---@param is_pre_load boolean local function load_resource(res_name, view_base, on_asset_comp, is_pre_load) local vm_name = view_base._vm_base.name local vm_config = VMConfig[vm_name] local async = vm_config.async local has_child = view_base:has_child() if is_pre_load == true then async = is_pre_load if has_child then return end -- end if on_asset_comp == nil then on_asset_comp = on_res_comp end if has_child then --and is_pre_load ~= true then --如果已经加载资源 init_view(view_base) else if async ~= false then ---异步加载 ResLoader.InstantiateAsync(res_name, on_asset_comp, nil, view_base) else local gobj = ResLoader.Instantiate(res_name) on_asset_comp(gobj, view_base) ---同步步加载 end end end ---加载场景 ---@overload fun(scene_name:string,view_base:ViewBase,on_asset_comp:function,is_pre_load:boolean) ---@param scene_name string ---@param view_base ViewBase ---@param on_asset_comp function ---@param is_pre_load boolean local function load_scene(scene_name, view_base, on_asset_comp, is_pre_load) --LoadScene local load_scene_mode if view_base.load_scene_mode ~= nil then load_scene_mode = view_base.load_scene_mode else load_scene_mode = LoadSceneMode.Additive end if on_asset_comp == nil then on_asset_comp = on_scene_comp end local allow_scene_activation = true if view_base.allow_scene_activation ~= nil then allow_scene_activation = view_base.allow_scene_activation end if is_pre_load == true then --强制设置scene active 一般用于预加载 allow_scene_activation = false if view_base:has_child() then return end -- end ResLoader.LoadSceneAsync(scene_name, on_asset_comp, on_res_end, view_base, allow_scene_activation, load_scene_mode) end --- 开始加载或者激活vm关联的view ---@overload fun(vm_name:string,arg:any) ---@param vm_name string ---@param arg any local function load(self, vm_name, arg, is_push, is_group) local curr_vm = VMGenerate[vm_name] --获取vm实例 if not is_push then --is back arg = curr_vm._push_arg end curr_vm:on_push_arg(arg) --有参数 curr_vm._push_arg = arg curr_vm._is_push = is_push --是否是push到栈上的 curr_vm._is_group = is_group --是否是组 local views = curr_vm.views if views == nil or #views == 0 then curr_vm.is_res_ready = true end -- Logger.Log("vm_mamanger.load ", curr_vm, curr_vm.is_active, "_isloading=", curr_vm._isloading) if curr_vm.is_res_ready == true then --已经加载过 active_view(self, vm_name) else curr_vm.is_active = true --需要重新加载,设置本身为激活状态 curr_vm._is_destory = nil --清理销毁标记 if views and curr_vm._isloading ~= true then curr_vm._isloading = true local find_path, res_name, scene_name for k, v in ipairs(views) do find_path, res_name, scene_name = v.find_path, v.key, v.scene_name if res_name ~= nil then load_resource(res_name, v) elseif scene_name ~= nil then load_scene(scene_name, v) elseif v.find_path ~= nil then find_gameobject(v.find_path, v) end end end end end ---激活vm 加载资源或者激活ui ---当vm为string单个 ---vm table 时候多个 ---@overload fun(vm_name:string,arg:any) ---@param vm_name string ---@param arg any ---@param is_group bool local function active(self, vm_name, arg, is_push, is_group) if vm_name == nil then error("VMManager.active vm_name is nil") end -- Logger.Log("vm_manager.active(", vm_name.name or vm_name) if type(vm_name) == "string" then --单个 load(self, vm_name, arg, is_push) else for k, v in ipairs(vm_name) do --多个 load(self, v, arg, is_push, is_group) end end end ---预加载vm资源 ---当vm为string单个 ---@overload fun(vm_name:string) ---@param vm_name string local function pre_load(self, vm_name) local curr_vm = VMGenerate[vm_name] --获取vm实例 local views = curr_vm.views if views and not curr_vm.is_res_ready then local res_name, scene_name for k, v in ipairs(views) do res_name, scene_name = v.key, v.scene_name if scene_name ~= nil then load_scene(scene_name, v, on_pre_scene_comp, true) elseif res_name ~= nil then load_resource(res_name, v, on_pre_load_comp, true) end Logger.Log("pre_load", vm_name, k, v) end end end ---热重载 vm ---当vm为string单个 ---@overload fun(vm_name:string) ---@param vm_name string local function re_load(self, vm_name) local curr_vm = VMGenerate[vm_name] --获取旧vm实例 local views = curr_vm.views local is_res_ready = curr_vm.is_res_ready local arg = curr_vm._push_arg --保存变量 VMGenerate:reload_vm(vm_name, true) --热重载模块 curr_vm = VMGenerate[vm_name] --新的模块 curr_vm:on_push_arg(arg) curr_vm._push_arg = arg curr_vm._is_push = true --是否是push到栈上的 if views == nil or #views == 0 then is_res_ready = true curr_vm.is_res_ready = true end if views and #views > 0 and is_res_ready then --如果资源已经加载需要重新刷新 -- local res_name, scene_name local new_views = curr_vm.views for k, v in ipairs(new_views) do v:set_child(views[k]._child) -- set view BindableContainer init_view(v) end --clear for k, v in ipairs(views) do v._child = nil v._vm_base = nil v._initialized = false end elseif is_res_ready then -- Logger.Log(" re_load no view", vm_name) active_view(self, vm_name) end end vm_manager.re_load = re_load vm_manager.pre_load = pre_load vm_manager.load = load vm_manager.active = active vm_manager.destroy = destroy vm_manager.deactive = deactive ---vm的激活与失活管理 ---@class VMManager ---@field active function ---@field pre_load function ---@field load function ---@field destroy function ---@field deactive function -- VMManager = vm_manager return vm_manager
-- /script hunter_mana_burn_skull() function hunter_mana_burn_skull() if castingOrChanneling() then return end if azs.targetSkull() then hunterManaDrain() end end function hunter_mana_burn_cross() if castingOrChanneling() then return end if azs.targetCross() then hunterManaDrain() end end function hunterManaDrain() cast_debuff("Ability_Hunter_AimedShot", "Viper Sting") end
-- Sandbox for executing WikiMedia Scribunto Lua code under Python -- -- Copyright (c) 2020 Tatu Ylonen. See file LICENSE and https://ylonen.org local env = _ENV mw = nil -- assigned in lua_set_loader() python_loader = nil -- Maximum allowed execution time in Lua code (seconds) lua_max_time = 20 -- Max time for the current call to Lua. This is reset for every call to the -- Lua sandbox. lua_current_max_time = nil -- This function loads new a new module, whether built-in or defined in the -- data file. function new_loader(modname) --print("lua new_loader: " .. modname) local content = nil if python_loader ~= nil then content = python_loader(modname) else error("PYTHON LOADER NOT SET - call lua_set_loader() first") end if content == nil then return nil end -- Wikimedia uses an older version of Lua. Make certain substitutions -- to make existing code run on more modern versions of Lua. content = string.gsub(content, "\\\\", "\\092") content = string.gsub(content, "%%\\%[", "%%%%[") content = string.gsub(content, "\\:", ":") content = string.gsub(content, "\\,", ",") content = string.gsub(content, "\\%(", "%%(") content = string.gsub(content, "\\%)", "%%)") content = string.gsub(content, "\\%+", "%%+") content = string.gsub(content, "\\%*", "%%*") content = string.gsub(content, "\\>", ">") content = string.gsub(content, "\\%.", "%%.") content = string.gsub(content, "\\%?", "%%?") content = string.gsub(content, "\\%-", "%%-") content = string.gsub(content, "\\!", "!") content = string.gsub(content, "\\|", "|") -- XXX tentative, see ryu:951 content = string.gsub(content, "\\ʺ", "ʺ") -- Load the content into the Lua interpreter. local ret = assert(load(content, modname, "bt", env)) return ret end -- Register the new loader as the only package searcher in Lua. package.searchers = {} package.searchers[0] = nil package.searchers[1] = new_loader -- This should be called immediately after loading the sandbox to set the -- Python function that will be used for loading Lua modules and various -- other Python functions that implement some of the functionality needed -- for executing Scribunto code (these functions are called from Lua code). function lua_set_loader(loader, mw_text_decode, mw_text_encode, mw_text_jsonencode, mw_text_jsondecode, get_page_info, get_page_content, fetch_language_name, fetch_language_names) python_loader = loader mw = require("mw") mw.text.decode = mw_text_decode mw.text.encode = mw_text_encode mw.text.jsonEncode = mw_text_jsonencode mw.text.jsonDecode = mw_text_jsondecode mw.title.python_get_page_info = get_page_info mw.title.python_get_page_content = get_page_content mw.language.python_fetch_language_name = fetch_language_name mw.language.python_fetch_language_names = fetch_language_names end function frame_args_index(new_args, key) -- print("frame_args_index", key) local v = new_args._orig[key] if v == nil then return nil end if not new_args._preprocessed[key] then local frame = new_args._frame v = frame:preprocess(v) -- Cache preprocessed value so we only preprocess each argument once new_args._preprocessed[key] = true new_args._orig[key] = v end -- print("frame_args_index", key, "->", v) return v end function frame_args_pairs(new_args) -- print("frame_args_pairs") local frame = new_args._frame local function stateless_iter(new_args, key) -- print("stateless_iter: " .. tostring(key)) if key == nil then key = "***nil***" end local nkey = new_args._next_key[key] if nkey == nil then return nil end local v = new_args[nkey] if v == nil then return nil end -- print("stateless_iter returning: " .. tostring(nkey) .. "=" .. -- tostring(v)) return nkey, v end return stateless_iter, new_args, nil end function frame_args_ipairs(new_args) -- print("frame_args_ipairs") local frame = new_args._frame local function stateless_iter(new_args, key) -- print("ipairs stateless_iter: " .. tostring(key)) if key == nil then key = 1 else key = key + 1 end local v = new_args[key] if v == nil then return nil end -- print("stateless_iter returning: " .. tostring(key) .. "=" .. -- tostring(v)) return key, v end return stateless_iter, new_args, nil end function frame_args_len(new_args) return #new_args._orig end function frame_args_next(t, key) if key == nil then key = "***nil***" end local nkey = t._next_key[key] if nkey == nil then return nil end local v = t[nkey] if v == nil then return nil end return nkey, v end frame_args_meta = { __index = frame_args_index, __pairs = frame_args_pairs, __next = frame_args_next, __len = frame_args_len } function frame_new_child(frame, o) local title = (o and o.title) or "" local args = (o and o.args) or {} local new_frame = mw.clone(frame) new_frame.getParent = function() return frame end new_frame.getTitle = function() return title end new_frame.args = args prepare_frame_args(new_frame) return new_frame end function prepare_frame_args(frame) local next_key = {} local prev = "***nil***" for k, v in pairs(frame.args) do -- print("prepare_frame_args: k=" .. tostring(k) .. " v=" .. tostring(v)) next_key[prev] = k prev = k end new_args = {_orig = frame.args, _frame = frame, _next_key = next_key, _preprocessed = {}} setmetatable(new_args, frame_args_meta) frame.args = new_args frame.argumentPairs = function (frame) return pairs(frame.args) end frame.getArgument = frame_get_argument frame.newChild = frame_new_child end function frame_get_argument(frame, name) if type(name) == "table" then name = name.name end v = frame.args[name] if v == nil then return nil end return { expand = function() return v end } end -- This function implements the {{#invoke:...}} parser function. -- XXX need better handling of parent frame and frame -- This returns (true, value) if successful, (false, error) if exception. function lua_invoke(mod_name, fn_name, frame, page_title) -- Initialize frame and parent frame local pframe = frame:getParent() -- print("lua_invoke", mod_name, fn_name) -- for k, v in pairs(frame.args) do -- print("", k, type(k), v, type(v)) -- end -- if pframe ~= nil then -- print("parent") -- for k, v in pairs(pframe.args) do -- print("", k, type(k), v, type(v)) -- end -- end io.flush() -- Convert frame.args into a metatable that preprocesses the values prepare_frame_args(frame) -- Implement some additional functions for frame if pframe ~= nil then prepare_frame_args(pframe) end -- Initialize some fields that will be referenced from functions mw._frame = frame mw._pageTitle = page_title -- Set time limit for execution of the Lua code local start_time = os.time() lua_current_max_time = lua_max_time debug.sethook(function() if os.time() > start_time + lua_current_max_time then error("Lua timeout error") end end, "", 100000) -- Load the module. Note that the initilizations above must be done before -- loading the module, as the module could refer to, e.g., page title -- during loading. local success local mod success, mod = xpcall(function() return require(mod_name) end, debug.traceback) if not success then return False, ("\tLoading module failed in #invoke: " .. mod_name .. "\n" .. mod) end -- Look up the target function in the module local fn = mod[fn_name] if fn == nil then return false, "\tNo function '" .. fn_name .. "' in module " .. mod_name end -- Call the function in the module local st, v = xpcall(function() return fn(frame) end, debug.traceback) -- print("Lua sandbox:", tostring(v)) return st, v end -- Sets maximum lua execution time for the current call to t seconds. The -- value can only be lowered. This intended for tests only. function lua_reduce_timeout(t) if t < lua_current_max_time then lua_current_max_time = t else error("maximum execution time can only be lowered") end end -- math.log10 seems to be sometimes missing??? function math.log10(x) return math.log(x, 10) end -- Limit access to traceback in the debug module local new_debug = { traceback = debug.traceback } -- Limit access to a few safe functions in the os module local new_os = { clock = os.clock, date = os.date, difftime = os.difftime, time = os.time, } -- This is a compatibility function for an older version of Lua (the getn -- function was deprecated and then removed, but it is used in Wiktionary) function table.getn(tbl) return #tbl end -- This is a compatibility function for an older version of Lua. Apparently -- the math.mod function was renamed to math.fmod in Lua 5.1. function math.mod(a, b) return math.fmod(a, b) end -- With the introduction of 64-bit integer type in Lua 5.3, the %d and similar -- formats in string.format no longer accept floating point arguments. Remedy -- that by expressly converting arguments to such formatting codes into -- integers. local orig_format = string.format function string.format(fmt, ...) local args = {...} local new_args = {} local i = 1 for m in string.gmatch(fmt, "%%[-# +'0-9.]*([cdEefgGiouXxqs%%])") do if m ~= "%" then local arg = args[i] i = i + 1 if (m == "d" or m == "i" or m == "o" or m == "u" or m == "x" or m == "X" or m == "c") then arg = math.floor(arg + 0.5) end table.insert(new_args, arg) end end if i < #args then print("Warning: extra arguments to string.format") end return orig_format(fmt, table.unpack(new_args)) end -- Original gsub does not accept "%]" in replacement string in modern Lua, -- while apparently some older versions did. This is used in Wiktionary. -- Thus we mungle the replacement string accordingly. local orig_gsub = string.gsub function string.gsub(text, pattern, repl) --print(string.format("string.gsub %q %q %q", text, pattern, tostring(repl))) if type(repl) == "string" then repl = orig_gsub(repl, "%%]", "]") end return orig_gsub(text, pattern, repl) end -- Original table.insert in Lua 5.1 allows inserting beyond the end of the -- table. Lua 5.3 does not. Implement the old functionality for compatibility; -- Wiktionary relies on it. Also, it seems Wiktionary calls insert with -- only one argument (or the second argument nil). Ignore those calls. local orig_insert = table.insert function table.insert(...) local args = {...} if #args < 2 then return end if #args < 3 then orig_insert(table.unpack(args)) else local pos = args[2] if pos > #args[1] + 1 then args[1][pos] = args[2] else orig_insert(table.unpack(args)) end end end -- Change next() to use a new metamethod __next so that we can redefine it for -- certain tables local orig_next = next function next(t, k) local m = getmetatable(t) local n = m and m.__next or orig_next return n(t, k) end -- This debugging snippet is adapted from: -- https://stackoverflow.com/questions/53399079/tracing-execution-of-lua-sripts local level=0 local function hook(event) local t=debug.getinfo(3) io.write(level," >>> ",string.rep(" ",level)) if t~=nil and t.currentline>=0 then io.write(t.short_src,":",t.currentline," ") end t=debug.getinfo(2) if event=="call" then level=level+1 else level=level-1 if level<0 then level=0 end end if t.what=="main" then if event=="call" then io.write("begin ",t.short_src) else io.write("end ",t.short_src) end elseif t.what=="Lua" then io.write(event," ",t.name or "(Lua)"," <",t.linedefined,":",t.short_src,">") else io.write(event," ",t.name or "(C)"," [",t.what,"] ") end io.write("\n") end -- Comment this out to disable debugging, uncomment to enable tracing Lua code. -- Warning: you may need to disable max time checking by commenting out -- its hook for this to work. -- debug.sethook(hook,"cr") -- Wiktionary uses a Module named "string". Force it to be loaded by -- require() when requested (it is used in many places in Wiktionary). package.loaded["string"] = nil -- Wiktionary uses a Module named "debug". Force it to be loaded by -- require() when requested. package.loaded["debug"] = nil -- Construct a new restricted environment. Lua modules should only be able -- to access the functionality that is available in this restricted -- environment. Please report an issue on github if you find a way to -- circumvent the environment restrictions and access outside the sandbox. env = {} env["_G"] = env env["_VERSION"] = _VERSION env["assert"] = assert env["debug"] = new_debug env["error"] = error env["getmetatable"] = getmetatable -- MODIFY env["ipairs"] = ipairs env["lua_invoke"] = lua_invoke env["lua_set_loader"] = lua_set_loader env["math"] = math env["mw"] = mw env["next"] = next env["os"] = new_os env["pairs"] = pairs env["pcall"] = pcall env["print"] = print env["rawequal"] = rawequal env["rawget"] = rawget env["rawset"] = rawset env["require"] = require env["select"] = select env["setmetatable"] = setmetatable env["string"] = string env["table"] = table env["tonumber"] = tonumber env["tostring"] = tostring env["type"] = type env["unpack"] = table.unpack env["xpcall"] = xpcall -- MODIFY env["lua_reduce_timeout"] = lua_reduce_timeout -- Start using the new environment we just constructed. local _ENV = env -- XXX missing built-in modules? -- bit32 -- libraryUtil -- luabit
local condition = Condition(CONDITION_ATTRIBUTES) condition:setParameter(CONDITION_PARAM_TICKS, 6000) condition:setParameter(CONDITION_PARAM_SKILL_DISTANCEPERCENT, 25) local combat = Combat() combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FLASHARROW) combat:setArea(createCombatArea(AREA_BEAM1)) combat:setCondition(condition) function onCastSpell(creature, variant) return combat:execute(creature, variant) end
local unit1 = system.loadunit 'unit1' local forms = system.loadunit 'forms' local keymap = { up = { forms.vk_up, 'Up' }, down = { forms.vk_down, 'Down' }, left = { forms.vk_left, 'Left' }, right = { forms.vk_right, 'Right' }, r1 = { 50, 'On/Off' }, l1 = { 49, 'Ama/Pro' }, } local menu = { { unit1.form1.btn_pro_down, 'Ama/Pro', 49 }, { unit1.form1.btn_power_down, 'On/Off', 50 } } local timers = { unit1.form1.timer_cherry_bonus, unit1.form1.timer_game, unit1.form1.timer_game_over, unit1.form1.timer_game_start, unit1.form1.timer_ghost_bonus, unit1.form1.timer_intermission, unit1.form1.timer_miss, unit1.form1.timer_power_pill_sound, unit1.form1.timer_stage_complete, } unit1.pfs_beep.data = system.loadbin( 'Beep.pcm' ) unit1.pfs_bonus.data = system.loadbin( 'Bonus.pcm' ) unit1.pfs_miss.data = system.loadbin( 'Miss.pcm' ) unit1.pfs_point.data = system.loadbin( 'Point.pcm' ) unit1.pfs_start.data = system.loadbin( 'Start.pcm' ) unit1.form1.oncreate() unit1.form1.im_background_screen_off_top.layer = 0; unit1.form1.im_background_screen_on.layer = 0; unit1.bsound = true unit1.imode = 0 unit1.form1.gam_set_mode() return system.init( unit1.form1.im_background, keymap, function( key ) unit1.form1.onkeydown( nil, key, 0 ) end, function( key ) unit1.form1.onkeyup( nil, key, 0 ) end, timers, { 302, 218, 340, 130 }, menu )
--[[ This file was extracted by 'EsoLuaGenerator' at '2021-09-04 16:42:28' using the latest game version. NOTE: This file should only be used as IDE support; it should NOT be distributed with addons! **************************************************************************** CONTENTS OF THIS FILE IS COPYRIGHT ZENIMAX MEDIA INC. **************************************************************************** ]] ZO_UnitVisualizer_UnwaveringModule = ZO_UnitAttributeVisualizerModuleBase:Subclass() function ZO_UnitVisualizer_UnwaveringModule:New(...) return ZO_UnitAttributeVisualizerModuleBase.New(self, ...) end function ZO_UnitVisualizer_UnwaveringModule:Initialize(layoutData) self.layoutData = layoutData end function ZO_UnitVisualizer_UnwaveringModule:GetInitialStatValue(stat, attribute, powerType) return self:GetInitialValueAndMarkMostRecent(ATTRIBUTE_VISUAL_UNWAVERING_POWER, stat, attribute, powerType) end function ZO_UnitVisualizer_UnwaveringModule:CreateInfoTable(control, oldBarInfo, stat, attribute, power) if control then local oldInfo = oldBarInfo and oldBarInfo[attribute] if oldInfo then oldInfo.value = self:GetInitialStatValue(stat, attribute, power) return oldInfo end return { value = self:GetInitialStatValue(stat, attribute, power), lastValue = 0 } end return nil end function ZO_UnitVisualizer_UnwaveringModule:OnAdded(healthBarControl, magickaBarControl, staminaBarControl) self.barControls = { [ATTRIBUTE_HEALTH] = healthBarControl, } if IsPlayerActivated() then self:InitializeBarValues() end EVENT_MANAGER:RegisterForEvent("ZO_UnitVisualizer_UnwaveringModule" .. self:GetModuleId(), EVENT_PLAYER_ACTIVATED, function() self:InitializeBarValues() end) end function ZO_UnitVisualizer_UnwaveringModule:InitializeBarValues() local healthBarControl = self.barControls[ATTRIBUTE_HEALTH] local oldBarInfo = self.barInfo self.barInfo = { [ATTRIBUTE_HEALTH] = self:CreateInfoTable(healthBarControl, oldBarInfo, STAT_MITIGATION, ATTRIBUTE_HEALTH, POWERTYPE_HEALTH), } for attribute, bar in pairs(self.barControls) do self:OnValueChanged(bar, self.barInfo[attribute], ANIMATION_INSTANT) end end function ZO_UnitVisualizer_UnwaveringModule:OnUnitChanged() self:InitializeBarValues() end function ZO_UnitVisualizer_UnwaveringModule:IsUnitVisualRelevant(visualType, stat, attribute, powerType) if visualType == ATTRIBUTE_VISUAL_UNWAVERING_POWER then return self.barInfo and self.barInfo[attribute] ~= nil end return false end function ZO_UnitVisualizer_UnwaveringModule:OnUnitAttributeVisualAdded(visualType, stat, attribute, powerType, value) self.barInfo[attribute].value = self.barInfo[attribute].value + value self:OnValueChanged(self.barControls[attribute], self.barInfo[attribute]) end function ZO_UnitVisualizer_UnwaveringModule:OnUnitAttributeVisualUpdated(visualType, stat, attribute, powerType, oldValue, newValue) self.barInfo[attribute].value = self.barInfo[attribute].value + (newValue - oldValue) self:OnValueChanged(self.barControls[attribute], self.barInfo[attribute]) end function ZO_UnitVisualizer_UnwaveringModule:OnUnitAttributeVisualRemoved(visualType, stat, attribute, powerType, value) self.barInfo[attribute].value = self.barInfo[attribute].value - value self:OnValueChanged(self.barControls[attribute], self.barInfo[attribute]) end local function ApplyPlatformStyleToUnwavering(control, overlay) ApplyTemplateToControl(control, ZO_GetPlatformTemplate(overlay)) end function ZO_UnitVisualizer_UnwaveringModule:PlayAnimation(bar, info, instant) if not info.animation then local control = CreateControlFromVirtual("$(parent)UnwaveringOverlayContainer", bar, self.layoutData.overlayContainerTemplate) local overlayOffsets = self.layoutData.overlayOffsets local currentOffsets = IsInGamepadPreferredMode() and overlayOffsets.gamepad or overlayOffsets.keyboard if not currentOffsets then currentOffsets = overlayOffsets.shared end control:SetAnchor(TOPLEFT, bar, TOPLEFT, currentOffsets.left, currentOffsets.top) control:SetAnchor(BOTTOMRIGHT, bar, BOTTOMRIGHT, currentOffsets.right, currentOffsets.bottom) local animation = ANIMATION_MANAGER:CreateTimelineFromVirtual("UnwaveringAnimation", control) info.control = control animation:SetHandler("OnPlay", function() self:GetOwner():NotifyTakingControlOf(bar) if bar.warner then bar.warner:SetPaused(false) end end) animation:SetHandler("OnStop", function() self:GetOwner():NotifyEndingControlOf(bar) if bar.warner then bar.warner:SetPaused(true) end end) for i, statusBar in ipairs(bar.barControls) do animation:InsertAnimationFromVirtual("UnwaveringBarAnimation", statusBar) end if bar.warnerContainer then animation:InsertAnimationFromVirtual("UnwaveringGlowInAnimation", bar.warnerContainer) animation:InsertAnimationFromVirtual("UnwaveringGlowOutAnimation", bar.warnerContainer) end info.animation = animation ApplyPlatformStyleToUnwavering(info.control, self.layoutData.overlayContainerTemplate) end info.animation.instant = instant info.animation.owner = self:GetOwner() if instant then info.control:SetAlpha(1) info.animation:PlayInstantlyToEnd() else info.animation:PlayForward() end end function ZO_UnitVisualizer_UnwaveringModule:OnValueChanged(bar, info, instant) local value = info.value local lastValue = info.lastValue info.lastValue = value if value > 0 and lastValue <= 0 then self:PlayAnimation(bar, info, instant) elseif value <= 0 and lastValue > 0 then info.animation.instant = instant ZO_Animation_PlayBackwardOrInstantlyToStart(info.animation, instant) end end function ZO_UnitVisualizer_UnwaveringModule:ApplyPlatformStyle() if self.barInfo then for _, info in pairs(self.barInfo) do if info.control then ApplyPlatformStyleToUnwavering(info.control, self.layoutData.overlayContainerTemplate) end end end end
-- awesome_mode: api-level=4:screen=on ----------------------------------------------------------- -- Includes {{{1 -- Standard awesome libraries local gears = require("gears") -- Utilities such as color parsing and objects -- Widget and layout library local wibox = require("wibox") -- Awesome own generic widget framework -- Theme handling library local beautiful = require("beautiful") -- Awesome theme module local M = {} ----------------------------------------------------------- -- Systray {{{1 function M.get_widget(s) if s == screen.primary then local systray = wibox.widget({ { { widget = wibox.widget.systray }, top = 2 * beautiful.useless_gap, bottom = 2 * beautiful.useless_gap, left = 5 * beautiful.useless_gap, right = 5 * beautiful.useless_gap, widget = wibox.container.margin, }, bg = beautiful.bg_systray, fg = beautiful.fg_normal, shape = gears.shape.rounded_bar, widget = wibox.container.background, }) return systray else return end end return M -- }}}1
BoulderRound = Engine:EntityClass('BoulderRound') function BoulderRound:setup(data) self._states = { STATIONARY = 1, ROLLING = 2 } self.image = Engine:getAsset('art/boulder_round.png') self.state = self.state or self._states.STATIONARY self.rollingDir = self.rollingDir or nil self.lastMoveTime = self.lastMoveTime or 0 BasicEntSetup(self, data) end function BoulderRound:blocksTraversal() return true end function BoulderRound:blocksVision() return true end function BoulderRound:blocksLight() return true end function BoulderRound:isMovable() return true end function BoulderRound:activatesFloorSensors() return true end function BoulderRound:render() love.graphics.setColor(1, 1, 1, 1) DrawSimpleEntImage(self, self.image) end function BoulderRound:update() if self.rollingDir ~= nil and GAMETIME > self.lastMoveTime + 4 * ONETICK then if not self:tryMove(self.rollingDir) then self.rollingDir = nil end self.lastMoveTime = GAMETIME end end function BoulderRound:onShoved(dir, other) self.rollingDir = dir end
#!/usr/bin/env lua local help_message = [[ bf2.lua - convert Brainfuck to Lua Convert: bf2.lua -i input.bf -o output.lua Convert and run: bf2.lua -i input.bf Options: -h --help print this message -i --input input file, - for stdin -o --output output file, - for stdout ]] local output_header = [[ #!/bin/env lua data = {} ptr = 1 ]] -- read brainfuck code from file read_brainfuck = function(file) local program = {} repeat command = file:read(1) if command ~= fail and string.match(command, "[<>%+%-%.,%[%]]") ~= fail then program[#program+1] = command end until command == fail -- EOF return table.concat(program, "") end -- removes useless sequences of commands from a brainfuck program optimise_brainfuck = function(program) local substitutions = {["<>"] = "", ["><"] = "", ["%+%-"] = "", ["%-%+"] = "", ["%[%]"] = ""} local sum = 0 repeat sum = 0 for i,v in pairs(substitutions) do program, s = string.gsub(program, i, v) sum = sum + s end until sum == 0 return program end -- counts the number of unmatched loop commands, should return 0 for a valid program count_brainfuck_loops = function(program) local loops = 0 for i = 1, #program do if string.sub(program, i, i) == "[" then loops = loops + 1 elseif string.sub(program, i, i) == "]" then loops = loops - 1 end end return loops end -- converts Brainfuck code to Lua code convert_brainfuck = function(program, output) local loops = 0 local counter = 1 output:write(output_header) for i = 1, #program do if string.sub(program, i, i) == "[" then output:write(string.rep("\t", loops).."while ((data[ptr] and data[ptr]) or 0) ~= 0 do\n") loops = loops + 1 elseif string.sub(program, i, i) == "]" then loops = loops - 1 output:write(string.rep("\t", loops).."end\n") elseif string.sub(program, i, i) == "," then output:write(string.rep("\t", loops).."data[ptr] = string.byte(io.read(1))\n") elseif string.sub(program, i, i) == "." then output:write(string.rep("\t", loops).."io.write(string.char((data[ptr] and data[ptr]) or 0))\n") elseif string.sub(program, i, i) == "+" then if string.sub(program, i+1, i+1) == "+" then counter = counter + 1 else output:write(string.rep("\t", loops).."data[ptr] = ((data[ptr] and data[ptr]) or 0) + "..counter.."\n") counter = 1 end elseif string.sub(program, i, i) == "-" then if string.sub(program, i+1, i+1) == "-" then counter = counter + 1 else output:write(string.rep("\t", loops).."data[ptr] = ((data[ptr] and data[ptr]) or 0) - "..counter.."\n") counter = 1 end elseif string.sub(program, i, i) == "<" then if string.sub(program, i+1, i+1) == "<" then counter = counter + 1 else output:write(string.rep("\t", loops).."ptr = ptr - "..counter.."\n") counter = 1 end elseif string.sub(program, i, i) == ">" then if string.sub(program, i+1, i+1) == ">" then counter = counter + 1 else output:write(string.rep("\t", loops).."ptr = ptr + "..counter.."\n") counter = 1 end end if loops < 0 then break end end end -- main function main = function() local infile = nil -- input filename local outfile = nil -- output filename local bfcode = "" -- Brainfuck code local output -- output file local run = false -- parse commandline args for i=1,#arg do if arg[i] == "-h" or arg[i] == "--help" then io.write(help_message) os.exit(0) elseif arg[i] == "-i" or arg[i] == "--input" then if arg[i+1] == nil then print("Option "..arg[i].." requires an argument") os.exit(1) else infile = tostring(arg[i+1]) end elseif arg[i] == "-o" or arg[i] == "--output" then if arg[i+1] == nil then print("Option "..arg[i].." requires an argument") os.exit(1) else outfile = tostring(arg[i+1]) end end end -- read input if infile == nil then print("Missing argument -i, run "..arg[0].." -h for help") os.exit(1) elseif infile == "-" then bfcode = read_brainfuck(io.input()) else input = io.open(infile) if input == fail then print("Couldn't open "..infile) os.exit(1) end bfcode = read_brainfuck(input) input:close() end bfcode = optimise_brainfuck(bfcode) -- check for unmatched loops local loops = count_brainfuck_loops(bfcode) if loops > 0 then print("Error: missing "..loops.." ]") os.exit(1) elseif loops < 0 then print("Error: missing "..-loops.." [") os.exit(1) end -- open output if outfile == nil then outfile = os.tmpname() output = io.open(outfile, "w") if output == fail then print("Couldn't open a temporary file") os.exit(1) end run = true elseif outfile == "-" then output = io.output() else output = io.open(outfile, "w") if output == fail then print("Couldn't open "..outfile) os.exit(1) end end convert_brainfuck(bfcode, output) output:close() -- run output if run then dofile(outfile) os.remove(outfile) end end main()
local utils = require(GetScriptDirectory() .. "/util") local X = {} local tableMeepos = {} local isFarmed = false function X.AddMeepo ( meepo ) table.insert(tableMeepos, meepo) end function X.GetMeepos () return tableMeepos end function X.GetIsFarmed() return isFarmed end function X.SetIsFarmed( bFarmed ) isFarmed = bFarmed end return X
local self = {} mUI.XML = self local TOKENIZER = { IDLE = 0, IDENTIFIER = 1, CARRIAGERETURN = 2, QUOTED_SINGLE = 3, QUOTED_DOUBLE = 4, ESCAPED = 5 } function self:Tokenize(str) local mode = TOKENIZER.IDLE local tokens = {} local line,col = 1,0 local tempBuffer1 local tempBuffer2 local escapeSequences = { nbsp = " ", lt = "<", gt = ">", amp = "&", quot = "\"", apos = "'", nl = "\n" -- because } for char in str:gmatch("(.)") do col = col + 1 ::parser:: if mode == TOKENIZER.IDLE then if char == "\n" then tokens[#tokens + 1] = { type = "NewLine", data = char, line = line, col = col } line = line + 1 col = 0 elseif char == "\r" then tokens[#tokens + 1] = { type = "NewLine", data = char, line = line, col = col } mode = TOKENIZER.CARRIAGERETURN elseif char == "<" then tokens[#tokens + 1] = { type = "TagOpen", data = char, line = line, col = col } elseif char == " " then if tokens[#tokens].type == "Whitespace" then tokens[#tokens].data = tokens[#tokens].data..char else tokens[#tokens + 1] = { type = "Whitespace", data = char, line = line, col = col } end elseif char == "\t" then if tokens[#tokens].type == "Tab" then tokens[#tokens].data = tokens[#tokens].data..char else tokens[#tokens + 1] = { type = "Tab", data = char, line = line, col = col } end elseif char == ">" then tokens[#tokens + 1] = { type = "TagClose", data = char, line = line, col = col } elseif char == "/" then tokens[#tokens + 1] = { type = "Slash", data = char, line = line, col = col } elseif char == "=" then tokens[#tokens + 1] = { type = "Equals", data = char, line = line, col = col } elseif char == "\"" then tokens[#tokens + 1] = { type = "Quote", data = char, line = line, col = col } tokens[#tokens + 1] = { type = "Text", data = "", line = line, col = col } mode = TOKENIZER.QUOTED_DOUBLE elseif char == "'" then tokens[#tokens + 1] = { type = "Quote", data = char, line = line, col = col } tokens[#tokens + 1] = { type = "Text", data = "", line = line, col = col } mode = TOKENIZER.QUOTED_SINGLE elseif char == "&" then if not (tokens[#tokens] and tokens[#tokens].type == "Identifier") then tokens[#tokens + 1] = { type = "Identifier", data = "", line = line, col = col } end tempBuffer1 = "" tempBuffer2 = mode mode = TOKENIZER.ESCAPED elseif char:match("[^<>\r\n =]") then tokens[#tokens + 1] = { type = "Identifier", data = char, line = line, col = col } mode = TOKENIZER.IDENTIFIER else error("Unexpected character: "..char.." at line "..line.." col "..col) end elseif mode == TOKENIZER.IDENTIFIER then if char:match("[^<>\r\n =]") then tokens[#tokens].data = tokens[#tokens].data..char else mode = TOKENIZER.IDLE goto parser end elseif mode == TOKENIZER.CARRIAGERETURN then if char == "\n" then tokens[#tokens].data = tokens[#tokens].data..char mode = TOKENIZER.IDLE line = line + 1 col = 0 else error("Malformed carriage return at line "..line.." col "..col) end elseif (mode == TOKENIZER.QUOTED_SINGLE) then if char:match("[^'\r\n&]") then tokens[#tokens].data = tokens[#tokens].data..char elseif char == "&" then tempBuffer1 = "" tempBuffer2 = mode mode = TOKENIZER.ESCAPED elseif char == "'" then tokens[#tokens + 1] = { type = "Quote", data = char, line = line, col = col } mode = TOKENIZER.IDLE else error("Malformed quoted text at line "..line.." col "..col) end elseif (mode == TOKENIZER.QUOTED_DOUBLE) then if char:match("[^\"\r\n&]") then tokens[#tokens].data = tokens[#tokens].data..char elseif char == "&" then tempBuffer1 = "" tempBuffer2 = mode mode = TOKENIZER.ESCAPED elseif char == "\"" then tokens[#tokens + 1] = { type = "Quote", data = char, line = line, col = col } mode = TOKENIZER.IDLE else error("Malformed quoted text at line "..line.." col "..col) end elseif (mode == TOKENIZER.ESCAPED) then if char == ";" then if tempBuffer1:sub(1,1) == "#" then if tempBuffer1:sub(2,2) == "x" then if tonumber(tempBuffer1:sub(3,-1) or "",16) then tokens[#tokens].data = tokens[#tokens].data..string.char(tonumber(tempBuffer1:sub(3,-1),16)) mode = tempBuffer2 else error("Invalid numeric hex escape sequence at line "..line.." col "..col) end elseif tonumber(tempBuffer1:sub(2,-1) or "") then tokens[#tokens].data = tokens[#tokens].data..string.char(tonumber(tempBuffer1:sub(2,-1))) mode = tempBuffer2 else error("Invalid numeric escape sequence at line "..line.." col "..col) end elseif escapeSequences[tempBuffer1] then tokens[#tokens].data = tokens[#tokens].data..escapeSequences[tempBuffer1] mode = tempBuffer2 else error("Invalid escape sequence \"&"..tempBuffer1..";\" at line "..line.." col "..col) end elseif tokens[#tokens - 1].data == char then error("Unterminated escape sequence at line "..line.." col "..col) else tempBuffer1 = tempBuffer1..char end end end if mode ~= TOKENIZER.IDLE then error("Unexpected EOF!") end return tokens end local PARSER = { IDLE = 0, TAG_NEED_IDENT = 1, TAG_NEED_CLOSE = 2, IDENT_NEED_EQUALS = 3, IDENT_NEED_QUOTE = 4, IDENT_NEED_DEFINE = 5, IDENT_NEED_QUOTE_CLOSE = 6, TAG_CLOSE_IDENT = 7, TAG_NEED_CLOSE_ONLY = 8 } self.Parsers = {} function self.Parsers.Whitespace()end function self.Parsers.NewLine(parser,token) parser.currentNode.text = parser.currentNode.text:sub(1,-1-#token.data) end function self.Parsers.Tab(parser,token) parser.currentNode.text = parser.currentNode.text:sub(1,-1-#token.data) end function self.Parsers.TagOpen(parser,token) assert(parser.mode == PARSER.IDLE,"Unexpected tag opening at line "..token.line.." col "..token.col.."!") parser.mode = PARSER.TAG_NEED_IDENT parser.isInBody = false parser.tempBuffer1 = parser:newChild(token) end function self.Parsers.Slash(parser,token) if parser.isInBody then return end assert((parser.mode == PARSER.TAG_NEED_IDENT) or (parser.mode == PARSER.TAG_NEED_CLOSE),"Unexpected slash at line "..token.line.." col "..token.col.."!") if parser.mode == PARSER.TAG_NEED_CLOSE then parser.tempBuffer1._id = parser.currentNode._id.."."..parser.tempBuffer1.identifier..(#parser.currentNode.children+1) parser:pushChild(parser.tempBuffer1) parser.tempBuffer1 = nil parser.mode = PARSER.TAG_NEED_CLOSE_ONLY else parser.tempBuffer1 = nil parser.mode = PARSER.TAG_CLOSE_IDENT end end function self.Parsers.Identifier(parser,token) if parser.mode == PARSER.TAG_NEED_IDENT then parser.mode = PARSER.TAG_NEED_CLOSE parser.tempBuffer1.identifier = token.data elseif parser.mode == PARSER.TAG_NEED_CLOSE then assert(token.data:match("[A-Za-z0-9%-]"),"Token contains non alphanumeric symbols!") parser.tempBuffer2 = token.data parser.mode = PARSER.IDENT_NEED_EQUALS elseif parser.mode == PARSER.TAG_CLOSE_IDENT then assert(parser.currentNode.identifier == token.data,"Tag "..token.data.." was unexpectedly closed at line "..token.line.." col "..token.col.."!") parser.mode = PARSER.TAG_NEED_CLOSE_ONLY elseif parser.mode == PARSER.IDLE then else error("Unexpected identifier at line "..token.line.." col "..token.col.."!") end end function self.Parsers.Equals(parser,token) if parser.isInBody then return end assert(parser.mode == PARSER.IDENT_NEED_EQUALS,"Unexpected '=' at line "..token.line.." col "..token.col.."!") parser.mode = PARSER.IDENT_NEED_QUOTE end function self.Parsers.Text(parser,token) assert(parser.mode == PARSER.IDENT_NEED_DEFINE,"Unexpected text at line "..token.line.." col "..token.col.."!") parser.mode = PARSER.IDENT_NEED_QUOTE_CLOSE parser.tempBuffer1.attributes[parser.tempBuffer2] = token.data parser.tempBuffer2 = nil end function self.Parsers.Quote(parser,token) if parser.mode == PARSER.IDENT_NEED_QUOTE then parser.mode = PARSER.IDENT_NEED_DEFINE elseif parser.mode == PARSER.IDENT_NEED_QUOTE_CLOSE then parser.mode = PARSER.TAG_NEED_CLOSE else error("Unexpected quote at line "..token.line.." col "..token.col.."!") end end function self.Parsers.TagClose(parser,token) assert((parser.mode == PARSER.TAG_NEED_CLOSE) or (parser.mode == PARSER.TAG_NEED_CLOSE_ONLY),"Unexpected tag closing at line "..token.line.." col "..token.col.."!") if parser.mode == PARSER.TAG_NEED_CLOSE_ONLY then parser:popChild() else parser.tempBuffer1._id = parser.currentNode._id.."."..parser.tempBuffer1.identifier..(#parser.currentNode.children+1) parser:pushChild(parser.tempBuffer1) parser.tempBuffer1 = nil end parser.isInBody = true parser.mode = PARSER.IDLE end function self:ParseTokens(tokens) local parser = {} parser.tempBuffer1 = nil -- for reference parser.tempBuffer2 = nil parser.mode = PARSER.IDLE parser.idx = 1 function parser:advanceIdx() self.idx = self.idx + 1 end function parser:getRelativeToken(relative) return tokens[self.idx + relative] end function parser:expect(type) return self:getRelativeToken(1) and (self:getRelativeToken(1).type == type) end function parser:is(type) return self:getRelativeToken(0) and (self:getRelativeToken(0).type == type) end function parser:newChild(token) local child = { text = "", children = {}, attributes = {}, parent = self.currentNode, identifier = "", token = token } return child end function parser:pushChild(child) self.currentNode.children[#self.currentNode.children+1] = child self.currentNode = child or self.currentNode end function parser:popChild() self.currentNode = self.currentNode.parent or self.currentNode end function parser:updateText(child,text) if self.isInBody and not self:is "TagOpen" then child.text = child.text..text end end parser.AST = { text = "", children = {}, attributes = {}, parent = false, identifier = "main", _id = "main", token = false } parser.isInBody = true parser.currentNode = parser.AST for _,token in ipairs(tokens) do parser:updateText(parser.currentNode,token.data) self.Parsers[token.type](parser,token) parser:advanceIdx() end if parser.mode ~= PARSER.IDLE then error("Unexpected EOF!") end if parser.currentNode ~= parser.AST then error("Tag "..parser.currentNode.identifier.." was not closed! (line "..parser.currentNode.token.line.." col "..parser.currentNode.token.col..")") end return parser.AST end function self:Parse(xml) return self:ParseTokens(self:Tokenize(xml)) end
#!/usr/bin/env tarantool local fio = require('fio') box.cfg{log = "tarantool.log"} build_path = os.getenv("BUILDDIR") package.cpath = fio.pathjoin(build_path, 'test/app-tap/?.so' ) .. ';' .. fio.pathjoin(build_path, 'test/app-tap/?.dylib') .. ';' .. package.cpath local function test_pushcdata(test, module) test:plan(6) local ffi = require('ffi') ffi.cdef('struct module_api_test { int a; };') local gc_counter = 0; local ct = ffi.typeof('struct module_api_test') ffi.metatype(ct, { __tostring = function(obj) return 'ok' end; __gc = function(obj) gc_counter = gc_counter + 1; end }) local ctid = tonumber(ct) local obj, ptr = module.pushcdata(ctid) test:is(ffi.typeof(obj), ct, 'pushcdata typeof') test:is(tostring(obj), 'ok', 'pushcdata metatable') local ctid2, ptr2 = module.checkcdata(obj) test:is(ctid, ctid2, 'checkcdata type') test:is(ptr, ptr2, 'checkcdata value') test:is(gc_counter, 0, 'pushcdata gc') obj = nil collectgarbage('collect') test:is(gc_counter, 1, 'pushcdata gc') end local test = require('tap').test("module_api", function(test) test:plan(23) local status, module = pcall(require, 'module_api') test:is(status, true, "module") test:ok(status, "module is loaded") if not status then test:diag("Failed to load library:") for _, line in ipairs(module:split("\n")) do test:diag("%s", line) end return end local space = box.schema.space.create("test") space:create_index('primary') for name, fun in pairs(module) do if string.sub(name,1, 5) == 'test_' then test:ok(fun(), name .. " is ok") end end local status, msg = pcall(module.check_error) test:like(msg, 'luaT_error', 'luaT_error') test:test("pushcdata", test_pushcdata, module) space:drop() end) os.exit(0)
local StringBuffer = require("string_buffer") local Command = require("uci.command") local M = {} function M.parse(list) local data = {} assert(list[1] == "id") data.command = Command.ID local index = 2 while index <= #list do if list[index] == "name" then index = index + 1 local str = StringBuffer(list[index]) for i = index + 1, #list do str:append(" "):append(list[i]) end index = #list data.name = str:tostring() elseif list[index] == "author" then index = index + 1 local str = StringBuffer(list[index]) for i = index + 1, #list do str:append(" "):append(list[i]) end index = #list data.author = str:tostring() end index = index + 1 end return data end return M