repo_name
stringlengths
6
69
path
stringlengths
6
178
copies
stringclasses
278 values
size
stringlengths
4
7
content
stringlengths
671
917k
license
stringclasses
15 values
zynjec/darkstar
scripts/zones/Bastok_Markets/npcs/Umberto.lua
9
1080
----------------------------------- -- Area: Bastok Markets -- NPC: Umberto -- Type: Quest NPC -- Involved in Quest: Too Many Chefs -- !pos -56.896 -5 -134.267 235 ----------------------------------- local ID = require("scripts/zones/Bastok_Markets/IDs"); ----------------------------------- function onTrade(player,npc,trade) end; function onTrigger(player,npc) if (player:getCharVar("TOO_MANY_CHEFS") == 5) then -- end Quest Too Many Chefs player:startEvent(473); else player:startEvent(411); end end; function onEventUpdate(player,csid,option) end; function onEventFinish(player,csid,option) if (csid == 473) then if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,5674); else player:addItem(5674); player:messageSpecial(ID.text.ITEM_OBTAINED,5674); player:addFame(BASTOK,30); player:setCharVar("TOO_MANY_CHEFS",0); player:completeQuest(BASTOK,dsp.quest.id.bastok.TOO_MANY_CHEFS); end end end;
gpl-3.0
zynjec/darkstar
scripts/globals/mobskills/ink_jet_alt.lua
9
1030
--------------------------------------------- -- Ink Jet alt -- -- Description: Unleashes a torrent of black spores in a fan-shaped area of effect, dealing dark damage to targets. Additional effect: Blind -- Type: Magical Dark (Element) -- -- Notes: Used by Fe'e in Up in Arms BCNM --------------------------------------------- require("scripts/globals/monstertpmoves") require("scripts/globals/settings") require("scripts/globals/status") --------------------------------------------- function onMobSkillCheck(target,mob,skill) return 0 end function onMobWeaponSkill(target, mob, skill) local dmgmod = 1 local info = MobMagicalMove(mob,target,skill,mob:getWeaponDmg()*2.5,dsp.magic.ele.DARK,dmgmod,TP_NO_EFFECT) local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,dsp.attackType.MAGICAL,dsp.damageType.DARK,MOBPARAM_IGNORE_SHADOWS) MobStatusEffectMove(mob, target, dsp.effect.BLINDNESS, 20, 0, 180) target:takeDamage(dmg, mob, dsp.attackType.MAGICAL, dsp.damageType.DARK) return dmg end
gpl-3.0
Colettechan/darkstar
scripts/zones/QuBia_Arena/mobs/Worgbut_of_Clan_Death.lua
23
2661
----------------------------------- -- Area: QuBia_Arena -- Mission 9-2 SANDO ----------------------------------- ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) end; ----------------------------------- -- onMobFight ----------------------------------- function onMobFight(mob,target) end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob, player, isKiller) local mobs= {{17621017,17621018,17621019,17621020,17621021,17621022,17621023,17621024,17621025,17621026,17621027},{17621031,17621032,17621033,17621034,17621035,17621036,17621037,17621038,17621039,17621040,17621041},{17621031,17621046,17621047,17621048,17621049,17621050,17621051,17621052,17621053,17621054,17621055}}; local inst=player:getBattlefield():getBattlefieldNumber(); local victory = true for i,v in ipairs(mobs[inst]) do local action = GetMobAction(v); printf("action %u",action); if not(action == 0 or (action >=21 and action <=23)) then victory = false end end if victory == true then player:startEvent(0x7d04,0,0,4); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) printf("finishCSID: %u",csid); printf("RESULT: %u",option); if (csid == 0x7d04) then if (player:getBattlefield():getBattlefieldNumber() == 1) then SpawnMob(17621014); SpawnMob(17621015); SpawnMob(17621016); local trion = player:getBattlefield():insertAlly(14183) trion:setSpawn(-403,-201,413,58); trion:spawn(); player:setPos(-400,-201,419,61); elseif (player:getBattlefield():getBattlefieldNumber() == 2) then SpawnMob(17621028); SpawnMob(17621029); SpawnMob(17621030); local trion = player:getBattlefield():insertAlly(14183) trion:setSpawn(-3,-1,4,61); trion:spawn(); player:setPos(0,-1,10,61); elseif (player:getBattlefield():getBattlefieldNumber() == 3) then SpawnMob(17621042); SpawnMob(17621043); SpawnMob(17621044); local trion = player:getBattlefield():insertAlly(14183) trion:setSpawn(397,198,-395,64); trion:spawn(); player:setPos(399,198,-381,57); end end end;
gpl-3.0
pspjuth/cqui
Assets/UI/Popups/greatpeoplepopup.lua
3
44930
-- =========================================================================== -- Great People Popup -- =========================================================================== include("InstanceManager"); include("TabSupport"); include("SupportFunctions"); include("Civ6Common"); --DifferentiateCivs include("ModalScreen_PlayerYieldsHelper"); include("GameCapabilities"); -- =========================================================================== -- CONSTANTS -- =========================================================================== local COLOR_CLAIMED : number = 0xffffffff; local COLOR_AVAILABLE : number = 0xbbffffff; local COLOR_UNAVAILABLE : number = 0x55ffffff; local MAX_BIOGRAPHY_PARAGRAPHS : number = 9; -- maximum # of paragraphs for a biography local MIN_WIDTH : number = 285 * 2; -- minimum width of screen (instance size x # of panels) local RELOAD_CACHE_ID : string = "GreatPeoplePopup"; -- hotloading local SIZE_ACTION_ICON : number = 38; local MAX_BEFORE_TRUNC_IND_NAME : number = 220; -- =========================================================================== -- VARIABLES -- =========================================================================== local m_greatPersonPanelIM :table = InstanceManager:new("PanelInstance", "Content", Controls.PeopleStack); local m_greatPersonRowIM :table = InstanceManager:new("PastRecruitmentInstance", "Content", Controls.RecruitedStack); local m_uiGreatPeople :table; local m_kData :table; local m_ToggleGreatPeopleId; local m_activeBiographyID :number = -1; -- Only allow one open at a time (or very quick exceed font allocation) local m_tabs :table; local m_defaultPastRowHeight :number = -1; -- Default/mix height (from XML) for a previously recruited row local m_screenWidth :number = -1; -- =========================================================================== function GetActivationEffectTextByGreatPersonClass( greatPersonClassID:number ) local text; if ((GameInfo.GreatPersonClasses["GREAT_PERSON_CLASS_WRITER"] ~= nil and greatPersonClassID == GameInfo.GreatPersonClasses["GREAT_PERSON_CLASS_WRITER"].Index) or (GameInfo.GreatPersonClasses["GREAT_PERSON_CLASS_ARTIST"] ~= nil and greatPersonClassID == GameInfo.GreatPersonClasses["GREAT_PERSON_CLASS_ARTIST"].Index) or (GameInfo.GreatPersonClasses["GREAT_PERSON_CLASS_MUSICIAN"] ~= nil and greatPersonClassID == GameInfo.GreatPersonClasses["GREAT_PERSON_CLASS_MUSICIAN"].Index)) then text = Locale.Lookup("LOC_GREAT_PEOPLE_WORK_CREATED"); else text = Locale.Lookup("LOC_GREAT_PEOPLE_PERSON_ACTIVATED"); end return text; end -- =========================================================================== -- Helper to obtain biography text. -- individualID index of the great person -- RETURNS: oreder table of biography text. -- =========================================================================== function GetBiographyTextTable( individualID:number ) if individualID == nil then return {}; end -- LOC_PEDIA_GREATPEOPLE_PAGE_GREAT_PERSON_INDIVIDUAL_ABU_AL_QASIM_AL_ZAHRAWI_CHAPTER_HISTORY_PARA_1 -- LOC_PEDIA_GREATPEOPLE_PAGE_GREAT_PERSON_INDIVIDUAL_ABDUS_SALAM_CHAPTER_HISTORY_PARA_3 local bioPrefix :string = "LOC_PEDIA_GREATPEOPLE_PAGE_"; local bioName :string = GameInfo.GreatPersonIndividuals[individualID].GreatPersonIndividualType; local bioPostfix:string = "_CHAPTER_HISTORY_PARA_"; local kBiography:table = {}; for i:number = 1,MAX_BIOGRAPHY_PARAGRAPHS,1 do local key:string = bioPrefix..bioName..bioPostfix..tostring(i); if Locale.HasTextKey(key) then kBiography[i] = Locale.Lookup(key); else break; end end return kBiography; end -- =========================================================================== -- View the great people currently available (to be purchased) -- =========================================================================== function ViewCurrent( data:table ) if (data == nil) then UI.DataError("GreatPeople attempting to view current timeline data but received NIL instead."); return; end m_uiGreatPeople = {}; m_greatPersonPanelIM:ResetInstances(); Controls.PeopleScroller:SetHide(false); Controls.RecruitedArea:SetHide(true); local firstAvailableIndex :number = 0; for i, kPerson:table in ipairs(data.Timeline) do local instance :table = m_greatPersonPanelIM:GetInstance(); local classData :table = GameInfo.GreatPersonClasses[kPerson.ClassID]; local individualData:table = GameInfo.GreatPersonIndividuals[kPerson.IndividualID]; local classText :string = ""; --CQUI Changes to Keep Great Person Class Label even when all are claimed --[[if (kPerson.ClassID ~= nil) then classText = Locale.Lookup(classData.Name); instance.ClassName:SetText(classText); --end]] if(i==1) then instance.ClassName:SetText(Locale.Lookup("LOC_GREAT_PERSON_CLASS_GENERAL_NAME")); elseif(i==2) then instance.ClassName:SetText(Locale.Lookup("LOC_GREAT_PERSON_CLASS_ADMIRAL_NAME")); elseif(i==3) then instance.ClassName:SetText(Locale.Lookup("LOC_GREAT_PERSON_CLASS_ENGINEER_NAME")); elseif(i==4) then instance.ClassName:SetText(Locale.Lookup("LOC_GREAT_PERSON_CLASS_MERCHANT_NAME")); elseif(i==5) then instance.ClassName:SetText(Locale.Lookup("LOC_GREAT_PERSON_CLASS_PROPHET_NAME")); elseif(i==6) then instance.ClassName:SetText(Locale.Lookup("LOC_GREAT_PERSON_CLASS_SCIENTIST_NAME")); elseif(i==7) then instance.ClassName:SetText(Locale.Lookup("LOC_GREAT_PERSON_CLASS_WRITER_NAME")); elseif(i==8) then instance.ClassName:SetText(Locale.Lookup("LOC_GREAT_PERSON_CLASS_ARTIST_NAME")); else instance.ClassName:SetText(Locale.Lookup("LOC_GREAT_PERSON_CLASS_MUSICIAN_NAME")); end if kPerson.IndividualID ~= nil then local individualName:string = Locale.ToUpper(kPerson.Name); instance.IndividualName:SetText( individualName ); --TruncateStringWithTooltip(instance.IndividualName, MAX_BEFORE_TRUNC_IND_NAME, individualName); end if kPerson.EraID ~= nil then local eraName:string = Locale.ToUpper(Locale.Lookup(GameInfo.Eras[kPerson.EraID].Name)); instance.EraName:SetText( eraName ); end -- Grab icon representing type of class if (kPerson.ClassID ~= nil) then local icon:string = "ICON_" .. classData.GreatPersonClassType; local textureOffsetX:number, textureOffsetY:number, textureSheet:string = IconManager:FindIconAtlas(icon, 90); if textureSheet == nil then -- Use default if none found print("WARNING: Could not find icon atlas entry for the class of Great Person '"..icon.."', using default instead."); textureOffsetX = 0; textureOffsetY = 0; textureSheet = "GreatPeopleClass90"; end instance.ClassImage:SetTexture( textureOffsetX, textureOffsetY, textureSheet ); end -- Grab icon of the great person themselves; first try a specific image, if it doesn't exist -- then grab a generic representation based on the class. if (kPerson.ClassID ~= nil) and (kPerson.IndividualID ~= nil) then local portrait:string = "ICON_" .. individualData.GreatPersonIndividualType; textureOffsetX, textureOffsetY, textureSheet = IconManager:FindIconAtlas(portrait, 160); if textureSheet == nil then -- Use a default if none found print("WARNING: Could not find icon atlas entry for the individual Great Person '"..portrait.."', using default instead."); portrait = "ICON_GENERIC_" .. classData.GreatPersonClassType .. "_" .. individualData.Gender; portrait = portrait:gsub("_CLASS","_INDIVIDUAL"); end local isValid = instance.Portrait:SetIcon(portrait); if (not isValid) then UI.DataError("Could not find icon for "..portrait); end end if instance["m_EffectsIM"] ~= nil then instance["m_EffectsIM"]:ResetInstances(); else instance["m_EffectsIM"] = InstanceManager:new("EffectInstance", "Top", instance.EffectStack); end if kPerson.PassiveNameText ~= nil and kPerson.PassiveNameText ~= "" then local effectInst:table = instance["m_EffectsIM"]:GetInstance(); local effectText:string = kPerson.PassiveEffectText; local fullText:string = kPerson.PassiveNameText .. "[NEWLINE][NEWLINE]" .. effectText; effectInst.Text:SetText( effectText ); effectInst.EffectTypeIcon:SetToolTipString( fullText ); effectInst.PassiveAbilityIcon:SetHide(false); effectInst.ActiveAbilityIcon:SetHide(true); end if (kPerson.ActionNameText ~= nil and kPerson.ActionNameText ~= "") then local effectInst:table = instance["m_EffectsIM"]:GetInstance(); local effectText:string = kPerson.ActionEffectText; local fullText:string = kPerson.ActionNameText; if (kPerson.ActionCharges > 0) then fullText = fullText .. " (" .. Locale.Lookup("LOC_GREATPERSON_ACTION_CHARGES", kPerson.ActionCharges) .. ")"; end fullText = fullText .. "[NEWLINE]" .. kPerson.ActionUsageText; fullText = fullText .. "[NEWLINE][NEWLINE]" .. effectText; effectInst.Text:SetText( effectText ); effectInst.EffectTypeIcon:SetToolTipString( fullText ); local actionIcon:string = classData.ActionIcon; if actionIcon ~= nil and actionIcon ~= "" then local textureOffsetX:number, textureOffsetY:number, textureSheet:string = IconManager:FindIconAtlas(actionIcon, SIZE_ACTION_ICON); if(textureSheet == nil or textureSheet == "") then UI.DataError("Could not find icon in ViewCurrent: icon=\""..actionIcon.."\", iconSize="..tostring(SIZE_ACTION_ICON) ); else effectInst.ActiveAbilityIcon:SetTexture(textureOffsetX, textureOffsetY, textureSheet); effectInst.ActiveAbilityIcon:SetHide(false); effectInst.PassiveAbilityIcon:SetHide(true); end else effectInst.ActiveAbilityIcon:SetHide(true); end end if instance["m_RecruitIM"] ~= nil then instance["m_RecruitIM"]:ResetInstances(); else instance["m_RecruitIM"] = InstanceManager:new("RecruitInstance", "Top", instance.RecruitStack); end if kPerson.IndividualID ~= nil and kPerson.ClassID ~= nil then -- Buy via gold if (HasCapability("CAPABILITY_GREAT_PEOPLE_RECRUIT_WITH_GOLD") and (not kPerson.CanRecruit and not kPerson.CanReject and kPerson.PatronizeWithGoldCost ~= nil and kPerson.PatronizeWithGoldCost < 1000000)) then local patronizeButtonText :string = kPerson.PatronizeWithGoldCost.."[ICON_Gold]"; local patronizeDetailsText:string = Locale.Lookup("LOC_GREAT_PEOPLE_PATRONAGE_GOLD_DETAILS", kPerson.PatronizeWithGoldCost); instance.GoldButton:SetText(patronizeButtonText); instance.GoldButton:SetToolTipString(patronizeDetailsText); instance.GoldButton:SetVoid1(kPerson.IndividualID); instance.GoldButton:RegisterCallback(Mouse.eLClick, OnGoldButtonClick); instance.GoldButton:SetDisabled(not kPerson.CanPatronizeWithGold); instance.GoldButton:SetHide(false); else instance.GoldButton:SetHide(true); end -- Buy via Faith if (HasCapability("CAPABILITY_GREAT_PEOPLE_RECRUIT_WITH_FAITH") and (not kPerson.CanRecruit and not kPerson.CanReject and kPerson.PatronizeWithFaithCost ~= nil and kPerson.PatronizeWithFaithCost < 1000000)) then local patronizeButtonText :string = kPerson.PatronizeWithFaithCost.."[ICON_Faith]"; local patronizeDetailsText :string = Locale.Lookup("LOC_GREAT_PEOPLE_PATRONAGE_FAITH_DETAILS", kPerson.PatronizeWithFaithCost); instance.FaithButton:SetText(patronizeButtonText); instance.FaithButton:SetToolTipString(patronizeDetailsText); instance.FaithButton:SetVoid1(kPerson.IndividualID); instance.FaithButton:RegisterCallback(Mouse.eLClick, OnFaithButtonClick); instance.FaithButton:SetDisabled(not kPerson.CanPatronizeWithFaith); instance.FaithButton:SetHide(false); else instance.FaithButton:SetHide(true); end -- Recruiting if (HasCapability("CAPABILITY_GREAT_PEOPLE_CAN_RECRUIT") and kPerson.CanRecruit and kPerson.RecruitCost ~= nil) then instance.RecruitButton:SetToolTipString( Locale.Lookup("LOC_GREAT_PEOPLE_RECRUIT_DETAILS", kPerson.RecruitCost) ); instance.RecruitButton:SetVoid1(kPerson.IndividualID); instance.RecruitButton:RegisterCallback(Mouse.eLClick, OnRecruitButtonClick); instance.RecruitButton:SetHide(false); -- Auto scroll to first recruitable person. if kInstanceToShow==nil then kInstanceToShow = instance; end else instance.RecruitButton:SetHide(true); end -- Rejecting if (HasCapability("CAPABILITY_GREAT_PEOPLE_CAN_REJECT") and kPerson.CanReject and kPerson.RejectCost ~= nil) then instance.RejectButton:SetToolTipString( Locale.Lookup("LOC_GREAT_PEOPLE_PASS_DETAILS", kPerson.RejectCost ) ); instance.RejectButton:SetVoid1(kPerson.IndividualID); instance.RejectButton:RegisterCallback(Mouse.eLClick, OnRejectButtonClick); instance.RejectButton:SetHide(false); else instance.RejectButton:SetHide(true); end -- Recruiting standings -- Let's sort the table first by points total, then by the lower player id (to push yours toward the top of the list for readability) local recruitTable: table = {}; for i, kPlayerPoints in ipairs(data.PointsByClass[kPerson.ClassID]) do table.insert(recruitTable,kPlayerPoints); end table.sort(recruitTable, function (a,b) if(a.PointsTotal == b.PointsTotal) then return a.PlayerID < b.PlayerID; else return a.PointsTotal > b.PointsTotal; end end); for i, kPlayerPoints in ipairs(recruitTable) do local canEarnAnotherOfThisClass:boolean = true; if (kPlayerPoints.MaxPlayerInstances ~= nil and kPlayerPoints.NumInstancesEarned ~= nil) then canEarnAnotherOfThisClass = kPlayerPoints.MaxPlayerInstances > kPlayerPoints.NumInstancesEarned; end if (canEarnAnotherOfThisClass) then local recruitInst:table = instance["m_RecruitIM"]:GetInstance(); recruitInst.Country:SetText( kPlayerPoints.PlayerName ); --recruitInst.Amount:SetText( tostring(Round(kPlayerPoints.PointsTotal,1)) .. "/" .. tostring(kPerson.RecruitCost) ); -- CQUI Points Per Turn and Turns Left -- Add the turn icon into the text --recruitTurnsLeft gets +0.5 so that's rounded up local recruitTurnsLeft = Round((kPerson.RecruitCost-kPlayerPoints.PointsTotal)/kPlayerPoints.PointsPerTurn + 0.5,0); if(recruitTurnsLeft == math.huge) then recruitTurnsLeft = "∞"; end recruitInst.CQUI_PerTurn:SetText( "(+" .. tostring(Round(kPlayerPoints.PointsPerTurn,1)) .. ") " .. tostring(recruitTurnsLeft) .. "[ICON_Turn]"); local progressPercent :number = Clamp( kPlayerPoints.PointsTotal / kPerson.RecruitCost, 0, 1 ); recruitInst.ProgressBar:SetPercent( progressPercent ); local recruitColorName:string = "GreatPeopleCS"; if kPlayerPoints.IsPlayer then recruitColorName = "GreatPeopleActiveCS"; end --recruitInst.Amount:SetColorByName( recruitColorName ); recruitInst.CQUI_PerTurn:SetColorByName( recruitColorName ); recruitInst.Country:SetColorByName( recruitColorName ); --recruitInst.Country:SetColorByName( recruitColorName ); recruitInst.ProgressBar:SetColorByName( recruitColorName ); local recruitDetails:string = Locale.Lookup("LOC_CQUI_GREAT_PERSON_PROGRESS") .. tostring(Round(kPlayerPoints.PointsTotal,1)) .. "/" .. tostring(kPerson.RecruitCost) .. "[NEWLINE]" .. Locale.Lookup("LOC_GREAT_PEOPLE_POINT_DETAILS", Round(kPlayerPoints.PointsPerTurn, 1), classData.IconString, classData.Name); DifferentiateCiv(kPlayerPoints.PlayerID,recruitInst.CivIcon,recruitInst.CivIcon,recruitInst.CivBacking, nil, nil, Game.GetLocalPlayer()); recruitInst.Top:SetToolTipString(recruitDetails); end end local sRecruitText:string = Locale.Lookup("LOC_GREAT_PEOPLE_OR_RECRUIT_WITH_PATRONAGE"); local sRecruitTooltip:string = ""; if (kPerson.EarnConditions ~= nil and kPerson.EarnConditions ~= "") then sRecruitText = "[COLOR_Civ6Red]" .. Locale.Lookup("LOC_GREAT_PEOPLE_CANNOT_EARN_PERSON") .. "[ENDCOLOR]" sRecruitTooltip = "[COLOR_Civ6Red]" .. kPerson.EarnConditions .. "[ENDCOLOR]"; end instance.RecruitInfo:SetText(sRecruitText); instance.RecruitInfo:SetToolTipString(sRecruitTooltip); instance.RecruitScroll:CalculateSize(); end -- Set the biography button. if kPerson.IndividualID ~= nil then instance.BiographyBackButton:SetText( Locale.Lookup("LOC_GREAT_PEOPLE_BIOGRAPHY") ); instance.BiographyBackButton:SetVoid1( kPerson.IndividualID ); instance.BiographyBackButton:RegisterCallback( Mouse.eLClick, OnBiographyBackClick ); m_uiGreatPeople[kPerson.IndividualID] = instance; -- Store instance for later look up end local noneAvailable :boolean = (kPerson.ClassID == nil); --instance.ClassName:SetHide( noneAvailable ); instance.TitleLine:SetHide( noneAvailable ); instance.IndividualName:SetHide( noneAvailable ); instance.EraName:SetHide( noneAvailable ); instance.MainInfo:SetHide( noneAvailable ); instance.BiographyBackButton:SetHide( noneAvailable ); instance.ClaimedLabel:SetHide( not noneAvailable ); instance.BiographyArea:SetHide( true ); instance.EffectStack:CalculateSize(); instance.EffectStackScroller:CalculateSize(); end Controls.PeopleStack:CalculateSize(); Controls.PeopleScroller:CalculateSize(); m_screenWidth = math.max(Controls.PeopleStack:GetSizeX(), 1024); Controls.WoodPaneling:SetSizeX( m_screenWidth ); -- Clamp overall popup size to not be larger than contents (overspills in 4k and eyefinitiy rigs.) local screenX,_ :number = UIManager:GetScreenSizeVal(); if m_screenWidth > screenX then m_screenWidth = screenX; end Controls.PopupContainer:SetSizeX( m_screenWidth ); Controls.ModalFrame:SetSizeX( m_screenWidth ); -- Has an instance been set to auto scroll to? Controls.PeopleScroller:SetScrollValue( 0 ); -- Either way reset scroll first (mostly for hot seat) if kInstanceToShow ~= nil then local contentWidth :number = kInstanceToShow.Content:GetSizeX(); local contentOffsetx :number = kInstanceToShow.Content:GetScreenOffset(); -- Obtaining normal offset would yield 0, but since modal is as wide as the window, this works. local offsetx :number = contentOffsetx + (contentWidth * 0.5) + (m_screenWidth * 0.5); -- Middle of screen local totalWidth :number = Controls.PeopleScroller:GetSizeX(); local scrollAmt :number = offsetx / totalWidth; scrollAmt = math.clamp( scrollAmt, 0, 1); Controls.PeopleScroller:SetScrollValue( scrollAmt ); end end -- ======================================================================================= -- Layout the data for previously recruited great people. -- ======================================================================================= function ViewPast( data:table ) if (data == nil) then UI.DataError("GreatPeople attempting to view past timeline data but received NIL instead."); return; end m_greatPersonRowIM:ResetInstances(); Controls.PeopleScroller:SetHide(true); Controls.RecruitedArea:SetHide(false); local firstAvailableIndex :number = 0; local localPlayerID :number = Game.GetLocalPlayer(); local PADDING_FOR_SPACE_AROUND_TEXT :number = 20; for i, kPerson:table in ipairs(data.Timeline) do local instance :table = m_greatPersonRowIM:GetInstance(); local classData :table = GameInfo.GreatPersonClasses[kPerson.ClassID]; if m_defaultPastRowHeight < 0 then m_defaultPastRowHeight = instance.Content:GetSizeY(); end local rowHeight :number = m_defaultPastRowHeight; local date :string = Calendar.MakeYearStr( kPerson.TurnGranted); instance.EarnDate:SetText( date ); local classText :string = ""; if kPerson.ClassID ~= nil then classText = Locale.Lookup(classData.Name); else UI.DataError("GreatPeople previous recruited as unable to find the class text for #"..tostring(i)); end instance.ClassName:SetText( Locale.ToUpper(classText) ); instance.GreatPersonInfo:SetText( kPerson.Name ); DifferentiateCiv(kPerson.ClaimantID, instance.CivIcon, instance.CivIcon, instance.CivIndicator, nil, nil, localPlayerID); instance.RecruitedImage:SetHide(true); instance.YouIndicator:SetHide(true); if (kPerson.ClaimantID ~= nil) then local playerConfig :table = PlayerConfigurations[kPerson.ClaimantID]; --:GetCivilizationShortDescription(); if (playerConfig ~= nil) then local iconName :string = "ICON_"..playerConfig:GetLeaderTypeName(); local localPlayer :table = Players[localPlayerID]; if(localPlayer ~= nil and localPlayerID == kPerson.ClaimantID) then instance.RecruitedImage:SetIcon(iconName, 55); instance.RecruitedImage:SetToolTipString( Locale.Lookup("LOC_GREAT_PEOPLE_RECRUITED_BY_YOU")); instance.RecruitedImage:SetHide(false); instance.YouIndicator:SetHide(false); elseif (localPlayer ~= nil and localPlayer:GetDiplomacy() ~= nil and localPlayer:GetDiplomacy():HasMet(kPerson.ClaimantID)) then instance.RecruitedImage:SetIcon(iconName, 55); instance.RecruitedImage:SetToolTipString( Locale.Lookup(playerConfig:GetPlayerName()) ); instance.RecruitedImage:SetHide(false); instance.YouIndicator:SetHide(true); else instance.RecruitedImage:SetIcon("ICON_CIVILIZATION_UNKNOWN", 55); instance.RecruitedImage:SetToolTipString( Locale.Lookup("LOC_GREAT_PEOPLE_RECRUITED_BY_UNKNOWN")); instance.RecruitedImage:SetHide(false); instance.YouIndicator:SetHide(true); end end end local isLocalPlayer:boolean = (kPerson.ClaimantID ~= nil and kPerson.ClaimantID == localPlayerID); instance.YouIndicator:SetHide( not isLocalPlayer ); local colorName:string = (isLocalPlayer and "GreatPeopleRow") or "GreatPeopleRowUnOwned"; instance.Content:SetColorByName( colorName ); -- Ability Effects colorName = (isLocalPlayer and "GreatPeoplePastCS") or "GreatPeoplePastUnownedCS"; if instance["m_EffectsIM"] ~= nil then instance["m_EffectsIM"]:ResetInstances(); else instance["m_EffectsIM"] = InstanceManager:new("PastEffectInstance", "Top", instance.EffectStack); end if kPerson.PassiveNameText ~= nil and kPerson.PassiveNameText ~= "" then local effectInst:table = instance["m_EffectsIM"]:GetInstance(); local effectText:string = kPerson.PassiveEffectText; local fullText:string = kPerson.PassiveNameText .. "[NEWLINE][NEWLINE]" .. effectText; effectInst.Text:SetText( effectText ); effectInst.EffectTypeIcon:SetToolTipString( fullText ); effectInst.Text:SetColorByName(colorName); rowHeight = math.max( rowHeight, effectInst.Text:GetSizeY() + PADDING_FOR_SPACE_AROUND_TEXT ); effectInst.PassiveAbilityIcon:SetHide(false); effectInst.ActiveAbilityIcon:SetHide(true); end if (kPerson.ActionNameText ~= nil and kPerson.ActionNameText ~= "") then local effectInst:table = instance["m_EffectsIM"]:GetInstance(); local effectText:string = kPerson.ActionEffectText; local fullText:string = kPerson.ActionNameText; if (kPerson.ActionCharges > 0) then fullText = fullText .. " (" .. Locale.Lookup("LOC_GREATPERSON_ACTION_CHARGES", kPerson.ActionCharges) .. ")"; end fullText = fullText .. "[NEWLINE]" .. kPerson.ActionUsageText; fullText = fullText .. "[NEWLINE][NEWLINE]" .. effectText; effectInst.Text:SetText( effectText ); effectInst.EffectTypeIcon:SetToolTipString( fullText ); effectInst.Text:SetColorByName(colorName); rowHeight = math.max( rowHeight, effectInst.Text:GetSizeY() + PADDING_FOR_SPACE_AROUND_TEXT ); local actionIcon:string = classData.ActionIcon; if actionIcon ~= nil and actionIcon ~= "" then local textureOffsetX:number, textureOffsetY:number, textureSheet:string = IconManager:FindIconAtlas(actionIcon, SIZE_ACTION_ICON); if(textureSheet == nil or textureSheet == "") then error("Could not find icon in ViewCurrent: icon=\""..actionIcon.."\", iconSize="..tostring(SIZE_ACTION_ICON) ); else effectInst.ActiveAbilityIcon:SetTexture(textureOffsetX, textureOffsetY, textureSheet); effectInst.ActiveAbilityIcon:SetHide(false); effectInst.PassiveAbilityIcon:SetHide(true); end else effectInst.ActiveAbilityIcon:SetHide(true); end end instance.Content:SetSizeY( rowHeight ); end -- Scaling to screen width required for the previously recruited tab Controls.PopupContainer:SetSizeX( m_screenWidth ); Controls.ModalFrame:SetSizeX( m_screenWidth ); Controls.RecruitedStack:CalculateSize(); Controls.RecruitedScroller:CalculateSize(); end -- ======================================================================================= -- Button Callback -- Switch between biography and stats for a great person -- ======================================================================================= function OnBiographyBackClick( individualID ) -- If a biography is open, close it via recursive magic... if m_activeBiographyID ~= -1 and individualID ~= m_activeBiographyID then OnBiographyBackClick( m_activeBiographyID ); end local instance:table= m_uiGreatPeople[individualID]; if instance == nil then print("WARNING: Was unable to find instance for individual \""..tostring(individualID).."\""); return; end local isShowingBiography :boolean = not instance.BiographyArea:IsHidden(); local buttonLabelText :string; instance.BiographyArea:SetHide( isShowingBiography ); instance.MainInfo:SetHide( not isShowingBiography ); instance.BiographyActiveBG:SetHide( isShowingBiography ); if isShowingBiography then m_activeBiographyID = -1; buttonLabelText = Locale.Lookup("LOC_GREAT_PEOPLE_BIOGRAPHY"); -- Current showing; so hide... else m_activeBiographyID = individualID; -- Current hidden, show biography... buttonLabelText = Locale.Lookup("LOC_GREAT_PEOPLE_BACK"); -- Get data local kBiographyText:table; for k,v in pairs(m_kData.Timeline) do if v.IndividualID == individualID then kBiographyText = v.BiographyTextTable; break; end end if kBiographyText ~= nil then instance.BiographyText:SetText( table.concat(kBiographyText, "[NEWLINE][NEWLINE]")); else instance.BiographyText:SetText(""); print("WARNING: Couldn't find data for \""..tostring(individualID).."\""); end instance.BiographyScroll:CalculateSize(); end instance.BiographyBackButton:SetText( buttonLabelText ); end -- ======================================================================================= -- Populate a data table with timeline information. -- data An allocated table to receive the timeline. -- isPast If the data should be from the past (instead of the current) -- ======================================================================================= function PopulateData( data:table, isPast:boolean ) if data == nil then error("GreatPeoplePopup received an empty data in to PopulateData"); return; end local localPlayerID :number = Game.GetLocalPlayer(); local pGreatPeople :table = Game.GetGreatPeople(); if pGreatPeople == nil then UI.DataError("GreatPeoplePopup received NIL great people object."); return; end local pTimeline:table = nil; if isPast then pTimeline = pGreatPeople:GetPastTimeline(); else pTimeline = pGreatPeople:GetTimeline(); end for i,entry in ipairs(pTimeline) do local claimantName :string = nil; if (entry.Claimant ~= nil) then claimantName = Locale.Lookup(PlayerConfigurations[entry.Claimant]:GetCivilizationShortDescription()); end local canRecruit :boolean = false; local canReject :boolean = false; local canPatronizeWithFaith :boolean = false; local canPatronizeWithGold :boolean = false; local actionCharges :number = 0; local patronizeWithGoldCost :number = nil; local patronizeWithFaithCost:number = nil; local recruitCost :number = entry.Cost; local rejectCost :number = nil; local earnConditions :string = nil; if (entry.Individual ~= nil) then if (Players[localPlayerID] ~= nil) then canRecruit = pGreatPeople:CanRecruitPerson(localPlayerID, entry.Individual); if (not isPast) then canReject = pGreatPeople:CanRejectPerson(localPlayerID, entry.Individual); if (canReject) then rejectCost = pGreatPeople:GetRejectCost(localPlayerID, entry.Individual); end end canPatronizeWithGold = pGreatPeople:CanPatronizePerson(localPlayerID, entry.Individual, YieldTypes.GOLD); patronizeWithGoldCost = pGreatPeople:GetPatronizeCost(localPlayerID, entry.Individual, YieldTypes.GOLD); canPatronizeWithFaith = pGreatPeople:CanPatronizePerson(localPlayerID, entry.Individual, YieldTypes.FAITH); patronizeWithFaithCost = pGreatPeople:GetPatronizeCost(localPlayerID, entry.Individual, YieldTypes.FAITH); earnConditions = pGreatPeople:GetEarnConditionsText(localPlayerID, entry.Individual); end local individualInfo = GameInfo.GreatPersonIndividuals[entry.Individual]; actionCharges = individualInfo.ActionCharges; end local color = COLOR_UNAVAILABLE; if (entry.Class ~= nil) then if (canRecruit or canReject) then color = COLOR_CLAIMED; else color = COLOR_AVAILABLE; end end local personName:string = ""; if GameInfo.GreatPersonIndividuals[entry.Individual] ~= nil then personName = Locale.Lookup(GameInfo.GreatPersonIndividuals[entry.Individual].Name); end local kPerson:table = { IndividualID = entry.Individual, ClassID = entry.Class, EraID = entry.Era, ClaimantID = entry.Claimant, ActionCharges = actionCharges, ActionNameText = entry.ActionNameText, ActionUsageText = entry.ActionUsageText, ActionEffectText = entry.ActionEffectText, BiographyTextTable = GetBiographyTextTable( entry.Individual ), CanPatronizeWithFaith = canPatronizeWithFaith, CanPatronizeWithGold = canPatronizeWithGold, CanReject = canReject, ClaimantName = claimantName, Color = color, CanRecruit = canRecruit, EarnConditions = earnConditions, Name = personName, PassiveNameText = entry.PassiveNameText, PassiveEffectText = entry.PassiveEffectText, PatronizeWithFaithCost = patronizeWithFaithCost, PatronizeWithGoldCost = patronizeWithGoldCost, RecruitCost = recruitCost, RejectCost = rejectCost, TurnGranted = entry.TurnGranted }; table.insert(data.Timeline, kPerson); end for classInfo in GameInfo.GreatPersonClasses() do local classID = classInfo.Index; local pointsTable = {}; local players = Game.GetPlayers{Major = true, Alive = true}; for i, player in ipairs(players) do local playerName = ""; local isPlayer:boolean = false; if (player:GetID() == localPlayerID) then playerName = playerName .. Locale.Lookup(PlayerConfigurations[player:GetID()]:GetCivilizationShortDescription()); isPlayer = true; elseif (Players[localPlayerID]:GetDiplomacy():HasMet(player:GetID())) then playerName = playerName .. Locale.Lookup(PlayerConfigurations[player:GetID()]:GetCivilizationShortDescription()); else playerName = playerName .. Locale.Lookup("LOC_DIPLOPANEL_UNMET_PLAYER"); end local playerPoints = { IsPlayer = isPlayer, MaxPlayerInstances = classInfo.MaxPlayerInstances, NumInstancesEarned = pGreatPeople:CountPeopleReceivedByPlayer(classID, player:GetID()); PlayerName = playerName, PointsTotal = player:GetGreatPeoplePoints():GetPointsTotal(classID), PointsPerTurn = player:GetGreatPeoplePoints():GetPointsPerTurn(classID), PlayerID = player:GetID() }; table.insert(pointsTable, playerPoints); end table.sort(pointsTable, function(a, b) if (a.IsPlayer and not b.IsPlayer) then return true; elseif (not a.IsPlayer and b.IsPlayer) then return false; end return a.PointsTotal > b.PointsTotal; end); data.PointsByClass[classID] = pointsTable; end end -- ======================================================================================= function Open() if (Game.GetLocalPlayer() == -1) then return end ContextPtr:SetHide(false); Refresh(); UI.PlaySound("UI_Screen_Open"); -- From Civ6_styles: FullScreenVignetteConsumer Controls.ScreenAnimIn:SetToBeginning(); Controls.ScreenAnimIn:Play(); LuaEvents.GreatPeople_OpenGreatPeople(); end -- ======================================================================================= function Close() ContextPtr:SetHide(true); UI.PlaySound("UI_Screen_Close"); LuaEvents.GreatPeople_CloseGreatPeople(); end -- ======================================================================================= -- UI Handler -- ======================================================================================= function OnClose() Close(); end -- ======================================================================================= -- LUA Event -- ======================================================================================= function OnOpenViaNotification() Open(); end -- ======================================================================================= -- LUA Event -- ======================================================================================= function OnOpenViaLaunchBar() Open(); end -- =========================================================================== function OnRecruitButtonClick( individualID:number ) local pLocalPlayer = Players[Game.GetLocalPlayer()]; if (pLocalPlayer ~= nil) then local kParameters:table = {}; kParameters[PlayerOperations.PARAM_GREAT_PERSON_INDIVIDUAL_TYPE] = individualID; UI.RequestPlayerOperation(Game.GetLocalPlayer(), PlayerOperations.RECRUIT_GREAT_PERSON, kParameters); Close(); end end -- =========================================================================== function OnRejectButtonClick( individualID:number ) local pLocalPlayer = Players[Game.GetLocalPlayer()]; if (pLocalPlayer ~= nil) then local kParameters:table = {}; kParameters[PlayerOperations.PARAM_GREAT_PERSON_INDIVIDUAL_TYPE] = individualID; UI.RequestPlayerOperation(Game.GetLocalPlayer(), PlayerOperations.REJECT_GREAT_PERSON, kParameters); Close(); end end -- =========================================================================== function OnGoldButtonClick( individualID:number ) local pLocalPlayer = Players[Game.GetLocalPlayer()]; if (pLocalPlayer ~= nil) then local kParameters:table = {}; kParameters[PlayerOperations.PARAM_GREAT_PERSON_INDIVIDUAL_TYPE] = individualID; kParameters[PlayerOperations.PARAM_YIELD_TYPE] = YieldTypes.GOLD; UI.RequestPlayerOperation(Game.GetLocalPlayer(), PlayerOperations.PATRONIZE_GREAT_PERSON, kParameters); Close(); end end -- =========================================================================== function OnFaithButtonClick( individualID:number ) local pLocalPlayer = Players[Game.GetLocalPlayer()]; if (pLocalPlayer ~= nil) then local kParameters:table = {}; kParameters[PlayerOperations.PARAM_GREAT_PERSON_INDIVIDUAL_TYPE] = individualID; kParameters[PlayerOperations.PARAM_YIELD_TYPE] = YieldTypes.FAITH; UI.RequestPlayerOperation(Game.GetLocalPlayer(), PlayerOperations.PATRONIZE_GREAT_PERSON, kParameters); Close(); end end -- =========================================================================== -- Game Engine Event -- =========================================================================== function OnLocalPlayerChanged( playerID:number , prevLocalPlayerID:number ) if playerID == -1 then return; end m_tabs.SelectTab( Controls.ButtonGreatPeople ); end -- =========================================================================== -- Game Engine Event -- =========================================================================== function OnLocalPlayerTurnBegin() if (not ContextPtr:IsHidden()) then Refresh(); end end -- =========================================================================== -- Game Engine Event -- =========================================================================== function OnLocalPlayerTurnEnd() if (not ContextPtr:IsHidden()) and GameConfiguration.IsHotseat() then Close(); end end -- =========================================================================== -- Game Engine Event -- =========================================================================== function OnUnitGreatPersonActivated( unitOwner:number, unitID:number, greatPersonClassID:number, greatPersonIndividualID:number ) if (unitOwner == Game.GetLocalPlayer()) then local player = Players[unitOwner]; if (player ~= nil) then local unit = player:GetUnits():FindID(unitID); if (unit ~= nil) then local message = GetActivationEffectTextByGreatPersonClass(greatPersonClassID); UI.AddWorldViewText(EventSubTypes.PLOT, message, unit:GetX(), unit:GetY(), 0); UI.PlaySound("Claim_Great_Person"); end end end end -- =========================================================================== -- Game Engine Event -- =========================================================================== function OnGreatPeoplePointsChanged( playerID:number ) -- Update for any player's change, so that the local player can see up to date information about other players' points if (not ContextPtr:IsHidden()) then Refresh(); end end -- =========================================================================== -- -- =========================================================================== function Refresh() local kData :table = { Timeline = {}, PointsByClass = {}, }; if m_tabs.selectedControl == Controls.ButtonPreviouslyRecruited then PopulateData(kData, true); -- use past data ViewPast(kData); else PopulateData(kData, false); -- do not use past data ViewCurrent(kData); end m_kData = kData; end -- =========================================================================== -- Tab callback -- =========================================================================== function OnGreatPeopleClick() Controls.ButtonGreatPeople:SetSelected( true ); Controls.ButtonPreviouslyRecruited:SetSelected( false ); Refresh(); end -- =========================================================================== -- Tab callback -- =========================================================================== function OnPreviousRecruitedClick() Controls.ButtonGreatPeople:SetSelected( false ); Controls.ButtonPreviouslyRecruited:SetSelected( true ); Refresh(); end -- ======================================================================================= -- UI Event -- ======================================================================================= function OnInit( isHotload:boolean ) if isHotload then LuaEvents.GameDebug_GetValues(RELOAD_CACHE_ID); end end -- ======================================================================================= -- UI Event -- Input -- ======================================================================================= -- =========================================================================== function KeyHandler( key:number ) if key == Keys.VK_ESCAPE then Close(); return true; end return false; end function OnInputHandler( pInputStruct:table ) local uiMsg = pInputStruct:GetMessageType(); if (uiMsg == KeyEvents.KeyUp) then return KeyHandler( pInputStruct:GetKey() ); end; return false; end -- ======================================================================================= -- UI Event -- ======================================================================================= function OnShutdown() LuaEvents.GameDebug_AddValue(RELOAD_CACHE_ID, "isHidden", ContextPtr:IsHidden() ); LuaEvents.GameDebug_AddValue(RELOAD_CACHE_ID, "isPreviousTab", (m_tabs.selectedControl == Controls.ButtonPreviouslyRecruited) ); end -- =========================================================================== -- LUA Event -- Set cached values back after a hotload. -- =========================================================================== function OnGameDebugReturn( context:string, contextTable:table ) if context ~= RELOAD_CACHE_ID then return; end local isHidden:boolean = contextTable["isHidden"]; if not isHidden then local isPreviouslyRecruited:boolean = contextTable["isPreviousTab"]; -- Open(); if isPreviouslyRecruited then m_tabs.SelectTab( Controls.ButtonPreviouslyRecruited ); else m_tabs.SelectTab( Controls.ButtonGreatPeople ); end end end -- =========================================================================== -- Input Hotkey Event -- =========================================================================== function OnInputActionTriggered( actionId ) if actionId == m_ToggleGreatPeopleId then if UI.QueryGlobalParameterInt("DISABLE_GREAT_PEOPLE_HOTKEY") ~= 1 then UI.PlaySound("Play_UI_Click"); if(ContextPtr:IsHidden()) then LuaEvents.LaunchBar_OpenGreatPeoplePopup(); else OnClose(); end end end end -- ======================================================================================= -- -- ======================================================================================= function Initialize() if (not HasCapability("CAPABILITY_GREAT_PEOPLE_VIEW")) then -- Great People Viewing is off, just exit return; end -- Tab setup and setting of default tab. m_tabs = CreateTabs( Controls.TabContainer, 42, 34, 0xFF331D05 ); m_tabs.AddTab( Controls.ButtonGreatPeople, OnGreatPeopleClick ); m_tabs.AddTab( Controls.ButtonPreviouslyRecruited, OnPreviousRecruitedClick ); m_tabs.CenterAlignTabs(-10); if Game.GetLocalPlayer() ~= -1 then m_tabs.SelectTab( Controls.ButtonGreatPeople ); end -- UI Events ContextPtr:SetInitHandler( OnInit ); ContextPtr:SetInputHandler( OnInputHandler, true ); ContextPtr:SetShutdown( OnShutdown ); -- UI Controls -- We use a separate BG within the PeopleScroller control since it needs to scroll with the contents Controls.ModalBG:SetHide(true); Controls.ModalScreenClose:RegisterCallback(Mouse.eLClick, OnClose); Controls.ModalScreenTitle:SetText(Locale.ToUpper(Locale.Lookup("LOC_GREAT_PEOPLE_TITLE"))); -- Game engine Events Events.LocalPlayerChanged.Add( OnLocalPlayerChanged ); Events.LocalPlayerTurnBegin.Add( OnLocalPlayerTurnBegin ); Events.LocalPlayerTurnEnd.Add( OnLocalPlayerTurnEnd ); Events.UnitGreatPersonActivated.Add( OnUnitGreatPersonActivated ); Events.GreatPeoplePointsChanged.Add( OnGreatPeoplePointsChanged ); -- LUA Events LuaEvents.GameDebug_Return.Add( OnGameDebugReturn ); LuaEvents.LaunchBar_OpenGreatPeoplePopup.Add( OnOpenViaLaunchBar ); LuaEvents.NotificationPanel_OpenGreatPeoplePopup.Add( OnOpenViaNotification ); LuaEvents.LaunchBar_CloseGreatPeoplePopup.Add(OnClose); -- Audio Events Controls.ButtonGreatPeople:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); Controls.ButtonPreviouslyRecruited:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); -- Hot Key Handling m_ToggleGreatPeopleId = Input.GetActionId("ToggleGreatPeople"); if m_ToggleGreatPeopleId ~= nil then Events.InputActionTriggered.Add( OnInputActionTriggered ); end end Initialize();
mit
zevv/lgi
samples/gtk-demo/demo-assistant.lua
6
2215
return function(parent, dir) local lgi = require 'lgi' local GLib = lgi.GLib local Gtk = lgi.Gtk local assistant = Gtk.Assistant { default_height = 300, { title = "Page 1", type = 'INTRO', Gtk.Grid { id = 'page1', orientation = 'HORIZONTAL', Gtk.Label { label = "You must fill out this entry to continue:" }, Gtk.Entry { vexpand = true, id = 'entry', activates_default = true, }, }, }, { title = "Page 2", complete = true, Gtk.Grid { orientation = 'VERTICAL', Gtk.CheckButton { label = "This is optional data, you may continue " .. "even if you do not check this" } }, }, { title = "Confirmation", type = 'CONFIRM', complete = true, Gtk.Label { label = "This is a confirmation page, press 'Apply' " .. "to apply changes" }, }, { title = "Applying changes", type = 'PROGRESS', Gtk.ProgressBar { id = 'progressbar', halign = 'CENTER', valign = 'CENTER' }, }, } function assistant.child.entry:on_changed() assistant.property.page1.complete = (self.text ~= '') end function assistant:on_cancel() self:destroy() end function assistant:on_close() self:destroy() end function assistant:on_prepare() self.title = ("Sample assistant (%d of %d)"):format( self:get_current_page() + 1, self:get_n_pages()) if self:get_current_page() == 3 then -- The changes are permanent and cannot be revisited. assistant:commit() end end local progressbar = assistant.child.progressbar function assistant:on_apply() GLib.timeout_add(GLib.PRIORITY_DEFAULT, 100, function() -- Simulate work. local fraction = progressbar.fraction + 0.05 if fraction < 1 then progressbar.fraction = fraction return true else assistant:destroy() return false end end) end assistant.child.page1:show_all() --assistant:set_screen(parent:get_screen()) assistant:show_all() return assistant end, "Assistant", table.concat { "Demonstrates a sample multi-step assistant.\n", "Assistants are used to divide an operation into several simpler ", "sequential steps, and to guide the user through these steps." }
mit
Colettechan/darkstar
scripts/zones/Northern_San_dOria/npcs/Arlenne.lua
13
2152
----------------------------------- -- Area: Northern San d'Oria -- NPC: Arlenne -- Standard Merchant NPC ----------------------------------- package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/shop"); require("scripts/globals/quests"); require("scripts/zones/Northern_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- "Flyers for Regine" conditional script FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE); if (FlyerForRegine == 1) then count = trade:getItemCount(); MagicFlyer = trade:hasItemQty(532,1); if (MagicFlyer == true and count == 1) then player:messageSpecial(FLYER_REFUSED); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc,ARLENNE_SHOP_DIALOG); stock = {17051,1409,1, --Yew Wand 17090,3245,1, --Elm Staff 17097,16416,1, --Elm Pole 16835,15876,1, --Spear 16845,16578,1, --Lance 16770,11286,1, --Zaghnal 17050,333,2, --Willow Wand 17089,571,2, --Holly Staff 17096,4568,2, --Holly Pole 16834,4680,2, --Brass Spear 16769,2542,2, --Brass Zaghnal 17049,46,3, --Maple Wand 17088,57,3, --Ash Staff 16833,792,3, --Bronze Spear 16768,309,3} --Bronze Zaghnal showNationShop(player, SANDORIA, stock); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
Vadavim/jsr-darkstar
scripts/zones/Maze_of_Shakhrami/Zone.lua
4
2071
----------------------------------- -- -- Zone: Maze_of_Shakhrami (198) -- ----------------------------------- package.loaded["scripts/zones/Maze_of_Shakhrami/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/zone"); require("scripts/zones/Maze_of_Shakhrami/TextIDs"); require("scripts/zones/Maze_of_Shakhrami/MobIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) local tomes = {17588784,17588785,17588786,17588787}; SetGroundsTome(tomes); local vwnpc = {17588778,17588779,17588780}; SetVoidwatchNPC(vwnpc); UpdateTreasureSpawnPoint(17588769); local whichNM = math.random(0,19); if (whichNM < 10) then SetRespawnTime(Argus, 900, 43200); -- 0-12 hours else SetRespawnTime(Leech_King, 900, 43200); -- 0-12 hours end end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) local cs = -1; if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then player:setPos(-140.246,-12.738,160.709,63); end return cs; end; ----------------------------------- -- onConquestUpdate ----------------------------------- function onConquestUpdate(zone, updatetype) local players = zone:getPlayers(); for name, player in pairs(players) do conquestUpdate(zone, player, updatetype, CONQUEST_BASE); end end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
lcf8858/Sample_Lua
frameworks/cocos2d-x/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua
38
2802
ccui = ccui or {} ccui.BrightStyle = { none = -1, normal = 0, highlight = 1, } ccui.TextureResType = { localType = 0, plistType = 1, } ccui.TouchEventType = { began = 0, moved = 1, ended = 2, canceled = 3, } ccui.SizeType = { absolute = 0, percent = 1, } ccui.PositionType = { absolute = 0, percent = 1, } ccui.CheckBoxEventType = { selected = 0, unselected = 1, } ccui.TextFiledEventType = { attach_with_ime = 0, detach_with_ime = 1, insert_text = 2, delete_backward = 3, } ccui.LayoutBackGroundColorType = { none = 0, solid = 1, gradient = 2, } ccui.LayoutType = { ABSOLUTE = 0, VERTICAL = 1, HORIZONTAL = 2, RELATIVE = 3, } ccui.LayoutParameterType = { none = 0, linear = 1, relative = 2, } ccui.LinearGravity = { none = 0, left = 1, top = 2, right = 3, bottom = 4, centerVertical = 5, centerHorizontal = 6, } ccui.RelativeAlign = { alignNone = 0, alignParentTopLeft = 1, alignParentTopCenterHorizontal = 2, alignParentTopRight = 3, alignParentLeftCenterVertical = 4, centerInParent = 5, alignParentRightCenterVertical = 6, alignParentLeftBottom = 7, alignParentBottomCenterHorizontal = 8, alignParentRightBottom = 9, locationAboveLeftAlign = 10, locationAboveCenter = 11, locationAboveRightAlign = 12, locationLeftOfTopAlign = 13, locationLeftOfCenter = 14, locationLeftOfBottomAlign = 15, locationRightOfTopAlign = 16, locationRightOfCenter = 17, locationRightOfBottomAlign = 18, locationBelowLeftAlign = 19, locationBelowCenter = 20, locationBelowRightAlign = 21, } ccui.SliderEventType = {percentChanged = 0} ccui.LoadingBarDirection = { LEFT = 0, RIGHT = 1} ccui.ScrollViewDir = { none = 0, vertical = 1, horizontal = 2, both = 3, } ccui.ScrollViewMoveDir = { none = 0, up = 1, down = 2, left = 3, right = 4, } ccui.ScrollviewEventType = { scrollToTop = 0, scrollToBottom = 1, scrollToLeft = 2, scrollToRight = 3, scrolling = 4, bounceTop = 5, bounceBottom = 6, bounceLeft = 7, bounceRight = 8, } ccui.ListViewDirection = { none = 0, vertical = 1, horizontal = 2, } ccui.ListViewMoveDirection = { none = 0, up = 1, down = 2, left = 3, right = 4, } ccui.ListViewEventType = { ONSELECTEDITEM_START = 0, ONSELECTEDITEM_END = 1, } ccui.PageViewEventType = { turning = 0, } ccui.PVTouchDir = { touchLeft = 0, touchRight = 1, } ccui.ListViewGravity = { left = 0, right = 1, centerHorizontal = 2, top = 3, bottom = 4 , centerVertical = 5, } ccui.TextType = { SYSTEM = 0, TTF = 1, }
mit
mlosch/nn
MM.lua
46
2695
--[[ Module to perform matrix multiplication on two minibatch inputs, producing a minibatch. ]] local MM, parent = torch.class('nn.MM', 'nn.Module') --[[ The constructor takes two optional arguments, specifying whether or not transpose any of the input matrices before perfoming the multiplication. ]] function MM:__init(transA, transB) parent.__init(self) self.transA = transA or false self.transB = transB or false self.gradInput = {torch.Tensor(), torch.Tensor()} end function MM:updateOutput(input) assert(#input == 2, 'input must be a pair of minibatch matrices') local a, b = table.unpack(input) assert(a:nDimension() == 2 or a:nDimension() == 3, 'input tensors must be 2D or 3D') if a:nDimension() == 2 then assert(b:nDimension() == 2, 'second input tensor must be 2D') if self.transA then a = a:t() end if self.transB then b = b:t() end assert(a:size(2) == b:size(1), 'matrix sizes do not match') self.output:resize(a:size(1), b:size(2)) self.output:mm(a, b) else assert(b:nDimension() == 3, 'second input tensor must be 3D') assert(a:size(1) == b:size(1), 'inputs must contain the same number of minibatches') if self.transA then a = a:transpose(2, 3) end if self.transB then b = b:transpose(2, 3) end assert(a:size(3) == b:size(2), 'matrix sizes do not match') self.output:resize(a:size(1), a:size(2), b:size(3)) self.output:bmm(a, b) end return self.output end function MM:updateGradInput(input, gradOutput) assert(#input == 2, 'input must be a pair of tensors') local a, b = table.unpack(input) self.gradInput[1]:resizeAs(a) self.gradInput[2]:resizeAs(b) assert(gradOutput:nDimension() == 2 or gradOutput:nDimension() == 3, 'arguments must be a 2D or 3D Tensor') local h_dim, w_dim, f if gradOutput:nDimension() == 2 then assert(a:nDimension() == 2, 'first input tensor must be 2D') assert(b:nDimension() == 2, 'second input tensor must be 2D') h_dim, w_dim = 1, 2 f = "mm" else assert(a:nDimension() == 3, 'first input tensor must be 3D') assert(b:nDimension() == 3, 'second input tensor must be 3D') h_dim, w_dim = 2, 3 f = "bmm" end if self.transA == self.transB then a = a:transpose(h_dim, w_dim) b = b:transpose(h_dim, w_dim) end if self.transA then self.gradInput[1][f](self.gradInput[1], b, gradOutput:transpose(h_dim, w_dim)) else self.gradInput[1][f](self.gradInput[1], gradOutput, b) end if self.transB then self.gradInput[2][f](self.gradInput[2], gradOutput:transpose(h_dim, w_dim), a) else self.gradInput[2][f](self.gradInput[2], a, gradOutput) end return self.gradInput end
bsd-3-clause
Colettechan/darkstar
scripts/zones/Labyrinth_of_Onzozo/npcs/qm2.lua
13
1588
----------------------------------- -- Area: Labyrinth of Onzozo -- NPC: ??? (qm2) -- Involved in Quest: Yomi Okuri -- @pos -176 10 -60 213 ----------------------------------- package.loaded["scripts/zones/Labyrinth_of_Onzozo/TextIDs"] = nil; ----------------------------------- require("scripts/globals/keyitems"); require("scripts/zones/Labyrinth_of_Onzozo/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:hasKeyItem(WASHUS_TASTY_WURST) and player:hasKeyItem(YOMOTSU_FEATHER) == false) then if (player:getVar("yomiOkuriKilledNM") >= 1) then player:delKeyItem(WASHUS_TASTY_WURST); player:addKeyItem(YOMOTSU_FEATHER); player:messageSpecial(KEYITEM_OBTAINED,YOMOTSU_FEATHER); player:setVar("yomiOkuriKilledNM",0); else SpawnMob(17649860,300):updateClaim(player); -- Ubume end else player:messageSpecial(NOTHING_OUT_OF_ORDINARY); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
Vadavim/jsr-darkstar
scripts/globals/spells/poisonga_ii.lua
1
1286
----------------------------------------- -- Spell: Poisonga II ----------------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) local effect = EFFECT_POISON; local duration = 180; local pINT = caster:getStat(MOD_INT); local mINT = target:getStat(MOD_INT); local dINT = (pINT - mINT); local power = caster:getSkillLevel(ENFEEBLING_MAGIC_SKILL) / 15 + 5; if power > 18 then power = 18; end local params = {}; params.bonusmab = 0; params.includemab = true; power = addBonusesAbility(caster, ELE_WATER, target, power, params, 1.0); local resist = applyResistanceEffect(caster,spell,target,dINT + 30,ENFEEBLING_MAGIC_SKILL,0,effect); if (resist == 1 or resist == 0.5) then -- effect taken duration = duration * resist; if (target:addStatusEffect(effect,power,3,duration)) then spell:setMsg(236); else spell:setMsg(75); end else -- resist entirely. spell:setMsg(85); end return effect; end;
gpl-3.0
zynjec/darkstar
scripts/commands/addmission.lua
11
1673
--------------------------------------------------------------------------------------------------- -- func: addmission <logID> <missionID> <player> -- desc: Adds a mission to the GM or target players log. --------------------------------------------------------------------------------------------------- require("scripts/globals/missions"); cmdprops = { permission = 1, parameters = "sss" }; function error(player, msg) player:PrintToPlayer(msg); player:PrintToPlayer("!addmission <logID> <missionID> {player}"); end; function onTrigger(player, logId, missionId, target) -- validate logId local logName; local logInfo = GetMissionLogInfo(logId); if (logInfo == nil) then error(player, "Invalid logID."); return; end logName = logInfo.full_name; logId = logInfo.mission_log; -- validate missionId local areaMissionIds = dsp.mission.id[dsp.mission.area[logId]] if (missionId ~= nil) then missionId = tonumber(missionId) or areaMissionIds[string.upper(missionId)] or _G[string.upper(missionId)]; end if (missionId == nil or missionId < 0) then error(player, "Invalid missionID."); return; end -- validate target local targ; if (target == nil) then targ = player; else targ = GetPlayerByName(target); if (targ == nil) then error(player, string.format("Player named '%s' not found!", target)); return; end end -- add mission targ:addMission(logId, missionId); player:PrintToPlayer(string.format("Added %s mission %i to %s.", logName, missionId, targ:getName())); end;
gpl-3.0
zynjec/darkstar
scripts/globals/spells/earth_carol.lua
10
1548
----------------------------------------- -- Spell: Earth Carol -- Increases earth resistance for party members within the area of effect. ----------------------------------------- require("scripts/globals/status") require("scripts/globals/magic") require("scripts/globals/msg") ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0 end function onSpellCast(caster,target,spell) local sLvl = caster:getSkillLevel(dsp.skill.SINGING) -- Gets skill level of Singing local iLvl = caster:getWeaponSkillLevel(dsp.slot.RANGED) local power = 20 if (sLvl+iLvl > 200) then power = power + math.floor((sLvl+iLvl-200) / 10) end if (power >= 80) then power = 80 end local iBoost = caster:getMod(dsp.mod.CAROL_EFFECT) + caster:getMod(dsp.mod.ALL_SONGS_EFFECT) power = power + iBoost*8 if (caster:hasStatusEffect(dsp.effect.SOUL_VOICE)) then power = power * 2 elseif (caster:hasStatusEffect(dsp.effect.MARCATO)) then power = power * 1.5 end caster:delStatusEffect(dsp.effect.MARCATO) local duration = 120 duration = duration * ((iBoost * 0.1) + (caster:getMod(dsp.mod.SONG_DURATION_BONUS)/100) + 1) if (caster:hasStatusEffect(dsp.effect.TROUBADOUR)) then duration = duration * 2 end if not (target:addBardSong(caster,dsp.effect.CAROL,power,0,duration,caster:getID(), dsp.magic.ele.EARTH, 1)) then spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT) end return dsp.effect.CAROL end
gpl-3.0
fraxken/Craftstudio-united
class/sound3D.lua
1
5275
-- > On vérifie que la metatable United est existante if United ~= nil then United["Sound3D"] = {} United["Sound3D"].Core = function() local Sound3D = United.Sound3D -- > Metamethode Sound3D.__index = Sound3D ------------------------------------------------------------------------------------- -- [ FUNCTION SOUND3D ] -- ------------------------------------------------------------------------------------- function Sound3D:New( asset, object, max, min, maxsound, loop, listener, static ) local mt = setmetatable( { gameObject = object, Instance = nil, max = max or 100, min = min or 3, maxsound = maxsound or 1, loop = loop or false, pos = nil, listener = nil, static = nil or true } , self ) local Craft = CS local sound = Craft.FindAsset( asset, "Sound" ) if sound == nil then print("Sound : "..asset.."doesn't exist !") return nil elseif listener == nil then print("Error : listener doesn't exist !") return nil else mt.listener = listener mt.pos = mt.gameObject.transform:GetPosition() mt.Instance = sound:CreateInstance() mt.Instance:Play() mt.Instance:SetLoop(mt.loop) return mt end end function Sound3D:Check() local V3 = Vector3 local ma = math local listenerPos = self.listener.transform:GetPosition() local distance = V3.Distance( listenerPos, self.pos ) -- Si l'objet d'écoute est dans le rayon du son alors if distance < self.max and distance > 0 then if distance < self.min then self.Instance:SetVolume(self.maxsound) else local factor = ( ( self.max - ( distance - self.min ) ) / self.max ) * self.maxsound self.Instance:SetVolume(factor) end -- On ajuste la balance des écouteurs local listenerPos = self.listener.transform:GetPosition() local listenerOrient = ma.rad(self.listener.transform:GetEulerAngles().y) local listenerDirection = V3:New( ma.sin( listenerOrient ), 0, ma.cos( listenerOrient ) ) local NormListennerDir = listenerDirection:Normalized() local SoundDirFromListener = listenerPos - self.pos SoundDirFromListener.y = 0 -- Produit scalaire : formule pour avoir un angle avec 2 vecteurs : cos(angle) = (O->A * O->B) / (OA * OB) et le resultat sera toujours positif entre 0 et 180 -- O->A * O->B = Vector3.Dot(A,B) -- Dot = produit scalaire -- OA = Vector3:Length() local DotProduct = V3.Dot(NormListennerDir , SoundDirFromListener) local LenghtProd = NormListennerDir:Length() * SoundDirFromListener:Length() local resulAngle = ma.deg(ma.acos(DotProduct / LenghtProd)) local pan = nil if resulAngle > 90 then pan = (90 - (resulAngle % 90)) / 100 else pan = resulAngle / 100 end -- On utilise la formule du déterminent d'une matrice 2*2 (X,Z) pour savoir si le son est à notre droite ou à notre gauche en fonction de notre orientation -- deter de la matrice 2x2 M : |a b| -- a b = 1er vecteur 2D -- c d = 2em vecteur 2D -- |c d| = a*d - b*c -- le vecteur ab sera représenté sous forme d'une droite et le vecteur cd sous forme d'un point donc -- vue que le vecteur ad est notre direction d'orientation et le vecteur cd notre point qui représente l'emplacement du son -- nous allons pouvoir savoir si le son est a droite ou a gauche de la droite local vec1 = listenerDirection local vec2 = SoundDirFromListener local determinent = vec1.x * vec2.z - vec1.z * vec2.x -- si le résultat est positif alors le point est à gauche de la droite -- si le résultat est négatif alors le point est à droite de la droite -- si le résultat est nul alors le point est sur la droite if determinent >= 0 then self.Instance:SetPan(pan) else self.Instance:SetPan(-pan) end else self.Instance:SetVolume(0) end if not self.static then self:Move() end end function Sound3D:Move() self.pos = self.gameObject.transform:GetPosition() end ------------------------------------------------------------------------------------- -- [ END FUNCTION SOUND3D ] -- ------------------------------------------------------------------------------------- United["Sound3D"].Core = nil end end
gpl-3.0
actboy168/MoeHero
scripts/maps/hero/阿尔托莉亚/风王结界.lua
1
2015
local mt = ac.skill['风王结界'] mt{ --初始等级 level = 0, --技能图标 art = [[BTNsaberq.blp]], --技能说明 title = '风王结界', tip = [[ 激活风王结界,提高%pene%点护甲穿透并持续对%slow_area%范围造成减速效果,持续%buff_time%秒 再次按下该技能解放风王结界,对%stun_area%范围造成%stun_time%秒晕眩,下次攻击额外造成%damage%(+%damage_plus%)点伤害 ]], --冷却 cool = {17, 14}, --耗蓝 cost = 100, --护甲穿透 pene = {5, 25}, --减速范围 slow_area = 500, --移速降低(%) slow_rate = {5, 25}, --持续时间 buff_time = 6, --晕眩范围 stun_area = 500, --晕眩时间 stun_time = 1, --额外伤害 damage = {70, 270}, --额外伤害加成 damage_plus = function(self, hero) return hero:get_ad() * 1.6 end, --解放Buff持续时间 attack_buff_time = 3, } function mt:on_cast_channel() local hero = self.owner hero:add_buff '风王结界-激活' { pene = self.pene, slow_area = self.slow_area, slow_rate = self.slow_rate, time = self.buff_time, } end local mt = ac.buff['风王结界-激活'] mt.pulse = 0.5 mt.pene = 0 mt.eff = nil function mt:on_add() local hero = self.target hero:add('破甲', self.pene) hero:replace_skill('风王结界', '风王结界-解放') self.eff = hero:add_effect('origin',[[modeldekan\ability\DEKAN_Saber_Q_WindBuff2.mdl]]) end function mt:on_remove() local hero = self.target hero:add('破甲', - self.pene) self.eff:remove() hero:replace_skill('风王结界-解放', '风王结界') end function mt:on_pulse() local hero = self.target local move_speed_rate = self.slow_rate local time = self.pulse + 0.1 for _, u in ac.selector() : in_range(hero, self.slow_area) : is_enemy(hero) : ipairs() do u:add_buff '减速' { source = hero, move_speed_rate = move_speed_rate, time = time, model = [[Abilities\Spells\Other\Tornado\Tornado_Target.mdl]], } end end function mt:on_cover() return true end
gpl-3.0
zynjec/darkstar
scripts/zones/Tavnazian_Safehold/npcs/Yurim.lua
9
6304
----------------------------------- -- Area: Tavnazian Safehold -- NPC: Yurim -- !pos 83.697 -25.000 3.250 26 ----------------------------------- require("scripts/globals/missions") require("scripts/globals/npc_util") require("scripts/globals/quests") ----------------------------------- -- base items local earring = 13327 local obi = 13205 local gorget = 13080 -- chips local red = 474 local blue = 475 local yellow = 476 local green = 477 local clear = 478 local purple = 479 local white = 480 local black = 481 -- organs local lumin = 1783 local phuabo = 1784 local xzomit = 1785 local aern = 1786 local hpemde = 1787 local yovra = 1788 local euvhi = 1818 local nosTrades = { [14792] = {hint = 17, base = {earring, black}, organs = { {lumin,5}, {euvhi,5} }}, -- Relaxing Earring [14791] = {hint = 17, base = {earring, white}, organs = { {lumin,5}, {euvhi,5} }}, -- Sanative Earring [15435] = {hint = 1, base = {obi, red}, organs = { {phuabo,7}, {xzomit,3}, {lumin,3} }}, -- Karin Obi (Fire) [15438] = {hint = 4, base = {obi, yellow}, organs = { {hpemde,7}, {aern,3}, {lumin,3} }}, -- Dorin Obi (Earth) [15440] = {hint = 6, base = {obi, blue}, organs = { {hpemde,7}, {phuabo,3}, {lumin,3} }}, -- Suirin Obi (Water) [15437] = {hint = 3, base = {obi, green}, organs = { {aern,7}, {hpemde,3}, {lumin,3} }}, -- Furin Obi (Wind) [15436] = {hint = 2, base = {obi, clear}, organs = { {xzomit,7}, {phuabo,3}, {lumin,3} }}, -- Hyorin Obi (Ice) [15439] = {hint = 5, base = {obi, purple}, organs = { {phuabo,7}, {hpemde,3}, {lumin,3} }}, -- Rairin Obi (Thunder) [15441] = {hint = 7, base = {obi, white}, organs = { {xzomit,7}, {aern,3}, {lumin,3} }}, -- Korin Obi (Light) [15442] = {hint = 8, base = {obi, black}, organs = { {aern,7}, {xzomit,3}, {lumin,3} }}, -- Anrin Obi (Dark) [15495] = {hint = 9, base = {gorget, red}, organs = { {phuabo,10}, {xzomit,5}, {yovra,1} }}, -- Flame Gorget [15498] = {hint = 12, base = {gorget, yellow}, organs = { {xzomit,10}, {aern,5}, {yovra,1} }}, -- Soil Gorget [15500] = {hint = 14, base = {gorget, blue}, organs = { {aern,10}, {hpemde,5}, {yovra,1} }}, -- Aqua Gorget [15497] = {hint = 11, base = {gorget, green}, organs = { {phuabo,10}, {hpemde,5}, {yovra,1} }}, -- Breeze Gorget [15496] = {hint = 10, base = {gorget, clear}, organs = { {phuabo,10}, {aern,5}, {yovra,1} }}, -- Snow Gorget [15499] = {hint = 13, base = {gorget, purple}, organs = { {xzomit,10}, {hpemde,5}, {yovra,1} }}, -- Thunder Gorget [15501] = {hint = 15, base = {gorget, white}, organs = { {aern,7}, {phuabo,3}, {hpemde,3}, {yovra,2} }}, -- Light Gorget [15502] = {hint = 16, base = {gorget, black}, organs = { {hpemde,7}, {phuabo,3}, {aern,3}, {yovra,2} }}, -- Shadow Gorget } function onTrade(player,npc,trade) local nameOfScience = player:getQuestStatus(OTHER_AREAS_LOG,dsp.quest.id.otherAreas.IN_THE_NAME_OF_SCIENCE) local itemInProgress = player:getCharVar("NAME_OF_SCIENCE_target") if itemInProgress > 0 and npcUtil.tradeHas(trade, nosTrades[itemInProgress].organs) then player:setLocalVar("NAME_OF_SCIENCE_complete", itemInProgress) player:startEvent(529, gorget, earring, obi) elseif (nameOfScience == QUEST_ACCEPTED or nameOfScience == QUEST_COMPLETED) and npcUtil.tradeHas(trade, 4413) and itemInProgress > 0 then -- apple pie hint player:startEvent(531, 4413, 0, nosTrades[itemInProgress].hint) elseif (nameOfScience == QUEST_ACCEPTED or nameOfScience == QUEST_COMPLETED) and itemInProgress == 0 then for k, v in pairs(nosTrades) do if npcUtil.tradeHas(trade, v.base) then player:setCharVar("NAME_OF_SCIENCE_target", k) player:startEvent(526, unpack(v.base)) break end end end end function onTrigger(player,npc) -- IN THE NAME OF SCIENCE if player:hasCompletedMission(COP, dsp.mission.id.cop.THE_WARRIOR_S_PATH) then local nameOfScience = player:getQuestStatus(OTHER_AREAS_LOG,dsp.quest.id.otherAreas.IN_THE_NAME_OF_SCIENCE) local itemInProgress = player:getCharVar("NAME_OF_SCIENCE_target") if nameOfScience == QUEST_AVAILABLE then player:startEvent(524, obi, earring, gorget) elseif (nameOfScience == QUEST_ACCEPTED or nameOfScience == QUEST_COMPLETED) and itemInProgress == 0 then player:startEvent(525, obi, earring, gorget) elseif nameOfScience == QUEST_ACCEPTED or nameOfScience == QUEST_COMPLETED then if math.random(100) <= 30 then player:startEvent(532, unpack(nosTrades[itemInProgress].base)) else player:startEvent(528, unpack(nosTrades[itemInProgress].base)) end end -- STANDARD DIALOG else if math.random(100) <= 50 then player:startEvent(527) else player:startEvent(519) end end end function onEventUpdate(player,csid,option) end function onEventFinish(player,csid,option) if csid == 524 then player:addQuest(OTHER_AREAS_LOG, dsp.quest.id.otherAreas.IN_THE_NAME_OF_SCIENCE) elseif csid == 531 then player:confirmTrade() elseif csid == 526 then player:confirmTrade() elseif csid == 529 then local itemInProgress = player:getCharVar("NAME_OF_SCIENCE_target") local itemComplete = player:getLocalVar("NAME_OF_SCIENCE_complete") if itemComplete > 0 and itemInProgress == itemComplete then player:setLocalVar("NAME_OF_SCIENCE_complete", 0) if npcUtil.completeQuest(player, OTHER_AREAS_LOG, dsp.quest.id.otherAreas.IN_THE_NAME_OF_SCIENCE, {item=itemComplete, var={"NAME_OF_SCIENCE_target"}}) then player:confirmTrade() end else printf("%s reached end of 'In The Name of Science' in a suspicious manner. No item rewarded.", player:getName()) end end end
gpl-3.0
Colettechan/darkstar
scripts/zones/Al_Zahbi/npcs/Sujyahn.lua
13
1036
----------------------------------- -- Area: Al Zahbi -- NPC: Sujyahn -- Type: Standard NPC -- @zone: 48 -- @pos -48.213 -1 34.723 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Al_Zahbi/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x00f2); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
lcf8858/Sample_Lua
frameworks/cocos2d-x/cocos/scripting/lua-bindings/auto/api/ComController.lua
10
1153
-------------------------------- -- @module ComController -- @extend Component,InputDelegate -- @parent_module ccs -------------------------------- -- -- @function [parent=#ComController] create -- @param self -- @return ComController#ComController ret (return value: ccs.ComController) -------------------------------- -- -- @function [parent=#ComController] createInstance -- @param self -- @return Ref#Ref ret (return value: cc.Ref) -------------------------------- -- -- @function [parent=#ComController] setEnabled -- @param self -- @param #bool b -------------------------------- -- -- @function [parent=#ComController] isEnabled -- @param self -- @return bool#bool ret (return value: bool) -------------------------------- -- -- @function [parent=#ComController] update -- @param self -- @param #float delta -------------------------------- -- -- @function [parent=#ComController] init -- @param self -- @return bool#bool ret (return value: bool) -------------------------------- -- js ctor -- @function [parent=#ComController] ComController -- @param self return nil
mit
Vadavim/jsr-darkstar
scripts/zones/Bastok_Markets/npcs/Nbu_Latteh.lua
26
3365
----------------------------------- -- Area: Bastok Markets -- NPC: Nbu Latteh -- Starts & Finishes Quest: Mom, The Adventurer? -- Starts Quest: The Signpost Marks the Spot ----------------------------------- package.loaded["scripts/zones/Bastok_Markets/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/titles"); require("scripts/globals/quests"); require("scripts/zones/Bastok_Markets/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local pFame = player:getFameLevel(BASTOK); local MomTheAdventurer = player:getQuestStatus(BASTOK,MOM_THE_ADVENTURER) local questStatus = player:getVar("MomTheAdventurer_Event"); if (player:needToZone()) then player:startEvent(127); -- chat about my work elseif (pFame < 2 and MomTheAdventurer ~= QUEST_ACCEPTED and questStatus == 0) then player:startEvent(0x00e6); elseif (MomTheAdventurer >= QUEST_ACCEPTED and questStatus == 2) then if (player:seenKeyItem(LETTER_FROM_ROH_LATTEH)) then player:startEvent(0x00ea); elseif (player:hasKeyItem(LETTER_FROM_ROH_LATTEH)) then player:startEvent(0x00e9); end elseif (pFame >= 2 and player:getQuestStatus(BASTOK,THE_SIGNPOST_MARKS_THE_SPOT) == QUEST_AVAILABLE) then player:startEvent(0x00eb); else player:startEvent(0x007f); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x00e6 and option == 0) then if (player:getFreeSlotsCount(0) > 0) then player:addQuest(BASTOK,MOM_THE_ADVENTURER); player:setVar("MomTheAdventurer_Event",1); player:addItem(4096); player:messageSpecial(ITEM_OBTAINED,4096); -- Fire Crystal else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,4096); end elseif (csid == 0x00e9 or csid == 0x00ea) then if (player:seenKeyItem(LETTER_FROM_ROH_LATTEH)) then gilReward = 100; else gilReward = 200; end player:needToZone(true); player:delKeyItem(LETTER_FROM_ROH_LATTEH); player:addTitle(RINGBEARER); player:addGil(GIL_RATE*gilReward); player:messageSpecial(GIL_OBTAINED, GIL_RATE*gilReward); player:setVar("MomTheAdventurer_Event",0); if (player:getQuestStatus(BASTOK,MOM_THE_ADVENTURER) == QUEST_ACCEPTED) then player:addFame(BASTOK,50); player:completeQuest(BASTOK,MOM_THE_ADVENTURER); else player:addFame(BASTOK,8) end elseif (csid == 0x00eb and option == 0) then player:addQuest(BASTOK,THE_SIGNPOST_MARKS_THE_SPOT); player:setVar("MomTheAdventurer_Event",0); end end;
gpl-3.0
Colettechan/darkstar
scripts/zones/Bastok_Markets/npcs/Nbu_Latteh.lua
26
3365
----------------------------------- -- Area: Bastok Markets -- NPC: Nbu Latteh -- Starts & Finishes Quest: Mom, The Adventurer? -- Starts Quest: The Signpost Marks the Spot ----------------------------------- package.loaded["scripts/zones/Bastok_Markets/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/titles"); require("scripts/globals/quests"); require("scripts/zones/Bastok_Markets/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local pFame = player:getFameLevel(BASTOK); local MomTheAdventurer = player:getQuestStatus(BASTOK,MOM_THE_ADVENTURER) local questStatus = player:getVar("MomTheAdventurer_Event"); if (player:needToZone()) then player:startEvent(127); -- chat about my work elseif (pFame < 2 and MomTheAdventurer ~= QUEST_ACCEPTED and questStatus == 0) then player:startEvent(0x00e6); elseif (MomTheAdventurer >= QUEST_ACCEPTED and questStatus == 2) then if (player:seenKeyItem(LETTER_FROM_ROH_LATTEH)) then player:startEvent(0x00ea); elseif (player:hasKeyItem(LETTER_FROM_ROH_LATTEH)) then player:startEvent(0x00e9); end elseif (pFame >= 2 and player:getQuestStatus(BASTOK,THE_SIGNPOST_MARKS_THE_SPOT) == QUEST_AVAILABLE) then player:startEvent(0x00eb); else player:startEvent(0x007f); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x00e6 and option == 0) then if (player:getFreeSlotsCount(0) > 0) then player:addQuest(BASTOK,MOM_THE_ADVENTURER); player:setVar("MomTheAdventurer_Event",1); player:addItem(4096); player:messageSpecial(ITEM_OBTAINED,4096); -- Fire Crystal else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,4096); end elseif (csid == 0x00e9 or csid == 0x00ea) then if (player:seenKeyItem(LETTER_FROM_ROH_LATTEH)) then gilReward = 100; else gilReward = 200; end player:needToZone(true); player:delKeyItem(LETTER_FROM_ROH_LATTEH); player:addTitle(RINGBEARER); player:addGil(GIL_RATE*gilReward); player:messageSpecial(GIL_OBTAINED, GIL_RATE*gilReward); player:setVar("MomTheAdventurer_Event",0); if (player:getQuestStatus(BASTOK,MOM_THE_ADVENTURER) == QUEST_ACCEPTED) then player:addFame(BASTOK,50); player:completeQuest(BASTOK,MOM_THE_ADVENTURER); else player:addFame(BASTOK,8) end elseif (csid == 0x00eb and option == 0) then player:addQuest(BASTOK,THE_SIGNPOST_MARKS_THE_SPOT); player:setVar("MomTheAdventurer_Event",0); end end;
gpl-3.0
Vadavim/jsr-darkstar
scripts/zones/The_Garden_of_RuHmet/mobs/Jailer_of_Fortitude.lua
18
2647
----------------------------------- -- Area: The Garden of Ru'Hmet -- NM: Jailer of Fortitude ----------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) -- Give it two hour mob:setMobMod(MOBMOD_MAIN_2HOUR, 1); mob:setMobMod(MOBMOD_2HOUR_MULTI, 1); -- Change animation to humanoid w/ prismatic core mob:AnimationSub(1); mob:setModelId(1169); end; ----------------------------------- -- onMobFight Action ----------------------------------- function onMobFight(mob, target) local delay = mob:getLocalVar("delay"); local LastCast = mob:getLocalVar("LAST_CAST"); local spell = mob:getLocalVar("COPY_SPELL"); if (mob:getBattleTime() - LastCast > 30) then mob:setLocalVar("COPY_SPELL", 0); mob:setLocalVar("delay", 0); end; if (IsMobDead(16921016) == false or IsMobDead(16921017) == false) then -- check for kf'ghrah if (spell > 0 and mob:hasStatusEffect(EFFECT_SILENCE) == false) then if (delay >= 3) then mob:castSpell(spell); mob:setLocalVar("COPY_SPELL", 0); mob:setLocalVar("delay", 0); else mob:setLocalVar("delay", delay+1); end end end end; ----------------------------------- -- onMagicHit Action ----------------------------------- function onMagicHit(caster,target,spell) if (spell:tookEffect() and (caster:isPC() or caster:isPet()) and spell:getSpellGroup() ~= SPELLGROUP_BLUE ) then -- Handle mimicked spells target:setLocalVar("COPY_SPELL", spell:getID()); target:setLocalVar("LAST_CAST", target:getBattleTime()); target:setLocalVar("reflectTime", target:getBattleTime()); target:AnimationSub(1); end; return 1; end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob, player, isKiller) -- Despawn the pets if alive DespawnMob(Kf_Ghrah_WHM); DespawnMob(Kf_Ghrah_BLM); end; ----------------------------------- -- onMobDespawn ----------------------------------- function onMobDespawn(mob) -- Set 15 mins respawn local qm1 = GetNPCByID(Jailer_of_Fortitude_QM); qm1:updateNPCHideTime(FORCE_SPAWN_QM_RESET_TIME); -- Move it to a random location local qm1position = math.random(1,5); qm1:setPos(Jailer_of_Fortitude_QM_POS[qm1position][1], Jailer_of_Fortitude_QM_POS[qm1position][2], Jailer_of_Fortitude_QM_POS[qm1position][3]); end;
gpl-3.0
Colettechan/darkstar
scripts/globals/mobskills/Flame_Thrower.lua
18
1281
--------------------------------------------------- -- Flame_Thrower -- Description: -- Type: Magical -- additional effect : plague --------------------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/monstertpmoves"); --------------------------------------------------- function onMobSkillCheck(target,mob,skill) -- skillList 54 = Omega -- skillList 727 = Proto-Omega -- skillList 728 = Ultima -- skillList 729 = Proto-Ultima local skillList = mob:getMobMod(MOBMOD_SKILL_LIST); local mobhp = mob:getHPP(); local phase = mob:getLocalVar("battlePhase"); if ((skillList == 729 and phase >= 1 and phase <= 2) or (skillList == 728 and mobhp < 70 and mobhp >= 40)) then return 0; end return 1; end; function onMobWeaponSkill(target, mob, skill) local typeEffect = EFFECT_PLAGUE; MobPhysicalStatusEffectMove(mob, target, skill, typeEffect, 5, 3, 30); local dmgmod = 2; local info = MobMagicalMove(mob,target,skill,mob:getWeaponDmg()*3,ELE_FIRE,dmgmod,TP_MAB_BONUS,1); local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_MAGICAL,MOBPARAM_LIGHT,MOBPARAM_IGNORE_SHADOWS); target:delHP(dmg); return dmg; end;
gpl-3.0
Colettechan/darkstar
scripts/globals/spells/hailstorm.lua
32
1182
-------------------------------------- -- Spell: Hailstorm -- Changes the weather around target party member to "snowy." -------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) target:delStatusEffectSilent(EFFECT_FIRESTORM); target:delStatusEffectSilent(EFFECT_SANDSTORM); target:delStatusEffectSilent(EFFECT_RAINSTORM); target:delStatusEffectSilent(EFFECT_WINDSTORM); target:delStatusEffectSilent(EFFECT_HAILSTORM); target:delStatusEffectSilent(EFFECT_THUNDERSTORM); target:delStatusEffectSilent(EFFECT_AURORASTORM); target:delStatusEffectSilent(EFFECT_VOIDSTORM); local merit = caster:getMerit(MERIT_STORMSURGE); local power = 0; if merit > 0 then power = merit + caster:getMod(MOD_STORMSURGE_EFFECT) + 2; end target:addStatusEffect(EFFECT_HAILSTORM,power,0,180); return EFFECT_HAILSTORM; end;
gpl-3.0
Vadavim/jsr-darkstar
scripts/globals/items/dil.lua
18
1304
----------------------------------------- -- ID: 5457 -- Item: Dil -- Food Effect: 5Min, Mithra only ----------------------------------------- -- Dexterity 4 -- Mind -6 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) result = 0 if (target:getRace() ~= 7) then result = 247; end if (target:getMod(MOD_EAT_RAW_FISH) == 1) then result = 0; end if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,300,5457); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_DEX, 4); target:addMod(MOD_MND, -6); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_DEX, 4); target:delMod(MOD_MND, -6); end;
gpl-3.0
Colettechan/darkstar
scripts/zones/Castle_Oztroja/npcs/_47j.lua
13
1608
----------------------------------- -- Area: Castle Oztroja -- NPC: _47j (Torch Stand) -- Notes: Opens door _472 near password #1 -- @pos -62.533 -1.859 -30.634 151 ----------------------------------- package.loaded["scripts/zones/Castle_Oztroja/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Castle_Oztroja/TextIDs"); require("scripts/globals/settings"); ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local DoorID = npc:getID() - 4; local DoorA = GetNPCByID(DoorID):getAnimation(); local TorchStandA = npc:getAnimation(); local Torch2 = npc:getID(); local Torch1 = npc:getID() - 1; if (DoorA == 9 and TorchStandA == 9) then player:startEvent(0x000a); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) local Torch2 = GetNPCByID(17396169):getID(); local Torch1 = GetNPCByID(Torch2):getID() - 1; local DoorID = GetNPCByID(Torch2):getID() - 4; if (option == 1) then GetNPCByID(Torch1):openDoor(10); -- Torch Lighting GetNPCByID(Torch2):openDoor(10); -- Torch Lighting GetNPCByID(DoorID):openDoor(6); end end; --printf("CSID: %u",csid); --printf("RESULT: %u",option);
gpl-3.0
Colettechan/darkstar
scripts/zones/The_Sanctuary_of_ZiTah/npcs/qm2.lua
13
1918
----------------------------------- -- Area: The Sanctuary of ZiTah -- NPC: qm2 (???) -- Involved in Quest: Forge Your Destiny -- @pos 639 -1 -151 121 ----------------------------------- package.loaded["scripts/zones/The_Sanctuary_of_ZiTah/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/quests"); require("scripts/zones/The_Sanctuary_of_ZiTah/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if (player:getQuestStatus(OUTLANDS,FORGE_YOUR_DESTINY) == QUEST_ACCEPTED) then if (trade:hasItemQty(1021,1) and trade:getItemCount() == 1 and player:hasItem(1153) == false) then if (GetMobAction(17272838) == 0) then SpawnMob(17272838,288):updateClaim(player); -- Spawn Guardian Treant player:tradeComplete(); end elseif (player:getVar("ForgeYourDestiny_killed") == 1) then if (trade:hasItemQty(1198,1) and trade:getItemCount() == 1) then player:tradeComplete(); player:addItem(1153); player:messageSpecial(ITEM_OBTAINED, 1153); -- Sacred Branch player:setVar("ForgeYourDestiny_killed",0); end end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:messageSpecial(STURDY_BRANCH,1021); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
zynjec/darkstar
scripts/zones/Nashmau/npcs/Jajaroon.lua
12
1129
----------------------------------- -- Area: Nashmau -- NPC: Jajaroon -- Standard Merchant NPC ----------------------------------- local ID = require("scripts/zones/Nashmau/IDs") require("scripts/globals/shop") function onTrade(player,npc,trade) end function onTrigger(player,npc) local stock = { 2176, 48, -- Fire Card 2177, 48, -- Ice Card 2178, 48, -- Wind Card 2179, 48, -- Earth Card 2180, 48, -- Thunder Card 2181, 48, -- Water Card 2182, 48, -- Light Card 2183, 48, -- Dark Card 5870, 10000, -- Trump Card Case 5488, 35200, -- Samurai Die 5489, 600, -- Ninja Die 5490, 9216, -- Dragoon Die 5491, 40000, -- Summoner Die 5492, 3525, -- Blue Mage Die 5493, 316, -- Corsair Die 5494, 82500 -- Puppetmaster Die } player:showText(npc, ID.text.JAJAROON_SHOP_DIALOG) dsp.shop.general(player, stock) end function onEventUpdate(player,csid,option) end function onEventFinish(player,csid,option) end
gpl-3.0
davidcarlisle/luaotfload
src/fontloader/runtime/fontloader-tl2014.lua
1
420090
-- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua -- merge date : 07/29/14 00:30:11 do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['l-lua']={ version=1.001, comment="companion to luat-lib.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local major,minor=string.match(_VERSION,"^[^%d]+(%d+)%.(%d+).*$") _MAJORVERSION=tonumber(major) or 5 _MINORVERSION=tonumber(minor) or 1 _LUAVERSION=_MAJORVERSION+_MINORVERSION/10 if not lpeg then lpeg=require("lpeg") end if loadstring then local loadnormal=load function load(first,...) if type(first)=="string" then return loadstring(first,...) else return loadnormal(first,...) end end else loadstring=load end if not ipairs then local function iterate(a,i) i=i+1 local v=a[i] if v~=nil then return i,v end end function ipairs(a) return iterate,a,0 end end if not pairs then function pairs(t) return next,t end end if not table.unpack then table.unpack=_G.unpack elseif not unpack then _G.unpack=table.unpack end if not package.loaders then package.loaders=package.searchers end local print,select,tostring=print,select,tostring local inspectors={} function setinspector(inspector) inspectors[#inspectors+1]=inspector end function inspect(...) for s=1,select("#",...) do local value=select(s,...) local done=false for i=1,#inspectors do done=inspectors[i](value) if done then break end end if not done then print(tostring(value)) end end end local dummy=function() end function optionalrequire(...) local ok,result=xpcall(require,dummy,...) if ok then return result end end if lua then lua.mask=load([[τεχ = 1]]) and "utf" or "ascii" end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['l-lpeg']={ version=1.001, comment="companion to luat-lib.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } lpeg=require("lpeg") if not lpeg.print then function lpeg.print(...) print(lpeg.pcode(...)) end end local type,next,tostring=type,next,tostring local byte,char,gmatch,format=string.byte,string.char,string.gmatch,string.format local floor=math.floor local P,R,S,V,Ct,C,Cs,Cc,Cp,Cmt=lpeg.P,lpeg.R,lpeg.S,lpeg.V,lpeg.Ct,lpeg.C,lpeg.Cs,lpeg.Cc,lpeg.Cp,lpeg.Cmt local lpegtype,lpegmatch,lpegprint=lpeg.type,lpeg.match,lpeg.print if setinspector then setinspector(function(v) if lpegtype(v) then lpegprint(v) return true end end) end lpeg.patterns=lpeg.patterns or {} local patterns=lpeg.patterns local anything=P(1) local endofstring=P(-1) local alwaysmatched=P(true) patterns.anything=anything patterns.endofstring=endofstring patterns.beginofstring=alwaysmatched patterns.alwaysmatched=alwaysmatched local sign=S('+-') local zero=P('0') local digit=R('09') local octdigit=R("07") local lowercase=R("az") local uppercase=R("AZ") local underscore=P("_") local hexdigit=digit+lowercase+uppercase local cr,lf,crlf=P("\r"),P("\n"),P("\r\n") local newline=P("\r")*(P("\n")+P(true))+P("\n") local escaped=P("\\")*anything local squote=P("'") local dquote=P('"') local space=P(" ") local period=P(".") local comma=P(",") local utfbom_32_be=P('\000\000\254\255') local utfbom_32_le=P('\255\254\000\000') local utfbom_16_be=P('\254\255') local utfbom_16_le=P('\255\254') local utfbom_8=P('\239\187\191') local utfbom=utfbom_32_be+utfbom_32_le+utfbom_16_be+utfbom_16_le+utfbom_8 local utftype=utfbom_32_be*Cc("utf-32-be")+utfbom_32_le*Cc("utf-32-le")+utfbom_16_be*Cc("utf-16-be")+utfbom_16_le*Cc("utf-16-le")+utfbom_8*Cc("utf-8")+alwaysmatched*Cc("utf-8") local utfstricttype=utfbom_32_be*Cc("utf-32-be")+utfbom_32_le*Cc("utf-32-le")+utfbom_16_be*Cc("utf-16-be")+utfbom_16_le*Cc("utf-16-le")+utfbom_8*Cc("utf-8") local utfoffset=utfbom_32_be*Cc(4)+utfbom_32_le*Cc(4)+utfbom_16_be*Cc(2)+utfbom_16_le*Cc(2)+utfbom_8*Cc(3)+Cc(0) local utf8next=R("\128\191") patterns.utfbom_32_be=utfbom_32_be patterns.utfbom_32_le=utfbom_32_le patterns.utfbom_16_be=utfbom_16_be patterns.utfbom_16_le=utfbom_16_le patterns.utfbom_8=utfbom_8 patterns.utf_16_be_nl=P("\000\r\000\n")+P("\000\r")+P("\000\n") patterns.utf_16_le_nl=P("\r\000\n\000")+P("\r\000")+P("\n\000") patterns.utf8one=R("\000\127") patterns.utf8two=R("\194\223")*utf8next patterns.utf8three=R("\224\239")*utf8next*utf8next patterns.utf8four=R("\240\244")*utf8next*utf8next*utf8next patterns.utfbom=utfbom patterns.utftype=utftype patterns.utfstricttype=utfstricttype patterns.utfoffset=utfoffset local utf8char=patterns.utf8one+patterns.utf8two+patterns.utf8three+patterns.utf8four local validutf8char=utf8char^0*endofstring*Cc(true)+Cc(false) local utf8character=P(1)*R("\128\191")^0 patterns.utf8=utf8char patterns.utf8char=utf8char patterns.utf8character=utf8character patterns.validutf8=validutf8char patterns.validutf8char=validutf8char local eol=S("\n\r") local spacer=S(" \t\f\v") local whitespace=eol+spacer local nonspacer=1-spacer local nonwhitespace=1-whitespace patterns.eol=eol patterns.spacer=spacer patterns.whitespace=whitespace patterns.nonspacer=nonspacer patterns.nonwhitespace=nonwhitespace local stripper=spacer^0*C((spacer^0*nonspacer^1)^0) local fullstripper=whitespace^0*C((whitespace^0*nonwhitespace^1)^0) local collapser=Cs(spacer^0/""*nonspacer^0*((spacer^0/" "*nonspacer^1)^0)) patterns.stripper=stripper patterns.fullstripper=fullstripper patterns.collapser=collapser patterns.lowercase=lowercase patterns.uppercase=uppercase patterns.letter=patterns.lowercase+patterns.uppercase patterns.space=space patterns.tab=P("\t") patterns.spaceortab=patterns.space+patterns.tab patterns.newline=newline patterns.emptyline=newline^1 patterns.equal=P("=") patterns.comma=comma patterns.commaspacer=comma*spacer^0 patterns.period=period patterns.colon=P(":") patterns.semicolon=P(";") patterns.underscore=underscore patterns.escaped=escaped patterns.squote=squote patterns.dquote=dquote patterns.nosquote=(escaped+(1-squote))^0 patterns.nodquote=(escaped+(1-dquote))^0 patterns.unsingle=(squote/"")*patterns.nosquote*(squote/"") patterns.undouble=(dquote/"")*patterns.nodquote*(dquote/"") patterns.unquoted=patterns.undouble+patterns.unsingle patterns.unspacer=((patterns.spacer^1)/"")^0 patterns.singlequoted=squote*patterns.nosquote*squote patterns.doublequoted=dquote*patterns.nodquote*dquote patterns.quoted=patterns.doublequoted+patterns.singlequoted patterns.digit=digit patterns.octdigit=octdigit patterns.hexdigit=hexdigit patterns.sign=sign patterns.cardinal=digit^1 patterns.integer=sign^-1*digit^1 patterns.unsigned=digit^0*period*digit^1 patterns.float=sign^-1*patterns.unsigned patterns.cunsigned=digit^0*comma*digit^1 patterns.cpunsigned=digit^0*(period+comma)*digit^1 patterns.cfloat=sign^-1*patterns.cunsigned patterns.cpfloat=sign^-1*patterns.cpunsigned patterns.number=patterns.float+patterns.integer patterns.cnumber=patterns.cfloat+patterns.integer patterns.cpnumber=patterns.cpfloat+patterns.integer patterns.oct=zero*octdigit^1 patterns.octal=patterns.oct patterns.HEX=zero*P("X")*(digit+uppercase)^1 patterns.hex=zero*P("x")*(digit+lowercase)^1 patterns.hexadecimal=zero*S("xX")*hexdigit^1 patterns.hexafloat=sign^-1*zero*S("xX")*(hexdigit^0*period*hexdigit^1+hexdigit^1*period*hexdigit^0+hexdigit^1)*(S("pP")*sign^-1*hexdigit^1)^-1 patterns.decafloat=sign^-1*(digit^0*period*digit^1+digit^1*period*digit^0+digit^1)*S("eE")*sign^-1*digit^1 patterns.propername=(uppercase+lowercase+underscore)*(uppercase+lowercase+underscore+digit)^0*endofstring patterns.somecontent=(anything-newline-space)^1 patterns.beginline=#(1-newline) patterns.longtostring=Cs(whitespace^0/""*((patterns.quoted+nonwhitespace^1+whitespace^1/""*(P(-1)+Cc(" ")))^0)) local function anywhere(pattern) return P { P(pattern)+1*V(1) } end lpeg.anywhere=anywhere function lpeg.instringchecker(p) p=anywhere(p) return function(str) return lpegmatch(p,str) and true or false end end function lpeg.splitter(pattern,action) return (((1-P(pattern))^1)/action+1)^0 end function lpeg.tsplitter(pattern,action) return Ct((((1-P(pattern))^1)/action+1)^0) end local splitters_s,splitters_m,splitters_t={},{},{} local function splitat(separator,single) local splitter=(single and splitters_s[separator]) or splitters_m[separator] if not splitter then separator=P(separator) local other=C((1-separator)^0) if single then local any=anything splitter=other*(separator*C(any^0)+"") splitters_s[separator]=splitter else splitter=other*(separator*other)^0 splitters_m[separator]=splitter end end return splitter end local function tsplitat(separator) local splitter=splitters_t[separator] if not splitter then splitter=Ct(splitat(separator)) splitters_t[separator]=splitter end return splitter end lpeg.splitat=splitat lpeg.tsplitat=tsplitat function string.splitup(str,separator) if not separator then separator="," end return lpegmatch(splitters_m[separator] or splitat(separator),str) end local cache={} function lpeg.split(separator,str) local c=cache[separator] if not c then c=tsplitat(separator) cache[separator]=c end return lpegmatch(c,str) end function string.split(str,separator) if separator then local c=cache[separator] if not c then c=tsplitat(separator) cache[separator]=c end return lpegmatch(c,str) else return { str } end end local spacing=patterns.spacer^0*newline local empty=spacing*Cc("") local nonempty=Cs((1-spacing)^1)*spacing^-1 local content=(empty+nonempty)^1 patterns.textline=content local linesplitter=tsplitat(newline) patterns.linesplitter=linesplitter function string.splitlines(str) return lpegmatch(linesplitter,str) end local cache={} function lpeg.checkedsplit(separator,str) local c=cache[separator] if not c then separator=P(separator) local other=C((1-separator)^1) c=Ct(separator^0*other*(separator^1*other)^0) cache[separator]=c end return lpegmatch(c,str) end function string.checkedsplit(str,separator) local c=cache[separator] if not c then separator=P(separator) local other=C((1-separator)^1) c=Ct(separator^0*other*(separator^1*other)^0) cache[separator]=c end return lpegmatch(c,str) end local function f2(s) local c1,c2=byte(s,1,2) return c1*64+c2-12416 end local function f3(s) local c1,c2,c3=byte(s,1,3) return (c1*64+c2)*64+c3-925824 end local function f4(s) local c1,c2,c3,c4=byte(s,1,4) return ((c1*64+c2)*64+c3)*64+c4-63447168 end local utf8byte=patterns.utf8one/byte+patterns.utf8two/f2+patterns.utf8three/f3+patterns.utf8four/f4 patterns.utf8byte=utf8byte local cache={} function lpeg.stripper(str) if type(str)=="string" then local s=cache[str] if not s then s=Cs(((S(str)^1)/""+1)^0) cache[str]=s end return s else return Cs(((str^1)/""+1)^0) end end local cache={} function lpeg.keeper(str) if type(str)=="string" then local s=cache[str] if not s then s=Cs((((1-S(str))^1)/""+1)^0) cache[str]=s end return s else return Cs((((1-str)^1)/""+1)^0) end end function lpeg.frontstripper(str) return (P(str)+P(true))*Cs(anything^0) end function lpeg.endstripper(str) return Cs((1-P(str)*endofstring)^0) end function lpeg.replacer(one,two,makefunction,isutf) local pattern local u=isutf and utf8char or 1 if type(one)=="table" then local no=#one local p=P(false) if no==0 then for k,v in next,one do p=p+P(k)/v end pattern=Cs((p+u)^0) elseif no==1 then local o=one[1] one,two=P(o[1]),o[2] pattern=Cs((one/two+u)^0) else for i=1,no do local o=one[i] p=p+P(o[1])/o[2] end pattern=Cs((p+u)^0) end else pattern=Cs((P(one)/(two or "")+u)^0) end if makefunction then return function(str) return lpegmatch(pattern,str) end else return pattern end end function lpeg.finder(lst,makefunction,isutf) local pattern if type(lst)=="table" then pattern=P(false) if #lst==0 then for k,v in next,lst do pattern=pattern+P(k) end else for i=1,#lst do pattern=pattern+P(lst[i]) end end else pattern=P(lst) end if isutf then pattern=((utf8char or 1)-pattern)^0*pattern else pattern=(1-pattern)^0*pattern end if makefunction then return function(str) return lpegmatch(pattern,str) end else return pattern end end local splitters_f,splitters_s={},{} function lpeg.firstofsplit(separator) local splitter=splitters_f[separator] if not splitter then local pattern=P(separator) splitter=C((1-pattern)^0) splitters_f[separator]=splitter end return splitter end function lpeg.secondofsplit(separator) local splitter=splitters_s[separator] if not splitter then local pattern=P(separator) splitter=(1-pattern)^0*pattern*C(anything^0) splitters_s[separator]=splitter end return splitter end local splitters_s,splitters_p={},{} function lpeg.beforesuffix(separator) local splitter=splitters_s[separator] if not splitter then local pattern=P(separator) splitter=C((1-pattern)^0)*pattern*endofstring splitters_s[separator]=splitter end return splitter end function lpeg.afterprefix(separator) local splitter=splitters_p[separator] if not splitter then local pattern=P(separator) splitter=pattern*C(anything^0) splitters_p[separator]=splitter end return splitter end function lpeg.balancer(left,right) left,right=P(left),P(right) return P { left*((1-left-right)+V(1))^0*right } end local nany=utf8char/"" function lpeg.counter(pattern) pattern=Cs((P(pattern)/" "+nany)^0) return function(str) return #lpegmatch(pattern,str) end end utf=utf or (unicode and unicode.utf8) or {} local utfcharacters=utf and utf.characters or string.utfcharacters local utfgmatch=utf and utf.gmatch local utfchar=utf and utf.char lpeg.UP=lpeg.P if utfcharacters then function lpeg.US(str) local p=P(false) for uc in utfcharacters(str) do p=p+P(uc) end return p end elseif utfgmatch then function lpeg.US(str) local p=P(false) for uc in utfgmatch(str,".") do p=p+P(uc) end return p end else function lpeg.US(str) local p=P(false) local f=function(uc) p=p+P(uc) end lpegmatch((utf8char/f)^0,str) return p end end local range=utf8byte*utf8byte+Cc(false) function lpeg.UR(str,more) local first,last if type(str)=="number" then first=str last=more or first else first,last=lpegmatch(range,str) if not last then return P(str) end end if first==last then return P(str) elseif utfchar and (last-first<8) then local p=P(false) for i=first,last do p=p+P(utfchar(i)) end return p else local f=function(b) return b>=first and b<=last end return utf8byte/f end end function lpeg.is_lpeg(p) return p and lpegtype(p)=="pattern" end function lpeg.oneof(list,...) if type(list)~="table" then list={ list,... } end local p=P(list[1]) for l=2,#list do p=p+P(list[l]) end return p end local sort=table.sort local function copyindexed(old) local new={} for i=1,#old do new[i]=old end return new end local function sortedkeys(tab) local keys,s={},0 for key,_ in next,tab do s=s+1 keys[s]=key end sort(keys) return keys end function lpeg.append(list,pp,delayed,checked) local p=pp if #list>0 then local keys=copyindexed(list) sort(keys) for i=#keys,1,-1 do local k=keys[i] if p then p=P(k)+p else p=P(k) end end elseif delayed then local keys=sortedkeys(list) if p then for i=1,#keys,1 do local k=keys[i] local v=list[k] p=P(k)/list+p end else for i=1,#keys do local k=keys[i] local v=list[k] if p then p=P(k)+p else p=P(k) end end if p then p=p/list end end elseif checked then local keys=sortedkeys(list) for i=1,#keys do local k=keys[i] local v=list[k] if p then if k==v then p=P(k)+p else p=P(k)/v+p end else if k==v then p=P(k) else p=P(k)/v end end end else local keys=sortedkeys(list) for i=1,#keys do local k=keys[i] local v=list[k] if p then p=P(k)/v+p else p=P(k)/v end end end return p end local function make(t,hash) local p=P(false) local keys=sortedkeys(t) for i=1,#keys do local k=keys[i] local v=t[k] local h=hash[v] if h then if next(v) then p=p+P(k)*(make(v,hash)+P(true)) else p=p+P(k)*P(true) end else if next(v) then p=p+P(k)*make(v,hash) else p=p+P(k) end end end return p end function lpeg.utfchartabletopattern(list) local tree={} local hash={} local n=#list if n==0 then for s in next,list do local t=tree for c in gmatch(s,".") do local tc=t[c] if not tc then tc={} t[c]=tc end t=tc end hash[t]=s end else for i=1,n do local t=tree local s=list[i] for c in gmatch(s,".") do local tc=t[c] if not tc then tc={} t[c]=tc end t=tc end hash[t]=s end end return make(tree,hash) end patterns.containseol=lpeg.finder(eol) local function nextstep(n,step,result) local m=n%step local d=floor(n/step) if d>0 then local v=V(tostring(step)) local s=result.start for i=1,d do if s then s=v*s else s=v end end result.start=s end if step>1 and result.start then local v=V(tostring(step/2)) result[tostring(step)]=v*v end if step>0 then return nextstep(m,step/2,result) else return result end end function lpeg.times(pattern,n) return P(nextstep(n,2^16,{ "start",["1"]=pattern })) end local trailingzeros=zero^0*-digit local case_1=period*trailingzeros/"" local case_2=period*(digit-trailingzeros)^1*(trailingzeros/"") local number=digit^1*(case_1+case_2) local stripper=Cs((number+1)^0) lpeg.patterns.stripzeros=stripper end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['l-functions']={ version=1.001, comment="companion to luat-lib.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } functions=functions or {} function functions.dummy() end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['l-string']={ version=1.001, comment="companion to luat-lib.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local string=string local sub,gmatch,format,char,byte,rep,lower=string.sub,string.gmatch,string.format,string.char,string.byte,string.rep,string.lower local lpegmatch,patterns=lpeg.match,lpeg.patterns local P,S,C,Ct,Cc,Cs=lpeg.P,lpeg.S,lpeg.C,lpeg.Ct,lpeg.Cc,lpeg.Cs local unquoted=patterns.squote*C(patterns.nosquote)*patterns.squote+patterns.dquote*C(patterns.nodquote)*patterns.dquote function string.unquoted(str) return lpegmatch(unquoted,str) or str end function string.quoted(str) return format("%q",str) end function string.count(str,pattern) local n=0 for _ in gmatch(str,pattern) do n=n+1 end return n end function string.limit(str,n,sentinel) if #str>n then sentinel=sentinel or "..." return sub(str,1,(n-#sentinel))..sentinel else return str end end local stripper=patterns.stripper local fullstripper=patterns.fullstripper local collapser=patterns.collapser local longtostring=patterns.longtostring function string.strip(str) return lpegmatch(stripper,str) or "" end function string.fullstrip(str) return lpegmatch(fullstripper,str) or "" end function string.collapsespaces(str) return lpegmatch(collapser,str) or "" end function string.longtostring(str) return lpegmatch(longtostring,str) or "" end local pattern=P(" ")^0*P(-1) function string.is_empty(str) if str=="" then return true else return lpegmatch(pattern,str) and true or false end end local anything=patterns.anything local allescapes=Cc("%")*S(".-+%?()[]*") local someescapes=Cc("%")*S(".-+%()[]") local matchescapes=Cc(".")*S("*?") local pattern_a=Cs ((allescapes+anything )^0 ) local pattern_b=Cs ((someescapes+matchescapes+anything )^0 ) local pattern_c=Cs (Cc("^")*(someescapes+matchescapes+anything )^0*Cc("$") ) function string.escapedpattern(str,simple) return lpegmatch(simple and pattern_b or pattern_a,str) end function string.topattern(str,lowercase,strict) if str=="" or type(str)~="string" then return ".*" elseif strict then str=lpegmatch(pattern_c,str) else str=lpegmatch(pattern_b,str) end if lowercase then return lower(str) else return str end end function string.valid(str,default) return (type(str)=="string" and str~="" and str) or default or nil end string.itself=function(s) return s end local pattern=Ct(C(1)^0) function string.totable(str) return lpegmatch(pattern,str) end local replacer=lpeg.replacer("@","%%") function string.tformat(fmt,...) return format(lpegmatch(replacer,fmt),...) end string.quote=string.quoted string.unquote=string.unquoted end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['l-table']={ version=1.001, comment="companion to luat-lib.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local type,next,tostring,tonumber,ipairs,select=type,next,tostring,tonumber,ipairs,select local table,string=table,string local concat,sort,insert,remove=table.concat,table.sort,table.insert,table.remove local format,lower,dump=string.format,string.lower,string.dump local getmetatable,setmetatable=getmetatable,setmetatable local getinfo=debug.getinfo local lpegmatch,patterns=lpeg.match,lpeg.patterns local floor=math.floor local stripper=patterns.stripper function table.strip(tab) local lst,l={},0 for i=1,#tab do local s=lpegmatch(stripper,tab[i]) or "" if s=="" then else l=l+1 lst[l]=s end end return lst end function table.keys(t) if t then local keys,k={},0 for key,_ in next,t do k=k+1 keys[k]=key end return keys else return {} end end local function compare(a,b) local ta,tb=type(a),type(b) if ta==tb then return a<b else return tostring(a)<tostring(b) end end local function sortedkeys(tab) if tab then local srt,category,s={},0,0 for key,_ in next,tab do s=s+1 srt[s]=key if category==3 then else local tkey=type(key) if tkey=="string" then category=(category==2 and 3) or 1 elseif tkey=="number" then category=(category==1 and 3) or 2 else category=3 end end end if category==0 or category==3 then sort(srt,compare) else sort(srt) end return srt else return {} end end local function sortedhashonly(tab) if tab then local srt,s={},0 for key,_ in next,tab do if type(key)=="string" then s=s+1 srt[s]=key end end sort(srt) return srt else return {} end end local function sortedindexonly(tab) if tab then local srt,s={},0 for key,_ in next,tab do if type(key)=="number" then s=s+1 srt[s]=key end end sort(srt) return srt else return {} end end local function sortedhashkeys(tab,cmp) if tab then local srt,s={},0 for key,_ in next,tab do if key then s=s+1 srt[s]=key end end sort(srt,cmp) return srt else return {} end end function table.allkeys(t) local keys={} for k,v in next,t do for k,v in next,v do keys[k]=true end end return sortedkeys(keys) end table.sortedkeys=sortedkeys table.sortedhashonly=sortedhashonly table.sortedindexonly=sortedindexonly table.sortedhashkeys=sortedhashkeys local function nothing() end local function sortedhash(t,cmp) if t then local s if cmp then s=sortedhashkeys(t,function(a,b) return cmp(t,a,b) end) else s=sortedkeys(t) end local n=0 local m=#s local function kv() if n<m then n=n+1 local k=s[n] return k,t[k] end end return kv else return nothing end end table.sortedhash=sortedhash table.sortedpairs=sortedhash function table.append(t,list) local n=#t for i=1,#list do n=n+1 t[n]=list[i] end return t end function table.prepend(t,list) local nl=#list local nt=nl+#t for i=#t,1,-1 do t[nt]=t[i] nt=nt-1 end for i=1,#list do t[i]=list[i] end return t end function table.merge(t,...) t=t or {} for i=1,select("#",...) do for k,v in next,(select(i,...)) do t[k]=v end end return t end function table.merged(...) local t={} for i=1,select("#",...) do for k,v in next,(select(i,...)) do t[k]=v end end return t end function table.imerge(t,...) local nt=#t for i=1,select("#",...) do local nst=select(i,...) for j=1,#nst do nt=nt+1 t[nt]=nst[j] end end return t end function table.imerged(...) local tmp,ntmp={},0 for i=1,select("#",...) do local nst=select(i,...) for j=1,#nst do ntmp=ntmp+1 tmp[ntmp]=nst[j] end end return tmp end local function fastcopy(old,metatabletoo) if old then local new={} for k,v in next,old do if type(v)=="table" then new[k]=fastcopy(v,metatabletoo) else new[k]=v end end if metatabletoo then local mt=getmetatable(old) if mt then setmetatable(new,mt) end end return new else return {} end end local function copy(t,tables) tables=tables or {} local tcopy={} if not tables[t] then tables[t]=tcopy end for i,v in next,t do if type(i)=="table" then if tables[i] then i=tables[i] else i=copy(i,tables) end end if type(v)~="table" then tcopy[i]=v elseif tables[v] then tcopy[i]=tables[v] else tcopy[i]=copy(v,tables) end end local mt=getmetatable(t) if mt then setmetatable(tcopy,mt) end return tcopy end table.fastcopy=fastcopy table.copy=copy function table.derive(parent) local child={} if parent then setmetatable(child,{ __index=parent }) end return child end function table.tohash(t,value) local h={} if t then if value==nil then value=true end for _,v in next,t do h[v]=value end end return h end function table.fromhash(t) local hsh,h={},0 for k,v in next,t do if v then h=h+1 hsh[h]=k end end return hsh end local noquotes,hexify,handle,reduce,compact,inline,functions local reserved=table.tohash { 'and','break','do','else','elseif','end','false','for','function','if', 'in','local','nil','not','or','repeat','return','then','true','until','while', 'NaN','goto', } local function simple_table(t) if #t>0 then local n=0 for _,v in next,t do n=n+1 end if n==#t then local tt,nt={},0 for i=1,#t do local v=t[i] local tv=type(v) if tv=="number" then nt=nt+1 if hexify then tt[nt]=format("0x%X",v) else tt[nt]=tostring(v) end elseif tv=="string" then nt=nt+1 tt[nt]=format("%q",v) elseif tv=="boolean" then nt=nt+1 tt[nt]=v and "true" or "false" else tt=nil break end end return tt end end return nil end local propername=patterns.propername local function dummy() end local function do_serialize(root,name,depth,level,indexed) if level>0 then depth=depth.." " if indexed then handle(format("%s{",depth)) else local tn=type(name) if tn=="number" then if hexify then handle(format("%s[0x%X]={",depth,name)) else handle(format("%s[%s]={",depth,name)) end elseif tn=="string" then if noquotes and not reserved[name] and lpegmatch(propername,name) then handle(format("%s%s={",depth,name)) else handle(format("%s[%q]={",depth,name)) end elseif tn=="boolean" then handle(format("%s[%s]={",depth,name and "true" or "false")) else handle(format("%s{",depth)) end end end if root and next(root) then local first,last=nil,0 if compact then last=#root for k=1,last do if root[k]==nil then last=k-1 break end end if last>0 then first=1 end end local sk=sortedkeys(root) for i=1,#sk do local k=sk[i] local v=root[k] local tv,tk=type(v),type(k) if compact and first and tk=="number" and k>=first and k<=last then if tv=="number" then if hexify then handle(format("%s 0x%X,",depth,v)) else handle(format("%s %s,",depth,v)) end elseif tv=="string" then if reduce and tonumber(v) then handle(format("%s %s,",depth,v)) else handle(format("%s %q,",depth,v)) end elseif tv=="table" then if not next(v) then handle(format("%s {},",depth)) elseif inline then local st=simple_table(v) if st then handle(format("%s { %s },",depth,concat(st,", "))) else do_serialize(v,k,depth,level+1,true) end else do_serialize(v,k,depth,level+1,true) end elseif tv=="boolean" then handle(format("%s %s,",depth,v and "true" or "false")) elseif tv=="function" then if functions then handle(format('%s load(%q),',depth,dump(v))) else handle(format('%s "function",',depth)) end else handle(format("%s %q,",depth,tostring(v))) end elseif k=="__p__" then if false then handle(format("%s __p__=nil,",depth)) end elseif tv=="number" then if tk=="number" then if hexify then handle(format("%s [0x%X]=0x%X,",depth,k,v)) else handle(format("%s [%s]=%s,",depth,k,v)) end elseif tk=="boolean" then if hexify then handle(format("%s [%s]=0x%X,",depth,k and "true" or "false",v)) else handle(format("%s [%s]=%s,",depth,k and "true" or "false",v)) end elseif noquotes and not reserved[k] and lpegmatch(propername,k) then if hexify then handle(format("%s %s=0x%X,",depth,k,v)) else handle(format("%s %s=%s,",depth,k,v)) end else if hexify then handle(format("%s [%q]=0x%X,",depth,k,v)) else handle(format("%s [%q]=%s,",depth,k,v)) end end elseif tv=="string" then if reduce and tonumber(v) then if tk=="number" then if hexify then handle(format("%s [0x%X]=%s,",depth,k,v)) else handle(format("%s [%s]=%s,",depth,k,v)) end elseif tk=="boolean" then handle(format("%s [%s]=%s,",depth,k and "true" or "false",v)) elseif noquotes and not reserved[k] and lpegmatch(propername,k) then handle(format("%s %s=%s,",depth,k,v)) else handle(format("%s [%q]=%s,",depth,k,v)) end else if tk=="number" then if hexify then handle(format("%s [0x%X]=%q,",depth,k,v)) else handle(format("%s [%s]=%q,",depth,k,v)) end elseif tk=="boolean" then handle(format("%s [%s]=%q,",depth,k and "true" or "false",v)) elseif noquotes and not reserved[k] and lpegmatch(propername,k) then handle(format("%s %s=%q,",depth,k,v)) else handle(format("%s [%q]=%q,",depth,k,v)) end end elseif tv=="table" then if not next(v) then if tk=="number" then if hexify then handle(format("%s [0x%X]={},",depth,k)) else handle(format("%s [%s]={},",depth,k)) end elseif tk=="boolean" then handle(format("%s [%s]={},",depth,k and "true" or "false")) elseif noquotes and not reserved[k] and lpegmatch(propername,k) then handle(format("%s %s={},",depth,k)) else handle(format("%s [%q]={},",depth,k)) end elseif inline then local st=simple_table(v) if st then if tk=="number" then if hexify then handle(format("%s [0x%X]={ %s },",depth,k,concat(st,", "))) else handle(format("%s [%s]={ %s },",depth,k,concat(st,", "))) end elseif tk=="boolean" then handle(format("%s [%s]={ %s },",depth,k and "true" or "false",concat(st,", "))) elseif noquotes and not reserved[k] and lpegmatch(propername,k) then handle(format("%s %s={ %s },",depth,k,concat(st,", "))) else handle(format("%s [%q]={ %s },",depth,k,concat(st,", "))) end else do_serialize(v,k,depth,level+1) end else do_serialize(v,k,depth,level+1) end elseif tv=="boolean" then if tk=="number" then if hexify then handle(format("%s [0x%X]=%s,",depth,k,v and "true" or "false")) else handle(format("%s [%s]=%s,",depth,k,v and "true" or "false")) end elseif tk=="boolean" then handle(format("%s [%s]=%s,",depth,tostring(k),v and "true" or "false")) elseif noquotes and not reserved[k] and lpegmatch(propername,k) then handle(format("%s %s=%s,",depth,k,v and "true" or "false")) else handle(format("%s [%q]=%s,",depth,k,v and "true" or "false")) end elseif tv=="function" then if functions then local f=getinfo(v).what=="C" and dump(dummy) or dump(v) if tk=="number" then if hexify then handle(format("%s [0x%X]=load(%q),",depth,k,f)) else handle(format("%s [%s]=load(%q),",depth,k,f)) end elseif tk=="boolean" then handle(format("%s [%s]=load(%q),",depth,k and "true" or "false",f)) elseif noquotes and not reserved[k] and lpegmatch(propername,k) then handle(format("%s %s=load(%q),",depth,k,f)) else handle(format("%s [%q]=load(%q),",depth,k,f)) end end else if tk=="number" then if hexify then handle(format("%s [0x%X]=%q,",depth,k,tostring(v))) else handle(format("%s [%s]=%q,",depth,k,tostring(v))) end elseif tk=="boolean" then handle(format("%s [%s]=%q,",depth,k and "true" or "false",tostring(v))) elseif noquotes and not reserved[k] and lpegmatch(propername,k) then handle(format("%s %s=%q,",depth,k,tostring(v))) else handle(format("%s [%q]=%q,",depth,k,tostring(v))) end end end end if level>0 then handle(format("%s},",depth)) end end local function serialize(_handle,root,name,specification) local tname=type(name) if type(specification)=="table" then noquotes=specification.noquotes hexify=specification.hexify handle=_handle or specification.handle or print reduce=specification.reduce or false functions=specification.functions compact=specification.compact inline=specification.inline and compact if functions==nil then functions=true end if compact==nil then compact=true end if inline==nil then inline=compact end else noquotes=false hexify=false handle=_handle or print reduce=false compact=true inline=true functions=true end if tname=="string" then if name=="return" then handle("return {") else handle(name.."={") end elseif tname=="number" then if hexify then handle(format("[0x%X]={",name)) else handle("["..name.."]={") end elseif tname=="boolean" then if name then handle("return {") else handle("{") end else handle("t={") end if root then if getmetatable(root) then local dummy=root._w_h_a_t_e_v_e_r_ root._w_h_a_t_e_v_e_r_=nil end if next(root) then do_serialize(root,name,"",0) end end handle("}") end function table.serialize(root,name,specification) local t,n={},0 local function flush(s) n=n+1 t[n]=s end serialize(flush,root,name,specification) return concat(t,"\n") end table.tohandle=serialize local maxtab=2*1024 function table.tofile(filename,root,name,specification) local f=io.open(filename,'w') if f then if maxtab>1 then local t,n={},0 local function flush(s) n=n+1 t[n]=s if n>maxtab then f:write(concat(t,"\n"),"\n") t,n={},0 end end serialize(flush,root,name,specification) f:write(concat(t,"\n"),"\n") else local function flush(s) f:write(s,"\n") end serialize(flush,root,name,specification) end f:close() io.flush() end end local function flattened(t,f,depth) if f==nil then f={} depth=0xFFFF elseif tonumber(f) then depth=f f={} elseif not depth then depth=0xFFFF end for k,v in next,t do if type(k)~="number" then if depth>0 and type(v)=="table" then flattened(v,f,depth-1) else f[#f+1]=v end end end for k=1,#t do local v=t[k] if depth>0 and type(v)=="table" then flattened(v,f,depth-1) else f[#f+1]=v end end return f end table.flattened=flattened local function unnest(t,f) if not f then f={} end for i=1,#t do local v=t[i] if type(v)=="table" then if type(v[1])=="table" then unnest(v,f) else f[#f+1]=v end else f[#f+1]=v end end return f end function table.unnest(t) return unnest(t) end local function are_equal(a,b,n,m) if a and b and #a==#b then n=n or 1 m=m or #a for i=n,m do local ai,bi=a[i],b[i] if ai==bi then elseif type(ai)=="table" and type(bi)=="table" then if not are_equal(ai,bi) then return false end else return false end end return true else return false end end local function identical(a,b) for ka,va in next,a do local vb=b[ka] if va==vb then elseif type(va)=="table" and type(vb)=="table" then if not identical(va,vb) then return false end else return false end end return true end table.identical=identical table.are_equal=are_equal local function sparse(old,nest,keeptables) local new={} for k,v in next,old do if not (v=="" or v==false) then if nest and type(v)=="table" then v=sparse(v,nest) if keeptables or next(v) then new[k]=v end else new[k]=v end end end return new end table.sparse=sparse function table.compact(t) return sparse(t,true,true) end function table.contains(t,v) if t then for i=1,#t do if t[i]==v then return i end end end return false end function table.count(t) local n=0 for k,v in next,t do n=n+1 end return n end function table.swapped(t,s) local n={} if s then for k,v in next,s do n[k]=v end end for k,v in next,t do n[v]=k end return n end function table.mirrored(t) local n={} for k,v in next,t do n[v]=k n[k]=v end return n end function table.reversed(t) if t then local tt,tn={},#t if tn>0 then local ttn=0 for i=tn,1,-1 do ttn=ttn+1 tt[ttn]=t[i] end end return tt end end function table.reverse(t) if t then local n=#t for i=1,floor(n/2) do local j=n-i+1 t[i],t[j]=t[j],t[i] end return t end end function table.sequenced(t,sep,simple) if not t then return "" end local n=#t local s={} if n>0 then for i=1,n do s[i]=tostring(t[i]) end else n=0 for k,v in sortedhash(t) do if simple then if v==true then n=n+1 s[n]=k elseif v and v~="" then n=n+1 s[n]=k.."="..tostring(v) end else n=n+1 s[n]=k.."="..tostring(v) end end end return concat(s,sep or " | ") end function table.print(t,...) if type(t)~="table" then print(tostring(t)) else serialize(print,t,...) end end if setinspector then setinspector(function(v) if type(v)=="table" then serialize(print,v,"table") return true end end) end function table.sub(t,i,j) return { unpack(t,i,j) } end function table.is_empty(t) return not t or not next(t) end function table.has_one_entry(t) return t and not next(t,next(t)) end function table.loweredkeys(t) local l={} for k,v in next,t do l[lower(k)]=v end return l end function table.unique(old) local hash={} local new={} local n=0 for i=1,#old do local oi=old[i] if not hash[oi] then n=n+1 new[n]=oi hash[oi]=true end end return new end function table.sorted(t,...) sort(t,...) return t end function table.values(t,s) if t then local values,keys,v={},{},0 for key,value in next,t do if not keys[value] then v=v+1 values[v]=value keys[k]=key end end if s then sort(values) end return values else return {} end end function table.filtered(t,pattern,sort,cmp) if t and type(pattern)=="string" then if sort then local s if cmp then s=sortedhashkeys(t,function(a,b) return cmp(t,a,b) end) else s=sortedkeys(t) end local n=0 local m=#s local function kv(s) while n<m do n=n+1 local k=s[n] if find(k,pattern) then return k,t[k] end end end return kv,s else local n=next(t) local function iterator() while n do local k=n n=next(t,k) if find(k,pattern) then return k,t[k] end end end return iterator,t end else return nothing end end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['l-io']={ version=1.001, comment="companion to luat-lib.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local io=io local byte,find,gsub,format=string.byte,string.find,string.gsub,string.format local concat=table.concat local floor=math.floor local type=type if string.find(os.getenv("PATH"),";",1,true) then io.fileseparator,io.pathseparator="\\",";" else io.fileseparator,io.pathseparator="/",":" end local function readall(f) return f:read("*all") end local function readall(f) local size=f:seek("end") if size==0 then return "" elseif size<1024*1024 then f:seek("set",0) return f:read('*all') else local done=f:seek("set",0) local step if size<1024*1024 then step=1024*1024 elseif size>16*1024*1024 then step=16*1024*1024 else step=floor(size/(1024*1024))*1024*1024/8 end local data={} while true do local r=f:read(step) if not r then return concat(data) else data[#data+1]=r end end end end io.readall=readall function io.loaddata(filename,textmode) local f=io.open(filename,(textmode and 'r') or 'rb') if f then local data=readall(f) f:close() if #data>0 then return data end end end function io.savedata(filename,data,joiner) local f=io.open(filename,"wb") if f then if type(data)=="table" then f:write(concat(data,joiner or "")) elseif type(data)=="function" then data(f) else f:write(data or "") end f:close() io.flush() return true else return false end end function io.loadlines(filename,n) local f=io.open(filename,'r') if not f then elseif n then local lines={} for i=1,n do local line=f:read("*lines") if line then lines[#lines+1]=line else break end end f:close() lines=concat(lines,"\n") if #lines>0 then return lines end else local line=f:read("*line") or "" f:close() if #line>0 then return line end end end function io.loadchunk(filename,n) local f=io.open(filename,'rb') if f then local data=f:read(n or 1024) f:close() if #data>0 then return data end end end function io.exists(filename) local f=io.open(filename) if f==nil then return false else f:close() return true end end function io.size(filename) local f=io.open(filename) if f==nil then return 0 else local s=f:seek("end") f:close() return s end end function io.noflines(f) if type(f)=="string" then local f=io.open(filename) if f then local n=f and io.noflines(f) or 0 f:close() return n else return 0 end else local n=0 for _ in f:lines() do n=n+1 end f:seek('set',0) return n end end local nextchar={ [ 4]=function(f) return f:read(1,1,1,1) end, [ 2]=function(f) return f:read(1,1) end, [ 1]=function(f) return f:read(1) end, [-2]=function(f) local a,b=f:read(1,1) return b,a end, [-4]=function(f) local a,b,c,d=f:read(1,1,1,1) return d,c,b,a end } function io.characters(f,n) if f then return nextchar[n or 1],f end end local nextbyte={ [4]=function(f) local a,b,c,d=f:read(1,1,1,1) if d then return byte(a),byte(b),byte(c),byte(d) end end, [3]=function(f) local a,b,c=f:read(1,1,1) if b then return byte(a),byte(b),byte(c) end end, [2]=function(f) local a,b=f:read(1,1) if b then return byte(a),byte(b) end end, [1]=function (f) local a=f:read(1) if a then return byte(a) end end, [-2]=function (f) local a,b=f:read(1,1) if b then return byte(b),byte(a) end end, [-3]=function(f) local a,b,c=f:read(1,1,1) if b then return byte(c),byte(b),byte(a) end end, [-4]=function(f) local a,b,c,d=f:read(1,1,1,1) if d then return byte(d),byte(c),byte(b),byte(a) end end } function io.bytes(f,n) if f then return nextbyte[n or 1],f else return nil,nil end end function io.ask(question,default,options) while true do io.write(question) if options then io.write(format(" [%s]",concat(options,"|"))) end if default then io.write(format(" [%s]",default)) end io.write(format(" ")) io.flush() local answer=io.read() answer=gsub(answer,"^%s*(.*)%s*$","%1") if answer=="" and default then return default elseif not options then return answer else for k=1,#options do if options[k]==answer then return answer end end local pattern="^"..answer for k=1,#options do local v=options[k] if find(v,pattern) then return v end end end end end local function readnumber(f,n,m) if m then f:seek("set",n) n=m end if n==1 then return byte(f:read(1)) elseif n==2 then local a,b=byte(f:read(2),1,2) return 256*a+b elseif n==3 then local a,b,c=byte(f:read(3),1,3) return 256*256*a+256*b+c elseif n==4 then local a,b,c,d=byte(f:read(4),1,4) return 256*256*256*a+256*256*b+256*c+d elseif n==8 then local a,b=readnumber(f,4),readnumber(f,4) return 256*a+b elseif n==12 then local a,b,c=readnumber(f,4),readnumber(f,4),readnumber(f,4) return 256*256*a+256*b+c elseif n==-2 then local b,a=byte(f:read(2),1,2) return 256*a+b elseif n==-3 then local c,b,a=byte(f:read(3),1,3) return 256*256*a+256*b+c elseif n==-4 then local d,c,b,a=byte(f:read(4),1,4) return 256*256*256*a+256*256*b+256*c+d elseif n==-8 then local h,g,f,e,d,c,b,a=byte(f:read(8),1,8) return 256*256*256*256*256*256*256*a+256*256*256*256*256*256*b+256*256*256*256*256*c+256*256*256*256*d+256*256*256*e+256*256*f+256*g+h else return 0 end end io.readnumber=readnumber function io.readstring(f,n,m) if m then f:seek("set",n) n=m end local str=gsub(f:read(n),"\000","") return str end if not io.i_limiter then function io.i_limiter() end end if not io.o_limiter then function io.o_limiter() end end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['l-file']={ version=1.001, comment="companion to luat-lib.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } file=file or {} local file=file if not lfs then lfs=optionalrequire("lfs") end if not lfs then lfs={ getcurrentdir=function() return "." end, attributes=function() return nil end, isfile=function(name) local f=io.open(name,'rb') if f then f:close() return true end end, isdir=function(name) print("you need to load lfs") return false end } elseif not lfs.isfile then local attributes=lfs.attributes function lfs.isdir(name) return attributes(name,"mode")=="directory" end function lfs.isfile(name) return attributes(name,"mode")=="file" end end local insert,concat=table.insert,table.concat local match,find,gmatch=string.match,string.find,string.gmatch local lpegmatch=lpeg.match local getcurrentdir,attributes=lfs.currentdir,lfs.attributes local checkedsplit=string.checkedsplit local P,R,S,C,Cs,Cp,Cc,Ct=lpeg.P,lpeg.R,lpeg.S,lpeg.C,lpeg.Cs,lpeg.Cp,lpeg.Cc,lpeg.Ct local colon=P(":") local period=P(".") local periods=P("..") local fwslash=P("/") local bwslash=P("\\") local slashes=S("\\/") local noperiod=1-period local noslashes=1-slashes local name=noperiod^1 local suffix=period/""*(1-period-slashes)^1*-1 local pattern=C((1-(slashes^1*noslashes^1*-1))^1)*P(1) local function pathpart(name,default) return name and lpegmatch(pattern,name) or default or "" end local pattern=(noslashes^0*slashes)^1*C(noslashes^1)*-1 local function basename(name) return name and lpegmatch(pattern,name) or name end local pattern=(noslashes^0*slashes^1)^0*Cs((1-suffix)^1)*suffix^0 local function nameonly(name) return name and lpegmatch(pattern,name) or name end local pattern=(noslashes^0*slashes)^0*(noperiod^1*period)^1*C(noperiod^1)*-1 local function suffixonly(name) return name and lpegmatch(pattern,name) or "" end local pattern=(noslashes^0*slashes)^0*noperiod^1*((period*C(noperiod^1))^1)*-1+Cc("") local function suffixesonly(name) if name then return lpegmatch(pattern,name) else return "" end end file.pathpart=pathpart file.basename=basename file.nameonly=nameonly file.suffixonly=suffixonly file.suffix=suffixonly file.suffixesonly=suffixesonly file.suffixes=suffixesonly file.dirname=pathpart file.extname=suffixonly local drive=C(R("az","AZ"))*colon local path=C((noslashes^0*slashes)^0) local suffix=period*C(P(1-period)^0*P(-1)) local base=C((1-suffix)^0) local rest=C(P(1)^0) drive=drive+Cc("") path=path+Cc("") base=base+Cc("") suffix=suffix+Cc("") local pattern_a=drive*path*base*suffix local pattern_b=path*base*suffix local pattern_c=C(drive*path)*C(base*suffix) local pattern_d=path*rest function file.splitname(str,splitdrive) if not str then elseif splitdrive then return lpegmatch(pattern_a,str) else return lpegmatch(pattern_b,str) end end function file.splitbase(str) if str then return lpegmatch(pattern_d,str) else return "",str end end function file.nametotable(str,splitdrive) if str then local path,drive,subpath,name,base,suffix=lpegmatch(pattern_c,str) if splitdrive then return { path=path, drive=drive, subpath=subpath, name=name, base=base, suffix=suffix, } else return { path=path, name=name, base=base, suffix=suffix, } end end end local pattern=Cs(((period*(1-period-slashes)^1*-1)/""+1)^1) function file.removesuffix(name) return name and lpegmatch(pattern,name) end local suffix=period/""*(1-period-slashes)^1*-1 local pattern=Cs((noslashes^0*slashes^1)^0*((1-suffix)^1))*Cs(suffix) function file.addsuffix(filename,suffix,criterium) if not filename or not suffix or suffix=="" then return filename elseif criterium==true then return filename.."."..suffix elseif not criterium then local n,s=lpegmatch(pattern,filename) if not s or s=="" then return filename.."."..suffix else return filename end else local n,s=lpegmatch(pattern,filename) if s and s~="" then local t=type(criterium) if t=="table" then for i=1,#criterium do if s==criterium[i] then return filename end end elseif t=="string" then if s==criterium then return filename end end end return (n or filename).."."..suffix end end local suffix=period*(1-period-slashes)^1*-1 local pattern=Cs((1-suffix)^0) function file.replacesuffix(name,suffix) if name and suffix and suffix~="" then return lpegmatch(pattern,name).."."..suffix else return name end end local reslasher=lpeg.replacer(P("\\"),"/") function file.reslash(str) return str and lpegmatch(reslasher,str) end function file.is_writable(name) if not name then elseif lfs.isdir(name) then name=name.."/m_t_x_t_e_s_t.tmp" local f=io.open(name,"wb") if f then f:close() os.remove(name) return true end elseif lfs.isfile(name) then local f=io.open(name,"ab") if f then f:close() return true end else local f=io.open(name,"ab") if f then f:close() os.remove(name) return true end end return false end local readable=P("r")*Cc(true) function file.is_readable(name) if name then local a=attributes(name) return a and lpegmatch(readable,a.permissions) or false else return false end end file.isreadable=file.is_readable file.iswritable=file.is_writable function file.size(name) if name then local a=attributes(name) return a and a.size or 0 else return 0 end end function file.splitpath(str,separator) return str and checkedsplit(lpegmatch(reslasher,str),separator or io.pathseparator) end function file.joinpath(tab,separator) return tab and concat(tab,separator or io.pathseparator) end local someslash=S("\\/") local stripper=Cs(P(fwslash)^0/""*reslasher) local isnetwork=someslash*someslash*(1-someslash)+(1-fwslash-colon)^1*colon local isroot=fwslash^1*-1 local hasroot=fwslash^1 local reslasher=lpeg.replacer(S("\\/"),"/") local deslasher=lpeg.replacer(S("\\/")^1,"/") function file.join(one,two,three,...) if not two then return one=="" and one or lpegmatch(stripper,one) end if one=="" then return lpegmatch(stripper,three and concat({ two,three,... },"/") or two) end if lpegmatch(isnetwork,one) then local one=lpegmatch(reslasher,one) local two=lpegmatch(deslasher,three and concat({ two,three,... },"/") or two) if lpegmatch(hasroot,two) then return one..two else return one.."/"..two end elseif lpegmatch(isroot,one) then local two=lpegmatch(deslasher,three and concat({ two,three,... },"/") or two) if lpegmatch(hasroot,two) then return two else return "/"..two end else return lpegmatch(deslasher,concat({ one,two,three,... },"/")) end end local drivespec=R("az","AZ")^1*colon local anchors=fwslash+drivespec local untouched=periods+(1-period)^1*P(-1) local mswindrive=Cs(drivespec*(bwslash/"/"+fwslash)^0) local mswinuncpath=(bwslash+fwslash)*(bwslash+fwslash)*Cc("//") local splitstarter=(mswindrive+mswinuncpath+Cc(false))*Ct(lpeg.splitat(S("/\\")^1)) local absolute=fwslash function file.collapsepath(str,anchor) if not str then return end if anchor==true and not lpegmatch(anchors,str) then str=getcurrentdir().."/"..str end if str=="" or str=="." then return "." elseif lpegmatch(untouched,str) then return lpegmatch(reslasher,str) end local starter,oldelements=lpegmatch(splitstarter,str) local newelements={} local i=#oldelements while i>0 do local element=oldelements[i] if element=='.' then elseif element=='..' then local n=i-1 while n>0 do local element=oldelements[n] if element~='..' and element~='.' then oldelements[n]='.' break else n=n-1 end end if n<1 then insert(newelements,1,'..') end elseif element~="" then insert(newelements,1,element) end i=i-1 end if #newelements==0 then return starter or "." elseif starter then return starter..concat(newelements,'/') elseif lpegmatch(absolute,str) then return "/"..concat(newelements,'/') else newelements=concat(newelements,'/') if anchor=="." and find(str,"^%./") then return "./"..newelements else return newelements end end end local tricky=S("/\\")*P(-1) local attributes=lfs.attributes function lfs.isdir(name) if lpegmatch(tricky,name) then return attributes(name,"mode")=="directory" else return attributes(name.."/.","mode")=="directory" end end function lfs.isfile(name) return attributes(name,"mode")=="file" end local validchars=R("az","09","AZ","--","..") local pattern_a=lpeg.replacer(1-validchars) local pattern_a=Cs((validchars+P(1)/"-")^1) local whatever=P("-")^0/"" local pattern_b=Cs(whatever*(1-whatever*-1)^1) function file.robustname(str,strict) if str then str=lpegmatch(pattern_a,str) or str if strict then return lpegmatch(pattern_b,str) or str else return str end end end file.readdata=io.loaddata file.savedata=io.savedata function file.copy(oldname,newname) if oldname and newname then local data=io.loaddata(oldname) if data and data~="" then file.savedata(newname,data) end end end local letter=R("az","AZ")+S("_-+") local separator=P("://") local qualified=period^0*fwslash+letter*colon+letter^1*separator+letter^1*fwslash local rootbased=fwslash+letter*colon lpeg.patterns.qualified=qualified lpeg.patterns.rootbased=rootbased function file.is_qualified_path(filename) return filename and lpegmatch(qualified,filename)~=nil end function file.is_rootbased_path(filename) return filename and lpegmatch(rootbased,filename)~=nil end function file.strip(name,dir) if name then local b,a=match(name,"^(.-)"..dir.."(.*)$") return a~="" and a or name end end function lfs.mkdirs(path) local full="" for sub in gmatch(path,"(/*[^\\/]+)") do full=full..sub lfs.mkdir(full) end end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['l-boolean']={ version=1.001, comment="companion to luat-lib.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local type,tonumber=type,tonumber boolean=boolean or {} local boolean=boolean function boolean.tonumber(b) if b then return 1 else return 0 end end function toboolean(str,tolerant) if str==nil then return false elseif str==false then return false elseif str==true then return true elseif str=="true" then return true elseif str=="false" then return false elseif not tolerant then return false elseif str==0 then return false elseif (tonumber(str) or 0)>0 then return true else return str=="yes" or str=="on" or str=="t" end end string.toboolean=toboolean function string.booleanstring(str) if str=="0" then return false elseif str=="1" then return true elseif str=="" then return false elseif str=="false" then return false elseif str=="true" then return true elseif (tonumber(str) or 0)>0 then return true else return str=="yes" or str=="on" or str=="t" end end function string.is_boolean(str,default) if type(str)=="string" then if str=="true" or str=="yes" or str=="on" or str=="t" or str=="1" then return true elseif str=="false" or str=="no" or str=="off" or str=="f" or str=="0" then return false end end return default end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['l-math']={ version=1.001, comment="companion to luat-lib.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local floor,sin,cos,tan=math.floor,math.sin,math.cos,math.tan if not math.round then function math.round(x) return floor(x+0.5) end end if not math.div then function math.div(n,m) return floor(n/m) end end if not math.mod then function math.mod(n,m) return n%m end end local pipi=2*math.pi/360 if not math.sind then function math.sind(d) return sin(d*pipi) end function math.cosd(d) return cos(d*pipi) end function math.tand(d) return tan(d*pipi) end end if not math.odd then function math.odd (n) return n%2~=0 end function math.even(n) return n%2==0 end end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['util-str']={ version=1.001, comment="companion to luat-lib.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } utilities=utilities or {} utilities.strings=utilities.strings or {} local strings=utilities.strings local format,gsub,rep,sub=string.format,string.gsub,string.rep,string.sub local load,dump=load,string.dump local tonumber,type,tostring=tonumber,type,tostring local unpack,concat=table.unpack,table.concat local P,V,C,S,R,Ct,Cs,Cp,Carg,Cc=lpeg.P,lpeg.V,lpeg.C,lpeg.S,lpeg.R,lpeg.Ct,lpeg.Cs,lpeg.Cp,lpeg.Carg,lpeg.Cc local patterns,lpegmatch=lpeg.patterns,lpeg.match local utfchar,utfbyte=utf.char,utf.byte local loadstripped=nil if _LUAVERSION<5.2 then loadstripped=function(str,shortcuts) return load(str) end else loadstripped=function(str,shortcuts) if shortcuts then return load(dump(load(str),true),nil,nil,shortcuts) else return load(dump(load(str),true)) end end end if not number then number={} end local stripper=patterns.stripzeros local function points(n) n=tonumber(n) return (not n or n==0) and "0pt" or lpegmatch(stripper,format("%.5fpt",n/65536)) end local function basepoints(n) n=tonumber(n) return (not n or n==0) and "0bp" or lpegmatch(stripper,format("%.5fbp",n*(7200/7227)/65536)) end number.points=points number.basepoints=basepoints local rubish=patterns.spaceortab^0*patterns.newline local anyrubish=patterns.spaceortab+patterns.newline local anything=patterns.anything local stripped=(patterns.spaceortab^1/"")*patterns.newline local leading=rubish^0/"" local trailing=(anyrubish^1*patterns.endofstring)/"" local redundant=rubish^3/"\n" local pattern=Cs(leading*(trailing+redundant+stripped+anything)^0) function strings.collapsecrlf(str) return lpegmatch(pattern,str) end local repeaters={} function strings.newrepeater(str,offset) offset=offset or 0 local s=repeaters[str] if not s then s={} repeaters[str]=s end local t=s[offset] if t then return t end t={} setmetatable(t,{ __index=function(t,k) if not k then return "" end local n=k+offset local s=n>0 and rep(str,n) or "" t[k]=s return s end }) s[offset]=t return t end local extra,tab,start=0,0,4,0 local nspaces=strings.newrepeater(" ") string.nspaces=nspaces local pattern=Carg(1)/function(t) extra,tab,start=0,t or 7,1 end*Cs(( Cp()*patterns.tab/function(position) local current=(position-start+1)+extra local spaces=tab-(current-1)%tab if spaces>0 then extra=extra+spaces-1 return nspaces[spaces] else return "" end end+patterns.newline*Cp()/function(position) extra,start=0,position end+patterns.anything )^1) function strings.tabtospace(str,tab) return lpegmatch(pattern,str,1,tab or 7) end local newline=patterns.newline local endofstring=patterns.endofstring local whitespace=patterns.whitespace local spacer=patterns.spacer local space=spacer^0 local nospace=space/"" local endofline=nospace*newline local stripend=(whitespace^1*endofstring)/"" local normalline=(nospace*((1-space*(newline+endofstring))^1)*nospace) local stripempty=endofline^1/"" local normalempty=endofline^1 local singleempty=endofline*(endofline^0/"") local doubleempty=endofline*endofline^-1*(endofline^0/"") local stripstart=stripempty^0 local p_prune_normal=Cs (stripstart*(stripend+normalline+normalempty )^0 ) local p_prune_collapse=Cs (stripstart*(stripend+normalline+doubleempty )^0 ) local p_prune_noempty=Cs (stripstart*(stripend+normalline+singleempty )^0 ) local p_retain_normal=Cs ((normalline+normalempty )^0 ) local p_retain_collapse=Cs ((normalline+doubleempty )^0 ) local p_retain_noempty=Cs ((normalline+singleempty )^0 ) local striplinepatterns={ ["prune"]=p_prune_normal, ["prune and collapse"]=p_prune_collapse, ["prune and no empty"]=p_prune_noempty, ["retain"]=p_retain_normal, ["retain and collapse"]=p_retain_collapse, ["retain and no empty"]=p_retain_noempty, ["collapse"]=patterns.collapser, } strings.striplinepatterns=striplinepatterns function strings.striplines(str,how) return str and lpegmatch(how and striplinepatterns[how] or p_prune_collapse,str) or str end strings.striplong=strings.striplines function strings.nice(str) str=gsub(str,"[:%-+_]+"," ") return str end local n=0 local sequenced=table.sequenced function string.autodouble(s,sep) if s==nil then return '""' end local t=type(s) if t=="number" then return tostring(s) end if t=="table" then return ('"'..sequenced(s,sep or ",")..'"') end return ('"'..tostring(s)..'"') end function string.autosingle(s,sep) if s==nil then return "''" end local t=type(s) if t=="number" then return tostring(s) end if t=="table" then return ("'"..sequenced(s,sep or ",").."'") end return ("'"..tostring(s).."'") end local tracedchars={} string.tracedchars=tracedchars strings.tracers=tracedchars function string.tracedchar(b) if type(b)=="number" then return tracedchars[b] or (utfchar(b).." (U+"..format('%05X',b)..")") else local c=utfbyte(b) return tracedchars[c] or (b.." (U+"..format('%05X',c)..")") end end function number.signed(i) if i>0 then return "+",i else return "-",-i end end local zero=P("0")^1/"" local plus=P("+")/"" local minus=P("-") local separator=S(".") local digit=R("09") local trailing=zero^1*#S("eE") local exponent=(S("eE")*(plus+Cs((minus*zero^0*P(-1))/"")+minus)*zero^0*(P(-1)*Cc("0")+P(1)^1)) local pattern_a=Cs(minus^0*digit^1*(separator/""*trailing+separator*(trailing+digit)^0)*exponent) local pattern_b=Cs((exponent+P(1))^0) function number.sparseexponent(f,n) if not n then n=f f="%e" end local tn=type(n) if tn=="string" then local m=tonumber(n) if m then return lpegmatch((f=="%e" or f=="%E") and pattern_a or pattern_b,format(f,m)) end elseif tn=="number" then return lpegmatch((f=="%e" or f=="%E") and pattern_a or pattern_b,format(f,n)) end return tostring(n) end local template=[[ %s %s return function(%s) return %s end ]] local preamble,environment="",{} if _LUAVERSION<5.2 then preamble=[[ local lpeg=lpeg local type=type local tostring=tostring local tonumber=tonumber local format=string.format local concat=table.concat local signed=number.signed local points=number.points local basepoints= number.basepoints local utfchar=utf.char local utfbyte=utf.byte local lpegmatch=lpeg.match local nspaces=string.nspaces local tracedchar=string.tracedchar local autosingle=string.autosingle local autodouble=string.autodouble local sequenced=table.sequenced local formattednumber=number.formatted local sparseexponent=number.sparseexponent ]] else environment={ global=global or _G, lpeg=lpeg, type=type, tostring=tostring, tonumber=tonumber, format=string.format, concat=table.concat, signed=number.signed, points=number.points, basepoints=number.basepoints, utfchar=utf.char, utfbyte=utf.byte, lpegmatch=lpeg.match, nspaces=string.nspaces, tracedchar=string.tracedchar, autosingle=string.autosingle, autodouble=string.autodouble, sequenced=table.sequenced, formattednumber=number.formatted, sparseexponent=number.sparseexponent, } end local arguments={ "a1" } setmetatable(arguments,{ __index=function(t,k) local v=t[k-1]..",a"..k t[k]=v return v end }) local prefix_any=C((S("+- .")+R("09"))^0) local prefix_tab=P("{")*C((1-P("}"))^0)*P("}")+C((1-R("az","AZ","09","%%"))^0) local format_s=function(f) n=n+1 if f and f~="" then return format("format('%%%ss',a%s)",f,n) else return format("(a%s or '')",n) end end local format_S=function(f) n=n+1 if f and f~="" then return format("format('%%%ss',tostring(a%s))",f,n) else return format("tostring(a%s)",n) end end local format_q=function() n=n+1 return format("(a%s and format('%%q',a%s) or '')",n,n) end local format_Q=function() n=n+1 return format("format('%%q',tostring(a%s))",n) end local format_i=function(f) n=n+1 if f and f~="" then return format("format('%%%si',a%s)",f,n) else return format("format('%%i',a%s)",n) end end local format_d=format_i local format_I=function(f) n=n+1 return format("format('%%s%%%si',signed(a%s))",f,n) end local format_f=function(f) n=n+1 return format("format('%%%sf',a%s)",f,n) end local format_F=function() n=n+1 if not f or f=="" then return format("(((a%s > -0.0000000005 and a%s < 0.0000000005) and '0') or format((a%s %% 1 == 0) and '%%i' or '%%.9f',a%s))",n,n,n,n) else return format("format((a%s %% 1 == 0) and '%%i' or '%%%sf',a%s)",n,f,n) end end local format_g=function(f) n=n+1 return format("format('%%%sg',a%s)",f,n) end local format_G=function(f) n=n+1 return format("format('%%%sG',a%s)",f,n) end local format_e=function(f) n=n+1 return format("format('%%%se',a%s)",f,n) end local format_E=function(f) n=n+1 return format("format('%%%sE',a%s)",f,n) end local format_j=function(f) n=n+1 return format("sparseexponent('%%%se',a%s)",f,n) end local format_J=function(f) n=n+1 return format("sparseexponent('%%%sE',a%s)",f,n) end local format_x=function(f) n=n+1 return format("format('%%%sx',a%s)",f,n) end local format_X=function(f) n=n+1 return format("format('%%%sX',a%s)",f,n) end local format_o=function(f) n=n+1 return format("format('%%%so',a%s)",f,n) end local format_c=function() n=n+1 return format("utfchar(a%s)",n) end local format_C=function() n=n+1 return format("tracedchar(a%s)",n) end local format_r=function(f) n=n+1 return format("format('%%%s.0f',a%s)",f,n) end local format_h=function(f) n=n+1 if f=="-" then f=sub(f,2) return format("format('%%%sx',type(a%s) == 'number' and a%s or utfbyte(a%s))",f=="" and "05" or f,n,n,n) else return format("format('0x%%%sx',type(a%s) == 'number' and a%s or utfbyte(a%s))",f=="" and "05" or f,n,n,n) end end local format_H=function(f) n=n+1 if f=="-" then f=sub(f,2) return format("format('%%%sX',type(a%s) == 'number' and a%s or utfbyte(a%s))",f=="" and "05" or f,n,n,n) else return format("format('0x%%%sX',type(a%s) == 'number' and a%s or utfbyte(a%s))",f=="" and "05" or f,n,n,n) end end local format_u=function(f) n=n+1 if f=="-" then f=sub(f,2) return format("format('%%%sx',type(a%s) == 'number' and a%s or utfbyte(a%s))",f=="" and "05" or f,n,n,n) else return format("format('u+%%%sx',type(a%s) == 'number' and a%s or utfbyte(a%s))",f=="" and "05" or f,n,n,n) end end local format_U=function(f) n=n+1 if f=="-" then f=sub(f,2) return format("format('%%%sX',type(a%s) == 'number' and a%s or utfbyte(a%s))",f=="" and "05" or f,n,n,n) else return format("format('U+%%%sX',type(a%s) == 'number' and a%s or utfbyte(a%s))",f=="" and "05" or f,n,n,n) end end local format_p=function() n=n+1 return format("points(a%s)",n) end local format_b=function() n=n+1 return format("basepoints(a%s)",n) end local format_t=function(f) n=n+1 if f and f~="" then return format("concat(a%s,%q)",n,f) else return format("concat(a%s)",n) end end local format_T=function(f) n=n+1 if f and f~="" then return format("sequenced(a%s,%q)",n,f) else return format("sequenced(a%s)",n) end end local format_l=function() n=n+1 return format("(a%s and 'true' or 'false')",n) end local format_L=function() n=n+1 return format("(a%s and 'TRUE' or 'FALSE')",n) end local format_N=function() n=n+1 return format("tostring(tonumber(a%s) or a%s)",n,n) end local format_a=function(f) n=n+1 if f and f~="" then return format("autosingle(a%s,%q)",n,f) else return format("autosingle(a%s)",n) end end local format_A=function(f) n=n+1 if f and f~="" then return format("autodouble(a%s,%q)",n,f) else return format("autodouble(a%s)",n) end end local format_w=function(f) n=n+1 f=tonumber(f) if f then return format("nspaces[%s+a%s]",f,n) else return format("nspaces[a%s]",n) end end local format_W=function(f) return format("nspaces[%s]",tonumber(f) or 0) end local digit=patterns.digit local period=patterns.period local three=digit*digit*digit local splitter=Cs ( (((1-(three^1*period))^1+C(three))*(Carg(1)*three)^1+C((1-period)^1))*(P(1)/""*Carg(2))*C(2) ) patterns.formattednumber=splitter function number.formatted(n,sep1,sep2) local s=type(s)=="string" and n or format("%0.2f",n) if sep1==true then return lpegmatch(splitter,s,1,".",",") elseif sep1=="." then return lpegmatch(splitter,s,1,sep1,sep2 or ",") elseif sep1=="," then return lpegmatch(splitter,s,1,sep1,sep2 or ".") else return lpegmatch(splitter,s,1,sep1 or ",",sep2 or ".") end end local format_m=function(f) n=n+1 if not f or f=="" then f="," end return format([[formattednumber(a%s,%q,".")]],n,f) end local format_M=function(f) n=n+1 if not f or f=="" then f="." end return format([[formattednumber(a%s,%q,",")]],n,f) end local format_z=function(f) n=n+(tonumber(f) or 1) return "''" end local format_rest=function(s) return format("%q",s) end local format_extension=function(extensions,f,name) local extension=extensions[name] or "tostring(%s)" local f=tonumber(f) or 1 if f==0 then return extension elseif f==1 then n=n+1 local a="a"..n return format(extension,a,a) elseif f<0 then local a="a"..(n+f+1) return format(extension,a,a) else local t={} for i=1,f do n=n+1 t[#t+1]="a"..n end return format(extension,unpack(t)) end end local builder=Cs { "start", start=( ( P("%")/""*( V("!") +V("s")+V("q")+V("i")+V("d")+V("f")+V("F")+V("g")+V("G")+V("e")+V("E")+V("x")+V("X")+V("o") +V("c")+V("C")+V("S") +V("Q") +V("N") +V("r")+V("h")+V("H")+V("u")+V("U")+V("p")+V("b")+V("t")+V("T")+V("l")+V("L")+V("I")+V("w") +V("W") +V("a") +V("A") +V("j")+V("J") +V("m")+V("M") +V("z") +V("*") )+V("*") )*(P(-1)+Carg(1)) )^0, ["s"]=(prefix_any*P("s"))/format_s, ["q"]=(prefix_any*P("q"))/format_q, ["i"]=(prefix_any*P("i"))/format_i, ["d"]=(prefix_any*P("d"))/format_d, ["f"]=(prefix_any*P("f"))/format_f, ["F"]=(prefix_any*P("F"))/format_F, ["g"]=(prefix_any*P("g"))/format_g, ["G"]=(prefix_any*P("G"))/format_G, ["e"]=(prefix_any*P("e"))/format_e, ["E"]=(prefix_any*P("E"))/format_E, ["x"]=(prefix_any*P("x"))/format_x, ["X"]=(prefix_any*P("X"))/format_X, ["o"]=(prefix_any*P("o"))/format_o, ["S"]=(prefix_any*P("S"))/format_S, ["Q"]=(prefix_any*P("Q"))/format_S, ["N"]=(prefix_any*P("N"))/format_N, ["c"]=(prefix_any*P("c"))/format_c, ["C"]=(prefix_any*P("C"))/format_C, ["r"]=(prefix_any*P("r"))/format_r, ["h"]=(prefix_any*P("h"))/format_h, ["H"]=(prefix_any*P("H"))/format_H, ["u"]=(prefix_any*P("u"))/format_u, ["U"]=(prefix_any*P("U"))/format_U, ["p"]=(prefix_any*P("p"))/format_p, ["b"]=(prefix_any*P("b"))/format_b, ["t"]=(prefix_tab*P("t"))/format_t, ["T"]=(prefix_tab*P("T"))/format_T, ["l"]=(prefix_any*P("l"))/format_l, ["L"]=(prefix_any*P("L"))/format_L, ["I"]=(prefix_any*P("I"))/format_I, ["w"]=(prefix_any*P("w"))/format_w, ["W"]=(prefix_any*P("W"))/format_W, ["j"]=(prefix_any*P("j"))/format_j, ["J"]=(prefix_any*P("J"))/format_J, ["m"]=(prefix_tab*P("m"))/format_m, ["M"]=(prefix_tab*P("M"))/format_M, ["z"]=(prefix_any*P("z"))/format_z, ["a"]=(prefix_any*P("a"))/format_a, ["A"]=(prefix_any*P("A"))/format_A, ["*"]=Cs(((1-P("%"))^1+P("%%")/"%%")^1)/format_rest, ["!"]=Carg(2)*prefix_any*P("!")*C((1-P("!"))^1)*P("!")/format_extension, } local direct=Cs ( P("%")*(S("+- .")+R("09"))^0*S("sqidfgGeExXo")*P(-1)/[[local format = string.format return function(str) return format("%0",str) end]] ) local function make(t,str) local f local p local p=lpegmatch(direct,str) if p then f=loadstripped(p)() else n=0 p=lpegmatch(builder,str,1,t._connector_,t._extensions_) if n>0 then p=format(template,preamble,t._preamble_,arguments[n],p) f=loadstripped(p,t._environment_)() else f=function() return str end end end t[str]=f return f end local function use(t,fmt,...) return t[fmt](...) end strings.formatters={} if _LUAVERSION<5.2 then function strings.formatters.new(noconcat) local t={ _type_="formatter",_connector_=noconcat and "," or "..",_extensions_={},_preamble_=preamble,_environment_={} } setmetatable(t,{ __index=make,__call=use }) return t end else function strings.formatters.new(noconcat) local e={} for k,v in next,environment do e[k]=v end local t={ _type_="formatter",_connector_=noconcat and "," or "..",_extensions_={},_preamble_="",_environment_=e } setmetatable(t,{ __index=make,__call=use }) return t end end local formatters=strings.formatters.new() string.formatters=formatters string.formatter=function(str,...) return formatters[str](...) end local function add(t,name,template,preamble) if type(t)=="table" and t._type_=="formatter" then t._extensions_[name]=template or "%s" if type(preamble)=="string" then t._preamble_=preamble.."\n"..t._preamble_ elseif type(preamble)=="table" then for k,v in next,preamble do t._environment_[k]=v end end end end strings.formatters.add=add patterns.xmlescape=Cs((P("<")/"&lt;"+P(">")/"&gt;"+P("&")/"&amp;"+P('"')/"&quot;"+P(1))^0) patterns.texescape=Cs((C(S("#$%\\{}"))/"\\%1"+P(1))^0) patterns.luaescape=Cs(((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0) patterns.luaquoted=Cs(Cc('"')*((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0*Cc('"')) if _LUAVERSION<5.2 then add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],"local xmlescape = lpeg.patterns.xmlescape") add(formatters,"tex",[[lpegmatch(texescape,%s)]],"local texescape = lpeg.patterns.texescape") add(formatters,"lua",[[lpegmatch(luaescape,%s)]],"local luaescape = lpeg.patterns.luaescape") else add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],{ xmlescape=lpeg.patterns.xmlescape }) add(formatters,"tex",[[lpegmatch(texescape,%s)]],{ texescape=lpeg.patterns.texescape }) add(formatters,"lua",[[lpegmatch(luaescape,%s)]],{ luaescape=lpeg.patterns.luaescape }) end local dquote=patterns.dquote local equote=patterns.escaped+dquote/'\\"'+1 local space=patterns.space local cquote=Cc('"') local pattern=Cs(dquote*(equote-P(-2))^0*dquote) +Cs(cquote*(equote-space)^0*space*equote^0*cquote) function string.optionalquoted(str) return lpegmatch(pattern,str) or str end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['luat-basics-gen']={ version=1.100, comment="companion to luatex-*.tex", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } if context then texio.write_nl("fatal error: this module is not for context") os.exit() end local dummyfunction=function() end local dummyreporter=function(c) return function(...) (texio.reporter or texio.write_nl)(c.." : "..string.formatters(...)) end end statistics={ register=dummyfunction, starttiming=dummyfunction, stoptiming=dummyfunction, elapsedtime=nil, } directives={ register=dummyfunction, enable=dummyfunction, disable=dummyfunction, } trackers={ register=dummyfunction, enable=dummyfunction, disable=dummyfunction, } experiments={ register=dummyfunction, enable=dummyfunction, disable=dummyfunction, } storage={ register=dummyfunction, shared={}, } logs={ new=dummyreporter, reporter=dummyreporter, messenger=dummyreporter, report=dummyfunction, } callbacks={ register=function(n,f) return callback.register(n,f) end, } utilities={ storage={ allocate=function(t) return t or {} end, mark=function(t) return t or {} end, }, } characters=characters or { data={} } texconfig.kpse_init=true resolvers=resolvers or {} local remapper={ otf="opentype fonts", ttf="truetype fonts", ttc="truetype fonts", dfont="truetype fonts", cid="cid maps", cidmap="cid maps", fea="font feature files", pfa="type1 fonts", pfb="type1 fonts", afm="afm", } function resolvers.findfile(name,fileformat) name=string.gsub(name,"\\","/") if not fileformat or fileformat=="" then fileformat=file.suffix(name) if fileformat=="" then fileformat="tex" end end fileformat=string.lower(fileformat) fileformat=remapper[fileformat] or fileformat local found=kpse.find_file(name,fileformat) if not found or found=="" then found=kpse.find_file(name,"other text files") end return found end resolvers.findbinfile=resolvers.findfile function resolvers.loadbinfile(filename,filetype) local data=io.loaddata(filename) return true,data,#data end function resolvers.resolve(s) return s end function resolvers.unresolve(s) return s end caches={} local writable=nil local readables={} local usingjit=jit if not caches.namespace or caches.namespace=="" or caches.namespace=="context" then caches.namespace='generic' end do local cachepaths=kpse.expand_var('$TEXMFCACHE') or "" if cachepaths=="" or cachepaths=="$TEXMFCACHE" then cachepaths=kpse.expand_var('$TEXMFVAR') or "" end if cachepaths=="" or cachepaths=="$TEXMFVAR" then cachepaths=kpse.expand_var('$VARTEXMF') or "" end if cachepaths=="" then local fallbacks={ "TMPDIR","TEMPDIR","TMP","TEMP","HOME","HOMEPATH" } for i=1,#fallbacks do cachepaths=os.getenv(fallbacks[i]) or "" if cachepath~="" and lfs.isdir(cachepath) then break end end end if cachepaths=="" then cachepaths="." end cachepaths=string.split(cachepaths,os.type=="windows" and ";" or ":") for i=1,#cachepaths do local cachepath=cachepaths[i] if not lfs.isdir(cachepath) then lfs.mkdirs(cachepath) if lfs.isdir(cachepath) then texio.write(string.format("(created cache path: %s)",cachepath)) end end if file.is_writable(cachepath) then writable=file.join(cachepath,"luatex-cache") lfs.mkdir(writable) writable=file.join(writable,caches.namespace) lfs.mkdir(writable) break end end for i=1,#cachepaths do if file.is_readable(cachepaths[i]) then readables[#readables+1]=file.join(cachepaths[i],"luatex-cache",caches.namespace) end end if not writable then texio.write_nl("quiting: fix your writable cache path") os.exit() elseif #readables==0 then texio.write_nl("quiting: fix your readable cache path") os.exit() elseif #readables==1 and readables[1]==writable then texio.write(string.format("(using cache: %s)",writable)) else texio.write(string.format("(using write cache: %s)",writable)) texio.write(string.format("(using read cache: %s)",table.concat(readables," "))) end end function caches.getwritablepath(category,subcategory) local path=file.join(writable,category) lfs.mkdir(path) path=file.join(path,subcategory) lfs.mkdir(path) return path end function caches.getreadablepaths(category,subcategory) local t={} for i=1,#readables do t[i]=file.join(readables[i],category,subcategory) end return t end local function makefullname(path,name) if path and path~="" then return file.addsuffix(file.join(path,name),"lua"),file.addsuffix(file.join(path,name),usingjit and "lub" or "luc") end end function caches.is_writable(path,name) local fullname=makefullname(path,name) return fullname and file.is_writable(fullname) end function caches.loaddata(paths,name) for i=1,#paths do local data=false local luaname,lucname=makefullname(paths[i],name) if lucname and not lfs.isfile(lucname) and type(caches.compile)=="function" then texio.write(string.format("(compiling luc: %s)",lucname)) data=loadfile(luaname) if data then data=data() end if data then caches.compile(data,luaname,lucname) return data end end if lucname and lfs.isfile(lucname) then texio.write(string.format("(load luc: %s)",lucname)) data=loadfile(lucname) if data then data=data() end if data then return data else texio.write(string.format("(loading failed: %s)",lucname)) end end if luaname and lfs.isfile(luaname) then texio.write(string.format("(load lua: %s)",luaname)) data=loadfile(luaname) if data then data=data() end if data then return data end end end end function caches.savedata(path,name,data) local luaname,lucname=makefullname(path,name) if luaname then texio.write(string.format("(save: %s)",luaname)) table.tofile(luaname,data,true) if lucname and type(caches.compile)=="function" then os.remove(lucname) texio.write(string.format("(save: %s)",lucname)) caches.compile(data,luaname,lucname) end end end function caches.compile(data,luaname,lucname) local d=io.loaddata(luaname) if not d or d=="" then d=table.serialize(data,true) end if d and d~="" then local f=io.open(lucname,'wb') if f then local s=loadstring(d) if s then f:write(string.dump(s,true)) end f:close() end end end function table.setmetatableindex(t,f) setmetatable(t,{ __index=f }) end arguments={} if arg then for i=1,#arg do local k,v=string.match(arg[i],"^%-%-([^=]+)=?(.-)$") if k and v then arguments[k]=v end end end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['data-con']={ version=1.100, comment="companion to luat-lib.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local format,lower,gsub=string.format,string.lower,string.gsub local trace_cache=false trackers.register("resolvers.cache",function(v) trace_cache=v end) local trace_containers=false trackers.register("resolvers.containers",function(v) trace_containers=v end) local trace_storage=false trackers.register("resolvers.storage",function(v) trace_storage=v end) containers=containers or {} local containers=containers containers.usecache=true local report_containers=logs.reporter("resolvers","containers") local allocated={} local mt={ __index=function(t,k) if k=="writable" then local writable=caches.getwritablepath(t.category,t.subcategory) or { "." } t.writable=writable return writable elseif k=="readables" then local readables=caches.getreadablepaths(t.category,t.subcategory) or { "." } t.readables=readables return readables end end, __storage__=true } function containers.define(category,subcategory,version,enabled) if category and subcategory then local c=allocated[category] if not c then c={} allocated[category]=c end local s=c[subcategory] if not s then s={ category=category, subcategory=subcategory, storage={}, enabled=enabled, version=version or math.pi, trace=false, } setmetatable(s,mt) c[subcategory]=s end return s end end function containers.is_usable(container,name) return container.enabled and caches and caches.is_writable(container.writable,name) end function containers.is_valid(container,name) if name and name~="" then local storage=container.storage[name] return storage and storage.cache_version==container.version else return false end end function containers.read(container,name) local storage=container.storage local stored=storage[name] if not stored and container.enabled and caches and containers.usecache then stored=caches.loaddata(container.readables,name) if stored and stored.cache_version==container.version then if trace_cache or trace_containers then report_containers("action %a, category %a, name %a","load",container.subcategory,name) end else stored=nil end storage[name]=stored elseif stored then if trace_cache or trace_containers then report_containers("action %a, category %a, name %a","reuse",container.subcategory,name) end end return stored end function containers.write(container,name,data) if data then data.cache_version=container.version if container.enabled and caches then local unique,shared=data.unique,data.shared data.unique,data.shared=nil,nil caches.savedata(container.writable,name,data) if trace_cache or trace_containers then report_containers("action %a, category %a, name %a","save",container.subcategory,name) end data.unique,data.shared=unique,shared end if trace_cache or trace_containers then report_containers("action %a, category %a, name %a","store",container.subcategory,name) end container.storage[name]=data end return data end function containers.content(container,name) return container.storage[name] end function containers.cleanname(name) return (gsub(lower(name),"[^%w\128-\255]+","-")) end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['luatex-fonts-nod']={ version=1.001, comment="companion to luatex-fonts.lua", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } if context then texio.write_nl("fatal error: this module is not for context") os.exit() end if tex.attribute[0]~=0 then texio.write_nl("log","!") texio.write_nl("log","! Attribute 0 is reserved for ConTeXt's font feature management and has to be") texio.write_nl("log","! set to zero. Also, some attributes in the range 1-255 are used for special") texio.write_nl("log","! purposes so setting them at the TeX end might break the font handler.") texio.write_nl("log","!") tex.attribute[0]=0 end attributes=attributes or {} attributes.unsetvalue=-0x7FFFFFFF local numbers,last={},127 attributes.private=attributes.private or function(name) local number=numbers[name] if not number then if last<255 then last=last+1 end number=last numbers[name]=number end return number end nodes={} nodes.pool={} nodes.handlers={} local nodecodes={} for k,v in next,node.types () do nodecodes[string.gsub(v,"_","")]=k end local whatcodes={} for k,v in next,node.whatsits() do whatcodes[string.gsub(v,"_","")]=k end local glyphcodes={ [0]="character","glyph","ligature","ghost","left","right" } local disccodes={ [0]="discretionary","explicit","automatic","regular","first","second" } nodes.nodecodes=nodecodes nodes.whatcodes=whatcodes nodes.whatsitcodes=whatcodes nodes.glyphcodes=glyphcodes nodes.disccodes=disccodes local free_node=node.free local remove_node=node.remove local new_node=node.new local traverse_id=node.traverse_id nodes.handlers.protectglyphs=node.protect_glyphs nodes.handlers.unprotectglyphs=node.unprotect_glyphs local math_code=nodecodes.math local end_of_math=node.end_of_math function node.end_of_math(n) if n.id==math_code and n.subtype==1 then return n else return end_of_math(n) end end function nodes.remove(head,current,free_too) local t=current head,current=remove_node(head,current) if t then if free_too then free_node(t) t=nil else t.next,t.prev=nil,nil end end return head,current,t end function nodes.delete(head,current) return nodes.remove(head,current,true) end function nodes.pool.kern(k) local n=new_node("kern",1) n.kern=k return n end local getfield=node.getfield or function(n,tag) return n[tag] end local setfield=node.setfield or function(n,tag,value) n[tag]=value end nodes.getfield=getfield nodes.setfield=setfield nodes.getattr=getfield nodes.setattr=setfield if node.getid then nodes.getid=node.getid else function nodes.getid (n) return getfield(n,"id") end end if node.getsubtype then nodes.getsubtype=node.getsubtype else function nodes.getsubtype(n) return getfield(n,"subtype") end end if node.getnext then nodes.getnext=node.getnext else function nodes.getnext (n) return getfield(n,"next") end end if node.getprev then nodes.getprev=node.getprev else function nodes.getprev (n) return getfield(n,"prev") end end if node.getchar then nodes.getchar=node.getchar else function nodes.getchar (n) return getfield(n,"char") end end if node.getfont then nodes.getfont=node.getfont else function nodes.getfont (n) return getfield(n,"font") end end if node.getlist then nodes.getlist=node.getlist else function nodes.getlist (n) return getfield(n,"list") end end function nodes.tonut (n) return n end function nodes.tonode(n) return n end nodes.tostring=node.tostring or tostring nodes.copy=node.copy nodes.copy_list=node.copy_list nodes.delete=node.delete nodes.dimensions=node.dimensions nodes.end_of_math=node.end_of_math nodes.flush_list=node.flush_list nodes.flush_node=node.flush_node nodes.free=node.free nodes.insert_after=node.insert_after nodes.insert_before=node.insert_before nodes.hpack=node.hpack nodes.new=node.new nodes.tail=node.tail nodes.traverse=node.traverse nodes.traverse_id=node.traverse_id nodes.slide=node.slide nodes.vpack=node.vpack nodes.first_glyph=node.first_glyph nodes.first_character=node.first_character nodes.has_glyph=node.has_glyph or node.first_glyph nodes.current_attr=node.current_attr nodes.do_ligature_n=node.do_ligature_n nodes.has_field=node.has_field nodes.last_node=node.last_node nodes.usedlist=node.usedlist nodes.protrusion_skippable=node.protrusion_skippable nodes.write=node.write nodes.has_attribute=node.has_attribute nodes.set_attribute=node.set_attribute nodes.unset_attribute=node.unset_attribute nodes.protect_glyphs=node.protect_glyphs nodes.unprotect_glyphs=node.unprotect_glyphs nodes.kerning=node.kerning nodes.ligaturing=node.ligaturing nodes.mlist_to_hlist=node.mlist_to_hlist nodes.nuts=nodes end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['font-ini']={ version=1.001, comment="companion to font-ini.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local allocate=utilities.storage.allocate local report_defining=logs.reporter("fonts","defining") fonts=fonts or {} local fonts=fonts fonts.hashes={ identifiers=allocate() } fonts.tables=fonts.tables or {} fonts.helpers=fonts.helpers or {} fonts.tracers=fonts.tracers or {} fonts.specifiers=fonts.specifiers or {} fonts.analyzers={} fonts.readers={} fonts.definers={ methods={} } fonts.loggers={ register=function() end } fontloader.totable=fontloader.to_table end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['font-con']={ version=1.001, comment="companion to font-ini.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local next,tostring,rawget=next,tostring,rawget local format,match,lower,gsub=string.format,string.match,string.lower,string.gsub local utfbyte=utf.byte local sort,insert,concat,sortedkeys,serialize,fastcopy=table.sort,table.insert,table.concat,table.sortedkeys,table.serialize,table.fastcopy local derivetable=table.derive local trace_defining=false trackers.register("fonts.defining",function(v) trace_defining=v end) local trace_scaling=false trackers.register("fonts.scaling",function(v) trace_scaling=v end) local report_defining=logs.reporter("fonts","defining") local fonts=fonts local constructors=fonts.constructors or {} fonts.constructors=constructors local handlers=fonts.handlers or {} fonts.handlers=handlers local allocate=utilities.storage.allocate local setmetatableindex=table.setmetatableindex constructors.dontembed=allocate() constructors.autocleanup=true constructors.namemode="fullpath" constructors.version=1.01 constructors.cache=containers.define("fonts","constructors",constructors.version,false) constructors.privateoffset=0xF0000 constructors.keys={ properties={ encodingbytes="number", embedding="number", cidinfo={}, format="string", fontname="string", fullname="string", filename="filename", psname="string", name="string", virtualized="boolean", hasitalics="boolean", autoitalicamount="basepoints", nostackmath="boolean", noglyphnames="boolean", mode="string", hasmath="boolean", mathitalics="boolean", textitalics="boolean", finalized="boolean", }, parameters={ mathsize="number", scriptpercentage="float", scriptscriptpercentage="float", units="cardinal", designsize="scaledpoints", expansion={ stretch="integerscale", shrink="integerscale", step="integerscale", auto="boolean", }, protrusion={ auto="boolean", }, slantfactor="float", extendfactor="float", factor="float", hfactor="float", vfactor="float", size="scaledpoints", units="scaledpoints", scaledpoints="scaledpoints", slantperpoint="scaledpoints", spacing={ width="scaledpoints", stretch="scaledpoints", shrink="scaledpoints", extra="scaledpoints", }, xheight="scaledpoints", quad="scaledpoints", ascender="scaledpoints", descender="scaledpoints", synonyms={ space="spacing.width", spacestretch="spacing.stretch", spaceshrink="spacing.shrink", extraspace="spacing.extra", x_height="xheight", space_stretch="spacing.stretch", space_shrink="spacing.shrink", extra_space="spacing.extra", em="quad", ex="xheight", slant="slantperpoint", }, }, description={ width="basepoints", height="basepoints", depth="basepoints", boundingbox={}, }, character={ width="scaledpoints", height="scaledpoints", depth="scaledpoints", italic="scaledpoints", }, } local designsizes=allocate() constructors.designsizes=designsizes local loadedfonts=allocate() constructors.loadedfonts=loadedfonts local factors={ pt=65536.0, bp=65781.8, } function constructors.setfactor(f) constructors.factor=factors[f or 'pt'] or factors.pt end constructors.setfactor() function constructors.scaled(scaledpoints,designsize) if scaledpoints<0 then if designsize then local factor=constructors.factor if designsize>factor then return (- scaledpoints/1000)*designsize else return (- scaledpoints/1000)*designsize*factor end else return (- scaledpoints/1000)*10*factor end else return scaledpoints end end function constructors.cleanuptable(tfmdata) if constructors.autocleanup and tfmdata.properties.virtualized then for k,v in next,tfmdata.characters do if v.commands then v.commands=nil end end end end function constructors.calculatescale(tfmdata,scaledpoints) local parameters=tfmdata.parameters if scaledpoints<0 then scaledpoints=(- scaledpoints/1000)*(tfmdata.designsize or parameters.designsize) end return scaledpoints,scaledpoints/(parameters.units or 1000) end local unscaled={ ScriptPercentScaleDown=true, ScriptScriptPercentScaleDown=true, RadicalDegreeBottomRaisePercent=true } function constructors.assignmathparameters(target,original) local mathparameters=original.mathparameters if mathparameters and next(mathparameters) then local targetparameters=target.parameters local targetproperties=target.properties local targetmathparameters={} local factor=targetproperties.math_is_scaled and 1 or targetparameters.factor for name,value in next,mathparameters do if unscaled[name] then targetmathparameters[name]=value else targetmathparameters[name]=value*factor end end if not targetmathparameters.FractionDelimiterSize then targetmathparameters.FractionDelimiterSize=1.01*targetparameters.size end if not mathparameters.FractionDelimiterDisplayStyleSize then targetmathparameters.FractionDelimiterDisplayStyleSize=2.40*targetparameters.size end target.mathparameters=targetmathparameters end end function constructors.beforecopyingcharacters(target,original) end function constructors.aftercopyingcharacters(target,original) end constructors.sharefonts=false constructors.nofsharedfonts=0 local sharednames={} function constructors.trytosharefont(target,tfmdata) if constructors.sharefonts then local characters=target.characters local n=1 local t={ target.psname } local u=sortedkeys(characters) for i=1,#u do local k=u[i] n=n+1;t[n]=k n=n+1;t[n]=characters[k].index or k end local h=md5.HEX(concat(t," ")) local s=sharednames[h] if s then if trace_defining then report_defining("font %a uses backend resources of font %a",target.fullname,s) end target.fullname=s constructors.nofsharedfonts=constructors.nofsharedfonts+1 target.properties.sharedwith=s else sharednames[h]=target.fullname end end end function constructors.enhanceparameters(parameters) local xheight=parameters.x_height local quad=parameters.quad local space=parameters.space local stretch=parameters.space_stretch local shrink=parameters.space_shrink local extra=parameters.extra_space local slant=parameters.slant parameters.xheight=xheight parameters.spacestretch=stretch parameters.spaceshrink=shrink parameters.extraspace=extra parameters.em=quad parameters.ex=xheight parameters.slantperpoint=slant parameters.spacing={ width=space, stretch=stretch, shrink=shrink, extra=extra, } end function constructors.scale(tfmdata,specification) local target={} if tonumber(specification) then specification={ size=specification } end target.specification=specification local scaledpoints=specification.size local relativeid=specification.relativeid local properties=tfmdata.properties or {} local goodies=tfmdata.goodies or {} local resources=tfmdata.resources or {} local descriptions=tfmdata.descriptions or {} local characters=tfmdata.characters or {} local changed=tfmdata.changed or {} local shared=tfmdata.shared or {} local parameters=tfmdata.parameters or {} local mathparameters=tfmdata.mathparameters or {} local targetcharacters={} local targetdescriptions=derivetable(descriptions) local targetparameters=derivetable(parameters) local targetproperties=derivetable(properties) local targetgoodies=goodies target.characters=targetcharacters target.descriptions=targetdescriptions target.parameters=targetparameters target.properties=targetproperties target.goodies=targetgoodies target.shared=shared target.resources=resources target.unscaled=tfmdata local mathsize=tonumber(specification.mathsize) or 0 local textsize=tonumber(specification.textsize) or scaledpoints local forcedsize=tonumber(parameters.mathsize ) or 0 local extrafactor=tonumber(specification.factor ) or 1 if (mathsize==2 or forcedsize==2) and parameters.scriptpercentage then scaledpoints=parameters.scriptpercentage*textsize/100 elseif (mathsize==3 or forcedsize==3) and parameters.scriptscriptpercentage then scaledpoints=parameters.scriptscriptpercentage*textsize/100 elseif forcedsize>1000 then scaledpoints=forcedsize end targetparameters.mathsize=mathsize targetparameters.textsize=textsize targetparameters.forcedsize=forcedsize targetparameters.extrafactor=extrafactor local tounicode=resources.tounicode local defaultwidth=resources.defaultwidth or 0 local defaultheight=resources.defaultheight or 0 local defaultdepth=resources.defaultdepth or 0 local units=parameters.units or 1000 if target.fonts then target.fonts=fastcopy(target.fonts) end targetproperties.language=properties.language or "dflt" targetproperties.script=properties.script or "dflt" targetproperties.mode=properties.mode or "base" local askedscaledpoints=scaledpoints local scaledpoints,delta=constructors.calculatescale(tfmdata,scaledpoints,nil,specification) local hdelta=delta local vdelta=delta target.designsize=parameters.designsize target.units_per_em=units local direction=properties.direction or tfmdata.direction or 0 target.direction=direction properties.direction=direction target.size=scaledpoints target.encodingbytes=properties.encodingbytes or 1 target.embedding=properties.embedding or "subset" target.tounicode=1 target.cidinfo=properties.cidinfo target.format=properties.format local fontname=properties.fontname or tfmdata.fontname local fullname=properties.fullname or tfmdata.fullname local filename=properties.filename or tfmdata.filename local psname=properties.psname or tfmdata.psname local name=properties.name or tfmdata.name if not psname or psname=="" then psname=fontname or (fullname and fonts.names.cleanname(fullname)) end target.fontname=fontname target.fullname=fullname target.filename=filename target.psname=psname target.name=name properties.fontname=fontname properties.fullname=fullname properties.filename=filename properties.psname=psname properties.name=name local expansion=parameters.expansion if expansion then target.stretch=expansion.stretch target.shrink=expansion.shrink target.step=expansion.step target.auto_expand=expansion.auto end local protrusion=parameters.protrusion if protrusion then target.auto_protrude=protrusion.auto end local extendfactor=parameters.extendfactor or 0 if extendfactor~=0 and extendfactor~=1 then hdelta=hdelta*extendfactor target.extend=extendfactor*1000 else target.extend=1000 end local slantfactor=parameters.slantfactor or 0 if slantfactor~=0 then target.slant=slantfactor*1000 else target.slant=0 end targetparameters.factor=delta targetparameters.hfactor=hdelta targetparameters.vfactor=vdelta targetparameters.size=scaledpoints targetparameters.units=units targetparameters.scaledpoints=askedscaledpoints local isvirtual=properties.virtualized or tfmdata.type=="virtual" local hasquality=target.auto_expand or target.auto_protrude local hasitalics=properties.hasitalics local autoitalicamount=properties.autoitalicamount local stackmath=not properties.nostackmath local nonames=properties.noglyphnames local nodemode=properties.mode=="node" if changed and not next(changed) then changed=false end target.type=isvirtual and "virtual" or "real" target.postprocessors=tfmdata.postprocessors local targetslant=(parameters.slant or parameters[1] or 0)*factors.pt local targetspace=(parameters.space or parameters[2] or 0)*hdelta local targetspace_stretch=(parameters.space_stretch or parameters[3] or 0)*hdelta local targetspace_shrink=(parameters.space_shrink or parameters[4] or 0)*hdelta local targetx_height=(parameters.x_height or parameters[5] or 0)*vdelta local targetquad=(parameters.quad or parameters[6] or 0)*hdelta local targetextra_space=(parameters.extra_space or parameters[7] or 0)*hdelta targetparameters.slant=targetslant targetparameters.space=targetspace targetparameters.space_stretch=targetspace_stretch targetparameters.space_shrink=targetspace_shrink targetparameters.x_height=targetx_height targetparameters.quad=targetquad targetparameters.extra_space=targetextra_space local ascender=parameters.ascender if ascender then targetparameters.ascender=delta*ascender end local descender=parameters.descender if descender then targetparameters.descender=delta*descender end constructors.enhanceparameters(targetparameters) local protrusionfactor=(targetquad~=0 and 1000/targetquad) or 0 local scaledwidth=defaultwidth*hdelta local scaledheight=defaultheight*vdelta local scaleddepth=defaultdepth*vdelta local hasmath=(properties.hasmath or next(mathparameters)) and true if hasmath then constructors.assignmathparameters(target,tfmdata) properties.hasmath=true target.nomath=false target.MathConstants=target.mathparameters else properties.hasmath=false target.nomath=true target.mathparameters=nil end local italickey="italic" local useitalics=true if hasmath then autoitalicamount=false elseif properties.textitalics then italickey="italic_correction" useitalics=false if properties.delaytextitalics then autoitalicamount=false end end if trace_defining then report_defining("defining tfm, name %a, fullname %a, filename %a, hscale %a, vscale %a, math %a, italics %a", name,fullname,filename,hdelta,vdelta, hasmath and "enabled" or "disabled",useitalics and "enabled" or "disabled") end constructors.beforecopyingcharacters(target,tfmdata) local sharedkerns={} for unicode,character in next,characters do local chr,description,index,touni if changed then local c=changed[unicode] if c then local ligatures=character.ligatures description=descriptions[c] or descriptions[unicode] or character character=characters[c] or character index=description.index or c if tounicode then touni=tounicode[index] if not touni then local d=descriptions[unicode] or characters[unicode] local i=d.index or unicode touni=tounicode[i] end end if ligatures and not character.ligatures then character.ligatures=ligatures end else description=descriptions[unicode] or character index=description.index or unicode if tounicode then touni=tounicode[index] end end else description=descriptions[unicode] or character index=description.index or unicode if tounicode then touni=tounicode[index] end end local width=description.width local height=description.height local depth=description.depth if width then width=hdelta*width else width=scaledwidth end if height then height=vdelta*height else height=scaledheight end if depth and depth~=0 then depth=delta*depth if nonames then chr={ index=index, height=height, depth=depth, width=width, } else chr={ name=description.name, index=index, height=height, depth=depth, width=width, } end else if nonames then chr={ index=index, height=height, width=width, } else chr={ name=description.name, index=index, height=height, width=width, } end end if touni then chr.tounicode=touni end if hasquality then local ve=character.expansion_factor if ve then chr.expansion_factor=ve*1000 end local vl=character.left_protruding if vl then chr.left_protruding=protrusionfactor*width*vl end local vr=character.right_protruding if vr then chr.right_protruding=protrusionfactor*width*vr end end if autoitalicamount then local vi=description.italic if not vi then local vi=description.boundingbox[3]-description.width+autoitalicamount if vi>0 then chr[italickey]=vi*hdelta end elseif vi~=0 then chr[italickey]=vi*hdelta end elseif hasitalics then local vi=description.italic if vi and vi~=0 then chr[italickey]=vi*hdelta end end if hasmath then local vn=character.next if vn then chr.next=vn else local vv=character.vert_variants if vv then local t={} for i=1,#vv do local vvi=vv[i] t[i]={ ["start"]=(vvi["start"] or 0)*vdelta, ["end"]=(vvi["end"] or 0)*vdelta, ["advance"]=(vvi["advance"] or 0)*vdelta, ["extender"]=vvi["extender"], ["glyph"]=vvi["glyph"], } end chr.vert_variants=t else local hv=character.horiz_variants if hv then local t={} for i=1,#hv do local hvi=hv[i] t[i]={ ["start"]=(hvi["start"] or 0)*hdelta, ["end"]=(hvi["end"] or 0)*hdelta, ["advance"]=(hvi["advance"] or 0)*hdelta, ["extender"]=hvi["extender"], ["glyph"]=hvi["glyph"], } end chr.horiz_variants=t end end end local va=character.top_accent if va then chr.top_accent=vdelta*va end if stackmath then local mk=character.mathkerns if mk then local kerns={} local v=mk.top_right if v then local k={} for i=1,#v do local vi=v[i] k[i]={ height=vdelta*vi.height,kern=vdelta*vi.kern } end kerns.top_right=k end local v=mk.top_left if v then local k={} for i=1,#v do local vi=v[i] k[i]={ height=vdelta*vi.height,kern=vdelta*vi.kern } end kerns.top_left=k end local v=mk.bottom_left if v then local k={} for i=1,#v do local vi=v[i] k[i]={ height=vdelta*vi.height,kern=vdelta*vi.kern } end kerns.bottom_left=k end local v=mk.bottom_right if v then local k={} for i=1,#v do local vi=v[i] k[i]={ height=vdelta*vi.height,kern=vdelta*vi.kern } end kerns.bottom_right=k end chr.mathkern=kerns end end end if not nodemode then local vk=character.kerns if vk then local s=sharedkerns[vk] if not s then s={} for k,v in next,vk do s[k]=v*hdelta end sharedkerns[vk]=s end chr.kerns=s end local vl=character.ligatures if vl then if true then chr.ligatures=vl else local tt={} for i,l in next,vl do tt[i]=l end chr.ligatures=tt end end end if isvirtual then local vc=character.commands if vc then local ok=false for i=1,#vc do local key=vc[i][1] if key=="right" or key=="down" then ok=true break end end if ok then local tt={} for i=1,#vc do local ivc=vc[i] local key=ivc[1] if key=="right" then tt[i]={ key,ivc[2]*hdelta } elseif key=="down" then tt[i]={ key,ivc[2]*vdelta } elseif key=="rule" then tt[i]={ key,ivc[2]*vdelta,ivc[3]*hdelta } else tt[i]=ivc end end chr.commands=tt else chr.commands=vc end chr.index=nil end end targetcharacters[unicode]=chr end constructors.aftercopyingcharacters(target,tfmdata) constructors.trytosharefont(target,tfmdata) return target end function constructors.finalize(tfmdata) if tfmdata.properties and tfmdata.properties.finalized then return end if not tfmdata.characters then return nil end if not tfmdata.goodies then tfmdata.goodies={} end local parameters=tfmdata.parameters if not parameters then return nil end if not parameters.expansion then parameters.expansion={ stretch=tfmdata.stretch or 0, shrink=tfmdata.shrink or 0, step=tfmdata.step or 0, auto=tfmdata.auto_expand or false, } end if not parameters.protrusion then parameters.protrusion={ auto=auto_protrude } end if not parameters.size then parameters.size=tfmdata.size end if not parameters.extendfactor then parameters.extendfactor=tfmdata.extend or 0 end if not parameters.slantfactor then parameters.slantfactor=tfmdata.slant or 0 end if not parameters.designsize then parameters.designsize=tfmdata.designsize or (factors.pt*10) end if not parameters.units then parameters.units=tfmdata.units_per_em or 1000 end if not tfmdata.descriptions then local descriptions={} setmetatableindex(descriptions,function(t,k) local v={} t[k]=v return v end) tfmdata.descriptions=descriptions end local properties=tfmdata.properties if not properties then properties={} tfmdata.properties=properties end if not properties.virtualized then properties.virtualized=tfmdata.type=="virtual" end if not tfmdata.properties then tfmdata.properties={ fontname=tfmdata.fontname, filename=tfmdata.filename, fullname=tfmdata.fullname, name=tfmdata.name, psname=tfmdata.psname, encodingbytes=tfmdata.encodingbytes or 1, embedding=tfmdata.embedding or "subset", tounicode=tfmdata.tounicode or 1, cidinfo=tfmdata.cidinfo or nil, format=tfmdata.format or "type1", direction=tfmdata.direction or 0, } end if not tfmdata.resources then tfmdata.resources={} end if not tfmdata.shared then tfmdata.shared={} end if not properties.hasmath then properties.hasmath=not tfmdata.nomath end tfmdata.MathConstants=nil tfmdata.postprocessors=nil tfmdata.fontname=nil tfmdata.filename=nil tfmdata.fullname=nil tfmdata.name=nil tfmdata.psname=nil tfmdata.encodingbytes=nil tfmdata.embedding=nil tfmdata.tounicode=nil tfmdata.cidinfo=nil tfmdata.format=nil tfmdata.direction=nil tfmdata.type=nil tfmdata.nomath=nil tfmdata.designsize=nil tfmdata.size=nil tfmdata.stretch=nil tfmdata.shrink=nil tfmdata.step=nil tfmdata.auto_expand=nil tfmdata.auto_protrude=nil tfmdata.extend=nil tfmdata.slant=nil tfmdata.units_per_em=nil properties.finalized=true return tfmdata end local hashmethods={} constructors.hashmethods=hashmethods function constructors.hashfeatures(specification) local features=specification.features if features then local t,tn={},0 for category,list in next,features do if next(list) then local hasher=hashmethods[category] if hasher then local hash=hasher(list) if hash then tn=tn+1 t[tn]=category..":"..hash end end end end if tn>0 then return concat(t," & ") end end return "unknown" end hashmethods.normal=function(list) local s={} local n=0 for k,v in next,list do if not k then elseif k=="number" or k=="features" then else n=n+1 s[n]=k end end if n>0 then sort(s) for i=1,n do local k=s[i] s[i]=k..'='..tostring(list[k]) end return concat(s,"+") end end function constructors.hashinstance(specification,force) local hash,size,fallbacks=specification.hash,specification.size,specification.fallbacks if force or not hash then hash=constructors.hashfeatures(specification) specification.hash=hash end if size<1000 and designsizes[hash] then size=math.round(constructors.scaled(size,designsizes[hash])) specification.size=size end if fallbacks then return hash..' @ '..tostring(size)..' @ '..fallbacks else return hash..' @ '..tostring(size) end end function constructors.setname(tfmdata,specification) if constructors.namemode=="specification" then local specname=specification.specification if specname then tfmdata.properties.name=specname if trace_defining then report_otf("overloaded fontname %a",specname) end end end end function constructors.checkedfilename(data) local foundfilename=data.foundfilename if not foundfilename then local askedfilename=data.filename or "" if askedfilename~="" then askedfilename=resolvers.resolve(askedfilename) foundfilename=resolvers.findbinfile(askedfilename,"") or "" if foundfilename=="" then report_defining("source file %a is not found",askedfilename) foundfilename=resolvers.findbinfile(file.basename(askedfilename),"") or "" if foundfilename~="" then report_defining("using source file %a due to cache mismatch",foundfilename) end end end data.foundfilename=foundfilename end return foundfilename end local formats=allocate() fonts.formats=formats setmetatableindex(formats,function(t,k) local l=lower(k) if rawget(t,k) then t[k]=l return l end return rawget(t,file.suffix(l)) end) local locations={} local function setindeed(mode,target,group,name,action,position) local t=target[mode] if not t then report_defining("fatal error in setting feature %a, group %a, mode %a",name,group,mode) os.exit() elseif position then insert(t,position,{ name=name,action=action }) else for i=1,#t do local ti=t[i] if ti.name==name then ti.action=action return end end insert(t,{ name=name,action=action }) end end local function set(group,name,target,source) target=target[group] if not target then report_defining("fatal target error in setting feature %a, group %a",name,group) os.exit() end local source=source[group] if not source then report_defining("fatal source error in setting feature %a, group %a",name,group) os.exit() end local node=source.node local base=source.base local position=source.position if node then setindeed("node",target,group,name,node,position) end if base then setindeed("base",target,group,name,base,position) end end local function register(where,specification) local name=specification.name if name and name~="" then local default=specification.default local description=specification.description local initializers=specification.initializers local processors=specification.processors local manipulators=specification.manipulators local modechecker=specification.modechecker if default then where.defaults[name]=default end if description and description~="" then where.descriptions[name]=description end if initializers then set('initializers',name,where,specification) end if processors then set('processors',name,where,specification) end if manipulators then set('manipulators',name,where,specification) end if modechecker then where.modechecker=modechecker end end end constructors.registerfeature=register function constructors.getfeatureaction(what,where,mode,name) what=handlers[what].features if what then where=what[where] if where then mode=where[mode] if mode then for i=1,#mode do local m=mode[i] if m.name==name then return m.action end end end end end end function constructors.newhandler(what) local handler=handlers[what] if not handler then handler={} handlers[what]=handler end return handler end function constructors.newfeatures(what) local handler=handlers[what] local features=handler.features if not features then local tables=handler.tables local statistics=handler.statistics features=allocate { defaults={}, descriptions=tables and tables.features or {}, used=statistics and statistics.usedfeatures or {}, initializers={ base={},node={} }, processors={ base={},node={} }, manipulators={ base={},node={} }, } features.register=function(specification) return register(features,specification) end handler.features=features end return features end function constructors.checkedfeatures(what,features) local defaults=handlers[what].features.defaults if features and next(features) then features=fastcopy(features) for key,value in next,defaults do if features[key]==nil then features[key]=value end end return features else return fastcopy(defaults) end end function constructors.initializefeatures(what,tfmdata,features,trace,report) if features and next(features) then local properties=tfmdata.properties or {} local whathandler=handlers[what] local whatfeatures=whathandler.features local whatinitializers=whatfeatures.initializers local whatmodechecker=whatfeatures.modechecker local mode=properties.mode or (whatmodechecker and whatmodechecker(tfmdata,features,features.mode)) or features.mode or "base" properties.mode=mode features.mode=mode local done={} while true do local redo=false local initializers=whatfeatures.initializers[mode] if initializers then for i=1,#initializers do local step=initializers[i] local feature=step.name local value=features[feature] if not value then elseif done[feature] then else local action=step.action if trace then report("initializing feature %a to %a for mode %a for font %a",feature, value,mode,tfmdata.properties.fullname) end action(tfmdata,value,features) if mode~=properties.mode or mode~=features.mode then if whatmodechecker then properties.mode=whatmodechecker(tfmdata,features,properties.mode) features.mode=properties.mode end if mode~=properties.mode then mode=properties.mode redo=true end end done[feature]=true end if redo then break end end if not redo then break end else break end end properties.mode=mode return true else return false end end function constructors.collectprocessors(what,tfmdata,features,trace,report) local processes,nofprocesses={},0 if features and next(features) then local properties=tfmdata.properties local whathandler=handlers[what] local whatfeatures=whathandler.features local whatprocessors=whatfeatures.processors local mode=properties.mode local processors=whatprocessors[mode] if processors then for i=1,#processors do local step=processors[i] local feature=step.name if features[feature] then local action=step.action if trace then report("installing feature processor %a for mode %a for font %a",feature,mode,tfmdata.properties.fullname) end if action then nofprocesses=nofprocesses+1 processes[nofprocesses]=action end end end elseif trace then report("no feature processors for mode %a for font %a",mode,properties.fullname) end end return processes end function constructors.applymanipulators(what,tfmdata,features,trace,report) if features and next(features) then local properties=tfmdata.properties local whathandler=handlers[what] local whatfeatures=whathandler.features local whatmanipulators=whatfeatures.manipulators local mode=properties.mode local manipulators=whatmanipulators[mode] if manipulators then for i=1,#manipulators do local step=manipulators[i] local feature=step.name local value=features[feature] if value then local action=step.action if trace then report("applying feature manipulator %a for mode %a for font %a",feature,mode,properties.fullname) end if action then action(tfmdata,feature,value) end end end end end end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['luatex-font-enc']={ version=1.001, comment="companion to luatex-*.tex", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } if context then texio.write_nl("fatal error: this module is not for context") os.exit() end local fonts=fonts fonts.encodings={} fonts.encodings.agl={} fonts.encodings.known={} setmetatable(fonts.encodings.agl,{ __index=function(t,k) if k=="unicodes" then texio.write(" <loading (extended) adobe glyph list>") local unicodes=dofile(resolvers.findfile("font-age.lua")) fonts.encodings.agl={ unicodes=unicodes } return unicodes else return nil end end }) end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['font-cid']={ version=1.001, comment="companion to font-otf.lua (cidmaps)", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local format,match,lower=string.format,string.match,string.lower local tonumber=tonumber local P,S,R,C,V,lpegmatch=lpeg.P,lpeg.S,lpeg.R,lpeg.C,lpeg.V,lpeg.match local fonts,logs,trackers=fonts,logs,trackers local trace_loading=false trackers.register("otf.loading",function(v) trace_loading=v end) local report_otf=logs.reporter("fonts","otf loading") local cid={} fonts.cid=cid local cidmap={} local cidmax=10 local number=C(R("09","af","AF")^1) local space=S(" \n\r\t") local spaces=space^0 local period=P(".") local periods=period*period local name=P("/")*C((1-space)^1) local unicodes,names={},{} local function do_one(a,b) unicodes[tonumber(a)]=tonumber(b,16) end local function do_range(a,b,c) c=tonumber(c,16) for i=tonumber(a),tonumber(b) do unicodes[i]=c c=c+1 end end local function do_name(a,b) names[tonumber(a)]=b end local grammar=P { "start", start=number*spaces*number*V("series"), series=(spaces*(V("one")+V("range")+V("named")))^1, one=(number*spaces*number)/do_one, range=(number*periods*number*spaces*number)/do_range, named=(number*spaces*name)/do_name } local function loadcidfile(filename) local data=io.loaddata(filename) if data then unicodes,names={},{} lpegmatch(grammar,data) local supplement,registry,ordering=match(filename,"^(.-)%-(.-)%-()%.(.-)$") return { supplement=supplement, registry=registry, ordering=ordering, filename=filename, unicodes=unicodes, names=names } end end cid.loadfile=loadcidfile local template="%s-%s-%s.cidmap" local function locate(registry,ordering,supplement) local filename=format(template,registry,ordering,supplement) local hashname=lower(filename) local found=cidmap[hashname] if not found then if trace_loading then report_otf("checking cidmap, registry %a, ordering %a, supplement %a, filename %a",registry,ordering,supplement,filename) end local fullname=resolvers.findfile(filename,'cid') or "" if fullname~="" then found=loadcidfile(fullname) if found then if trace_loading then report_otf("using cidmap file %a",filename) end cidmap[hashname]=found found.usedname=file.basename(filename) end end end return found end function cid.getmap(specification) if not specification then report_otf("invalid cidinfo specification, table expected") return end local registry=specification.registry local ordering=specification.ordering local supplement=specification.supplement local filename=format(registry,ordering,supplement) local found=cidmap[lower(filename)] if found then return found end if trace_loading then report_otf("cidmap needed, registry %a, ordering %a, supplement %a",registry,ordering,supplement) end found=locate(registry,ordering,supplement) if not found then local supnum=tonumber(supplement) local cidnum=nil if supnum<cidmax then for s=supnum+1,cidmax do local c=locate(registry,ordering,s) if c then found,cidnum=c,s break end end end if not found and supnum>0 then for s=supnum-1,0,-1 do local c=locate(registry,ordering,s) if c then found,cidnum=c,s break end end end registry=lower(registry) ordering=lower(ordering) if found and cidnum>0 then for s=0,cidnum-1 do local filename=format(template,registry,ordering,s) if not cidmap[filename] then cidmap[filename]=found end end end end return found end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['font-map']={ version=1.001, comment="companion to font-ini.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local tonumber=tonumber local match,format,find,concat,gsub,lower=string.match,string.format,string.find,table.concat,string.gsub,string.lower local P,R,S,C,Ct,Cc,lpegmatch=lpeg.P,lpeg.R,lpeg.S,lpeg.C,lpeg.Ct,lpeg.Cc,lpeg.match local utfbyte=utf.byte local floor=math.floor local trace_loading=false trackers.register("fonts.loading",function(v) trace_loading=v end) local trace_mapping=false trackers.register("fonts.mapping",function(v) trace_unimapping=v end) local report_fonts=logs.reporter("fonts","loading") local fonts=fonts or {} local mappings=fonts.mappings or {} fonts.mappings=mappings local function loadlumtable(filename) local lumname=file.replacesuffix(file.basename(filename),"lum") local lumfile=resolvers.findfile(lumname,"map") or "" if lumfile~="" and lfs.isfile(lumfile) then if trace_loading or trace_mapping then report_fonts("loading map table %a",lumfile) end lumunic=dofile(lumfile) return lumunic,lumfile end end local hex=R("AF","09") local hexfour=(hex*hex*hex*hex)/function(s) return tonumber(s,16) end local hexsix=(hex*hex*hex*hex*hex*hex)/function(s) return tonumber(s,16) end local dec=(R("09")^1)/tonumber local period=P(".") local unicode=P("uni")*(hexfour*(period+P(-1))*Cc(false)+Ct(hexfour^1)*Cc(true)) local ucode=P("u")*(hexsix*(period+P(-1))*Cc(false)+Ct(hexsix^1)*Cc(true)) local index=P("index")*dec*Cc(false) local parser=unicode+ucode+index local parsers={} local function makenameparser(str) if not str or str=="" then return parser else local p=parsers[str] if not p then p=P(str)*period*dec*Cc(false) parsers[str]=p end return p end end local function tounicode16(unicode,name) if unicode<0x10000 then return format("%04X",unicode) elseif unicode<0x1FFFFFFFFF then return format("%04X%04X",floor(unicode/1024),unicode%1024+0xDC00) else report_fonts("can't convert %a in %a into tounicode",unicode,name) end end local function tounicode16sequence(unicodes,name) local t={} for l=1,#unicodes do local unicode=unicodes[l] if unicode<0x10000 then t[l]=format("%04X",unicode) elseif unicode<0x1FFFFFFFFF then t[l]=format("%04X%04X",floor(unicode/1024),unicode%1024+0xDC00) else report_fonts ("can't convert %a in %a into tounicode",unicode,name) end end return concat(t) end local function fromunicode16(str) if #str==4 then return tonumber(str,16) else local l,r=match(str,"(....)(....)") return (tonumber(l,16))*0x400+tonumber(r,16)-0xDC00 end end mappings.loadlumtable=loadlumtable mappings.makenameparser=makenameparser mappings.tounicode16=tounicode16 mappings.tounicode16sequence=tounicode16sequence mappings.fromunicode16=fromunicode16 local ligseparator=P("_") local varseparator=P(".") local namesplitter=Ct(C((1-ligseparator-varseparator)^1)*(ligseparator*C((1-ligseparator-varseparator)^1))^0) function mappings.addtounicode(data,filename) local resources=data.resources local properties=data.properties local descriptions=data.descriptions local unicodes=resources.unicodes if not unicodes then return end unicodes['space']=unicodes['space'] or 32 unicodes['hyphen']=unicodes['hyphen'] or 45 unicodes['zwj']=unicodes['zwj'] or 0x200D unicodes['zwnj']=unicodes['zwnj'] or 0x200C local private=fonts.constructors.privateoffset local unknown=format("%04X",utfbyte("?")) local unicodevector=fonts.encodings.agl.unicodes local tounicode={} local originals={} resources.tounicode=tounicode resources.originals=originals local lumunic,uparser,oparser local cidinfo,cidnames,cidcodes,usedmap if false then lumunic=loadlumtable(filename) lumunic=lumunic and lumunic.tounicode end cidinfo=properties.cidinfo usedmap=cidinfo and fonts.cid.getmap(cidinfo) if usedmap then oparser=usedmap and makenameparser(cidinfo.ordering) cidnames=usedmap.names cidcodes=usedmap.unicodes end uparser=makenameparser() local ns,nl=0,0 for unic,glyph in next,descriptions do local index=glyph.index local name=glyph.name if unic==-1 or unic>=private or (unic>=0xE000 and unic<=0xF8FF) or unic==0xFFFE or unic==0xFFFF then local unicode=lumunic and lumunic[name] or unicodevector[name] if unicode then originals[index]=unicode tounicode[index]=tounicode16(unicode,name) ns=ns+1 end if (not unicode) and usedmap then local foundindex=lpegmatch(oparser,name) if foundindex then unicode=cidcodes[foundindex] if unicode then originals[index]=unicode tounicode[index]=tounicode16(unicode,name) ns=ns+1 else local reference=cidnames[foundindex] if reference then local foundindex=lpegmatch(oparser,reference) if foundindex then unicode=cidcodes[foundindex] if unicode then originals[index]=unicode tounicode[index]=tounicode16(unicode,name) ns=ns+1 end end if not unicode or unicode=="" then local foundcodes,multiple=lpegmatch(uparser,reference) if foundcodes then originals[index]=foundcodes if multiple then tounicode[index]=tounicode16sequence(foundcodes) nl=nl+1 unicode=true else tounicode[index]=tounicode16(foundcodes,name) ns=ns+1 unicode=foundcodes end end end end end end end if not unicode or unicode=="" then local split=lpegmatch(namesplitter,name) local nsplit=split and #split or 0 local t,n={},0 unicode=true for l=1,nsplit do local base=split[l] local u=unicodes[base] or unicodevector[base] if not u then break elseif type(u)=="table" then if u[1]>=private then unicode=false break end n=n+1 t[n]=u[1] else if u>=private then unicode=false break end n=n+1 t[n]=u end end if n==0 then elseif n==1 then originals[index]=t[1] tounicode[index]=tounicode16(t[1],name) else originals[index]=t tounicode[index]=tounicode16sequence(t) end nl=nl+1 end if not unicode or unicode=="" then local foundcodes,multiple=lpegmatch(uparser,name) if foundcodes then if multiple then originals[index]=foundcodes tounicode[index]=tounicode16sequence(foundcodes,name) nl=nl+1 unicode=true else originals[index]=foundcodes tounicode[index]=tounicode16(foundcodes,name) ns=ns+1 unicode=foundcodes end end end end end if trace_mapping then for unic,glyph in table.sortedhash(descriptions) do local name=glyph.name local index=glyph.index local toun=tounicode[index] if toun then report_fonts("internal slot %U, name %a, unicode %U, tounicode %a",index,name,unic,toun) else report_fonts("internal slot %U, name %a, unicode %U",index,name,unic) end end end if trace_loading and (ns>0 or nl>0) then report_fonts("%s tounicode entries added, ligatures %s",nl+ns,ns) end end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['luatex-fonts-syn']={ version=1.001, comment="companion to luatex-*.tex", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } if context then texio.write_nl("fatal error: this module is not for context") os.exit() end local fonts=fonts fonts.names=fonts.names or {} fonts.names.version=1.001 fonts.names.basename="luatex-fonts-names" fonts.names.new_to_old={} fonts.names.old_to_new={} fonts.names.cache=containers.define("fonts","data",fonts.names.version,true) local data,loaded=nil,false local fileformats={ "lua","tex","other text files" } function fonts.names.reportmissingbase() texio.write("<missing font database, run: mtxrun --script fonts --reload --simple>") fonts.names.reportmissingbase=nil end function fonts.names.reportmissingname() texio.write("<unknown font in database, run: mtxrun --script fonts --reload --simple>") fonts.names.reportmissingname=nil end function fonts.names.resolve(name,sub) if not loaded then local basename=fonts.names.basename if basename and basename~="" then data=containers.read(fonts.names.cache,basename) if not data then basename=file.addsuffix(basename,"lua") for i=1,#fileformats do local format=fileformats[i] local foundname=resolvers.findfile(basename,format) or "" if foundname~="" then data=dofile(foundname) texio.write("<font database loaded: ",foundname,">") break end end end end loaded=true end if type(data)=="table" and data.version==fonts.names.version then local condensed=string.gsub(string.lower(name),"[^%a%d]","") local found=data.mappings and data.mappings[condensed] if found then local fontname,filename,subfont=found[1],found[2],found[3] if subfont then return filename,fontname else return filename,false end elseif fonts.names.reportmissingname then fonts.names.reportmissingname() return name,false end elseif fonts.names.reportmissingbase then fonts.names.reportmissingbase() end end fonts.names.resolvespec=fonts.names.resolve function fonts.names.getfilename(askedname,suffix) return "" end function fonts.names.ignoredfile(filename) return false end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['font-tfm']={ version=1.001, comment="companion to font-ini.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local next=next local match=string.match local trace_defining=false trackers.register("fonts.defining",function(v) trace_defining=v end) local trace_features=false trackers.register("tfm.features",function(v) trace_features=v end) local report_defining=logs.reporter("fonts","defining") local report_tfm=logs.reporter("fonts","tfm loading") local findbinfile=resolvers.findbinfile local fonts=fonts local handlers=fonts.handlers local readers=fonts.readers local constructors=fonts.constructors local encodings=fonts.encodings local tfm=constructors.newhandler("tfm") local tfmfeatures=constructors.newfeatures("tfm") local registertfmfeature=tfmfeatures.register constructors.resolvevirtualtoo=false fonts.formats.tfm="type1" function tfm.setfeatures(tfmdata,features) local okay=constructors.initializefeatures("tfm",tfmdata,features,trace_features,report_tfm) if okay then return constructors.collectprocessors("tfm",tfmdata,features,trace_features,report_tfm) else return {} end end local function read_from_tfm(specification) local filename=specification.filename local size=specification.size if trace_defining then report_defining("loading tfm file %a at size %s",filename,size) end local tfmdata=font.read_tfm(filename,size) if tfmdata then local features=specification.features and specification.features.normal or {} local resources=tfmdata.resources or {} local properties=tfmdata.properties or {} local parameters=tfmdata.parameters or {} local shared=tfmdata.shared or {} properties.name=tfmdata.name properties.fontname=tfmdata.fontname properties.psname=tfmdata.psname properties.filename=specification.filename parameters.size=size shared.rawdata={} shared.features=features shared.processes=next(features) and tfm.setfeatures(tfmdata,features) or nil tfmdata.properties=properties tfmdata.resources=resources tfmdata.parameters=parameters tfmdata.shared=shared parameters.slant=parameters.slant or parameters[1] or 0 parameters.space=parameters.space or parameters[2] or 0 parameters.space_stretch=parameters.space_stretch or parameters[3] or 0 parameters.space_shrink=parameters.space_shrink or parameters[4] or 0 parameters.x_height=parameters.x_height or parameters[5] or 0 parameters.quad=parameters.quad or parameters[6] or 0 parameters.extra_space=parameters.extra_space or parameters[7] or 0 constructors.enhanceparameters(parameters) if constructors.resolvevirtualtoo then fonts.loggers.register(tfmdata,file.suffix(filename),specification) local vfname=findbinfile(specification.name,'ovf') if vfname and vfname~="" then local vfdata=font.read_vf(vfname,size) if vfdata then local chars=tfmdata.characters for k,v in next,vfdata.characters do chars[k].commands=v.commands end properties.virtualized=true tfmdata.fonts=vfdata.fonts end end end local allfeatures=tfmdata.shared.features or specification.features.normal constructors.applymanipulators("tfm",tfmdata,allfeatures.normal,trace_features,report_tfm) if not features.encoding then local encoding,filename=match(properties.filename,"^(.-)%-(.*)$") if filename and encoding and encodings.known and encodings.known[encoding] then features.encoding=encoding end end return tfmdata end end local function check_tfm(specification,fullname) local foundname=findbinfile(fullname,'tfm') or "" if foundname=="" then foundname=findbinfile(fullname,'ofm') or "" end if foundname=="" then foundname=fonts.names.getfilename(fullname,"tfm") or "" end if foundname~="" then specification.filename=foundname specification.format="ofm" return read_from_tfm(specification) elseif trace_defining then report_defining("loading tfm with name %a fails",specification.name) end end readers.check_tfm=check_tfm function readers.tfm(specification) local fullname=specification.filename or "" if fullname=="" then local forced=specification.forced or "" if forced~="" then fullname=specification.name.."."..forced else fullname=specification.name end end return check_tfm(specification,fullname) end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['font-afm']={ version=1.001, comment="companion to font-ini.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local fonts,logs,trackers,containers,resolvers=fonts,logs,trackers,containers,resolvers local next,type,tonumber=next,type,tonumber local format,match,gmatch,lower,gsub,strip=string.format,string.match,string.gmatch,string.lower,string.gsub,string.strip local abs=math.abs local P,S,C,R,lpegmatch,patterns=lpeg.P,lpeg.S,lpeg.C,lpeg.R,lpeg.match,lpeg.patterns local derivetable=table.derive local trace_features=false trackers.register("afm.features",function(v) trace_features=v end) local trace_indexing=false trackers.register("afm.indexing",function(v) trace_indexing=v end) local trace_loading=false trackers.register("afm.loading",function(v) trace_loading=v end) local trace_defining=false trackers.register("fonts.defining",function(v) trace_defining=v end) local report_afm=logs.reporter("fonts","afm loading") local findbinfile=resolvers.findbinfile local definers=fonts.definers local readers=fonts.readers local constructors=fonts.constructors local afm=constructors.newhandler("afm") local pfb=constructors.newhandler("pfb") local afmfeatures=constructors.newfeatures("afm") local registerafmfeature=afmfeatures.register afm.version=1.410 afm.cache=containers.define("fonts","afm",afm.version,true) afm.autoprefixed=true afm.helpdata={} afm.syncspace=true afm.addligatures=true afm.addtexligatures=true afm.addkerns=true local applyruntimefixes=fonts.treatments and fonts.treatments.applyfixes local function setmode(tfmdata,value) if value then tfmdata.properties.mode=lower(value) end end registerafmfeature { name="mode", description="mode", initializers={ base=setmode, node=setmode, } } local comment=P("Comment") local spacing=patterns.spacer local lineend=patterns.newline local words=C((1-lineend)^1) local number=C((R("09")+S("."))^1)/tonumber*spacing^0 local data=lpeg.Carg(1) local pattern=( comment*spacing*( data*( ("CODINGSCHEME"*spacing*words )/function(fd,a) end+("DESIGNSIZE"*spacing*number*words )/function(fd,a) fd[ 1]=a end+("CHECKSUM"*spacing*number*words )/function(fd,a) fd[ 2]=a end+("SPACE"*spacing*number*"plus"*number*"minus"*number)/function(fd,a,b,c) fd[ 3],fd[ 4],fd[ 5]=a,b,c end+("QUAD"*spacing*number )/function(fd,a) fd[ 6]=a end+("EXTRASPACE"*spacing*number )/function(fd,a) fd[ 7]=a end+("NUM"*spacing*number*number*number )/function(fd,a,b,c) fd[ 8],fd[ 9],fd[10]=a,b,c end+("DENOM"*spacing*number*number )/function(fd,a,b ) fd[11],fd[12]=a,b end+("SUP"*spacing*number*number*number )/function(fd,a,b,c) fd[13],fd[14],fd[15]=a,b,c end+("SUB"*spacing*number*number )/function(fd,a,b) fd[16],fd[17]=a,b end+("SUPDROP"*spacing*number )/function(fd,a) fd[18]=a end+("SUBDROP"*spacing*number )/function(fd,a) fd[19]=a end+("DELIM"*spacing*number*number )/function(fd,a,b) fd[20],fd[21]=a,b end+("AXISHEIGHT"*spacing*number )/function(fd,a) fd[22]=a end )+(1-lineend)^0 )+(1-comment)^1 )^0 local function scan_comment(str) local fd={} lpegmatch(pattern,str,1,fd) return fd end local keys={} function keys.FontName (data,line) data.metadata.fontname=strip (line) data.metadata.fullname=strip (line) end function keys.ItalicAngle (data,line) data.metadata.italicangle=tonumber (line) end function keys.IsFixedPitch(data,line) data.metadata.isfixedpitch=toboolean(line,true) end function keys.CharWidth (data,line) data.metadata.charwidth=tonumber (line) end function keys.XHeight (data,line) data.metadata.xheight=tonumber (line) end function keys.Descender (data,line) data.metadata.descender=tonumber (line) end function keys.Ascender (data,line) data.metadata.ascender=tonumber (line) end function keys.Comment (data,line) line=lower(line) local designsize=match(line,"designsize[^%d]*(%d+)") if designsize then data.metadata.designsize=tonumber(designsize) end end local function get_charmetrics(data,charmetrics,vector) local characters=data.characters local chr,ind={},0 for k,v in gmatch(charmetrics,"([%a]+) +(.-) *;") do if k=='C' then v=tonumber(v) if v<0 then ind=ind+1 else ind=v end chr={ index=ind } elseif k=='WX' then chr.width=tonumber(v) elseif k=='N' then characters[v]=chr elseif k=='B' then local llx,lly,urx,ury=match(v,"^ *(.-) +(.-) +(.-) +(.-)$") chr.boundingbox={ tonumber(llx),tonumber(lly),tonumber(urx),tonumber(ury) } elseif k=='L' then local plus,becomes=match(v,"^(.-) +(.-)$") local ligatures=chr.ligatures if ligatures then ligatures[plus]=becomes else chr.ligatures={ [plus]=becomes } end end end end local function get_kernpairs(data,kernpairs) local characters=data.characters for one,two,value in gmatch(kernpairs,"KPX +(.-) +(.-) +(.-)\n") do local chr=characters[one] if chr then local kerns=chr.kerns if kerns then kerns[two]=tonumber(value) else chr.kerns={ [two]=tonumber(value) } end end end end local function get_variables(data,fontmetrics) for key,rest in gmatch(fontmetrics,"(%a+) *(.-)[\n\r]") do local keyhandler=keys[key] if keyhandler then keyhandler(data,rest) end end end local function get_indexes(data,pfbname) data.resources.filename=resolvers.unresolve(pfbname) local pfbblob=fontloader.open(pfbname) if pfbblob then local characters=data.characters local pfbdata=fontloader.to_table(pfbblob) if pfbdata then local glyphs=pfbdata.glyphs if glyphs then if trace_loading then report_afm("getting index data from %a",pfbname) end for index,glyph in next,glyphs do local name=glyph.name if name then local char=characters[name] if char then if trace_indexing then report_afm("glyph %a has index %a",name,index) end char.index=index end end end elseif trace_loading then report_afm("no glyph data in pfb file %a",pfbname) end elseif trace_loading then report_afm("no data in pfb file %a",pfbname) end fontloader.close(pfbblob) elseif trace_loading then report_afm("invalid pfb file %a",pfbname) end end local function readafm(filename) local ok,afmblob,size=resolvers.loadbinfile(filename) if ok and afmblob then local data={ resources={ filename=resolvers.unresolve(filename), version=afm.version, creator="context mkiv", }, properties={ hasitalics=false, }, goodies={}, metadata={ filename=file.removesuffix(file.basename(filename)) }, characters={ }, descriptions={ }, } afmblob=gsub(afmblob,"StartCharMetrics(.-)EndCharMetrics",function(charmetrics) if trace_loading then report_afm("loading char metrics") end get_charmetrics(data,charmetrics,vector) return "" end) afmblob=gsub(afmblob,"StartKernPairs(.-)EndKernPairs",function(kernpairs) if trace_loading then report_afm("loading kern pairs") end get_kernpairs(data,kernpairs) return "" end) afmblob=gsub(afmblob,"StartFontMetrics%s+([%d%.]+)(.-)EndFontMetrics",function(version,fontmetrics) if trace_loading then report_afm("loading variables") end data.afmversion=version get_variables(data,fontmetrics) data.fontdimens=scan_comment(fontmetrics) return "" end) return data else if trace_loading then report_afm("no valid afm file %a",filename) end return nil end end local addkerns,addligatures,addtexligatures,unify,normalize function afm.load(filename) filename=resolvers.findfile(filename,'afm') or "" if filename~="" and not fonts.names.ignoredfile(filename) then local name=file.removesuffix(file.basename(filename)) local data=containers.read(afm.cache,name) local attr=lfs.attributes(filename) local size,time=attr.size or 0,attr.modification or 0 local pfbfile=file.replacesuffix(name,"pfb") local pfbname=resolvers.findfile(pfbfile,"pfb") or "" if pfbname=="" then pfbname=resolvers.findfile(file.basename(pfbfile),"pfb") or "" end local pfbsize,pfbtime=0,0 if pfbname~="" then local attr=lfs.attributes(pfbname) pfbsize=attr.size or 0 pfbtime=attr.modification or 0 end if not data or data.size~=size or data.time~=time or data.pfbsize~=pfbsize or data.pfbtime~=pfbtime then report_afm("reading %a",filename) data=readafm(filename) if data then if pfbname~="" then get_indexes(data,pfbname) elseif trace_loading then report_afm("no pfb file for %a",filename) end report_afm("unifying %a",filename) unify(data,filename) if afm.addligatures then report_afm("add ligatures") addligatures(data) end if afm.addtexligatures then report_afm("add tex ligatures") addtexligatures(data) end if afm.addkerns then report_afm("add extra kerns") addkerns(data) end normalize(data) report_afm("add tounicode data") fonts.mappings.addtounicode(data,filename) data.size=size data.time=time data.pfbsize=pfbsize data.pfbtime=pfbtime report_afm("saving %a in cache",name) data=containers.write(afm.cache,name,data) data=containers.read(afm.cache,name) end if applyruntimefixes and data then applyruntimefixes(filename,data) end end return data else return nil end end local uparser=fonts.mappings.makenameparser() unify=function(data,filename) local unicodevector=fonts.encodings.agl.unicodes local unicodes,names={},{} local private=constructors.privateoffset local descriptions=data.descriptions for name,blob in next,data.characters do local code=unicodevector[name] if not code then code=lpegmatch(uparser,name) if not code then code=private private=private+1 report_afm("assigning private slot %U for unknown glyph name %a",code,name) end end local index=blob.index unicodes[name]=code names[name]=index blob.name=name descriptions[code]={ boundingbox=blob.boundingbox, width=blob.width, kerns=blob.kerns, index=index, name=name, } end for unicode,description in next,descriptions do local kerns=description.kerns if kerns then local krn={} for name,kern in next,kerns do local unicode=unicodes[name] if unicode then krn[unicode]=kern else end end description.kerns=krn end end data.characters=nil local resources=data.resources local filename=resources.filename or file.removesuffix(file.basename(filename)) resources.filename=resolvers.unresolve(filename) resources.unicodes=unicodes resources.marks={} resources.names=names resources.private=private end normalize=function(data) end local addthem=function(rawdata,ligatures) if ligatures then local descriptions=rawdata.descriptions local resources=rawdata.resources local unicodes=resources.unicodes local names=resources.names for ligname,ligdata in next,ligatures do local one=descriptions[unicodes[ligname]] if one then for _,pair in next,ligdata do local two,three=unicodes[pair[1]],unicodes[pair[2]] if two and three then local ol=one.ligatures if ol then if not ol[two] then ol[two]=three end else one.ligatures={ [two]=three } end end end end end end end addligatures=function(rawdata) addthem(rawdata,afm.helpdata.ligatures ) end addtexligatures=function(rawdata) addthem(rawdata,afm.helpdata.texligatures) end addkerns=function(rawdata) local descriptions=rawdata.descriptions local resources=rawdata.resources local unicodes=resources.unicodes local function do_it_left(what) if what then for unicode,description in next,descriptions do local kerns=description.kerns if kerns then local extrakerns for complex,simple in next,what do complex=unicodes[complex] simple=unicodes[simple] if complex and simple then local ks=kerns[simple] if ks and not kerns[complex] then if extrakerns then extrakerns[complex]=ks else extrakerns={ [complex]=ks } end end end end if extrakerns then description.extrakerns=extrakerns end end end end end local function do_it_copy(what) if what then for complex,simple in next,what do complex=unicodes[complex] simple=unicodes[simple] if complex and simple then local complexdescription=descriptions[complex] if complexdescription then local simpledescription=descriptions[complex] if simpledescription then local extrakerns local kerns=simpledescription.kerns if kerns then for unicode,kern in next,kerns do if extrakerns then extrakerns[unicode]=kern else extrakerns={ [unicode]=kern } end end end local extrakerns=simpledescription.extrakerns if extrakerns then for unicode,kern in next,extrakerns do if extrakerns then extrakerns[unicode]=kern else extrakerns={ [unicode]=kern } end end end if extrakerns then complexdescription.extrakerns=extrakerns end end end end end end end do_it_left(afm.helpdata.leftkerned) do_it_left(afm.helpdata.bothkerned) do_it_copy(afm.helpdata.bothkerned) do_it_copy(afm.helpdata.rightkerned) end local function adddimensions(data) if data then for unicode,description in next,data.descriptions do local bb=description.boundingbox if bb then local ht,dp=bb[4],-bb[2] if ht==0 or ht<0 then else description.height=ht end if dp==0 or dp<0 then else description.depth=dp end end end end end local function copytotfm(data) if data and data.descriptions then local metadata=data.metadata local resources=data.resources local properties=derivetable(data.properties) local descriptions=derivetable(data.descriptions) local goodies=derivetable(data.goodies) local characters={} local parameters={} local unicodes=resources.unicodes for unicode,description in next,data.descriptions do characters[unicode]={} end local filename=constructors.checkedfilename(resources) local fontname=metadata.fontname or metadata.fullname local fullname=metadata.fullname or metadata.fontname local endash=unicodes['space'] local emdash=unicodes['emdash'] local spacer="space" local spaceunits=500 local monospaced=metadata.isfixedpitch local charwidth=metadata.charwidth local italicangle=metadata.italicangle local charxheight=metadata.xheight and metadata.xheight>0 and metadata.xheight properties.monospaced=monospaced parameters.italicangle=italicangle parameters.charwidth=charwidth parameters.charxheight=charxheight if properties.monospaced then if descriptions[endash] then spaceunits,spacer=descriptions[endash].width,"space" end if not spaceunits and descriptions[emdash] then spaceunits,spacer=descriptions[emdash].width,"emdash" end if not spaceunits and charwidth then spaceunits,spacer=charwidth,"charwidth" end else if descriptions[endash] then spaceunits,spacer=descriptions[endash].width,"space" end if not spaceunits and charwidth then spaceunits,spacer=charwidth,"charwidth" end end spaceunits=tonumber(spaceunits) if spaceunits<200 then end parameters.slant=0 parameters.space=spaceunits parameters.space_stretch=500 parameters.space_shrink=333 parameters.x_height=400 parameters.quad=1000 if italicangle and italicangle~=0 then parameters.italicangle=italicangle parameters.italicfactor=math.cos(math.rad(90+italicangle)) parameters.slant=- math.tan(italicangle*math.pi/180) end if monospaced then parameters.space_stretch=0 parameters.space_shrink=0 elseif afm.syncspace then parameters.space_stretch=spaceunits/2 parameters.space_shrink=spaceunits/3 end parameters.extra_space=parameters.space_shrink if charxheight then parameters.x_height=charxheight else local x=unicodes['x'] if x then local x=descriptions[x] if x then parameters.x_height=x.height end end end local fd=data.fontdimens if fd and fd[8] and fd[9] and fd[10] then for k,v in next,fd do parameters[k]=v end end parameters.designsize=(metadata.designsize or 10)*65536 parameters.ascender=abs(metadata.ascender or 0) parameters.descender=abs(metadata.descender or 0) parameters.units=1000 properties.spacer=spacer properties.encodingbytes=2 properties.format=fonts.formats[filename] or "type1" properties.filename=filename properties.fontname=fontname properties.fullname=fullname properties.psname=fullname properties.name=filename or fullname or fontname if next(characters) then return { characters=characters, descriptions=descriptions, parameters=parameters, resources=resources, properties=properties, goodies=goodies, } end end return nil end function afm.setfeatures(tfmdata,features) local okay=constructors.initializefeatures("afm",tfmdata,features,trace_features,report_afm) if okay then return constructors.collectprocessors("afm",tfmdata,features,trace_features,report_afm) else return {} end end local function checkfeatures(specification) end local function afmtotfm(specification) local afmname=specification.filename or specification.name if specification.forced=="afm" or specification.format=="afm" then if trace_loading then report_afm("forcing afm format for %a",afmname) end else local tfmname=findbinfile(afmname,"ofm") or "" if tfmname~="" then if trace_loading then report_afm("fallback from afm to tfm for %a",afmname) end return end end if afmname~="" then local features=constructors.checkedfeatures("afm",specification.features.normal) specification.features.normal=features constructors.hashinstance(specification,true) specification=definers.resolve(specification) local cache_id=specification.hash local tfmdata=containers.read(constructors.cache,cache_id) if not tfmdata then local rawdata=afm.load(afmname) if rawdata and next(rawdata) then adddimensions(rawdata) tfmdata=copytotfm(rawdata) if tfmdata and next(tfmdata) then local shared=tfmdata.shared if not shared then shared={} tfmdata.shared=shared end shared.rawdata=rawdata shared.features=features shared.processes=afm.setfeatures(tfmdata,features) end elseif trace_loading then report_afm("no (valid) afm file found with name %a",afmname) end tfmdata=containers.write(constructors.cache,cache_id,tfmdata) end return tfmdata end end local function read_from_afm(specification) local tfmdata=afmtotfm(specification) if tfmdata then tfmdata.properties.name=specification.name tfmdata=constructors.scale(tfmdata,specification) local allfeatures=tfmdata.shared.features or specification.features.normal constructors.applymanipulators("afm",tfmdata,allfeatures,trace_features,report_afm) fonts.loggers.register(tfmdata,'afm',specification) end return tfmdata end local function prepareligatures(tfmdata,ligatures,value) if value then local descriptions=tfmdata.descriptions for unicode,character in next,tfmdata.characters do local description=descriptions[unicode] local dligatures=description.ligatures if dligatures then local cligatures=character.ligatures if not cligatures then cligatures={} character.ligatures=cligatures end for unicode,ligature in next,dligatures do cligatures[unicode]={ char=ligature, type=0 } end end end end end local function preparekerns(tfmdata,kerns,value) if value then local rawdata=tfmdata.shared.rawdata local resources=rawdata.resources local unicodes=resources.unicodes local descriptions=tfmdata.descriptions for u,chr in next,tfmdata.characters do local d=descriptions[u] local newkerns=d[kerns] if newkerns then local kerns=chr.kerns if not kerns then kerns={} chr.kerns=kerns end for k,v in next,newkerns do local uk=unicodes[k] if uk then kerns[uk]=v end end end end end end local list={ [0x0027]=0x2019, } local function texreplacements(tfmdata,value) local descriptions=tfmdata.descriptions local characters=tfmdata.characters for k,v in next,list do characters [k]=characters [v] descriptions[k]=descriptions[v] end end local function ligatures (tfmdata,value) prepareligatures(tfmdata,'ligatures',value) end local function texligatures(tfmdata,value) prepareligatures(tfmdata,'texligatures',value) end local function kerns (tfmdata,value) preparekerns (tfmdata,'kerns',value) end local function extrakerns (tfmdata,value) preparekerns (tfmdata,'extrakerns',value) end registerafmfeature { name="liga", description="traditional ligatures", initializers={ base=ligatures, node=ligatures, } } registerafmfeature { name="kern", description="intercharacter kerning", initializers={ base=kerns, node=kerns, } } registerafmfeature { name="extrakerns", description="additional intercharacter kerning", initializers={ base=extrakerns, node=extrakerns, } } registerafmfeature { name='tlig', description='tex ligatures', initializers={ base=texligatures, node=texligatures, } } registerafmfeature { name='trep', description='tex replacements', initializers={ base=texreplacements, node=texreplacements, } } local check_tfm=readers.check_tfm fonts.formats.afm="type1" fonts.formats.pfb="type1" local function check_afm(specification,fullname) local foundname=findbinfile(fullname,'afm') or "" if foundname=="" then foundname=fonts.names.getfilename(fullname,"afm") or "" end if foundname=="" and afm.autoprefixed then local encoding,shortname=match(fullname,"^(.-)%-(.*)$") if encoding and shortname and fonts.encodings.known[encoding] then shortname=findbinfile(shortname,'afm') or "" if shortname~="" then foundname=shortname if trace_defining then report_afm("stripping encoding prefix from filename %a",afmname) end end end end if foundname~="" then specification.filename=foundname specification.format="afm" return read_from_afm(specification) end end function readers.afm(specification,method) local fullname,tfmdata=specification.filename or "",nil if fullname=="" then local forced=specification.forced or "" if forced~="" then tfmdata=check_afm(specification,specification.name.."."..forced) end if not tfmdata then method=method or definers.method or "afm or tfm" if method=="tfm" then tfmdata=check_tfm(specification,specification.name) elseif method=="afm" then tfmdata=check_afm(specification,specification.name) elseif method=="tfm or afm" then tfmdata=check_tfm(specification,specification.name) or check_afm(specification,specification.name) else tfmdata=check_afm(specification,specification.name) or check_tfm(specification,specification.name) end end else tfmdata=check_afm(specification,fullname) end return tfmdata end function readers.pfb(specification,method) local original=specification.specification if trace_defining then report_afm("using afm reader for %a",original) end specification.specification=gsub(original,"%.pfb",".afm") specification.forced="afm" return readers.afm(specification,method) end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['font-afk']={ version=1.001, comment="companion to font-afm.lua", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files", dataonly=true, } local allocate=utilities.storage.allocate fonts.handlers.afm.helpdata={ ligatures=allocate { ['f']={ { 'f','ff' }, { 'i','fi' }, { 'l','fl' }, }, ['ff']={ { 'i','ffi' } }, ['fi']={ { 'i','fii' } }, ['fl']={ { 'i','fli' } }, ['s']={ { 't','st' } }, ['i']={ { 'j','ij' } }, }, texligatures=allocate { ['quoteleft']={ { 'quoteleft','quotedblleft' } }, ['quoteright']={ { 'quoteright','quotedblright' } }, ['hyphen']={ { 'hyphen','endash' } }, ['endash']={ { 'hyphen','emdash' } } }, leftkerned=allocate { AEligature="A",aeligature="a", OEligature="O",oeligature="o", IJligature="I",ijligature="i", AE="A",ae="a", OE="O",oe="o", IJ="I",ij="i", Ssharp="S",ssharp="s", }, rightkerned=allocate { AEligature="E",aeligature="e", OEligature="E",oeligature="e", IJligature="J",ijligature="j", AE="E",ae="e", OE="E",oe="e", IJ="J",ij="j", Ssharp="S",ssharp="s", }, bothkerned=allocate { Acircumflex="A",acircumflex="a", Ccircumflex="C",ccircumflex="c", Ecircumflex="E",ecircumflex="e", Gcircumflex="G",gcircumflex="g", Hcircumflex="H",hcircumflex="h", Icircumflex="I",icircumflex="i", Jcircumflex="J",jcircumflex="j", Ocircumflex="O",ocircumflex="o", Scircumflex="S",scircumflex="s", Ucircumflex="U",ucircumflex="u", Wcircumflex="W",wcircumflex="w", Ycircumflex="Y",ycircumflex="y", Agrave="A",agrave="a", Egrave="E",egrave="e", Igrave="I",igrave="i", Ograve="O",ograve="o", Ugrave="U",ugrave="u", Ygrave="Y",ygrave="y", Atilde="A",atilde="a", Itilde="I",itilde="i", Otilde="O",otilde="o", Utilde="U",utilde="u", Ntilde="N",ntilde="n", Adiaeresis="A",adiaeresis="a",Adieresis="A",adieresis="a", Ediaeresis="E",ediaeresis="e",Edieresis="E",edieresis="e", Idiaeresis="I",idiaeresis="i",Idieresis="I",idieresis="i", Odiaeresis="O",odiaeresis="o",Odieresis="O",odieresis="o", Udiaeresis="U",udiaeresis="u",Udieresis="U",udieresis="u", Ydiaeresis="Y",ydiaeresis="y",Ydieresis="Y",ydieresis="y", Aacute="A",aacute="a", Cacute="C",cacute="c", Eacute="E",eacute="e", Iacute="I",iacute="i", Lacute="L",lacute="l", Nacute="N",nacute="n", Oacute="O",oacute="o", Racute="R",racute="r", Sacute="S",sacute="s", Uacute="U",uacute="u", Yacute="Y",yacute="y", Zacute="Z",zacute="z", Dstroke="D",dstroke="d", Hstroke="H",hstroke="h", Tstroke="T",tstroke="t", Cdotaccent="C",cdotaccent="c", Edotaccent="E",edotaccent="e", Gdotaccent="G",gdotaccent="g", Idotaccent="I",idotaccent="i", Zdotaccent="Z",zdotaccent="z", Amacron="A",amacron="a", Emacron="E",emacron="e", Imacron="I",imacron="i", Omacron="O",omacron="o", Umacron="U",umacron="u", Ccedilla="C",ccedilla="c", Kcedilla="K",kcedilla="k", Lcedilla="L",lcedilla="l", Ncedilla="N",ncedilla="n", Rcedilla="R",rcedilla="r", Scedilla="S",scedilla="s", Tcedilla="T",tcedilla="t", Ohungarumlaut="O",ohungarumlaut="o", Uhungarumlaut="U",uhungarumlaut="u", Aogonek="A",aogonek="a", Eogonek="E",eogonek="e", Iogonek="I",iogonek="i", Uogonek="U",uogonek="u", Aring="A",aring="a", Uring="U",uring="u", Abreve="A",abreve="a", Ebreve="E",ebreve="e", Gbreve="G",gbreve="g", Ibreve="I",ibreve="i", Obreve="O",obreve="o", Ubreve="U",ubreve="u", Ccaron="C",ccaron="c", Dcaron="D",dcaron="d", Ecaron="E",ecaron="e", Lcaron="L",lcaron="l", Ncaron="N",ncaron="n", Rcaron="R",rcaron="r", Scaron="S",scaron="s", Tcaron="T",tcaron="t", Zcaron="Z",zcaron="z", dotlessI="I",dotlessi="i", dotlessJ="J",dotlessj="j", AEligature="AE",aeligature="ae",AE="AE",ae="ae", OEligature="OE",oeligature="oe",OE="OE",oe="oe", IJligature="IJ",ijligature="ij",IJ="IJ",ij="ij", Lstroke="L",lstroke="l",Lslash="L",lslash="l", Ostroke="O",ostroke="o",Oslash="O",oslash="o", Ssharp="SS",ssharp="ss", Aumlaut="A",aumlaut="a", Eumlaut="E",eumlaut="e", Iumlaut="I",iumlaut="i", Oumlaut="O",oumlaut="o", Uumlaut="U",uumlaut="u", } } end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['luatex-fonts-tfm']={ version=1.001, comment="companion to luatex-*.tex", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } if context then texio.write_nl("fatal error: this module is not for context") os.exit() end local fonts=fonts local tfm={} fonts.handlers.tfm=tfm fonts.formats.tfm="type1" function fonts.readers.tfm(specification) local fullname=specification.filename or "" if fullname=="" then local forced=specification.forced or "" if forced~="" then fullname=specification.name.."."..forced else fullname=specification.name end end local foundname=resolvers.findbinfile(fullname,'tfm') or "" if foundname=="" then foundname=resolvers.findbinfile(fullname,'ofm') or "" end if foundname~="" then specification.filename=foundname specification.format="ofm" return font.read_tfm(specification.filename,specification.size) end end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['font-oti']={ version=1.001, comment="companion to font-ini.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local lower=string.lower local fonts=fonts local constructors=fonts.constructors local otf=constructors.newhandler("otf") local otffeatures=constructors.newfeatures("otf") local otftables=otf.tables local registerotffeature=otffeatures.register local allocate=utilities.storage.allocate registerotffeature { name="features", description="initialization of feature handler", default=true, } local function setmode(tfmdata,value) if value then tfmdata.properties.mode=lower(value) end end local function setlanguage(tfmdata,value) if value then local cleanvalue=lower(value) local languages=otftables and otftables.languages local properties=tfmdata.properties if not languages then properties.language=cleanvalue elseif languages[value] then properties.language=cleanvalue else properties.language="dflt" end end end local function setscript(tfmdata,value) if value then local cleanvalue=lower(value) local scripts=otftables and otftables.scripts local properties=tfmdata.properties if not scripts then properties.script=cleanvalue elseif scripts[value] then properties.script=cleanvalue else properties.script="dflt" end end end registerotffeature { name="mode", description="mode", initializers={ base=setmode, node=setmode, } } registerotffeature { name="language", description="language", initializers={ base=setlanguage, node=setlanguage, } } registerotffeature { name="script", description="script", initializers={ base=setscript, node=setscript, } } end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['font-otf']={ version=1.001, comment="companion to font-ini.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local utfbyte=utf.byte local format,gmatch,gsub,find,match,lower,strip=string.format,string.gmatch,string.gsub,string.find,string.match,string.lower,string.strip local type,next,tonumber,tostring=type,next,tonumber,tostring local abs=math.abs local insert=table.insert local lpegmatch=lpeg.match local reversed,concat,remove,sortedkeys=table.reversed,table.concat,table.remove,table.sortedkeys local ioflush=io.flush local fastcopy,tohash,derivetable=table.fastcopy,table.tohash,table.derive local formatters=string.formatters local allocate=utilities.storage.allocate local registertracker=trackers.register local registerdirective=directives.register local starttiming=statistics.starttiming local stoptiming=statistics.stoptiming local elapsedtime=statistics.elapsedtime local findbinfile=resolvers.findbinfile local trace_private=false registertracker("otf.private",function(v) trace_private=v end) local trace_loading=false registertracker("otf.loading",function(v) trace_loading=v end) local trace_features=false registertracker("otf.features",function(v) trace_features=v end) local trace_dynamics=false registertracker("otf.dynamics",function(v) trace_dynamics=v end) local trace_sequences=false registertracker("otf.sequences",function(v) trace_sequences=v end) local trace_markwidth=false registertracker("otf.markwidth",function(v) trace_markwidth=v end) local trace_defining=false registertracker("fonts.defining",function(v) trace_defining=v end) local report_otf=logs.reporter("fonts","otf loading") local fonts=fonts local otf=fonts.handlers.otf otf.glists={ "gsub","gpos" } otf.version=2.759 otf.cache=containers.define("fonts","otf",otf.version,true) local fontdata=fonts.hashes.identifiers local chardata=characters and characters.data local otffeatures=fonts.constructors.newfeatures("otf") local registerotffeature=otffeatures.register local enhancers=allocate() otf.enhancers=enhancers local patches={} enhancers.patches=patches local definers=fonts.definers local readers=fonts.readers local constructors=fonts.constructors local forceload=false local cleanup=0 local usemetatables=false local packdata=true local syncspace=true local forcenotdef=false local includesubfonts=false local overloadkerns=false local applyruntimefixes=fonts.treatments and fonts.treatments.applyfixes local wildcard="*" local default="dflt" local fontloaderfields=fontloader.fields local mainfields=nil local glyphfields=nil local formats=fonts.formats formats.otf="opentype" formats.ttf="truetype" formats.ttc="truetype" formats.dfont="truetype" registerdirective("fonts.otf.loader.cleanup",function(v) cleanup=tonumber(v) or (v and 1) or 0 end) registerdirective("fonts.otf.loader.force",function(v) forceload=v end) registerdirective("fonts.otf.loader.usemetatables",function(v) usemetatables=v end) registerdirective("fonts.otf.loader.pack",function(v) packdata=v end) registerdirective("fonts.otf.loader.syncspace",function(v) syncspace=v end) registerdirective("fonts.otf.loader.forcenotdef",function(v) forcenotdef=v end) registerdirective("fonts.otf.loader.overloadkerns",function(v) overloadkerns=v end) function otf.fileformat(filename) local leader=lower(io.loadchunk(filename,4)) local suffix=lower(file.suffix(filename)) if leader=="otto" then return formats.otf,suffix=="otf" elseif leader=="ttcf" then return formats.ttc,suffix=="ttc" elseif suffix=="ttc" then return formats.ttc,true elseif suffix=="dfont" then return formats.dfont,true else return formats.ttf,suffix=="ttf" end end local function otf_format(filename) local format,okay=otf.fileformat(filename) if not okay then report_otf("font %a is actually an %a file",filename,format) end return format end local function load_featurefile(raw,featurefile) if featurefile and featurefile~="" then if trace_loading then report_otf("using featurefile %a",featurefile) end fontloader.apply_featurefile(raw,featurefile) end end local function showfeatureorder(rawdata,filename) local sequences=rawdata.resources.sequences if sequences and #sequences>0 then if trace_loading then report_otf("font %a has %s sequences",filename,#sequences) report_otf(" ") end for nos=1,#sequences do local sequence=sequences[nos] local typ=sequence.type or "no-type" local name=sequence.name or "no-name" local subtables=sequence.subtables or { "no-subtables" } local features=sequence.features if trace_loading then report_otf("%3i %-15s %-20s [% t]",nos,name,typ,subtables) end if features then for feature,scripts in next,features do local tt={} if type(scripts)=="table" then for script,languages in next,scripts do local ttt={} for language,_ in next,languages do ttt[#ttt+1]=language end tt[#tt+1]=formatters["[%s: % t]"](script,ttt) end if trace_loading then report_otf(" %s: % t",feature,tt) end else if trace_loading then report_otf(" %s: %S",feature,scripts) end end end end end if trace_loading then report_otf("\n") end elseif trace_loading then report_otf("font %a has no sequences",filename) end end local valid_fields=table.tohash { "ascent", "cidinfo", "copyright", "descent", "design_range_bottom", "design_range_top", "design_size", "encodingchanged", "extrema_bound", "familyname", "fontname", "fontname", "fontstyle_id", "fontstyle_name", "fullname", "hasvmetrics", "horiz_base", "issans", "isserif", "italicangle", "macstyle", "onlybitmaps", "origname", "os2_version", "pfminfo", "serifcheck", "sfd_version", "strokedfont", "strokewidth", "table_version", "ttf_tables", "uni_interp", "uniqueid", "units_per_em", "upos", "use_typo_metrics", "uwidth", "validation_state", "version", "vert_base", "weight", "weight_width_slope_only", } local ordered_enhancers={ "prepare tables", "prepare glyphs", "prepare lookups", "analyze glyphs", "analyze math", "prepare tounicode", "reorganize lookups", "reorganize mark classes", "reorganize anchor classes", "reorganize glyph kerns", "reorganize glyph lookups", "reorganize glyph anchors", "merge kern classes", "reorganize features", "reorganize subtables", "check glyphs", "check metadata", "check extra features", "check encoding", "add duplicates", "cleanup tables", } local actions=allocate() local before=allocate() local after=allocate() patches.before=before patches.after=after local function enhance(name,data,filename,raw) local enhancer=actions[name] if enhancer then if trace_loading then report_otf("apply enhancement %a to file %a",name,filename) ioflush() end enhancer(data,filename,raw) else end end function enhancers.apply(data,filename,raw) local basename=file.basename(lower(filename)) if trace_loading then report_otf("%s enhancing file %a","start",filename) end ioflush() for e=1,#ordered_enhancers do local enhancer=ordered_enhancers[e] local b=before[enhancer] if b then for pattern,action in next,b do if find(basename,pattern) then action(data,filename,raw) end end end enhance(enhancer,data,filename,raw) local a=after[enhancer] if a then for pattern,action in next,a do if find(basename,pattern) then action(data,filename,raw) end end end ioflush() end if trace_loading then report_otf("%s enhancing file %a","stop",filename) end ioflush() end function patches.register(what,where,pattern,action) local pw=patches[what] if pw then local ww=pw[where] if ww then ww[pattern]=action else pw[where]={ [pattern]=action} end end end function patches.report(fmt,...) if trace_loading then report_otf("patching: %s",formatters[fmt](...)) end end function enhancers.register(what,action) actions[what]=action end function otf.load(filename,sub,featurefile) local base=file.basename(file.removesuffix(filename)) local name=file.removesuffix(base) local attr=lfs.attributes(filename) local size=attr and attr.size or 0 local time=attr and attr.modification or 0 if featurefile then name=name.."@"..file.removesuffix(file.basename(featurefile)) end if sub=="" then sub=false end local hash=name if sub then hash=hash.."-"..sub end hash=containers.cleanname(hash) local featurefiles if featurefile then featurefiles={} for s in gmatch(featurefile,"[^,]+") do local name=resolvers.findfile(file.addsuffix(s,'fea'),'fea') or "" if name=="" then report_otf("loading error, no featurefile %a",s) else local attr=lfs.attributes(name) featurefiles[#featurefiles+1]={ name=name, size=attr and attr.size or 0, time=attr and attr.modification or 0, } end end if #featurefiles==0 then featurefiles=nil end end local data=containers.read(otf.cache,hash) local reload=not data or data.size~=size or data.time~=time if forceload then report_otf("forced reload of %a due to hard coded flag",filename) reload=true end if not reload then local featuredata=data.featuredata if featurefiles then if not featuredata or #featuredata~=#featurefiles then reload=true else for i=1,#featurefiles do local fi,fd=featurefiles[i],featuredata[i] if fi.name~=fd.name or fi.size~=fd.size or fi.time~=fd.time then reload=true break end end end elseif featuredata then reload=true end if reload then report_otf("loading: forced reload due to changed featurefile specification %a",featurefile) end end if reload then report_otf("loading %a, hash %a",filename,hash) local fontdata,messages if sub then fontdata,messages=fontloader.open(filename,sub) else fontdata,messages=fontloader.open(filename) end if fontdata then mainfields=mainfields or (fontloaderfields and fontloaderfields(fontdata)) end if trace_loading and messages and #messages>0 then if type(messages)=="string" then report_otf("warning: %s",messages) else for m=1,#messages do report_otf("warning: %S",messages[m]) end end else report_otf("loading done") end if fontdata then if featurefiles then for i=1,#featurefiles do load_featurefile(fontdata,featurefiles[i].name) end end local unicodes={ } local splitter=lpeg.splitter(" ",unicodes) data={ size=size, time=time, format=otf_format(filename), featuredata=featurefiles, resources={ filename=resolvers.unresolve(filename), version=otf.version, creator="context mkiv", unicodes=unicodes, indices={ }, duplicates={ }, variants={ }, lookuptypes={}, }, metadata={ }, properties={ }, descriptions={}, goodies={}, helpers={ tounicodelist=splitter, tounicodetable=lpeg.Ct(splitter), }, } starttiming(data) report_otf("file size: %s",size) enhancers.apply(data,filename,fontdata) local packtime={} if packdata then if cleanup>0 then collectgarbage("collect") end starttiming(packtime) enhance("pack",data,filename,nil) stoptiming(packtime) end report_otf("saving %a in cache",filename) data=containers.write(otf.cache,hash,data) if cleanup>1 then collectgarbage("collect") end stoptiming(data) if elapsedtime then report_otf("preprocessing and caching time %s, packtime %s", elapsedtime(data),packdata and elapsedtime(packtime) or 0) end fontloader.close(fontdata) if cleanup>3 then collectgarbage("collect") end data=containers.read(otf.cache,hash) if cleanup>2 then collectgarbage("collect") end else data=nil report_otf("loading failed due to read error") end end if data then if trace_defining then report_otf("loading from cache using hash %a",hash) end enhance("unpack",data,filename,nil,false) if applyruntimefixes then applyruntimefixes(filename,data) end enhance("add dimensions",data,filename,nil,false) if trace_sequences then showfeatureorder(data,filename) end end return data end local mt={ __index=function(t,k) if k=="height" then local ht=t.boundingbox[4] return ht<0 and 0 or ht elseif k=="depth" then local dp=-t.boundingbox[2] return dp<0 and 0 or dp elseif k=="width" then return 0 elseif k=="name" then return forcenotdef and ".notdef" end end } actions["prepare tables"]=function(data,filename,raw) data.properties.hasitalics=false end actions["add dimensions"]=function(data,filename) if data then local descriptions=data.descriptions local resources=data.resources local defaultwidth=resources.defaultwidth or 0 local defaultheight=resources.defaultheight or 0 local defaultdepth=resources.defaultdepth or 0 local basename=trace_markwidth and file.basename(filename) if usemetatables then for _,d in next,descriptions do local wd=d.width if not wd then d.width=defaultwidth elseif trace_markwidth and wd~=0 and d.class=="mark" then report_otf("mark %a with width %b found in %a",d.name or "<noname>",wd,basename) end setmetatable(d,mt) end else for _,d in next,descriptions do local bb,wd=d.boundingbox,d.width if not wd then d.width=defaultwidth elseif trace_markwidth and wd~=0 and d.class=="mark" then report_otf("mark %a with width %b found in %a",d.name or "<noname>",wd,basename) end if bb then local ht,dp=bb[4],-bb[2] if ht==0 or ht<0 then else d.height=ht end if dp==0 or dp<0 then else d.depth=dp end end end end end end local function somecopy(old) if old then local new={} if type(old)=="table" then for k,v in next,old do if k=="glyphs" then elseif type(v)=="table" then new[k]=somecopy(v) else new[k]=v end end else for i=1,#mainfields do local k=mainfields[i] local v=old[k] if k=="glyphs" then elseif type(v)=="table" then new[k]=somecopy(v) else new[k]=v end end end return new else return {} end end actions["prepare glyphs"]=function(data,filename,raw) local rawglyphs=raw.glyphs local rawsubfonts=raw.subfonts local rawcidinfo=raw.cidinfo local criterium=constructors.privateoffset local private=criterium local resources=data.resources local metadata=data.metadata local properties=data.properties local descriptions=data.descriptions local unicodes=resources.unicodes local indices=resources.indices local duplicates=resources.duplicates local variants=resources.variants if rawsubfonts then metadata.subfonts=includesubfonts and {} properties.cidinfo=rawcidinfo if rawcidinfo.registry then local cidmap=fonts.cid.getmap(rawcidinfo) if cidmap then rawcidinfo.usedname=cidmap.usedname local nofnames,nofunicodes=0,0 local cidunicodes,cidnames=cidmap.unicodes,cidmap.names for cidindex=1,#rawsubfonts do local subfont=rawsubfonts[cidindex] local cidglyphs=subfont.glyphs if includesubfonts then metadata.subfonts[cidindex]=somecopy(subfont) end for index=0,subfont.glyphcnt-1 do local glyph=cidglyphs[index] if glyph then local unicode=glyph.unicode if unicode>=0x00E000 and unicode<=0x00F8FF then unicode=-1 elseif unicode>=0x0F0000 and unicode<=0x0FFFFD then unicode=-1 elseif unicode>=0x100000 and unicode<=0x10FFFD then unicode=-1 end local name=glyph.name or cidnames[index] if not unicode or unicode==-1 then unicode=cidunicodes[index] end if unicode and descriptions[unicode] then if trace_private then report_otf("preventing glyph %a at index %H to overload unicode %U",name or "noname",index,unicode) end unicode=-1 end if not unicode or unicode==-1 then if not name then name=format("u%06X.ctx",private) end unicode=private unicodes[name]=private if trace_private then report_otf("glyph %a at index %H is moved to private unicode slot %U",name,index,private) end private=private+1 nofnames=nofnames+1 else if not name then name=format("u%06X.ctx",unicode) end unicodes[name]=unicode nofunicodes=nofunicodes+1 end indices[index]=unicode local description={ boundingbox=glyph.boundingbox, name=glyph.name or name or "unknown", cidindex=cidindex, index=index, glyph=glyph, } descriptions[unicode]=description else end end end if trace_loading then report_otf("cid font remapped, %s unicode points, %s symbolic names, %s glyphs",nofunicodes,nofnames,nofunicodes+nofnames) end elseif trace_loading then report_otf("unable to remap cid font, missing cid file for %a",filename) end elseif trace_loading then report_otf("font %a has no glyphs",filename) end else for index=0,raw.glyphcnt-1 do local glyph=rawglyphs[index] if glyph then local unicode=glyph.unicode local name=glyph.name if not unicode or unicode==-1 then unicode=private unicodes[name]=private if trace_private then report_otf("glyph %a at index %H is moved to private unicode slot %U",name,index,private) end private=private+1 else if unicode>criterium then local taken=descriptions[unicode] if taken then if unicode>=private then private=unicode+1 else private=private+1 end descriptions[private]=taken unicodes[taken.name]=private indices[taken.index]=private if trace_private then report_otf("slot %U is moved to %U due to private in font",unicode) end else if unicode>=private then private=unicode+1 end end end unicodes[name]=unicode end indices[index]=unicode descriptions[unicode]={ boundingbox=glyph.boundingbox, name=name, index=index, glyph=glyph, } local altuni=glyph.altuni if altuni then for i=1,#altuni do local a=altuni[i] local u=a.unicode local v=a.variant if v then local vv=variants[v] if vv then vv[u]=unicode else vv={ [u]=unicode } variants[v]=vv end end end end else report_otf("potential problem: glyph %U is used but empty",index) end end end resources.private=private end actions["check encoding"]=function(data,filename,raw) local descriptions=data.descriptions local resources=data.resources local properties=data.properties local unicodes=resources.unicodes local indices=resources.indices local duplicates=resources.duplicates local mapdata=raw.map or {} local unicodetoindex=mapdata and mapdata.map or {} local indextounicode=mapdata and mapdata.backmap or {} local encname=lower(data.enc_name or mapdata.enc_name or "") local criterium=0xFFFF local privateoffset=constructors.privateoffset if find(encname,"unicode") then if trace_loading then report_otf("checking embedded unicode map %a",encname) end local reported={} for maybeunicode,index in next,unicodetoindex do if descriptions[maybeunicode] then else local unicode=indices[index] if not unicode then elseif maybeunicode==unicode then elseif unicode>privateoffset then else local d=descriptions[unicode] if d then local c=d.copies if c then c[maybeunicode]=true else d.copies={ [maybeunicode]=true } end elseif index and not reported[index] then report_otf("missing index %i",index) reported[index]=true end end end end for unicode,data in next,descriptions do local d=data.copies if d then duplicates[unicode]=sortedkeys(d) data.copies=nil end end elseif properties.cidinfo then report_otf("warning: no unicode map, used cidmap %a",properties.cidinfo.usedname) else report_otf("warning: non unicode map %a, only using glyph unicode data",encname or "whatever") end if mapdata then mapdata.map={} mapdata.backmap={} end end actions["add duplicates"]=function(data,filename,raw) local descriptions=data.descriptions local resources=data.resources local properties=data.properties local unicodes=resources.unicodes local indices=resources.indices local duplicates=resources.duplicates for unicode,d in next,duplicates do local nofduplicates=#d if nofduplicates>4 then if trace_loading then report_otf("ignoring excessive duplicates of %U (n=%s)",unicode,nofduplicates) end else for i=1,nofduplicates do local u=d[i] if not descriptions[u] then local description=descriptions[unicode] local n=0 for _,description in next,descriptions do if kerns then local kerns=description.kerns for _,k in next,kerns do local ku=k[unicode] if ku then k[u]=ku n=n+1 end end end end if u>0 then local duplicate=table.copy(description) duplicate.comment=format("copy of U+%05X",unicode) descriptions[u]=duplicate if trace_loading then report_otf("duplicating %U to %U with index %H (%s kerns)",unicode,u,description.index,n) end end end end end end end actions["analyze glyphs"]=function(data,filename,raw) local descriptions=data.descriptions local resources=data.resources local metadata=data.metadata local properties=data.properties local hasitalics=false local widths={} local marks={} for unicode,description in next,descriptions do local glyph=description.glyph local italic=glyph.italic_correction if not italic then elseif italic==0 then else description.italic=italic hasitalics=true end local width=glyph.width widths[width]=(widths[width] or 0)+1 local class=glyph.class if class then if class=="mark" then marks[unicode]=true end description.class=class end end properties.hasitalics=hasitalics resources.marks=marks local wd,most=0,1 for k,v in next,widths do if v>most then wd,most=k,v end end if most>1000 then if trace_loading then report_otf("most common width: %s (%s times), sharing (cjk font)",wd,most) end for unicode,description in next,descriptions do if description.width==wd then else description.width=description.glyph.width end end resources.defaultwidth=wd else for unicode,description in next,descriptions do description.width=description.glyph.width end end end actions["reorganize mark classes"]=function(data,filename,raw) local mark_classes=raw.mark_classes if mark_classes then local resources=data.resources local unicodes=resources.unicodes local markclasses={} resources.markclasses=markclasses for name,class in next,mark_classes do local t={} for s in gmatch(class,"[^ ]+") do t[unicodes[s]]=true end markclasses[name]=t end end end actions["reorganize features"]=function(data,filename,raw) local features={} data.resources.features=features for k,what in next,otf.glists do local dw=raw[what] if dw then local f={} features[what]=f for i=1,#dw do local d=dw[i] local dfeatures=d.features if dfeatures then for i=1,#dfeatures do local df=dfeatures[i] local tag=strip(lower(df.tag)) local ft=f[tag] if not ft then ft={} f[tag]=ft end local dscripts=df.scripts for i=1,#dscripts do local d=dscripts[i] local languages=d.langs local script=strip(lower(d.script)) local fts=ft[script] if not fts then fts={} ft[script]=fts end for i=1,#languages do fts[strip(lower(languages[i]))]=true end end end end end end end end actions["reorganize anchor classes"]=function(data,filename,raw) local resources=data.resources local anchor_to_lookup={} local lookup_to_anchor={} resources.anchor_to_lookup=anchor_to_lookup resources.lookup_to_anchor=lookup_to_anchor local classes=raw.anchor_classes if classes then for c=1,#classes do local class=classes[c] local anchor=class.name local lookups=class.lookup if type(lookups)~="table" then lookups={ lookups } end local a=anchor_to_lookup[anchor] if not a then a={} anchor_to_lookup[anchor]=a end for l=1,#lookups do local lookup=lookups[l] local l=lookup_to_anchor[lookup] if l then l[anchor]=true else l={ [anchor]=true } lookup_to_anchor[lookup]=l end a[lookup]=true end end end end actions["prepare tounicode"]=function(data,filename,raw) fonts.mappings.addtounicode(data,filename) end local g_directions={ gsub_contextchain=1, gpos_contextchain=1, gsub_reversecontextchain=-1, gpos_reversecontextchain=-1, } actions["reorganize subtables"]=function(data,filename,raw) local resources=data.resources local sequences={} local lookups={} local chainedfeatures={} resources.sequences=sequences resources.lookups=lookups for _,what in next,otf.glists do local dw=raw[what] if dw then for k=1,#dw do local gk=dw[k] local features=gk.features local typ=gk.type local chain=g_directions[typ] or 0 local subtables=gk.subtables if subtables then local t={} for s=1,#subtables do t[s]=subtables[s].name end subtables=t end local flags,markclass=gk.flags,nil if flags then local t={ (flags.ignorecombiningmarks and "mark") or false, (flags.ignoreligatures and "ligature") or false, (flags.ignorebaseglyphs and "base") or false, flags.r2l or false, } markclass=flags.mark_class if markclass then markclass=resources.markclasses[markclass] end flags=t end local name=gk.name if not name then report_otf("skipping weird lookup number %s",k) elseif features then local f={} local o={} for i=1,#features do local df=features[i] local tag=strip(lower(df.tag)) local ft=f[tag] if not ft then ft={} f[tag]=ft o[#o+1]=tag end local dscripts=df.scripts for i=1,#dscripts do local d=dscripts[i] local languages=d.langs local script=strip(lower(d.script)) local fts=ft[script] if not fts then fts={} ft[script]=fts end for i=1,#languages do fts[strip(lower(languages[i]))]=true end end end sequences[#sequences+1]={ type=typ, chain=chain, flags=flags, name=name, subtables=subtables, markclass=markclass, features=f, order=o, } else lookups[name]={ type=typ, chain=chain, flags=flags, subtables=subtables, markclass=markclass, } end end end end end actions["prepare lookups"]=function(data,filename,raw) local lookups=raw.lookups if lookups then data.lookups=lookups end end local function t_uncover(splitter,cache,covers) local result={} for n=1,#covers do local cover=covers[n] local uncovered=cache[cover] if not uncovered then uncovered=lpegmatch(splitter,cover) cache[cover]=uncovered end result[n]=uncovered end return result end local function s_uncover(splitter,cache,cover) if cover=="" then return nil else local uncovered=cache[cover] if not uncovered then uncovered=lpegmatch(splitter,cover) cache[cover]=uncovered end return { uncovered } end end local function t_hashed(t,cache) if t then local ht={} for i=1,#t do local ti=t[i] local tih=cache[ti] if not tih then tih={} for i=1,#ti do tih[ti[i]]=true end cache[ti]=tih end ht[i]=tih end return ht else return nil end end local function s_hashed(t,cache) if t then local ht={} local tf=t[1] for i=1,#tf do ht[i]={ [tf[i]]=true } end return ht else return nil end end local function r_uncover(splitter,cache,cover,replacements) if cover=="" then return nil else local uncovered=cover[1] local replaced=cache[replacements] if not replaced then replaced=lpegmatch(splitter,replacements) cache[replacements]=replaced end local nu,nr=#uncovered,#replaced local r={} if nu==nr then for i=1,nu do r[uncovered[i]]=replaced[i] end end return r end end actions["reorganize lookups"]=function(data,filename,raw) if data.lookups then local splitter=data.helpers.tounicodetable local t_u_cache={} local s_u_cache=t_u_cache local t_h_cache={} local s_h_cache=t_h_cache local r_u_cache={} for _,lookup in next,data.lookups do local rules=lookup.rules if rules then local format=lookup.format if format=="class" then local before_class=lookup.before_class if before_class then before_class=t_uncover(splitter,t_u_cache,reversed(before_class)) end local current_class=lookup.current_class if current_class then current_class=t_uncover(splitter,t_u_cache,current_class) end local after_class=lookup.after_class if after_class then after_class=t_uncover(splitter,t_u_cache,after_class) end for i=1,#rules do local rule=rules[i] local class=rule.class local before=class.before if before then for i=1,#before do before[i]=before_class[before[i]] or {} end rule.before=t_hashed(before,t_h_cache) end local current=class.current local lookups=rule.lookups if current then for i=1,#current do current[i]=current_class[current[i]] or {} if lookups and not lookups[i] then lookups[i]="" end end rule.current=t_hashed(current,t_h_cache) end local after=class.after if after then for i=1,#after do after[i]=after_class[after[i]] or {} end rule.after=t_hashed(after,t_h_cache) end rule.class=nil end lookup.before_class=nil lookup.current_class=nil lookup.after_class=nil lookup.format="coverage" elseif format=="coverage" then for i=1,#rules do local rule=rules[i] local coverage=rule.coverage if coverage then local before=coverage.before if before then before=t_uncover(splitter,t_u_cache,reversed(before)) rule.before=t_hashed(before,t_h_cache) end local current=coverage.current if current then current=t_uncover(splitter,t_u_cache,current) local lookups=rule.lookups if lookups then for i=1,#current do if not lookups[i] then lookups[i]="" end end end rule.current=t_hashed(current,t_h_cache) end local after=coverage.after if after then after=t_uncover(splitter,t_u_cache,after) rule.after=t_hashed(after,t_h_cache) end rule.coverage=nil end end elseif format=="reversecoverage" then for i=1,#rules do local rule=rules[i] local reversecoverage=rule.reversecoverage if reversecoverage then local before=reversecoverage.before if before then before=t_uncover(splitter,t_u_cache,reversed(before)) rule.before=t_hashed(before,t_h_cache) end local current=reversecoverage.current if current then current=t_uncover(splitter,t_u_cache,current) rule.current=t_hashed(current,t_h_cache) end local after=reversecoverage.after if after then after=t_uncover(splitter,t_u_cache,after) rule.after=t_hashed(after,t_h_cache) end local replacements=reversecoverage.replacements if replacements then rule.replacements=r_uncover(splitter,r_u_cache,current,replacements) end rule.reversecoverage=nil end end elseif format=="glyphs" then for i=1,#rules do local rule=rules[i] local glyphs=rule.glyphs if glyphs then local fore=glyphs.fore if fore and fore~="" then fore=s_uncover(splitter,s_u_cache,fore) rule.after=s_hashed(fore,s_h_cache) end local back=glyphs.back if back then back=s_uncover(splitter,s_u_cache,back) rule.before=s_hashed(back,s_h_cache) end local names=glyphs.names if names then names=s_uncover(splitter,s_u_cache,names) rule.current=s_hashed(names,s_h_cache) end rule.glyphs=nil local lookups=rule.lookups if lookups then for i=1,#names do if not lookups[i] then lookups[i]="" end end end end end end end end end end local function check_variants(unicode,the_variants,splitter,unicodes) local variants=the_variants.variants if variants then local glyphs=lpegmatch(splitter,variants) local done={ [unicode]=true } local n=0 for i=1,#glyphs do local g=glyphs[i] if done[g] then if i>1 then report_otf("skipping cyclic reference %U in math variant %U",g,unicode) end else if n==0 then n=1 variants={ g } else n=n+1 variants[n]=g end done[g]=true end end if n==0 then variants=nil end end local parts=the_variants.parts if parts then local p=#parts if p>0 then for i=1,p do local pi=parts[i] pi.glyph=unicodes[pi.component] or 0 pi.component=nil end else parts=nil end end local italic_correction=the_variants.italic_correction if italic_correction and italic_correction==0 then italic_correction=nil end return variants,parts,italic_correction end actions["analyze math"]=function(data,filename,raw) if raw.math then data.metadata.math=raw.math local unicodes=data.resources.unicodes local splitter=data.helpers.tounicodetable for unicode,description in next,data.descriptions do local glyph=description.glyph local mathkerns=glyph.mathkern local horiz_variants=glyph.horiz_variants local vert_variants=glyph.vert_variants local top_accent=glyph.top_accent if mathkerns or horiz_variants or vert_variants or top_accent then local math={} if top_accent then math.top_accent=top_accent end if mathkerns then for k,v in next,mathkerns do if not next(v) then mathkerns[k]=nil else for k,v in next,v do if v==0 then k[v]=nil end end end end math.kerns=mathkerns end if horiz_variants then math.horiz_variants,math.horiz_parts,math.horiz_italic_correction=check_variants(unicode,horiz_variants,splitter,unicodes) end if vert_variants then math.vert_variants,math.vert_parts,math.vert_italic_correction=check_variants(unicode,vert_variants,splitter,unicodes) end local italic_correction=description.italic if italic_correction and italic_correction~=0 then math.italic_correction=italic_correction end description.math=math end end end end actions["reorganize glyph kerns"]=function(data,filename,raw) local descriptions=data.descriptions local resources=data.resources local unicodes=resources.unicodes for unicode,description in next,descriptions do local kerns=description.glyph.kerns if kerns then local newkerns={} for k,kern in next,kerns do local name=kern.char local offset=kern.off local lookup=kern.lookup if name and offset and lookup then local unicode=unicodes[name] if unicode then if type(lookup)=="table" then for l=1,#lookup do local lookup=lookup[l] local lookupkerns=newkerns[lookup] if lookupkerns then lookupkerns[unicode]=offset else newkerns[lookup]={ [unicode]=offset } end end else local lookupkerns=newkerns[lookup] if lookupkerns then lookupkerns[unicode]=offset else newkerns[lookup]={ [unicode]=offset } end end elseif trace_loading then report_otf("problems with unicode %a of kern %a of glyph %U",name,k,unicode) end end end description.kerns=newkerns end end end actions["merge kern classes"]=function(data,filename,raw) local gposlist=raw.gpos if gposlist then local descriptions=data.descriptions local resources=data.resources local unicodes=resources.unicodes local splitter=data.helpers.tounicodetable local ignored=0 local blocked=0 for gp=1,#gposlist do local gpos=gposlist[gp] local subtables=gpos.subtables if subtables then local first_done={} local split={} for s=1,#subtables do local subtable=subtables[s] local kernclass=subtable.kernclass local lookup=subtable.lookup or subtable.name if kernclass then if #kernclass>0 then kernclass=kernclass[1] lookup=type(kernclass.lookup)=="string" and kernclass.lookup or lookup report_otf("fixing kernclass table of lookup %a",lookup) end local firsts=kernclass.firsts local seconds=kernclass.seconds local offsets=kernclass.offsets for n,s in next,firsts do split[s]=split[s] or lpegmatch(splitter,s) end local maxseconds=0 for n,s in next,seconds do if n>maxseconds then maxseconds=n end split[s]=split[s] or lpegmatch(splitter,s) end for fk=1,#firsts do local fv=firsts[fk] local splt=split[fv] if splt then local extrakerns={} local baseoffset=(fk-1)*maxseconds for sk=2,maxseconds do local sv=seconds[sk] local splt=split[sv] if splt then local offset=offsets[baseoffset+sk] if offset then for i=1,#splt do extrakerns[splt[i]]=offset end end end end for i=1,#splt do local first_unicode=splt[i] if first_done[first_unicode] then report_otf("lookup %a: ignoring further kerns of %C",lookup,first_unicode) blocked=blocked+1 else first_done[first_unicode]=true local description=descriptions[first_unicode] if description then local kerns=description.kerns if not kerns then kerns={} description.kerns=kerns end local lookupkerns=kerns[lookup] if not lookupkerns then lookupkerns={} kerns[lookup]=lookupkerns end if overloadkerns then for second_unicode,kern in next,extrakerns do lookupkerns[second_unicode]=kern end else for second_unicode,kern in next,extrakerns do local k=lookupkerns[second_unicode] if not k then lookupkerns[second_unicode]=kern elseif k~=kern then if trace_loading then report_otf("lookup %a: ignoring overload of kern between %C and %C, rejecting %a, keeping %a",lookup,first_unicode,second_unicode,k,kern) end ignored=ignored+1 end end end elseif trace_loading then report_otf("no glyph data for %U",first_unicode) end end end end end subtable.kernclass={} end end end end if ignored>0 then report_otf("%s kern overloads ignored",ignored) end if blocked>0 then report_otf("%s succesive kerns blocked",blocked) end end end actions["check glyphs"]=function(data,filename,raw) for unicode,description in next,data.descriptions do description.glyph=nil end end actions["check metadata"]=function(data,filename,raw) local metadata=data.metadata for _,k in next,mainfields do if valid_fields[k] then local v=raw[k] if not metadata[k] then metadata[k]=v end end end local ttftables=metadata.ttf_tables if ttftables then for i=1,#ttftables do ttftables[i].data="deleted" end end if metadata.validation_state and table.contains(metadata.validation_state,"bad_ps_fontname") then local name=file.nameonly(filename) metadata.fontname="bad-fontname-"..name metadata.fullname="bad-fullname-"..name end end actions["cleanup tables"]=function(data,filename,raw) data.resources.indices=nil data.helpers=nil end actions["reorganize glyph lookups"]=function(data,filename,raw) local resources=data.resources local unicodes=resources.unicodes local descriptions=data.descriptions local splitter=data.helpers.tounicodelist local lookuptypes=resources.lookuptypes for unicode,description in next,descriptions do local lookups=description.glyph.lookups if lookups then for tag,lookuplist in next,lookups do for l=1,#lookuplist do local lookup=lookuplist[l] local specification=lookup.specification local lookuptype=lookup.type local lt=lookuptypes[tag] if not lt then lookuptypes[tag]=lookuptype elseif lt~=lookuptype then report_otf("conflicting lookuptypes, %a points to %a and %a",tag,lt,lookuptype) end if lookuptype=="ligature" then lookuplist[l]={ lpegmatch(splitter,specification.components) } elseif lookuptype=="alternate" then lookuplist[l]={ lpegmatch(splitter,specification.components) } elseif lookuptype=="substitution" then lookuplist[l]=unicodes[specification.variant] elseif lookuptype=="multiple" then lookuplist[l]={ lpegmatch(splitter,specification.components) } elseif lookuptype=="position" then lookuplist[l]={ specification.x or 0, specification.y or 0, specification.h or 0, specification.v or 0 } elseif lookuptype=="pair" then local one=specification.offsets[1] local two=specification.offsets[2] local paired=unicodes[specification.paired] if one then if two then lookuplist[l]={ paired,{ one.x or 0,one.y or 0,one.h or 0,one.v or 0 },{ two.x or 0,two.y or 0,two.h or 0,two.v or 0 } } else lookuplist[l]={ paired,{ one.x or 0,one.y or 0,one.h or 0,one.v or 0 } } end else if two then lookuplist[l]={ paired,{},{ two.x or 0,two.y or 0,two.h or 0,two.v or 0} } else lookuplist[l]={ paired } end end end end end local slookups,mlookups for tag,lookuplist in next,lookups do if #lookuplist==1 then if slookups then slookups[tag]=lookuplist[1] else slookups={ [tag]=lookuplist[1] } end else if mlookups then mlookups[tag]=lookuplist else mlookups={ [tag]=lookuplist } end end end if slookups then description.slookups=slookups end if mlookups then description.mlookups=mlookups end end end end actions["reorganize glyph anchors"]=function(data,filename,raw) local descriptions=data.descriptions for unicode,description in next,descriptions do local anchors=description.glyph.anchors if anchors then for class,data in next,anchors do if class=="baselig" then for tag,specification in next,data do for i=1,#specification do local si=specification[i] specification[i]={ si and si.x or 0,si and si.y or 0 } end end else for tag,specification in next,data do data[tag]={ specification.x or 0,specification.y or 0 } end end end description.anchors=anchors end end end function otf.setfeatures(tfmdata,features) local okay=constructors.initializefeatures("otf",tfmdata,features,trace_features,report_otf) if okay then return constructors.collectprocessors("otf",tfmdata,features,trace_features,report_otf) else return {} end end local function copytotfm(data,cache_id) if data then local metadata=data.metadata local resources=data.resources local properties=derivetable(data.properties) local descriptions=derivetable(data.descriptions) local goodies=derivetable(data.goodies) local characters={} local parameters={} local mathparameters={} local pfminfo=metadata.pfminfo or {} local resources=data.resources local unicodes=resources.unicodes local spaceunits=500 local spacer="space" local designsize=metadata.designsize or metadata.design_size or 100 local mathspecs=metadata.math if designsize==0 then designsize=100 end if mathspecs then for name,value in next,mathspecs do mathparameters[name]=value end end for unicode,_ in next,data.descriptions do characters[unicode]={} end if mathspecs then for unicode,character in next,characters do local d=descriptions[unicode] local m=d.math if m then local variants=m.horiz_variants local parts=m.horiz_parts if variants then local c=character for i=1,#variants do local un=variants[i] c.next=un c=characters[un] end c.horiz_variants=parts elseif parts then character.horiz_variants=parts end local variants=m.vert_variants local parts=m.vert_parts if variants then local c=character for i=1,#variants do local un=variants[i] c.next=un c=characters[un] end c.vert_variants=parts elseif parts then character.vert_variants=parts end local italic_correction=m.vert_italic_correction if italic_correction then character.vert_italic_correction=italic_correction end local top_accent=m.top_accent if top_accent then character.top_accent=top_accent end local kerns=m.kerns if kerns then character.mathkerns=kerns end end end end local filename=constructors.checkedfilename(resources) local fontname=metadata.fontname local fullname=metadata.fullname or fontname local units=metadata.units_per_em or 1000 if units==0 then units=1000 metadata.units_per_em=1000 report_otf("changing %a units to %a",0,units) end local monospaced=metadata.isfixedpitch or (pfminfo.panose and pfminfo.panose.proportion=="Monospaced") local charwidth=pfminfo.avgwidth local charxheight=pfminfo.os2_xheight and pfminfo.os2_xheight>0 and pfminfo.os2_xheight local italicangle=metadata.italicangle properties.monospaced=monospaced parameters.italicangle=italicangle parameters.charwidth=charwidth parameters.charxheight=charxheight local space=0x0020 local emdash=0x2014 if monospaced then if descriptions[space] then spaceunits,spacer=descriptions[space].width,"space" end if not spaceunits and descriptions[emdash] then spaceunits,spacer=descriptions[emdash].width,"emdash" end if not spaceunits and charwidth then spaceunits,spacer=charwidth,"charwidth" end else if descriptions[space] then spaceunits,spacer=descriptions[space].width,"space" end if not spaceunits and descriptions[emdash] then spaceunits,spacer=descriptions[emdash].width/2,"emdash/2" end if not spaceunits and charwidth then spaceunits,spacer=charwidth,"charwidth" end end spaceunits=tonumber(spaceunits) or 500 parameters.slant=0 parameters.space=spaceunits parameters.space_stretch=units/2 parameters.space_shrink=1*units/3 parameters.x_height=2*units/5 parameters.quad=units if spaceunits<2*units/5 then end if italicangle and italicangle~=0 then parameters.italicangle=italicangle parameters.italicfactor=math.cos(math.rad(90+italicangle)) parameters.slant=- math.tan(italicangle*math.pi/180) end if monospaced then parameters.space_stretch=0 parameters.space_shrink=0 elseif syncspace then parameters.space_stretch=spaceunits/2 parameters.space_shrink=spaceunits/3 end parameters.extra_space=parameters.space_shrink if charxheight then parameters.x_height=charxheight else local x=0x78 if x then local x=descriptions[x] if x then parameters.x_height=x.height end end end parameters.designsize=(designsize/10)*65536 parameters.ascender=abs(metadata.ascent or 0) parameters.descender=abs(metadata.descent or 0) parameters.units=units properties.space=spacer properties.encodingbytes=2 properties.format=data.format or otf_format(filename) or formats.otf properties.noglyphnames=true properties.filename=filename properties.fontname=fontname properties.fullname=fullname properties.psname=fontname or fullname properties.name=filename or fullname return { characters=characters, descriptions=descriptions, parameters=parameters, mathparameters=mathparameters, resources=resources, properties=properties, goodies=goodies, } end end local function otftotfm(specification) local cache_id=specification.hash local tfmdata=containers.read(constructors.cache,cache_id) if not tfmdata then local name=specification.name local sub=specification.sub local filename=specification.filename local features=specification.features.normal local rawdata=otf.load(filename,sub,features and features.featurefile) if rawdata and next(rawdata) then local descriptions=rawdata.descriptions local duplicates=rawdata.resources.duplicates if duplicates then local nofduplicates,nofduplicated=0,0 for parent,list in next,duplicates do for i=1,#list do local unicode=list[i] if not descriptions[unicode] then descriptions[unicode]=descriptions[parent] nofduplicated=nofduplicated+1 end end nofduplicates=nofduplicates+#list end if trace_otf and nofduplicated~=nofduplicates then report_otf("%i extra duplicates copied out of %i",nofduplicated,nofduplicates) end end rawdata.lookuphash={} tfmdata=copytotfm(rawdata,cache_id) if tfmdata and next(tfmdata) then local features=constructors.checkedfeatures("otf",features) local shared=tfmdata.shared if not shared then shared={} tfmdata.shared=shared end shared.rawdata=rawdata shared.dynamics={} tfmdata.changed={} shared.features=features shared.processes=otf.setfeatures(tfmdata,features) end end containers.write(constructors.cache,cache_id,tfmdata) end return tfmdata end local function read_from_otf(specification) local tfmdata=otftotfm(specification) if tfmdata then tfmdata.properties.name=specification.name tfmdata.properties.sub=specification.sub tfmdata=constructors.scale(tfmdata,specification) local allfeatures=tfmdata.shared.features or specification.features.normal constructors.applymanipulators("otf",tfmdata,allfeatures,trace_features,report_otf) constructors.setname(tfmdata,specification) fonts.loggers.register(tfmdata,file.suffix(specification.filename),specification) end return tfmdata end local function checkmathsize(tfmdata,mathsize) local mathdata=tfmdata.shared.rawdata.metadata.math local mathsize=tonumber(mathsize) if mathdata then local parameters=tfmdata.parameters parameters.scriptpercentage=mathdata.ScriptPercentScaleDown parameters.scriptscriptpercentage=mathdata.ScriptScriptPercentScaleDown parameters.mathsize=mathsize end end registerotffeature { name="mathsize", description="apply mathsize specified in the font", initializers={ base=checkmathsize, node=checkmathsize, } } function otf.collectlookups(rawdata,kind,script,language) local sequences=rawdata.resources.sequences if sequences then local featuremap,featurelist={},{} for s=1,#sequences do local sequence=sequences[s] local features=sequence.features features=features and features[kind] features=features and (features[script] or features[default] or features[wildcard]) features=features and (features[language] or features[default] or features[wildcard]) if features then local subtables=sequence.subtables if subtables then for s=1,#subtables do local ss=subtables[s] if not featuremap[s] then featuremap[ss]=true featurelist[#featurelist+1]=ss end end end end end if #featurelist>0 then return featuremap,featurelist end end return nil,nil end local function check_otf(forced,specification,suffix) local name=specification.name if forced then name=specification.forcedname end local fullname=findbinfile(name,suffix) or "" if fullname=="" then fullname=fonts.names.getfilename(name,suffix) or "" end if fullname~="" and not fonts.names.ignoredfile(fullname) then specification.filename=fullname return read_from_otf(specification) end end local function opentypereader(specification,suffix) local forced=specification.forced or "" if formats[forced] then return check_otf(true,specification,forced) else return check_otf(false,specification,suffix) end end readers.opentype=opentypereader function readers.otf (specification) return opentypereader(specification,"otf") end function readers.ttf (specification) return opentypereader(specification,"ttf") end function readers.ttc (specification) return opentypereader(specification,"ttf") end function readers.dfont(specification) return opentypereader(specification,"ttf") end function otf.scriptandlanguage(tfmdata,attr) local properties=tfmdata.properties return properties.script or "dflt",properties.language or "dflt" end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['font-otb']={ version=1.001, comment="companion to font-ini.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local concat=table.concat local format,gmatch,gsub,find,match,lower,strip=string.format,string.gmatch,string.gsub,string.find,string.match,string.lower,string.strip local type,next,tonumber,tostring=type,next,tonumber,tostring local lpegmatch=lpeg.match local utfchar=utf.char local trace_baseinit=false trackers.register("otf.baseinit",function(v) trace_baseinit=v end) local trace_singles=false trackers.register("otf.singles",function(v) trace_singles=v end) local trace_multiples=false trackers.register("otf.multiples",function(v) trace_multiples=v end) local trace_alternatives=false trackers.register("otf.alternatives",function(v) trace_alternatives=v end) local trace_ligatures=false trackers.register("otf.ligatures",function(v) trace_ligatures=v end) local trace_ligatures_detail=false trackers.register("otf.ligatures.detail",function(v) trace_ligatures_detail=v end) local trace_kerns=false trackers.register("otf.kerns",function(v) trace_kerns=v end) local trace_preparing=false trackers.register("otf.preparing",function(v) trace_preparing=v end) local report_prepare=logs.reporter("fonts","otf prepare") local fonts=fonts local otf=fonts.handlers.otf local otffeatures=otf.features local registerotffeature=otffeatures.register otf.defaultbasealternate="none" local wildcard="*" local default="dflt" local formatters=string.formatters local f_unicode=formatters["%U"] local f_uniname=formatters["%U (%s)"] local f_unilist=formatters["% t (% t)"] local function gref(descriptions,n) if type(n)=="number" then local name=descriptions[n].name if name then return f_uniname(n,name) else return f_unicode(n) end elseif n then local num,nam,j={},{},0 for i=1,#n do local ni=n[i] if tonumber(ni) then j=j+1 local di=descriptions[ni] num[j]=f_unicode(ni) nam[j]=di and di.name or "-" end end return f_unilist(num,nam) else return "<error in base mode tracing>" end end local function cref(feature,lookupname) if lookupname then return formatters["feature %a, lookup %a"](feature,lookupname) else return formatters["feature %a"](feature) end end local function report_alternate(feature,lookupname,descriptions,unicode,replacement,value,comment) report_prepare("%s: base alternate %s => %s (%S => %S)", cref(feature,lookupname), gref(descriptions,unicode), replacement and gref(descriptions,replacement), value, comment) end local function report_substitution(feature,lookupname,descriptions,unicode,substitution) report_prepare("%s: base substitution %s => %S", cref(feature,lookupname), gref(descriptions,unicode), gref(descriptions,substitution)) end local function report_ligature(feature,lookupname,descriptions,unicode,ligature) report_prepare("%s: base ligature %s => %S", cref(feature,lookupname), gref(descriptions,ligature), gref(descriptions,unicode)) end local function report_kern(feature,lookupname,descriptions,unicode,otherunicode,value) report_prepare("%s: base kern %s + %s => %S", cref(feature,lookupname), gref(descriptions,unicode), gref(descriptions,otherunicode), value) end local basemethods={} local basemethod="<unset>" local function applybasemethod(what,...) local m=basemethods[basemethod][what] if m then return m(...) end end local basehash,basehashes,applied={},1,{} local function registerbasehash(tfmdata) local properties=tfmdata.properties local hash=concat(applied," ") local base=basehash[hash] if not base then basehashes=basehashes+1 base=basehashes basehash[hash]=base end properties.basehash=base properties.fullname=properties.fullname.."-"..base applied={} end local function registerbasefeature(feature,value) applied[#applied+1]=feature.."="..tostring(value) end local trace=false local function finalize_ligatures(tfmdata,ligatures) local nofligatures=#ligatures if nofligatures>0 then local characters=tfmdata.characters local descriptions=tfmdata.descriptions local resources=tfmdata.resources local unicodes=resources.unicodes local private=resources.private local alldone=false while not alldone do local done=0 for i=1,nofligatures do local ligature=ligatures[i] if ligature then local unicode,lookupdata=ligature[1],ligature[2] if trace_ligatures_detail then report_prepare("building % a into %a",lookupdata,unicode) end local size=#lookupdata local firstcode=lookupdata[1] local firstdata=characters[firstcode] local okay=false if firstdata then local firstname="ctx_"..firstcode for i=1,size-1 do local firstdata=characters[firstcode] if not firstdata then firstcode=private if trace_ligatures_detail then report_prepare("defining %a as %a",firstname,firstcode) end unicodes[firstname]=firstcode firstdata={ intermediate=true,ligatures={} } characters[firstcode]=firstdata descriptions[firstcode]={ name=firstname } private=private+1 end local target local secondcode=lookupdata[i+1] local secondname=firstname.."_"..secondcode if i==size-1 then target=unicode if not unicodes[secondname] then unicodes[secondname]=unicode end okay=true else target=unicodes[secondname] if not target then break end end if trace_ligatures_detail then report_prepare("codes (%a,%a) + (%a,%a) -> %a",firstname,firstcode,secondname,secondcode,target) end local firstligs=firstdata.ligatures if firstligs then firstligs[secondcode]={ char=target } else firstdata.ligatures={ [secondcode]={ char=target } } end firstcode=target firstname=secondname end elseif trace_ligatures_detail then report_prepare("no glyph (%a,%a) for building %a",firstname,firstcode,target) end if okay then ligatures[i]=false done=done+1 end end end alldone=done==0 end if trace_ligatures_detail then for k,v in table.sortedhash(characters) do if v.ligatures then table.print(v,k) end end end resources.private=private end end local function preparesubstitutions(tfmdata,feature,value,validlookups,lookuplist) local characters=tfmdata.characters local descriptions=tfmdata.descriptions local resources=tfmdata.resources local changed=tfmdata.changed local unicodes=resources.unicodes local lookuphash=resources.lookuphash local lookuptypes=resources.lookuptypes local ligatures={} local alternate=tonumber(value) or true and 1 local defaultalt=otf.defaultbasealternate local trace_singles=trace_baseinit and trace_singles local trace_alternatives=trace_baseinit and trace_alternatives local trace_ligatures=trace_baseinit and trace_ligatures local actions={ substitution=function(lookupdata,lookupname,description,unicode) if trace_singles then report_substitution(feature,lookupname,descriptions,unicode,lookupdata) end changed[unicode]=lookupdata end, alternate=function(lookupdata,lookupname,description,unicode) local replacement=lookupdata[alternate] if replacement then changed[unicode]=replacement if trace_alternatives then report_alternate(feature,lookupname,descriptions,unicode,replacement,value,"normal") end elseif defaultalt=="first" then replacement=lookupdata[1] changed[unicode]=replacement if trace_alternatives then report_alternate(feature,lookupname,descriptions,unicode,replacement,value,defaultalt) end elseif defaultalt=="last" then replacement=lookupdata[#data] if trace_alternatives then report_alternate(feature,lookupname,descriptions,unicode,replacement,value,defaultalt) end else if trace_alternatives then report_alternate(feature,lookupname,descriptions,unicode,replacement,value,"unknown") end end end, ligature=function(lookupdata,lookupname,description,unicode) if trace_ligatures then report_ligature(feature,lookupname,descriptions,unicode,lookupdata) end ligatures[#ligatures+1]={ unicode,lookupdata } end, } for unicode,character in next,characters do local description=descriptions[unicode] local lookups=description.slookups if lookups then for l=1,#lookuplist do local lookupname=lookuplist[l] local lookupdata=lookups[lookupname] if lookupdata then local lookuptype=lookuptypes[lookupname] local action=actions[lookuptype] if action then action(lookupdata,lookupname,description,unicode) end end end end local lookups=description.mlookups if lookups then for l=1,#lookuplist do local lookupname=lookuplist[l] local lookuplist=lookups[lookupname] if lookuplist then local lookuptype=lookuptypes[lookupname] local action=actions[lookuptype] if action then for i=1,#lookuplist do action(lookuplist[i],lookupname,description,unicode) end end end end end end finalize_ligatures(tfmdata,ligatures) end local function preparepositionings(tfmdata,feature,value,validlookups,lookuplist) local characters=tfmdata.characters local descriptions=tfmdata.descriptions local resources=tfmdata.resources local unicodes=resources.unicodes local sharedkerns={} local traceindeed=trace_baseinit and trace_kerns for unicode,character in next,characters do local description=descriptions[unicode] local rawkerns=description.kerns if rawkerns then local s=sharedkerns[rawkerns] if s==false then elseif s then character.kerns=s else local newkerns=character.kerns local done=false for l=1,#lookuplist do local lookup=lookuplist[l] local kerns=rawkerns[lookup] if kerns then for otherunicode,value in next,kerns do if value==0 then elseif not newkerns then newkerns={ [otherunicode]=value } done=true if traceindeed then report_kern(feature,lookup,descriptions,unicode,otherunicode,value) end elseif not newkerns[otherunicode] then newkerns[otherunicode]=value done=true if traceindeed then report_kern(feature,lookup,descriptions,unicode,otherunicode,value) end end end end end if done then sharedkerns[rawkerns]=newkerns character.kerns=newkerns else sharedkerns[rawkerns]=false end end end end end basemethods.independent={ preparesubstitutions=preparesubstitutions, preparepositionings=preparepositionings, } local function makefake(tfmdata,name,present) local resources=tfmdata.resources local private=resources.private local character={ intermediate=true,ligatures={} } resources.unicodes[name]=private tfmdata.characters[private]=character tfmdata.descriptions[private]={ name=name } resources.private=private+1 present[name]=private return character end local function make_1(present,tree,name) for k,v in next,tree do if k=="ligature" then present[name]=v else make_1(present,v,name.."_"..k) end end end local function make_2(present,tfmdata,characters,tree,name,preceding,unicode,done,lookupname) for k,v in next,tree do if k=="ligature" then local character=characters[preceding] if not character then if trace_baseinit then report_prepare("weird ligature in lookup %a, current %C, preceding %C",lookupname,v,preceding) end character=makefake(tfmdata,name,present) end local ligatures=character.ligatures if ligatures then ligatures[unicode]={ char=v } else character.ligatures={ [unicode]={ char=v } } end if done then local d=done[lookupname] if not d then done[lookupname]={ "dummy",v } else d[#d+1]=v end end else local code=present[name] or unicode local name=name.."_"..k make_2(present,tfmdata,characters,v,name,code,k,done,lookupname) end end end local function preparesubstitutions(tfmdata,feature,value,validlookups,lookuplist) local characters=tfmdata.characters local descriptions=tfmdata.descriptions local resources=tfmdata.resources local changed=tfmdata.changed local lookuphash=resources.lookuphash local lookuptypes=resources.lookuptypes local ligatures={} local alternate=tonumber(value) or true and 1 local defaultalt=otf.defaultbasealternate local trace_singles=trace_baseinit and trace_singles local trace_alternatives=trace_baseinit and trace_alternatives local trace_ligatures=trace_baseinit and trace_ligatures for l=1,#lookuplist do local lookupname=lookuplist[l] local lookupdata=lookuphash[lookupname] local lookuptype=lookuptypes[lookupname] for unicode,data in next,lookupdata do if lookuptype=="substitution" then if trace_singles then report_substitution(feature,lookupname,descriptions,unicode,data) end changed[unicode]=data elseif lookuptype=="alternate" then local replacement=data[alternate] if replacement then changed[unicode]=replacement if trace_alternatives then report_alternate(feature,lookupname,descriptions,unicode,replacement,value,"normal") end elseif defaultalt=="first" then replacement=data[1] changed[unicode]=replacement if trace_alternatives then report_alternate(feature,lookupname,descriptions,unicode,replacement,value,defaultalt) end elseif defaultalt=="last" then replacement=data[#data] if trace_alternatives then report_alternate(feature,lookupname,descriptions,unicode,replacement,value,defaultalt) end else if trace_alternatives then report_alternate(feature,lookupname,descriptions,unicode,replacement,value,"unknown") end end elseif lookuptype=="ligature" then ligatures[#ligatures+1]={ unicode,data,lookupname } if trace_ligatures then report_ligature(feature,lookupname,descriptions,unicode,data) end end end end local nofligatures=#ligatures if nofligatures>0 then local characters=tfmdata.characters local present={} local done=trace_baseinit and trace_ligatures and {} for i=1,nofligatures do local ligature=ligatures[i] local unicode,tree=ligature[1],ligature[2] make_1(present,tree,"ctx_"..unicode) end for i=1,nofligatures do local ligature=ligatures[i] local unicode,tree,lookupname=ligature[1],ligature[2],ligature[3] make_2(present,tfmdata,characters,tree,"ctx_"..unicode,unicode,unicode,done,lookupname) end end end local function preparepositionings(tfmdata,feature,value,validlookups,lookuplist) local characters=tfmdata.characters local descriptions=tfmdata.descriptions local resources=tfmdata.resources local lookuphash=resources.lookuphash local traceindeed=trace_baseinit and trace_kerns for l=1,#lookuplist do local lookupname=lookuplist[l] local lookupdata=lookuphash[lookupname] for unicode,data in next,lookupdata do local character=characters[unicode] local kerns=character.kerns if not kerns then kerns={} character.kerns=kerns end if traceindeed then for otherunicode,kern in next,data do if not kerns[otherunicode] and kern~=0 then kerns[otherunicode]=kern report_kern(feature,lookup,descriptions,unicode,otherunicode,kern) end end else for otherunicode,kern in next,data do if not kerns[otherunicode] and kern~=0 then kerns[otherunicode]=kern end end end end end end local function initializehashes(tfmdata) nodeinitializers.features(tfmdata) end basemethods.shared={ initializehashes=initializehashes, preparesubstitutions=preparesubstitutions, preparepositionings=preparepositionings, } basemethod="independent" local function featuresinitializer(tfmdata,value) if true then local starttime=trace_preparing and os.clock() local features=tfmdata.shared.features local fullname=tfmdata.properties.fullname or "?" if features then applybasemethod("initializehashes",tfmdata) local collectlookups=otf.collectlookups local rawdata=tfmdata.shared.rawdata local properties=tfmdata.properties local script=properties.script local language=properties.language local basesubstitutions=rawdata.resources.features.gsub local basepositionings=rawdata.resources.features.gpos if basesubstitutions or basepositionings then local sequences=tfmdata.resources.sequences for s=1,#sequences do local sequence=sequences[s] local sfeatures=sequence.features if sfeatures then local order=sequence.order if order then for i=1,#order do local feature=order[i] local value=features[feature] if value then local validlookups,lookuplist=collectlookups(rawdata,feature,script,language) if not validlookups then elseif basesubstitutions and basesubstitutions[feature] then if trace_preparing then report_prepare("filtering base %s feature %a for %a with value %a","sub",feature,fullname,value) end applybasemethod("preparesubstitutions",tfmdata,feature,value,validlookups,lookuplist) registerbasefeature(feature,value) elseif basepositionings and basepositionings[feature] then if trace_preparing then report_prepare("filtering base %a feature %a for %a with value %a","pos",feature,fullname,value) end applybasemethod("preparepositionings",tfmdata,feature,value,validlookups,lookuplist) registerbasefeature(feature,value) end end end end end end end registerbasehash(tfmdata) end if trace_preparing then report_prepare("preparation time is %0.3f seconds for %a",os.clock()-starttime,fullname) end end end registerotffeature { name="features", description="features", default=true, initializers={ base=featuresinitializer, } } directives.register("fonts.otf.loader.basemethod",function(v) if basemethods[v] then basemethod=v end end) end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['node-inj']={ version=1.001, comment="companion to node-ini.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files", } local next=next local utfchar=utf.char local trace_injections=false trackers.register("nodes.injections",function(v) trace_injections=v end) local report_injections=logs.reporter("nodes","injections") local attributes,nodes,node=attributes,nodes,node fonts=fonts local fontdata=fonts.hashes.identifiers nodes.injections=nodes.injections or {} local injections=nodes.injections local nodecodes=nodes.nodecodes local glyph_code=nodecodes.glyph local kern_code=nodecodes.kern local nodepool=nodes.pool local newkern=nodepool.kern local traverse_id=node.traverse_id local insert_node_before=node.insert_before local insert_node_after=node.insert_after local a_kernpair=attributes.private('kernpair') local a_ligacomp=attributes.private('ligacomp') local a_markbase=attributes.private('markbase') local a_markmark=attributes.private('markmark') local a_markdone=attributes.private('markdone') local a_cursbase=attributes.private('cursbase') local a_curscurs=attributes.private('curscurs') local a_cursdone=attributes.private('cursdone') function injections.installnewkern(nk) newkern=nk or newkern end local cursives={} local marks={} local kerns={} function injections.setcursive(start,nxt,factor,rlmode,exit,entry,tfmstart,tfmnext) local dx,dy=factor*(exit[1]-entry[1]),factor*(exit[2]-entry[2]) local ws,wn=tfmstart.width,tfmnext.width local bound=#cursives+1 start[a_cursbase]=bound nxt[a_curscurs]=bound cursives[bound]={ rlmode,dx,dy,ws,wn } return dx,dy,bound end function injections.setpair(current,factor,rlmode,r2lflag,spec,tfmchr) local x,y,w,h=factor*spec[1],factor*spec[2],factor*spec[3],factor*spec[4] if x~=0 or w~=0 or y~=0 or h~=0 then local bound=current[a_kernpair] if bound then local kb=kerns[bound] kb[2],kb[3],kb[4],kb[5]=(kb[2] or 0)+x,(kb[3] or 0)+y,(kb[4] or 0)+w,(kb[5] or 0)+h else bound=#kerns+1 current[a_kernpair]=bound kerns[bound]={ rlmode,x,y,w,h,r2lflag,tfmchr.width } end return x,y,w,h,bound end return x,y,w,h end function injections.setkern(current,factor,rlmode,x,tfmchr) local dx=factor*x if dx~=0 then local bound=#kerns+1 current[a_kernpair]=bound kerns[bound]={ rlmode,dx } return dx,bound else return 0,0 end end function injections.setmark(start,base,factor,rlmode,ba,ma) local dx,dy=factor*(ba[1]-ma[1]),factor*(ba[2]-ma[2]) local bound=base[a_markbase] local index=1 if bound then local mb=marks[bound] if mb then index=#mb+1 mb[index]={ dx,dy,rlmode } start[a_markmark]=bound start[a_markdone]=index return dx,dy,bound else report_injections("possible problem, %U is base mark without data (id %a)",base.char,bound) end end index=index or 1 bound=#marks+1 base[a_markbase]=bound start[a_markmark]=bound start[a_markdone]=index marks[bound]={ [index]={ dx,dy,rlmode } } return dx,dy,bound end local function dir(n) return (n and n<0 and "r-to-l") or (n and n>0 and "l-to-r") or "unset" end local function trace(head) report_injections("begin run") for n in traverse_id(glyph_code,head) do if n.subtype<256 then local kp=n[a_kernpair] local mb=n[a_markbase] local mm=n[a_markmark] local md=n[a_markdone] local cb=n[a_cursbase] local cc=n[a_curscurs] local char=n.char report_injections("font %s, char %U, glyph %c",n.font,char,char) if kp then local k=kerns[kp] if k[3] then report_injections(" pairkern: dir %a, x %p, y %p, w %p, h %p",dir(k[1]),k[2],k[3],k[4],k[5]) else report_injections(" kern: dir %a, dx %p",dir(k[1]),k[2]) end end if mb then report_injections(" markbase: bound %a",mb) end if mm then local m=marks[mm] if mb then local m=m[mb] if m then report_injections(" markmark: bound %a, index %a, dx %p, dy %p",mm,md,m[1],m[2]) else report_injections(" markmark: bound %a, missing index",mm) end else m=m[1] report_injections(" markmark: bound %a, dx %p, dy %p",mm,m and m[1],m and m[2]) end end if cb then report_injections(" cursbase: bound %a",cb) end if cc then local c=cursives[cc] report_injections(" curscurs: bound %a, dir %a, dx %p, dy %p",cc,dir(c[1]),c[2],c[3]) end end end report_injections("end run") end local function show_result(head) local current=head local skipping=false while current do local id=current.id if id==glyph_code then report_injections("char: %C, width %p, xoffset %p, yoffset %p",current.char,current.width,current.xoffset,current.yoffset) skipping=false elseif id==kern_code then report_injections("kern: %p",current.kern) skipping=false elseif not skipping then report_injections() skipping=true end current=current.next end end function injections.handler(head,where,keep) local has_marks,has_cursives,has_kerns=next(marks),next(cursives),next(kerns) if has_marks or has_cursives then if trace_injections then trace(head) end local done,ky,rl,valid,cx,wx,mk,nofvalid=false,{},{},{},{},{},{},0 if has_kerns then local nf,tm=nil,nil for n in traverse_id(glyph_code,head) do if n.subtype<256 then nofvalid=nofvalid+1 valid[nofvalid]=n if n.font~=nf then nf=n.font tm=fontdata[nf].resources.marks end if tm then mk[n]=tm[n.char] end local k=n[a_kernpair] if k then local kk=kerns[k] if kk then local x,y,w,h=kk[2] or 0,kk[3] or 0,kk[4] or 0,kk[5] or 0 local dy=y-h if dy~=0 then ky[n]=dy end if w~=0 or x~=0 then wx[n]=kk end rl[n]=kk[1] end end end end else local nf,tm=nil,nil for n in traverse_id(glyph_code,head) do if n.subtype<256 then nofvalid=nofvalid+1 valid[nofvalid]=n if n.font~=nf then nf=n.font tm=fontdata[nf].resources.marks end if tm then mk[n]=tm[n.char] end end end end if nofvalid>0 then local cx={} if has_kerns and next(ky) then for n,k in next,ky do n.yoffset=k end end if has_cursives then local p_cursbase,p=nil,nil local t,d,maxt={},{},0 for i=1,nofvalid do local n=valid[i] if not mk[n] then local n_cursbase=n[a_cursbase] if p_cursbase then local n_curscurs=n[a_curscurs] if p_cursbase==n_curscurs then local c=cursives[n_curscurs] if c then local rlmode,dx,dy,ws,wn=c[1],c[2],c[3],c[4],c[5] if rlmode>=0 then dx=dx-ws else dx=dx+wn end if dx~=0 then cx[n]=dx rl[n]=rlmode end dy=-dy maxt=maxt+1 t[maxt]=p d[maxt]=dy else maxt=0 end end elseif maxt>0 then local ny=n.yoffset for i=maxt,1,-1 do ny=ny+d[i] local ti=t[i] ti.yoffset=ti.yoffset+ny end maxt=0 end if not n_cursbase and maxt>0 then local ny=n.yoffset for i=maxt,1,-1 do ny=ny+d[i] local ti=t[i] ti.yoffset=ny end maxt=0 end p_cursbase,p=n_cursbase,n end end if maxt>0 then local ny=n.yoffset for i=maxt,1,-1 do ny=ny+d[i] local ti=t[i] ti.yoffset=ny end maxt=0 end if not keep then cursives={} end end if has_marks then for i=1,nofvalid do local p=valid[i] local p_markbase=p[a_markbase] if p_markbase then local mrks=marks[p_markbase] local nofmarks=#mrks for n in traverse_id(glyph_code,p.next) do local n_markmark=n[a_markmark] if p_markbase==n_markmark then local index=n[a_markdone] or 1 local d=mrks[index] if d then local rlmode=d[3] local k=wx[p] if k then local x=k[2] local w=k[4] if w then if rlmode and rlmode>=0 then n.xoffset=p.xoffset-p.width+d[1]-(w-x) else n.xoffset=p.xoffset-d[1]-x end else if rlmode and rlmode>=0 then n.xoffset=p.xoffset-p.width+d[1] else n.xoffset=p.xoffset-d[1]-x end end else if rlmode and rlmode>=0 then n.xoffset=p.xoffset-p.width+d[1] else n.xoffset=p.xoffset-d[1] end local w=n.width if w~=0 then insert_node_before(head,n,newkern(-w/2)) insert_node_after(head,n,newkern(-w/2)) end end if mk[p] then n.yoffset=p.yoffset+d[2] else n.yoffset=n.yoffset+p.yoffset+d[2] end if nofmarks==1 then break else nofmarks=nofmarks-1 end end else end end end end if not keep then marks={} end end if next(wx) then for n,k in next,wx do local x=k[2] local w=k[4] if w then local rl=k[1] local wx=w-x if rl<0 then if wx~=0 then insert_node_before(head,n,newkern(wx)) end if x~=0 then insert_node_after (head,n,newkern(x)) end else if x~=0 then insert_node_before(head,n,newkern(x)) end if wx~=0 then insert_node_after (head,n,newkern(wx)) end end elseif x~=0 then insert_node_before(head,n,newkern(x)) end end end if next(cx) then for n,k in next,cx do if k~=0 then local rln=rl[n] if rln and rln<0 then insert_node_before(head,n,newkern(-k)) else insert_node_before(head,n,newkern(k)) end end end end if not keep then kerns={} end return head,true elseif not keep then kerns,cursives,marks={},{},{} end elseif has_kerns then if trace_injections then trace(head) end for n in traverse_id(glyph_code,head) do if n.subtype<256 then local k=n[a_kernpair] if k then local kk=kerns[k] if kk then local rl,x,y,w=kk[1],kk[2] or 0,kk[3],kk[4] if y and y~=0 then n.yoffset=y end if w then local wx=w-x if rl<0 then if wx~=0 then insert_node_before(head,n,newkern(wx)) end if x~=0 then insert_node_after (head,n,newkern(x)) end else if x~=0 then insert_node_before(head,n,newkern(x)) end if wx~=0 then insert_node_after(head,n,newkern(wx)) end end else if x~=0 then insert_node_before(head,n,newkern(x)) end end end end end end if not keep then kerns={} end return head,true else end return head,false end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['font-ota']={ version=1.001, comment="companion to font-otf.lua (analysing)", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local type=type if not trackers then trackers={ register=function() end } end local fonts,nodes,node=fonts,nodes,node local allocate=utilities.storage.allocate local otf=fonts.handlers.otf local analyzers=fonts.analyzers local initializers=allocate() local methods=allocate() analyzers.initializers=initializers analyzers.methods=methods analyzers.useunicodemarks=false local a_state=attributes.private('state') local nodecodes=nodes.nodecodes local glyph_code=nodecodes.glyph local disc_code=nodecodes.disc local math_code=nodecodes.math local traverse_id=node.traverse_id local traverse_node_list=node.traverse local end_of_math=node.end_of_math local fontdata=fonts.hashes.identifiers local categories=characters and characters.categories or {} local otffeatures=fonts.constructors.newfeatures("otf") local registerotffeature=otffeatures.register local s_init=1 local s_rphf=7 local s_medi=2 local s_half=8 local s_fina=3 local s_pref=9 local s_isol=4 local s_blwf=10 local s_mark=5 local s_pstf=11 local s_rest=6 local states={ init=s_init, medi=s_medi, fina=s_fina, isol=s_isol, mark=s_mark, rest=s_rest, rphf=s_rphf, half=s_half, pref=s_pref, blwf=s_blwf, pstf=s_pstf, } local features={ init=s_init, medi=s_medi, fina=s_fina, isol=s_isol, rphf=s_rphf, half=s_half, pref=s_pref, blwf=s_blwf, pstf=s_pstf, } analyzers.states=states analyzers.features=features function analyzers.setstate(head,font) local useunicodemarks=analyzers.useunicodemarks local tfmdata=fontdata[font] local descriptions=tfmdata.descriptions local first,last,current,n,done=nil,nil,head,0,false while current do local id=current.id if id==glyph_code and current.font==font then done=true local char=current.char local d=descriptions[char] if d then if d.class=="mark" or (useunicodemarks and categories[char]=="mn") then done=true current[a_state]=s_mark elseif n==0 then first,last,n=current,current,1 current[a_state]=s_init else last,n=current,n+1 current[a_state]=s_medi end else if first and first==last then last[a_state]=s_isol elseif last then last[a_state]=s_fina end first,last,n=nil,nil,0 end elseif id==disc_code then current[a_state]=s_medi last=current else if first and first==last then last[a_state]=s_isol elseif last then last[a_state]=s_fina end first,last,n=nil,nil,0 if id==math_code then current=end_of_math(current) end end current=current.next end if first and first==last then last[a_state]=s_isol elseif last then last[a_state]=s_fina end return head,done end local function analyzeinitializer(tfmdata,value) local script,language=otf.scriptandlanguage(tfmdata) local action=initializers[script] if not action then elseif type(action)=="function" then return action(tfmdata,value) else local action=action[language] if action then return action(tfmdata,value) end end end local function analyzeprocessor(head,font,attr) local tfmdata=fontdata[font] local script,language=otf.scriptandlanguage(tfmdata,attr) local action=methods[script] if not action then elseif type(action)=="function" then return action(head,font,attr) else action=action[language] if action then return action(head,font,attr) end end return head,false end registerotffeature { name="analyze", description="analysis of character classes", default=true, initializers={ node=analyzeinitializer, }, processors={ position=1, node=analyzeprocessor, } } methods.latn=analyzers.setstate local tatweel=0x0640 local zwnj=0x200C local zwj=0x200D local isolated={ [0x0600]=true,[0x0601]=true,[0x0602]=true,[0x0603]=true, [0x0604]=true, [0x0608]=true,[0x060B]=true,[0x0621]=true,[0x0674]=true, [0x06DD]=true, [0x0856]=true,[0x0858]=true,[0x0857]=true, [0x07FA]=true, [zwnj]=true, [0x08AD]=true, } local final={ [0x0622]=true,[0x0623]=true,[0x0624]=true,[0x0625]=true, [0x0627]=true,[0x0629]=true,[0x062F]=true,[0x0630]=true, [0x0631]=true,[0x0632]=true,[0x0648]=true,[0x0671]=true, [0x0672]=true,[0x0673]=true,[0x0675]=true,[0x0676]=true, [0x0677]=true,[0x0688]=true,[0x0689]=true,[0x068A]=true, [0x068B]=true,[0x068C]=true,[0x068D]=true,[0x068E]=true, [0x068F]=true,[0x0690]=true,[0x0691]=true,[0x0692]=true, [0x0693]=true,[0x0694]=true,[0x0695]=true,[0x0696]=true, [0x0697]=true,[0x0698]=true,[0x0699]=true,[0x06C0]=true, [0x06C3]=true,[0x06C4]=true,[0x06C5]=true,[0x06C6]=true, [0x06C7]=true,[0x06C8]=true,[0x06C9]=true,[0x06CA]=true, [0x06CB]=true,[0x06CD]=true,[0x06CF]=true,[0x06D2]=true, [0x06D3]=true,[0x06D5]=true,[0x06EE]=true,[0x06EF]=true, [0x0759]=true,[0x075A]=true,[0x075B]=true,[0x076B]=true, [0x076C]=true,[0x0771]=true,[0x0773]=true,[0x0774]=true, [0x0778]=true,[0x0779]=true, [0x08AA]=true,[0x08AB]=true,[0x08AC]=true, [0xFEF5]=true,[0xFEF7]=true,[0xFEF9]=true,[0xFEFB]=true, [0x0710]=true,[0x0715]=true,[0x0716]=true,[0x0717]=true, [0x0718]=true,[0x0719]=true,[0x0728]=true,[0x072A]=true, [0x072C]=true,[0x071E]=true, [0x072F]=true,[0x074D]=true, [0x0840]=true,[0x0849]=true,[0x0854]=true,[0x0846]=true, [0x084F]=true, [0x08AE]=true,[0x08B1]=true,[0x08B2]=true, } local medial={ [0x0626]=true,[0x0628]=true,[0x062A]=true,[0x062B]=true, [0x062C]=true,[0x062D]=true,[0x062E]=true,[0x0633]=true, [0x0634]=true,[0x0635]=true,[0x0636]=true,[0x0637]=true, [0x0638]=true,[0x0639]=true,[0x063A]=true,[0x063B]=true, [0x063C]=true,[0x063D]=true,[0x063E]=true,[0x063F]=true, [0x0641]=true,[0x0642]=true,[0x0643]=true, [0x0644]=true,[0x0645]=true,[0x0646]=true,[0x0647]=true, [0x0649]=true,[0x064A]=true,[0x066E]=true,[0x066F]=true, [0x0678]=true,[0x0679]=true,[0x067A]=true,[0x067B]=true, [0x067C]=true,[0x067D]=true,[0x067E]=true,[0x067F]=true, [0x0680]=true,[0x0681]=true,[0x0682]=true,[0x0683]=true, [0x0684]=true,[0x0685]=true,[0x0686]=true,[0x0687]=true, [0x069A]=true,[0x069B]=true,[0x069C]=true,[0x069D]=true, [0x069E]=true,[0x069F]=true,[0x06A0]=true,[0x06A1]=true, [0x06A2]=true,[0x06A3]=true,[0x06A4]=true,[0x06A5]=true, [0x06A6]=true,[0x06A7]=true,[0x06A8]=true,[0x06A9]=true, [0x06AA]=true,[0x06AB]=true,[0x06AC]=true,[0x06AD]=true, [0x06AE]=true,[0x06AF]=true,[0x06B0]=true,[0x06B1]=true, [0x06B2]=true,[0x06B3]=true,[0x06B4]=true,[0x06B5]=true, [0x06B6]=true,[0x06B7]=true,[0x06B8]=true,[0x06B9]=true, [0x06BA]=true,[0x06BB]=true,[0x06BC]=true,[0x06BD]=true, [0x06BE]=true,[0x06BF]=true,[0x06C1]=true,[0x06C2]=true, [0x06CC]=true,[0x06CE]=true,[0x06D0]=true,[0x06D1]=true, [0x06FA]=true,[0x06FB]=true,[0x06FC]=true,[0x06FF]=true, [0x0750]=true,[0x0751]=true,[0x0752]=true,[0x0753]=true, [0x0754]=true,[0x0755]=true,[0x0756]=true,[0x0757]=true, [0x0758]=true,[0x075C]=true,[0x075D]=true,[0x075E]=true, [0x075F]=true,[0x0760]=true,[0x0761]=true,[0x0762]=true, [0x0763]=true,[0x0764]=true,[0x0765]=true,[0x0766]=true, [0x0767]=true,[0x0768]=true,[0x0769]=true,[0x076A]=true, [0x076D]=true,[0x076E]=true,[0x076F]=true,[0x0770]=true, [0x0772]=true,[0x0775]=true,[0x0776]=true,[0x0777]=true, [0x077A]=true,[0x077B]=true,[0x077C]=true,[0x077D]=true, [0x077E]=true,[0x077F]=true, [0x08A0]=true,[0x08A2]=true,[0x08A4]=true,[0x08A5]=true, [0x08A6]=true,[0x0620]=true,[0x08A8]=true,[0x08A9]=true, [0x08A7]=true,[0x08A3]=true, [0x0712]=true,[0x0713]=true,[0x0714]=true,[0x071A]=true, [0x071B]=true,[0x071C]=true,[0x071D]=true,[0x071F]=true, [0x0720]=true,[0x0721]=true,[0x0722]=true,[0x0723]=true, [0x0724]=true,[0x0725]=true,[0x0726]=true,[0x0727]=true, [0x0729]=true,[0x072B]=true,[0x072D]=true,[0x072E]=true, [0x074E]=true,[0x074F]=true, [0x0841]=true,[0x0842]=true,[0x0843]=true,[0x0844]=true, [0x0845]=true,[0x0847]=true,[0x0848]=true,[0x0855]=true, [0x0851]=true,[0x084E]=true,[0x084D]=true,[0x084A]=true, [0x084B]=true,[0x084C]=true,[0x0850]=true,[0x0852]=true, [0x0853]=true, [0x07D7]=true,[0x07E8]=true,[0x07D9]=true,[0x07EA]=true, [0x07CA]=true,[0x07DB]=true,[0x07CC]=true,[0x07DD]=true, [0x07CE]=true,[0x07DF]=true,[0x07D4]=true,[0x07E5]=true, [0x07E9]=true,[0x07E7]=true,[0x07E3]=true,[0x07E2]=true, [0x07E0]=true,[0x07E1]=true,[0x07DE]=true,[0x07DC]=true, [0x07D1]=true,[0x07DA]=true,[0x07D8]=true,[0x07D6]=true, [0x07D2]=true,[0x07D0]=true,[0x07CF]=true,[0x07CD]=true, [0x07CB]=true,[0x07D3]=true,[0x07E4]=true,[0x07D5]=true, [0x07E6]=true, [tatweel]=true,[zwj]=true, [0x08A1]=true,[0x08AF]=true,[0x08B0]=true, } local arab_warned={} local function warning(current,what) local char=current.char if not arab_warned[char] then log.report("analyze","arab: character %C has no %a class",char,what) arab_warned[char]=true end end local function finish(first,last) if last then if first==last then local fc=first.char if medial[fc] or final[fc] then first[a_state]=s_isol else warning(first,"isol") first[a_state]=s_error end else local lc=last.char if medial[lc] or final[lc] then last[a_state]=s_fina else warning(last,"fina") last[a_state]=s_error end end first,last=nil,nil elseif first then local fc=first.char if medial[fc] or final[fc] then first[a_state]=s_isol else warning(first,"isol") first[a_state]=s_error end first=nil end return first,last end function methods.arab(head,font,attr) local useunicodemarks=analyzers.useunicodemarks local tfmdata=fontdata[font] local marks=tfmdata.resources.marks local first,last,current,done=nil,nil,head,false while current do local id=current.id if id==glyph_code and current.font==font and current.subtype<256 and not current[a_state] then done=true local char=current.char if marks[char] or (useunicodemarks and categories[char]=="mn") then current[a_state]=s_mark elseif isolated[char] then first,last=finish(first,last) current[a_state]=s_isol first,last=nil,nil elseif not first then if medial[char] then current[a_state]=s_init first,last=first or current,current elseif final[char] then current[a_state]=s_isol first,last=nil,nil else first,last=finish(first,last) end elseif medial[char] then first,last=first or current,current current[a_state]=s_medi elseif final[char] then if not last[a_state]==s_init then last[a_state]=s_medi end current[a_state]=s_fina first,last=nil,nil elseif char>=0x0600 and char<=0x06FF then current[a_state]=s_rest first,last=finish(first,last) else first,last=finish(first,last) end else if first or last then first,last=finish(first,last) end if id==math_code then current=end_of_math(current) end end current=current.next end if first or last then finish(first,last) end return head,done end methods.syrc=methods.arab methods.mand=methods.arab methods.nko=methods.arab directives.register("otf.analyze.useunicodemarks",function(v) analyzers.useunicodemarks=v end) end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['font-otn']={ version=1.001, comment="companion to font-ini.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files", } local concat,insert,remove=table.concat,table.insert,table.remove local gmatch,gsub,find,match,lower,strip=string.gmatch,string.gsub,string.find,string.match,string.lower,string.strip local type,next,tonumber,tostring=type,next,tonumber,tostring local lpegmatch=lpeg.match local random=math.random local formatters=string.formatters local logs,trackers,nodes,attributes=logs,trackers,nodes,attributes local registertracker=trackers.register local fonts=fonts local otf=fonts.handlers.otf local trace_lookups=false registertracker("otf.lookups",function(v) trace_lookups=v end) local trace_singles=false registertracker("otf.singles",function(v) trace_singles=v end) local trace_multiples=false registertracker("otf.multiples",function(v) trace_multiples=v end) local trace_alternatives=false registertracker("otf.alternatives",function(v) trace_alternatives=v end) local trace_ligatures=false registertracker("otf.ligatures",function(v) trace_ligatures=v end) local trace_contexts=false registertracker("otf.contexts",function(v) trace_contexts=v end) local trace_marks=false registertracker("otf.marks",function(v) trace_marks=v end) local trace_kerns=false registertracker("otf.kerns",function(v) trace_kerns=v end) local trace_cursive=false registertracker("otf.cursive",function(v) trace_cursive=v end) local trace_preparing=false registertracker("otf.preparing",function(v) trace_preparing=v end) local trace_bugs=false registertracker("otf.bugs",function(v) trace_bugs=v end) local trace_details=false registertracker("otf.details",function(v) trace_details=v end) local trace_applied=false registertracker("otf.applied",function(v) trace_applied=v end) local trace_steps=false registertracker("otf.steps",function(v) trace_steps=v end) local trace_skips=false registertracker("otf.skips",function(v) trace_skips=v end) local trace_directions=false registertracker("otf.directions",function(v) trace_directions=v end) local report_direct=logs.reporter("fonts","otf direct") local report_subchain=logs.reporter("fonts","otf subchain") local report_chain=logs.reporter("fonts","otf chain") local report_process=logs.reporter("fonts","otf process") local report_prepare=logs.reporter("fonts","otf prepare") local report_warning=logs.reporter("fonts","otf warning") registertracker("otf.verbose_chain",function(v) otf.setcontextchain(v and "verbose") end) registertracker("otf.normal_chain",function(v) otf.setcontextchain(v and "normal") end) registertracker("otf.replacements","otf.singles,otf.multiples,otf.alternatives,otf.ligatures") registertracker("otf.positions","otf.marks,otf.kerns,otf.cursive") registertracker("otf.actions","otf.replacements,otf.positions") registertracker("otf.injections","nodes.injections") registertracker("*otf.sample","otf.steps,otf.actions,otf.analyzing") local insert_node_after=node.insert_after local delete_node=nodes.delete local copy_node=node.copy local find_node_tail=node.tail or node.slide local flush_node_list=node.flush_list local end_of_math=node.end_of_math local setmetatableindex=table.setmetatableindex local zwnj=0x200C local zwj=0x200D local wildcard="*" local default="dflt" local nodecodes=nodes.nodecodes local whatcodes=nodes.whatcodes local glyphcodes=nodes.glyphcodes local disccodes=nodes.disccodes local glyph_code=nodecodes.glyph local glue_code=nodecodes.glue local disc_code=nodecodes.disc local whatsit_code=nodecodes.whatsit local math_code=nodecodes.math local dir_code=whatcodes.dir local localpar_code=whatcodes.localpar local discretionary_code=disccodes.discretionary local ligature_code=glyphcodes.ligature local privateattribute=attributes.private local a_state=privateattribute('state') local a_markbase=privateattribute('markbase') local a_markmark=privateattribute('markmark') local a_markdone=privateattribute('markdone') local a_cursbase=privateattribute('cursbase') local a_curscurs=privateattribute('curscurs') local a_cursdone=privateattribute('cursdone') local a_kernpair=privateattribute('kernpair') local a_ligacomp=privateattribute('ligacomp') local injections=nodes.injections local setmark=injections.setmark local setcursive=injections.setcursive local setkern=injections.setkern local setpair=injections.setpair local markonce=true local cursonce=true local kernonce=true local fonthashes=fonts.hashes local fontdata=fonthashes.identifiers local otffeatures=fonts.constructors.newfeatures("otf") local registerotffeature=otffeatures.register local onetimemessage=fonts.loggers.onetimemessage or function() end otf.defaultnodealternate="none" local tfmdata=false local characters=false local descriptions=false local resources=false local marks=false local currentfont=false local lookuptable=false local anchorlookups=false local lookuptypes=false local handlers={} local rlmode=0 local featurevalue=false local checkstep=(nodes and nodes.tracers and nodes.tracers.steppers.check) or function() end local registerstep=(nodes and nodes.tracers and nodes.tracers.steppers.register) or function() end local registermessage=(nodes and nodes.tracers and nodes.tracers.steppers.message) or function() end local function logprocess(...) if trace_steps then registermessage(...) end report_direct(...) end local function logwarning(...) report_direct(...) end local f_unicode=formatters["%U"] local f_uniname=formatters["%U (%s)"] local f_unilist=formatters["% t (% t)"] local function gref(n) if type(n)=="number" then local description=descriptions[n] local name=description and description.name if name then return f_uniname(n,name) else return f_unicode(n) end elseif n then local num,nam={},{} for i=1,#n do local ni=n[i] if tonumber(ni) then local di=descriptions[ni] num[i]=f_unicode(ni) nam[i]=di and di.name or "-" end end return f_unilist(num,nam) else return "<error in node mode tracing>" end end local function cref(kind,chainname,chainlookupname,lookupname,index) if index then return formatters["feature %a, chain %a, sub %a, lookup %a, index %a"](kind,chainname,chainlookupname,lookupname,index) elseif lookupname then return formatters["feature %a, chain %a, sub %a, lookup %a"](kind,chainname,chainlookupname,lookupname) elseif chainlookupname then return formatters["feature %a, chain %a, sub %a"](kind,chainname,chainlookupname) elseif chainname then return formatters["feature %a, chain %a"](kind,chainname) else return formatters["feature %a"](kind) end end local function pref(kind,lookupname) return formatters["feature %a, lookup %a"](kind,lookupname) end local function copy_glyph(g) local components=g.components if components then g.components=nil local n=copy_node(g) g.components=components return n else return copy_node(g) end end local function markstoligature(kind,lookupname,head,start,stop,char) if start==stop and start.char==char then return head,start else local prev=start.prev local next=stop.next start.prev=nil stop.next=nil local base=copy_glyph(start) if head==start then head=base end base.char=char base.subtype=ligature_code base.components=start if prev then prev.next=base end if next then next.prev=base end base.next=next base.prev=prev return head,base end end local function getcomponentindex(start) if start.id~=glyph_code then return 0 elseif start.subtype==ligature_code then local i=0 local components=start.components while components do i=i+getcomponentindex(components) components=components.next end return i elseif not marks[start.char] then return 1 else return 0 end end local function toligature(kind,lookupname,head,start,stop,char,markflag,discfound) if start==stop and start.char==char then start.char=char return head,start end local prev=start.prev local next=stop.next start.prev=nil stop.next=nil local base=copy_glyph(start) if start==head then head=base end base.char=char base.subtype=ligature_code base.components=start if prev then prev.next=base end if next then next.prev=base end base.next=next base.prev=prev if not discfound then local deletemarks=markflag~="mark" local components=start local baseindex=0 local componentindex=0 local head=base local current=base while start do local char=start.char if not marks[char] then baseindex=baseindex+componentindex componentindex=getcomponentindex(start) elseif not deletemarks then start[a_ligacomp]=baseindex+(start[a_ligacomp] or componentindex) if trace_marks then logwarning("%s: keep mark %s, gets index %s",pref(kind,lookupname),gref(char),start[a_ligacomp]) end head,current=insert_node_after(head,current,copy_node(start)) elseif trace_marks then logwarning("%s: delete mark %s",pref(kind,lookupname),gref(char)) end start=start.next end local start=current.next while start and start.id==glyph_code do local char=start.char if marks[char] then start[a_ligacomp]=baseindex+(start[a_ligacomp] or componentindex) if trace_marks then logwarning("%s: set mark %s, gets index %s",pref(kind,lookupname),gref(char),start[a_ligacomp]) end else break end start=start.next end end return head,base end function handlers.gsub_single(head,start,kind,lookupname,replacement) if trace_singles then logprocess("%s: replacing %s by single %s",pref(kind,lookupname),gref(start.char),gref(replacement)) end start.char=replacement return head,start,true end local function get_alternative_glyph(start,alternatives,value,trace_alternatives) local n=#alternatives if value=="random" then local r=random(1,n) return alternatives[r],trace_alternatives and formatters["value %a, taking %a"](value,r) elseif value=="first" then return alternatives[1],trace_alternatives and formatters["value %a, taking %a"](value,1) elseif value=="last" then return alternatives[n],trace_alternatives and formatters["value %a, taking %a"](value,n) else value=tonumber(value) if type(value)~="number" then return alternatives[1],trace_alternatives and formatters["invalid value %s, taking %a"](value,1) elseif value>n then local defaultalt=otf.defaultnodealternate if defaultalt=="first" then return alternatives[n],trace_alternatives and formatters["invalid value %s, taking %a"](value,1) elseif defaultalt=="last" then return alternatives[1],trace_alternatives and formatters["invalid value %s, taking %a"](value,n) else return false,trace_alternatives and formatters["invalid value %a, %s"](value,"out of range") end elseif value==0 then return start.char,trace_alternatives and formatters["invalid value %a, %s"](value,"no change") elseif value<1 then return alternatives[1],trace_alternatives and formatters["invalid value %a, taking %a"](value,1) else return alternatives[value],trace_alternatives and formatters["value %a, taking %a"](value,value) end end end local function multiple_glyphs(head,start,multiple,ignoremarks) local nofmultiples=#multiple if nofmultiples>0 then start.char=multiple[1] if nofmultiples>1 then local sn=start.next for k=2,nofmultiples do local n=copy_node(start) n.char=multiple[k] n.next=sn n.prev=start if sn then sn.prev=n end start.next=n start=n end end return head,start,true else if trace_multiples then logprocess("no multiple for %s",gref(start.char)) end return head,start,false end end function handlers.gsub_alternate(head,start,kind,lookupname,alternative,sequence) local value=featurevalue==true and tfmdata.shared.features[kind] or featurevalue local choice,comment=get_alternative_glyph(start,alternative,value,trace_alternatives) if choice then if trace_alternatives then logprocess("%s: replacing %s by alternative %a to %s, %s",pref(kind,lookupname),gref(start.char),choice,gref(choice),comment) end start.char=choice else if trace_alternatives then logwarning("%s: no variant %a for %s, %s",pref(kind,lookupname),value,gref(start.char),comment) end end return head,start,true end function handlers.gsub_multiple(head,start,kind,lookupname,multiple,sequence) if trace_multiples then logprocess("%s: replacing %s by multiple %s",pref(kind,lookupname),gref(start.char),gref(multiple)) end return multiple_glyphs(head,start,multiple,sequence.flags[1]) end function handlers.gsub_ligature(head,start,kind,lookupname,ligature,sequence) local s,stop,discfound=start.next,nil,false local startchar=start.char if marks[startchar] then while s do local id=s.id if id==glyph_code and s.font==currentfont and s.subtype<256 then local lg=ligature[s.char] if lg then stop=s ligature=lg s=s.next else break end else break end end if stop then local lig=ligature.ligature if lig then if trace_ligatures then local stopchar=stop.char head,start=markstoligature(kind,lookupname,head,start,stop,lig) logprocess("%s: replacing %s upto %s by ligature %s case 1",pref(kind,lookupname),gref(startchar),gref(stopchar),gref(start.char)) else head,start=markstoligature(kind,lookupname,head,start,stop,lig) end return head,start,true else end end else local skipmark=sequence.flags[1] while s do local id=s.id if id==glyph_code and s.subtype<256 then if s.font==currentfont then local char=s.char if skipmark and marks[char] then s=s.next else local lg=ligature[char] if lg then stop=s ligature=lg s=s.next else break end end else break end elseif id==disc_code then discfound=true s=s.next else break end end local lig=ligature.ligature if lig then if stop then if trace_ligatures then local stopchar=stop.char head,start=toligature(kind,lookupname,head,start,stop,lig,skipmark,discfound) logprocess("%s: replacing %s upto %s by ligature %s case 2",pref(kind,lookupname),gref(startchar),gref(stopchar),gref(start.char)) else head,start=toligature(kind,lookupname,head,start,stop,lig,skipmark,discfound) end return head,start,true else start.char=lig if trace_ligatures then logprocess("%s: replacing %s by (no real) ligature %s case 3",pref(kind,lookupname),gref(startchar),gref(lig)) end return head,start,true end else end end return head,start,false end function handlers.gpos_mark2base(head,start,kind,lookupname,markanchors,sequence) local markchar=start.char if marks[markchar] then local base=start.prev if base and base.id==glyph_code and base.font==currentfont and base.subtype<256 then local basechar=base.char if marks[basechar] then while true do base=base.prev if base and base.id==glyph_code and base.font==currentfont and base.subtype<256 then basechar=base.char if not marks[basechar] then break end else if trace_bugs then logwarning("%s: no base for mark %s",pref(kind,lookupname),gref(markchar)) end return head,start,false end end end local baseanchors=descriptions[basechar] if baseanchors then baseanchors=baseanchors.anchors end if baseanchors then local baseanchors=baseanchors['basechar'] if baseanchors then local al=anchorlookups[lookupname] for anchor,ba in next,baseanchors do if al[anchor] then local ma=markanchors[anchor] if ma then local dx,dy,bound=setmark(start,base,tfmdata.parameters.factor,rlmode,ba,ma) if trace_marks then logprocess("%s, anchor %s, bound %s: anchoring mark %s to basechar %s => (%p,%p)", pref(kind,lookupname),anchor,bound,gref(markchar),gref(basechar),dx,dy) end return head,start,true end end end if trace_bugs then logwarning("%s, no matching anchors for mark %s and base %s",pref(kind,lookupname),gref(markchar),gref(basechar)) end end elseif trace_bugs then onetimemessage(currentfont,basechar,"no base anchors",report_fonts) end elseif trace_bugs then logwarning("%s: prev node is no char",pref(kind,lookupname)) end elseif trace_bugs then logwarning("%s: mark %s is no mark",pref(kind,lookupname),gref(markchar)) end return head,start,false end function handlers.gpos_mark2ligature(head,start,kind,lookupname,markanchors,sequence) local markchar=start.char if marks[markchar] then local base=start.prev if base and base.id==glyph_code and base.font==currentfont and base.subtype<256 then local basechar=base.char if marks[basechar] then while true do base=base.prev if base and base.id==glyph_code and base.font==currentfont and base.subtype<256 then basechar=base.char if not marks[basechar] then break end else if trace_bugs then logwarning("%s: no base for mark %s",pref(kind,lookupname),gref(markchar)) end return head,start,false end end end local index=start[a_ligacomp] local baseanchors=descriptions[basechar] if baseanchors then baseanchors=baseanchors.anchors if baseanchors then local baseanchors=baseanchors['baselig'] if baseanchors then local al=anchorlookups[lookupname] for anchor,ba in next,baseanchors do if al[anchor] then local ma=markanchors[anchor] if ma then ba=ba[index] if ba then local dx,dy,bound=setmark(start,base,tfmdata.parameters.factor,rlmode,ba,ma) if trace_marks then logprocess("%s, anchor %s, index %s, bound %s: anchoring mark %s to baselig %s at index %s => (%p,%p)", pref(kind,lookupname),anchor,index,bound,gref(markchar),gref(basechar),index,dx,dy) end return head,start,true else if trace_bugs then logwarning("%s: no matching anchors for mark %s and baselig %s with index %a",pref(kind,lookupname),gref(markchar),gref(basechar),index) end end end end end if trace_bugs then logwarning("%s: no matching anchors for mark %s and baselig %s",pref(kind,lookupname),gref(markchar),gref(basechar)) end end end elseif trace_bugs then onetimemessage(currentfont,basechar,"no base anchors",report_fonts) end elseif trace_bugs then logwarning("%s: prev node is no char",pref(kind,lookupname)) end elseif trace_bugs then logwarning("%s: mark %s is no mark",pref(kind,lookupname),gref(markchar)) end return head,start,false end function handlers.gpos_mark2mark(head,start,kind,lookupname,markanchors,sequence) local markchar=start.char if marks[markchar] then local base=start.prev local slc=start[a_ligacomp] if slc then while base do local blc=base[a_ligacomp] if blc and blc~=slc then base=base.prev else break end end end if base and base.id==glyph_code and base.font==currentfont and base.subtype<256 then local basechar=base.char local baseanchors=descriptions[basechar] if baseanchors then baseanchors=baseanchors.anchors if baseanchors then baseanchors=baseanchors['basemark'] if baseanchors then local al=anchorlookups[lookupname] for anchor,ba in next,baseanchors do if al[anchor] then local ma=markanchors[anchor] if ma then local dx,dy,bound=setmark(start,base,tfmdata.parameters.factor,rlmode,ba,ma,true) if trace_marks then logprocess("%s, anchor %s, bound %s: anchoring mark %s to basemark %s => (%p,%p)", pref(kind,lookupname),anchor,bound,gref(markchar),gref(basechar),dx,dy) end return head,start,true end end end if trace_bugs then logwarning("%s: no matching anchors for mark %s and basemark %s",pref(kind,lookupname),gref(markchar),gref(basechar)) end end end elseif trace_bugs then onetimemessage(currentfont,basechar,"no base anchors",report_fonts) end elseif trace_bugs then logwarning("%s: prev node is no mark",pref(kind,lookupname)) end elseif trace_bugs then logwarning("%s: mark %s is no mark",pref(kind,lookupname),gref(markchar)) end return head,start,false end function handlers.gpos_cursive(head,start,kind,lookupname,exitanchors,sequence) local alreadydone=cursonce and start[a_cursbase] if not alreadydone then local done=false local startchar=start.char if marks[startchar] then if trace_cursive then logprocess("%s: ignoring cursive for mark %s",pref(kind,lookupname),gref(startchar)) end else local nxt=start.next while not done and nxt and nxt.id==glyph_code and nxt.font==currentfont and nxt.subtype<256 do local nextchar=nxt.char if marks[nextchar] then nxt=nxt.next else local entryanchors=descriptions[nextchar] if entryanchors then entryanchors=entryanchors.anchors if entryanchors then entryanchors=entryanchors['centry'] if entryanchors then local al=anchorlookups[lookupname] for anchor,entry in next,entryanchors do if al[anchor] then local exit=exitanchors[anchor] if exit then local dx,dy,bound=setcursive(start,nxt,tfmdata.parameters.factor,rlmode,exit,entry,characters[startchar],characters[nextchar]) if trace_cursive then logprocess("%s: moving %s to %s cursive (%p,%p) using anchor %s and bound %s in rlmode %s",pref(kind,lookupname),gref(startchar),gref(nextchar),dx,dy,anchor,bound,rlmode) end done=true break end end end end end elseif trace_bugs then onetimemessage(currentfont,startchar,"no entry anchors",report_fonts) end break end end end return head,start,done else if trace_cursive and trace_details then logprocess("%s, cursive %s is already done",pref(kind,lookupname),gref(start.char),alreadydone) end return head,start,false end end function handlers.gpos_single(head,start,kind,lookupname,kerns,sequence) local startchar=start.char local dx,dy,w,h=setpair(start,tfmdata.parameters.factor,rlmode,sequence.flags[4],kerns,characters[startchar]) if trace_kerns then logprocess("%s: shifting single %s by (%p,%p) and correction (%p,%p)",pref(kind,lookupname),gref(startchar),dx,dy,w,h) end return head,start,false end function handlers.gpos_pair(head,start,kind,lookupname,kerns,sequence) local snext=start.next if not snext then return head,start,false else local prev,done=start,false local factor=tfmdata.parameters.factor local lookuptype=lookuptypes[lookupname] while snext and snext.id==glyph_code and snext.font==currentfont and snext.subtype<256 do local nextchar=snext.char local krn=kerns[nextchar] if not krn and marks[nextchar] then prev=snext snext=snext.next else if not krn then elseif type(krn)=="table" then if lookuptype=="pair" then local a,b=krn[2],krn[3] if a and #a>0 then local startchar=start.char local x,y,w,h=setpair(start,factor,rlmode,sequence.flags[4],a,characters[startchar]) if trace_kerns then logprocess("%s: shifting first of pair %s and %s by (%p,%p) and correction (%p,%p)",pref(kind,lookupname),gref(startchar),gref(nextchar),x,y,w,h) end end if b and #b>0 then local startchar=start.char local x,y,w,h=setpair(snext,factor,rlmode,sequence.flags[4],b,characters[nextchar]) if trace_kerns then logprocess("%s: shifting second of pair %s and %s by (%p,%p) and correction (%p,%p)",pref(kind,lookupname),gref(startchar),gref(nextchar),x,y,w,h) end end else report_process("%s: check this out (old kern stuff)",pref(kind,lookupname)) end done=true elseif krn~=0 then local k=setkern(snext,factor,rlmode,krn) if trace_kerns then logprocess("%s: inserting kern %s between %s and %s",pref(kind,lookupname),k,gref(prev.char),gref(nextchar)) end done=true end break end end return head,start,done end end local chainmores={} local chainprocs={} local function logprocess(...) if trace_steps then registermessage(...) end report_subchain(...) end local logwarning=report_subchain local function logprocess(...) if trace_steps then registermessage(...) end report_chain(...) end local logwarning=report_chain function chainprocs.chainsub(head,start,stop,kind,chainname,currentcontext,lookuphash,lookuplist,chainlookupname) logwarning("%s: a direct call to chainsub cannot happen",cref(kind,chainname,chainlookupname)) return head,start,false end function chainmores.chainsub(head,start,stop,kind,chainname,currentcontext,lookuphash,lookuplist,chainlookupname,n) logprocess("%s: a direct call to chainsub cannot happen",cref(kind,chainname,chainlookupname)) return head,start,false end function chainprocs.reversesub(head,start,stop,kind,chainname,currentcontext,lookuphash,replacements) local char=start.char local replacement=replacements[char] if replacement then if trace_singles then logprocess("%s: single reverse replacement of %s by %s",cref(kind,chainname),gref(char),gref(replacement)) end start.char=replacement return head,start,true else return head,start,false end end function chainprocs.gsub_single(head,start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname,chainindex) local current=start local subtables=currentlookup.subtables if #subtables>1 then logwarning("todo: check if we need to loop over the replacements: %s",concat(subtables," ")) end while current do if current.id==glyph_code then local currentchar=current.char local lookupname=subtables[1] local replacement=lookuphash[lookupname] if not replacement then if trace_bugs then logwarning("%s: no single hits",cref(kind,chainname,chainlookupname,lookupname,chainindex)) end else replacement=replacement[currentchar] if not replacement or replacement=="" then if trace_bugs then logwarning("%s: no single for %s",cref(kind,chainname,chainlookupname,lookupname,chainindex),gref(currentchar)) end else if trace_singles then logprocess("%s: replacing single %s by %s",cref(kind,chainname,chainlookupname,lookupname,chainindex),gref(currentchar),gref(replacement)) end current.char=replacement end end return head,start,true elseif current==stop then break else current=current.next end end return head,start,false end chainmores.gsub_single=chainprocs.gsub_single function chainprocs.gsub_multiple(head,start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname) local startchar=start.char local subtables=currentlookup.subtables local lookupname=subtables[1] local replacements=lookuphash[lookupname] if not replacements then if trace_bugs then logwarning("%s: no multiple hits",cref(kind,chainname,chainlookupname,lookupname)) end else replacements=replacements[startchar] if not replacements or replacement=="" then if trace_bugs then logwarning("%s: no multiple for %s",cref(kind,chainname,chainlookupname,lookupname),gref(startchar)) end else if trace_multiples then logprocess("%s: replacing %s by multiple characters %s",cref(kind,chainname,chainlookupname,lookupname),gref(startchar),gref(replacements)) end return multiple_glyphs(head,start,replacements,currentlookup.flags[1]) end end return head,start,false end chainmores.gsub_multiple=chainprocs.gsub_multiple function chainprocs.gsub_alternate(head,start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname) local current=start local subtables=currentlookup.subtables local value=featurevalue==true and tfmdata.shared.features[kind] or featurevalue while current do if current.id==glyph_code then local currentchar=current.char local lookupname=subtables[1] local alternatives=lookuphash[lookupname] if not alternatives then if trace_bugs then logwarning("%s: no alternative hit",cref(kind,chainname,chainlookupname,lookupname)) end else alternatives=alternatives[currentchar] if alternatives then local choice,comment=get_alternative_glyph(current,alternatives,value,trace_alternatives) if choice then if trace_alternatives then logprocess("%s: replacing %s by alternative %a to %s, %s",cref(kind,chainname,chainlookupname,lookupname),gref(char),choice,gref(choice),comment) end start.char=choice else if trace_alternatives then logwarning("%s: no variant %a for %s, %s",cref(kind,chainname,chainlookupname,lookupname),value,gref(char),comment) end end elseif trace_bugs then logwarning("%s: no alternative for %s, %s",cref(kind,chainname,chainlookupname,lookupname),gref(currentchar),comment) end end return head,start,true elseif current==stop then break else current=current.next end end return head,start,false end chainmores.gsub_alternate=chainprocs.gsub_alternate function chainprocs.gsub_ligature(head,start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname,chainindex) local startchar=start.char local subtables=currentlookup.subtables local lookupname=subtables[1] local ligatures=lookuphash[lookupname] if not ligatures then if trace_bugs then logwarning("%s: no ligature hits",cref(kind,chainname,chainlookupname,lookupname,chainindex)) end else ligatures=ligatures[startchar] if not ligatures then if trace_bugs then logwarning("%s: no ligatures starting with %s",cref(kind,chainname,chainlookupname,lookupname,chainindex),gref(startchar)) end else local s=start.next local discfound=false local last=stop local nofreplacements=0 local skipmark=currentlookup.flags[1] while s do local id=s.id if id==disc_code then s=s.next discfound=true else local schar=s.char if skipmark and marks[schar] then s=s.next else local lg=ligatures[schar] if lg then ligatures,last,nofreplacements=lg,s,nofreplacements+1 if s==stop then break else s=s.next end else break end end end end local l2=ligatures.ligature if l2 then if chainindex then stop=last end if trace_ligatures then if start==stop then logprocess("%s: replacing character %s by ligature %s case 3",cref(kind,chainname,chainlookupname,lookupname,chainindex),gref(startchar),gref(l2)) else logprocess("%s: replacing character %s upto %s by ligature %s case 4",cref(kind,chainname,chainlookupname,lookupname,chainindex),gref(startchar),gref(stop.char),gref(l2)) end end head,start=toligature(kind,lookupname,head,start,stop,l2,currentlookup.flags[1],discfound) return head,start,true,nofreplacements elseif trace_bugs then if start==stop then logwarning("%s: replacing character %s by ligature fails",cref(kind,chainname,chainlookupname,lookupname,chainindex),gref(startchar)) else logwarning("%s: replacing character %s upto %s by ligature fails",cref(kind,chainname,chainlookupname,lookupname,chainindex),gref(startchar),gref(stop.char)) end end end end return head,start,false,0 end chainmores.gsub_ligature=chainprocs.gsub_ligature function chainprocs.gpos_mark2base(head,start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname) local markchar=start.char if marks[markchar] then local subtables=currentlookup.subtables local lookupname=subtables[1] local markanchors=lookuphash[lookupname] if markanchors then markanchors=markanchors[markchar] end if markanchors then local base=start.prev if base and base.id==glyph_code and base.font==currentfont and base.subtype<256 then local basechar=base.char if marks[basechar] then while true do base=base.prev if base and base.id==glyph_code and base.font==currentfont and base.subtype<256 then basechar=base.char if not marks[basechar] then break end else if trace_bugs then logwarning("%s: no base for mark %s",pref(kind,lookupname),gref(markchar)) end return head,start,false end end end local baseanchors=descriptions[basechar].anchors if baseanchors then local baseanchors=baseanchors['basechar'] if baseanchors then local al=anchorlookups[lookupname] for anchor,ba in next,baseanchors do if al[anchor] then local ma=markanchors[anchor] if ma then local dx,dy,bound=setmark(start,base,tfmdata.parameters.factor,rlmode,ba,ma) if trace_marks then logprocess("%s, anchor %s, bound %s: anchoring mark %s to basechar %s => (%p,%p)", cref(kind,chainname,chainlookupname,lookupname),anchor,bound,gref(markchar),gref(basechar),dx,dy) end return head,start,true end end end if trace_bugs then logwarning("%s, no matching anchors for mark %s and base %s",cref(kind,chainname,chainlookupname,lookupname),gref(markchar),gref(basechar)) end end end elseif trace_bugs then logwarning("%s: prev node is no char",cref(kind,chainname,chainlookupname,lookupname)) end elseif trace_bugs then logwarning("%s: mark %s has no anchors",cref(kind,chainname,chainlookupname,lookupname),gref(markchar)) end elseif trace_bugs then logwarning("%s: mark %s is no mark",cref(kind,chainname,chainlookupname),gref(markchar)) end return head,start,false end function chainprocs.gpos_mark2ligature(head,start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname) local markchar=start.char if marks[markchar] then local subtables=currentlookup.subtables local lookupname=subtables[1] local markanchors=lookuphash[lookupname] if markanchors then markanchors=markanchors[markchar] end if markanchors then local base=start.prev if base and base.id==glyph_code and base.font==currentfont and base.subtype<256 then local basechar=base.char if marks[basechar] then while true do base=base.prev if base and base.id==glyph_code and base.font==currentfont and base.subtype<256 then basechar=base.char if not marks[basechar] then break end else if trace_bugs then logwarning("%s: no base for mark %s",cref(kind,chainname,chainlookupname,lookupname),markchar) end return head,start,false end end end local index=start[a_ligacomp] local baseanchors=descriptions[basechar].anchors if baseanchors then local baseanchors=baseanchors['baselig'] if baseanchors then local al=anchorlookups[lookupname] for anchor,ba in next,baseanchors do if al[anchor] then local ma=markanchors[anchor] if ma then ba=ba[index] if ba then local dx,dy,bound=setmark(start,base,tfmdata.parameters.factor,rlmode,ba,ma) if trace_marks then logprocess("%s, anchor %s, bound %s: anchoring mark %s to baselig %s at index %s => (%p,%p)", cref(kind,chainname,chainlookupname,lookupname),anchor,a or bound,gref(markchar),gref(basechar),index,dx,dy) end return head,start,true end end end end if trace_bugs then logwarning("%s: no matching anchors for mark %s and baselig %s",cref(kind,chainname,chainlookupname,lookupname),gref(markchar),gref(basechar)) end end end elseif trace_bugs then logwarning("feature %s, lookup %s: prev node is no char",kind,lookupname) end elseif trace_bugs then logwarning("%s: mark %s has no anchors",cref(kind,chainname,chainlookupname,lookupname),gref(markchar)) end elseif trace_bugs then logwarning("%s: mark %s is no mark",cref(kind,chainname,chainlookupname),gref(markchar)) end return head,start,false end function chainprocs.gpos_mark2mark(head,start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname) local markchar=start.char if marks[markchar] then local subtables=currentlookup.subtables local lookupname=subtables[1] local markanchors=lookuphash[lookupname] if markanchors then markanchors=markanchors[markchar] end if markanchors then local base=start.prev local slc=start[a_ligacomp] if slc then while base do local blc=base[a_ligacomp] if blc and blc~=slc then base=base.prev else break end end end if base and base.id==glyph_code and base.font==currentfont and base.subtype<256 then local basechar=base.char local baseanchors=descriptions[basechar].anchors if baseanchors then baseanchors=baseanchors['basemark'] if baseanchors then local al=anchorlookups[lookupname] for anchor,ba in next,baseanchors do if al[anchor] then local ma=markanchors[anchor] if ma then local dx,dy,bound=setmark(start,base,tfmdata.parameters.factor,rlmode,ba,ma,true) if trace_marks then logprocess("%s, anchor %s, bound %s: anchoring mark %s to basemark %s => (%p,%p)", cref(kind,chainname,chainlookupname,lookupname),anchor,bound,gref(markchar),gref(basechar),dx,dy) end return head,start,true end end end if trace_bugs then logwarning("%s: no matching anchors for mark %s and basemark %s",gref(kind,chainname,chainlookupname,lookupname),gref(markchar),gref(basechar)) end end end elseif trace_bugs then logwarning("%s: prev node is no mark",cref(kind,chainname,chainlookupname,lookupname)) end elseif trace_bugs then logwarning("%s: mark %s has no anchors",cref(kind,chainname,chainlookupname,lookupname),gref(markchar)) end elseif trace_bugs then logwarning("%s: mark %s is no mark",cref(kind,chainname,chainlookupname),gref(markchar)) end return head,start,false end function chainprocs.gpos_cursive(head,start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname) local alreadydone=cursonce and start[a_cursbase] if not alreadydone then local startchar=start.char local subtables=currentlookup.subtables local lookupname=subtables[1] local exitanchors=lookuphash[lookupname] if exitanchors then exitanchors=exitanchors[startchar] end if exitanchors then local done=false if marks[startchar] then if trace_cursive then logprocess("%s: ignoring cursive for mark %s",pref(kind,lookupname),gref(startchar)) end else local nxt=start.next while not done and nxt and nxt.id==glyph_code and nxt.font==currentfont and nxt.subtype<256 do local nextchar=nxt.char if marks[nextchar] then nxt=nxt.next else local entryanchors=descriptions[nextchar] if entryanchors then entryanchors=entryanchors.anchors if entryanchors then entryanchors=entryanchors['centry'] if entryanchors then local al=anchorlookups[lookupname] for anchor,entry in next,entryanchors do if al[anchor] then local exit=exitanchors[anchor] if exit then local dx,dy,bound=setcursive(start,nxt,tfmdata.parameters.factor,rlmode,exit,entry,characters[startchar],characters[nextchar]) if trace_cursive then logprocess("%s: moving %s to %s cursive (%p,%p) using anchor %s and bound %s in rlmode %s",pref(kind,lookupname),gref(startchar),gref(nextchar),dx,dy,anchor,bound,rlmode) end done=true break end end end end end elseif trace_bugs then onetimemessage(currentfont,startchar,"no entry anchors",report_fonts) end break end end end return head,start,done else if trace_cursive and trace_details then logprocess("%s, cursive %s is already done",pref(kind,lookupname),gref(start.char),alreadydone) end return head,start,false end end return head,start,false end function chainprocs.gpos_single(head,start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname,chainindex,sequence) local startchar=start.char local subtables=currentlookup.subtables local lookupname=subtables[1] local kerns=lookuphash[lookupname] if kerns then kerns=kerns[startchar] if kerns then local dx,dy,w,h=setpair(start,tfmdata.parameters.factor,rlmode,sequence.flags[4],kerns,characters[startchar]) if trace_kerns then logprocess("%s: shifting single %s by (%p,%p) and correction (%p,%p)",cref(kind,chainname,chainlookupname),gref(startchar),dx,dy,w,h) end end end return head,start,false end chainmores.gpos_single=chainprocs.gpos_single function chainprocs.gpos_pair(head,start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname,chainindex,sequence) local snext=start.next if snext then local startchar=start.char local subtables=currentlookup.subtables local lookupname=subtables[1] local kerns=lookuphash[lookupname] if kerns then kerns=kerns[startchar] if kerns then local lookuptype=lookuptypes[lookupname] local prev,done=start,false local factor=tfmdata.parameters.factor while snext and snext.id==glyph_code and snext.font==currentfont and snext.subtype<256 do local nextchar=snext.char local krn=kerns[nextchar] if not krn and marks[nextchar] then prev=snext snext=snext.next else if not krn then elseif type(krn)=="table" then if lookuptype=="pair" then local a,b=krn[2],krn[3] if a and #a>0 then local startchar=start.char local x,y,w,h=setpair(start,factor,rlmode,sequence.flags[4],a,characters[startchar]) if trace_kerns then logprocess("%s: shifting first of pair %s and %s by (%p,%p) and correction (%p,%p)",cref(kind,chainname,chainlookupname),gref(startchar),gref(nextchar),x,y,w,h) end end if b and #b>0 then local startchar=start.char local x,y,w,h=setpair(snext,factor,rlmode,sequence.flags[4],b,characters[nextchar]) if trace_kerns then logprocess("%s: shifting second of pair %s and %s by (%p,%p) and correction (%p,%p)",cref(kind,chainname,chainlookupname),gref(startchar),gref(nextchar),x,y,w,h) end end else report_process("%s: check this out (old kern stuff)",cref(kind,chainname,chainlookupname)) local a,b=krn[2],krn[6] if a and a~=0 then local k=setkern(snext,factor,rlmode,a) if trace_kerns then logprocess("%s: inserting first kern %s between %s and %s",cref(kind,chainname,chainlookupname),k,gref(prev.char),gref(nextchar)) end end if b and b~=0 then logwarning("%s: ignoring second kern xoff %s",cref(kind,chainname,chainlookupname),b*factor) end end done=true elseif krn~=0 then local k=setkern(snext,factor,rlmode,krn) if trace_kerns then logprocess("%s: inserting kern %s between %s and %s",cref(kind,chainname,chainlookupname),k,gref(prev.char),gref(nextchar)) end done=true end break end end return head,start,done end end end return head,start,false end chainmores.gpos_pair=chainprocs.gpos_pair local function show_skip(kind,chainname,char,ck,class) if ck[9] then logwarning("%s: skipping char %s, class %a, rule %a, lookuptype %a, %a => %a",cref(kind,chainname),gref(char),class,ck[1],ck[2],ck[9],ck[10]) else logwarning("%s: skipping char %s, class %a, rule %a, lookuptype %a",cref(kind,chainname),gref(char),class,ck[1],ck[2]) end end local function normal_handle_contextchain(head,start,kind,chainname,contexts,sequence,lookuphash) local flags=sequence.flags local done=false local skipmark=flags[1] local skipligature=flags[2] local skipbase=flags[3] local someskip=skipmark or skipligature or skipbase local markclass=sequence.markclass local skipped=false for k=1,#contexts do local match=true local current=start local last=start local ck=contexts[k] local seq=ck[3] local s=#seq if s==1 then match=current.id==glyph_code and current.font==currentfont and current.subtype<256 and seq[1][current.char] else local f,l=ck[4],ck[5] if f==1 and f==l then else if f==l then else local n=f+1 last=last.next while n<=l do if last then local id=last.id if id==glyph_code then if last.font==currentfont and last.subtype<256 then local char=last.char local ccd=descriptions[char] if ccd then local class=ccd.class if class==skipmark or class==skipligature or class==skipbase or (markclass and class=="mark" and not markclass[char]) then skipped=true if trace_skips then show_skip(kind,chainname,char,ck,class) end last=last.next elseif seq[n][char] then if n<l then last=last.next end n=n+1 else match=false break end else match=false break end else match=false break end elseif id==disc_code then last=last.next else match=false break end else match=false break end end end end if match and f>1 then local prev=start.prev if prev then local n=f-1 while n>=1 do if prev then local id=prev.id if id==glyph_code then if prev.font==currentfont and prev.subtype<256 then local char=prev.char local ccd=descriptions[char] if ccd then local class=ccd.class if class==skipmark or class==skipligature or class==skipbase or (markclass and class=="mark" and not markclass[char]) then skipped=true if trace_skips then show_skip(kind,chainname,char,ck,class) end elseif seq[n][char] then n=n -1 else match=false break end else match=false break end else match=false break end elseif id==disc_code then elseif seq[n][32] then n=n -1 else match=false break end prev=prev.prev elseif seq[n][32] then n=n -1 else match=false break end end elseif f==2 then match=seq[1][32] else for n=f-1,1 do if not seq[n][32] then match=false break end end end end if match and s>l then local current=last and last.next if current then local n=l+1 while n<=s do if current then local id=current.id if id==glyph_code then if current.font==currentfont and current.subtype<256 then local char=current.char local ccd=descriptions[char] if ccd then local class=ccd.class if class==skipmark or class==skipligature or class==skipbase or (markclass and class=="mark" and not markclass[char]) then skipped=true if trace_skips then show_skip(kind,chainname,char,ck,class) end elseif seq[n][char] then n=n+1 else match=false break end else match=false break end else match=false break end elseif id==disc_code then elseif seq[n][32] then n=n+1 else match=false break end current=current.next elseif seq[n][32] then n=n+1 else match=false break end end elseif s-l==1 then match=seq[s][32] else for n=l+1,s do if not seq[n][32] then match=false break end end end end end if match then if trace_contexts then local rule,lookuptype,f,l=ck[1],ck[2],ck[4],ck[5] local char=start.char if ck[9] then logwarning("%s: rule %s matches at char %s for (%s,%s,%s) chars, lookuptype %a, %a => %a", cref(kind,chainname),rule,gref(char),f-1,l-f+1,s-l,lookuptype,ck[9],ck[10]) else logwarning("%s: rule %s matches at char %s for (%s,%s,%s) chars, lookuptype %a", cref(kind,chainname),rule,gref(char),f-1,l-f+1,s-l,lookuptype) end end local chainlookups=ck[6] if chainlookups then local nofchainlookups=#chainlookups if nofchainlookups==1 then local chainlookupname=chainlookups[1] local chainlookup=lookuptable[chainlookupname] if chainlookup then local cp=chainprocs[chainlookup.type] if cp then local ok head,start,ok=cp(head,start,last,kind,chainname,ck,lookuphash,chainlookup,chainlookupname,nil,sequence) if ok then done=true end else logprocess("%s: %s is not yet supported",cref(kind,chainname,chainlookupname),chainlookup.type) end else logprocess("%s is not yet supported",cref(kind,chainname,chainlookupname)) end else local i=1 repeat if skipped then while true do local char=start.char local ccd=descriptions[char] if ccd then local class=ccd.class if class==skipmark or class==skipligature or class==skipbase or (markclass and class=="mark" and not markclass[char]) then start=start.next else break end else break end end end local chainlookupname=chainlookups[i] local chainlookup=lookuptable[chainlookupname] if not chainlookup then i=i+1 else local cp=chainmores[chainlookup.type] if not cp then logprocess("%s: %s is not yet supported",cref(kind,chainname,chainlookupname),chainlookup.type) i=i+1 else local ok,n head,start,ok,n=cp(head,start,last,kind,chainname,ck,lookuphash,chainlookup,chainlookupname,i,sequence) if ok then done=true i=i+(n or 1) else i=i+1 end end end if start then start=start.next else end until i>nofchainlookups end else local replacements=ck[7] if replacements then head,start,done=chainprocs.reversesub(head,start,last,kind,chainname,ck,lookuphash,replacements) else done=true if trace_contexts then logprocess("%s: skipping match",cref(kind,chainname)) end end end end end return head,start,done end local verbose_handle_contextchain=function(font,...) logwarning("no verbose handler installed, reverting to 'normal'") otf.setcontextchain() return normal_handle_contextchain(...) end otf.chainhandlers={ normal=normal_handle_contextchain, verbose=verbose_handle_contextchain, } function otf.setcontextchain(method) if not method or method=="normal" or not otf.chainhandlers[method] then if handlers.contextchain then logwarning("installing normal contextchain handler") end handlers.contextchain=normal_handle_contextchain else logwarning("installing contextchain handler %a",method) local handler=otf.chainhandlers[method] handlers.contextchain=function(...) return handler(currentfont,...) end end handlers.gsub_context=handlers.contextchain handlers.gsub_contextchain=handlers.contextchain handlers.gsub_reversecontextchain=handlers.contextchain handlers.gpos_contextchain=handlers.contextchain handlers.gpos_context=handlers.contextchain end otf.setcontextchain() local missing={} local function logprocess(...) if trace_steps then registermessage(...) end report_process(...) end local logwarning=report_process local function report_missing_cache(typ,lookup) local f=missing[currentfont] if not f then f={} missing[currentfont]=f end local t=f[typ] if not t then t={} f[typ]=t end if not t[lookup] then t[lookup]=true logwarning("missing cache for lookup %a, type %a, font %a, name %a",lookup,typ,currentfont,tfmdata.properties.fullname) end end local resolved={} local lookuphashes={} setmetatableindex(lookuphashes,function(t,font) local lookuphash=fontdata[font].resources.lookuphash if not lookuphash or not next(lookuphash) then lookuphash=false end t[font]=lookuphash return lookuphash end) local autofeatures=fonts.analyzers.features local function initialize(sequence,script,language,enabled) local features=sequence.features if features then local order=sequence.order if order then for i=1,#order do local kind=order[i] local valid=enabled[kind] if valid then local scripts=features[kind] local languages=scripts[script] or scripts[wildcard] if languages and (languages[language] or languages[wildcard]) then return { valid,autofeatures[kind] or false,sequence.chain or 0,kind,sequence } end end end else end end return false end function otf.dataset(tfmdata,font) local shared=tfmdata.shared local properties=tfmdata.properties local language=properties.language or "dflt" local script=properties.script or "dflt" local enabled=shared.features local res=resolved[font] if not res then res={} resolved[font]=res end local rs=res[script] if not rs then rs={} res[script]=rs end local rl=rs[language] if not rl then rl={ } rs[language]=rl local sequences=tfmdata.resources.sequences for s=1,#sequences do local v=enabled and initialize(sequences[s],script,language,enabled) if v then rl[#rl+1]=v end end end return rl end local function featuresprocessor(head,font,attr) local lookuphash=lookuphashes[font] if not lookuphash then return head,false end if trace_steps then checkstep(head) end tfmdata=fontdata[font] descriptions=tfmdata.descriptions characters=tfmdata.characters resources=tfmdata.resources marks=resources.marks anchorlookups=resources.lookup_to_anchor lookuptable=resources.lookups lookuptypes=resources.lookuptypes currentfont=font rlmode=0 local sequences=resources.sequences local done=false local datasets=otf.dataset(tfmdata,font,attr) local dirstack={} for s=1,#datasets do local dataset=datasets[s] featurevalue=dataset[1] local sequence=dataset[5] local rlparmode=0 local topstack=0 local success=false local attribute=dataset[2] local chain=dataset[3] local typ=sequence.type local subtables=sequence.subtables if chain<0 then local handler=handlers[typ] local start=find_node_tail(head) while start do local id=start.id if id==glyph_code then if start.font==font and start.subtype<256 then local a=start[0] if a then a=a==attr else a=true end if a then for i=1,#subtables do local lookupname=subtables[i] local lookupcache=lookuphash[lookupname] if lookupcache then local lookupmatch=lookupcache[start.char] if lookupmatch then head,start,success=handler(head,start,dataset[4],lookupname,lookupmatch,sequence,lookuphash,i) if success then break end end else report_missing_cache(typ,lookupname) end end if start then start=start.prev end else start=start.prev end else start=start.prev end else start=start.prev end end else local handler=handlers[typ] local ns=#subtables local start=head rlmode=0 if ns==1 then local lookupname=subtables[1] local lookupcache=lookuphash[lookupname] if not lookupcache then report_missing_cache(typ,lookupname) else local function subrun(start) local head=start local done=false while start do local id=start.id if id==glyph_code and start.font==font and start.subtype<256 then local a=start[0] if a then a=(a==attr) and (not attribute or start[a_state]==attribute) else a=not attribute or start[a_state]==attribute end if a then local lookupmatch=lookupcache[start.char] if lookupmatch then local ok head,start,ok=handler(head,start,dataset[4],lookupname,lookupmatch,sequence,lookuphash,1) if ok then done=true end end if start then start=start.next end else start=start.next end else start=start.next end end if done then success=true return head end end local function kerndisc(disc) local prev=disc.prev local next=disc.next if prev and next then prev.next=next local a=prev[0] if a then a=(a==attr) and (not attribute or prev[a_state]==attribute) else a=not attribute or prev[a_state]==attribute end if a then local lookupmatch=lookupcache[prev.char] if lookupmatch then local h,d,ok=handler(head,prev,dataset[4],lookupname,lookupmatch,sequence,lookuphash,1) if ok then done=true success=true end end end prev.next=disc end return next end while start do local id=start.id if id==glyph_code then if start.font==font and start.subtype<256 then local a=start[0] if a then a=(a==attr) and (not attribute or start[a_state]==attribute) else a=not attribute or start[a_state]==attribute end if a then local lookupmatch=lookupcache[start.char] if lookupmatch then local ok head,start,ok=handler(head,start,dataset[4],lookupname,lookupmatch,sequence,lookuphash,1) if ok then success=true end end if start then start=start.next end else start=start.next end else start=start.next end elseif id==disc_code then if start.subtype==discretionary_code then local pre=start.pre if pre then local new=subrun(pre) if new then start.pre=new end end local post=start.post if post then local new=subrun(post) if new then start.post=new end end local replace=start.replace if replace then local new=subrun(replace) if new then start.replace=new end end elseif typ=="gpos_single" or typ=="gpos_pair" then kerndisc(start) end start=start.next elseif id==whatsit_code then local subtype=start.subtype if subtype==dir_code then local dir=start.dir if dir=="+TRT" or dir=="+TLT" then topstack=topstack+1 dirstack[topstack]=dir elseif dir=="-TRT" or dir=="-TLT" then topstack=topstack-1 end local newdir=dirstack[topstack] if newdir=="+TRT" then rlmode=-1 elseif newdir=="+TLT" then rlmode=1 else rlmode=rlparmode end if trace_directions then report_process("directions after txtdir %a: parmode %a, txtmode %a, # stack %a, new dir %a",dir,rlparmode,rlmode,topstack,newdir) end elseif subtype==localpar_code then local dir=start.dir if dir=="TRT" then rlparmode=-1 elseif dir=="TLT" then rlparmode=1 else rlparmode=0 end rlmode=rlparmode if trace_directions then report_process("directions after pardir %a: parmode %a, txtmode %a",dir,rlparmode,rlmode) end end start=start.next elseif id==math_code then start=end_of_math(start).next else start=start.next end end end else local function subrun(start) local head=start local done=false while start do local id=start.id if id==glyph_code and start.id==font and start.subtype<256 then local a=start[0] if a then a=(a==attr) and (not attribute or start[a_state]==attribute) else a=not attribute or start[a_state]==attribute end if a then for i=1,ns do local lookupname=subtables[i] local lookupcache=lookuphash[lookupname] if lookupcache then local lookupmatch=lookupcache[start.char] if lookupmatch then local ok head,start,ok=handler(head,start,dataset[4],lookupname,lookupmatch,sequence,lookuphash,i) if ok then done=true break elseif not start then break end end else report_missing_cache(typ,lookupname) end end if start then start=start.next end else start=start.next end else start=start.next end end if done then success=true return head end end local function kerndisc(disc) local prev=disc.prev local next=disc.next if prev and next then prev.next=next local a=prev[0] if a then a=(a==attr) and (not attribute or prev[a_state]==attribute) else a=not attribute or prev[a_state]==attribute end if a then for i=1,ns do local lookupname=subtables[i] local lookupcache=lookuphash[lookupname] if lookupcache then local lookupmatch=lookupcache[prev.char] if lookupmatch then local h,d,ok=handler(head,prev,dataset[4],lookupname,lookupmatch,sequence,lookuphash,i) if ok then done=true break end end else report_missing_cache(typ,lookupname) end end end prev.next=disc end return next end while start do local id=start.id if id==glyph_code then if start.font==font and start.subtype<256 then local a=start[0] if a then a=(a==attr) and (not attribute or start[a_state]==attribute) else a=not attribute or start[a_state]==attribute end if a then for i=1,ns do local lookupname=subtables[i] local lookupcache=lookuphash[lookupname] if lookupcache then local lookupmatch=lookupcache[start.char] if lookupmatch then local ok head,start,ok=handler(head,start,dataset[4],lookupname,lookupmatch,sequence,lookuphash,i) if ok then success=true break elseif not start then break end end else report_missing_cache(typ,lookupname) end end if start then start=start.next end else start=start.next end else start=start.next end elseif id==disc_code then if start.subtype==discretionary_code then local pre=start.pre if pre then local new=subrun(pre) if new then start.pre=new end end local post=start.post if post then local new=subrun(post) if new then start.post=new end end local replace=start.replace if replace then local new=subrun(replace) if new then start.replace=new end end elseif typ=="gpos_single" or typ=="gpos_pair" then kerndisc(start) end start=start.next elseif id==whatsit_code then local subtype=start.subtype if subtype==dir_code then local dir=start.dir if dir=="+TRT" or dir=="+TLT" then topstack=topstack+1 dirstack[topstack]=dir elseif dir=="-TRT" or dir=="-TLT" then topstack=topstack-1 end local newdir=dirstack[topstack] if newdir=="+TRT" then rlmode=-1 elseif newdir=="+TLT" then rlmode=1 else rlmode=rlparmode end if trace_directions then report_process("directions after txtdir %a: parmode %a, txtmode %a, # stack %a, new dir %a",dir,rlparmode,rlmode,topstack,newdir) end elseif subtype==localpar_code then local dir=start.dir if dir=="TRT" then rlparmode=-1 elseif dir=="TLT" then rlparmode=1 else rlparmode=0 end rlmode=rlparmode if trace_directions then report_process("directions after pardir %a: parmode %a, txtmode %a",dir,rlparmode,rlmode) end end start=start.next elseif id==math_code then start=end_of_math(start).next else start=start.next end end end end if success then done=true end if trace_steps then registerstep(head) end end return head,done end local function generic(lookupdata,lookupname,unicode,lookuphash) local target=lookuphash[lookupname] if target then target[unicode]=lookupdata else lookuphash[lookupname]={ [unicode]=lookupdata } end end local action={ substitution=generic, multiple=generic, alternate=generic, position=generic, ligature=function(lookupdata,lookupname,unicode,lookuphash) local target=lookuphash[lookupname] if not target then target={} lookuphash[lookupname]=target end for i=1,#lookupdata do local li=lookupdata[i] local tu=target[li] if not tu then tu={} target[li]=tu end target=tu end target.ligature=unicode end, pair=function(lookupdata,lookupname,unicode,lookuphash) local target=lookuphash[lookupname] if not target then target={} lookuphash[lookupname]=target end local others=target[unicode] local paired=lookupdata[1] if others then others[paired]=lookupdata else others={ [paired]=lookupdata } target[unicode]=others end end, } local function prepare_lookups(tfmdata) local rawdata=tfmdata.shared.rawdata local resources=rawdata.resources local lookuphash=resources.lookuphash local anchor_to_lookup=resources.anchor_to_lookup local lookup_to_anchor=resources.lookup_to_anchor local lookuptypes=resources.lookuptypes local characters=tfmdata.characters local descriptions=tfmdata.descriptions for unicode,character in next,characters do local description=descriptions[unicode] if description then local lookups=description.slookups if lookups then for lookupname,lookupdata in next,lookups do action[lookuptypes[lookupname]](lookupdata,lookupname,unicode,lookuphash) end end local lookups=description.mlookups if lookups then for lookupname,lookuplist in next,lookups do local lookuptype=lookuptypes[lookupname] for l=1,#lookuplist do local lookupdata=lookuplist[l] action[lookuptype](lookupdata,lookupname,unicode,lookuphash) end end end local list=description.kerns if list then for lookup,krn in next,list do local target=lookuphash[lookup] if target then target[unicode]=krn else lookuphash[lookup]={ [unicode]=krn } end end end local list=description.anchors if list then for typ,anchors in next,list do if typ=="mark" or typ=="cexit" then for name,anchor in next,anchors do local lookups=anchor_to_lookup[name] if lookups then for lookup,_ in next,lookups do local target=lookuphash[lookup] if target then target[unicode]=anchors else lookuphash[lookup]={ [unicode]=anchors } end end end end end end end end end end local function split(replacement,original) local result={} for i=1,#replacement do result[original[i]]=replacement[i] end return result end local valid={ coverage={ chainsub=true,chainpos=true,contextsub=true }, reversecoverage={ reversesub=true }, glyphs={ chainsub=true,chainpos=true }, } local function prepare_contextchains(tfmdata) local rawdata=tfmdata.shared.rawdata local resources=rawdata.resources local lookuphash=resources.lookuphash local lookups=rawdata.lookups if lookups then for lookupname,lookupdata in next,rawdata.lookups do local lookuptype=lookupdata.type if lookuptype then local rules=lookupdata.rules if rules then local format=lookupdata.format local validformat=valid[format] if not validformat then report_prepare("unsupported format %a",format) elseif not validformat[lookuptype] then report_prepare("unsupported format %a, lookuptype %a, lookupname %a",format,lookuptype,lookupname) else local contexts=lookuphash[lookupname] if not contexts then contexts={} lookuphash[lookupname]=contexts end local t,nt={},0 for nofrules=1,#rules do local rule=rules[nofrules] local current=rule.current local before=rule.before local after=rule.after local replacements=rule.replacements local sequence={} local nofsequences=0 if before then for n=1,#before do nofsequences=nofsequences+1 sequence[nofsequences]=before[n] end end local start=nofsequences+1 for n=1,#current do nofsequences=nofsequences+1 sequence[nofsequences]=current[n] end local stop=nofsequences if after then for n=1,#after do nofsequences=nofsequences+1 sequence[nofsequences]=after[n] end end if sequence[1] then nt=nt+1 t[nt]={ nofrules,lookuptype,sequence,start,stop,rule.lookups,replacements } for unic,_ in next,sequence[start] do local cu=contexts[unic] if not cu then contexts[unic]=t end end end end end else end else report_prepare("missing lookuptype for lookupname %a",lookupname) end end end end local function featuresinitializer(tfmdata,value) if true then local rawdata=tfmdata.shared.rawdata local properties=rawdata.properties if not properties.initialized then local starttime=trace_preparing and os.clock() local resources=rawdata.resources resources.lookuphash=resources.lookuphash or {} prepare_contextchains(tfmdata) prepare_lookups(tfmdata) properties.initialized=true if trace_preparing then report_prepare("preparation time is %0.3f seconds for %a",os.clock()-starttime,tfmdata.properties.fullname) end end end end registerotffeature { name="features", description="features", default=true, initializers={ position=1, node=featuresinitializer, }, processors={ node=featuresprocessor, } } otf.handlers=handlers end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['font-otp']={ version=1.001, comment="companion to font-otf.lua (packing)", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local next,type=next,type local sort,concat=table.sort,table.concat local sortedhash=table.sortedhash local trace_packing=false trackers.register("otf.packing",function(v) trace_packing=v end) local trace_loading=false trackers.register("otf.loading",function(v) trace_loading=v end) local report_otf=logs.reporter("fonts","otf loading") fonts=fonts or {} local handlers=fonts.handlers or {} fonts.handlers=handlers local otf=handlers.otf or {} handlers.otf=otf local enhancers=otf.enhancers or {} otf.enhancers=enhancers local glists=otf.glists or { "gsub","gpos" } otf.glists=glists local criterium=1 local threshold=0 local function tabstr_normal(t) local s={} local n=0 for k,v in next,t do n=n+1 if type(v)=="table" then s[n]=k..">"..tabstr_normal(v) elseif v==true then s[n]=k.."+" elseif v then s[n]=k.."="..v else s[n]=k.."-" end end if n==0 then return "" elseif n==1 then return s[1] else sort(s) return concat(s,",") end end local function tabstr_flat(t) local s={} local n=0 for k,v in next,t do n=n+1 s[n]=k.."="..v end if n==0 then return "" elseif n==1 then return s[1] else sort(s) return concat(s,",") end end local function tabstr_mixed(t) local s={} local n=#t if n==0 then return "" elseif n==1 then local k=t[1] if k==true then return "++" elseif k==false then return "--" else return tostring(k) end else for i=1,n do local k=t[i] if k==true then s[i]="++" elseif k==false then s[i]="--" else s[i]=k end end return concat(s,",") end end local function tabstr_boolean(t) local s={} local n=0 for k,v in next,t do n=n+1 if v then s[n]=k.."+" else s[n]=k.."-" end end if n==0 then return "" elseif n==1 then return s[1] else sort(s) return concat(s,",") end end local function packdata(data) if data then local h,t,c={},{},{} local hh,tt,cc={},{},{} local nt,ntt=0,0 local function pack_normal(v) local tag=tabstr_normal(v) local ht=h[tag] if ht then c[ht]=c[ht]+1 return ht else nt=nt+1 t[nt]=v h[tag]=nt c[nt]=1 return nt end end local function pack_flat(v) local tag=tabstr_flat(v) local ht=h[tag] if ht then c[ht]=c[ht]+1 return ht else nt=nt+1 t[nt]=v h[tag]=nt c[nt]=1 return nt end end local function pack_boolean(v) local tag=tabstr_boolean(v) local ht=h[tag] if ht then c[ht]=c[ht]+1 return ht else nt=nt+1 t[nt]=v h[tag]=nt c[nt]=1 return nt end end local function pack_indexed(v) local tag=concat(v," ") local ht=h[tag] if ht then c[ht]=c[ht]+1 return ht else nt=nt+1 t[nt]=v h[tag]=nt c[nt]=1 return nt end end local function pack_mixed(v) local tag=tabstr_mixed(v) local ht=h[tag] if ht then c[ht]=c[ht]+1 return ht else nt=nt+1 t[nt]=v h[tag]=nt c[nt]=1 return nt end end local function pack_final(v) if c[v]<=criterium then return t[v] else local hv=hh[v] if hv then return hv else ntt=ntt+1 tt[ntt]=t[v] hh[v]=ntt cc[ntt]=c[v] return ntt end end end local function success(stage,pass) if nt==0 then if trace_loading or trace_packing then report_otf("pack quality: nothing to pack") end return false elseif nt>=threshold then local one,two,rest=0,0,0 if pass==1 then for k,v in next,c do if v==1 then one=one+1 elseif v==2 then two=two+1 else rest=rest+1 end end else for k,v in next,cc do if v>20 then rest=rest+1 elseif v>10 then two=two+1 else one=one+1 end end data.tables=tt end if trace_loading or trace_packing then report_otf("pack quality: stage %s, pass %s, %s packed, 1-10:%s, 11-20:%s, rest:%s (criterium: %s)",stage,pass,one+two+rest,one,two,rest,criterium) end return true else if trace_loading or trace_packing then report_otf("pack quality: stage %s, pass %s, %s packed, aborting pack (threshold: %s)",stage,pass,nt,threshold) end return false end end local function packers(pass) if pass==1 then return pack_normal,pack_indexed,pack_flat,pack_boolean,pack_mixed else return pack_final,pack_final,pack_final,pack_final,pack_final end end local resources=data.resources local lookuptypes=resources.lookuptypes for pass=1,2 do if trace_packing then report_otf("start packing: stage 1, pass %s",pass) end local pack_normal,pack_indexed,pack_flat,pack_boolean,pack_mixed=packers(pass) for unicode,description in next,data.descriptions do local boundingbox=description.boundingbox if boundingbox then description.boundingbox=pack_indexed(boundingbox) end local slookups=description.slookups if slookups then for tag,slookup in next,slookups do local what=lookuptypes[tag] if what=="pair" then local t=slookup[2] if t then slookup[2]=pack_indexed(t) end local t=slookup[3] if t then slookup[3]=pack_indexed(t) end elseif what~="substitution" then slookups[tag]=pack_indexed(slookup) end end end local mlookups=description.mlookups if mlookups then for tag,mlookup in next,mlookups do local what=lookuptypes[tag] if what=="pair" then for i=1,#mlookup do local lookup=mlookup[i] local t=lookup[2] if t then lookup[2]=pack_indexed(t) end local t=lookup[3] if t then lookup[3]=pack_indexed(t) end end elseif what~="substitution" then for i=1,#mlookup do mlookup[i]=pack_indexed(mlookup[i]) end end end end local kerns=description.kerns if kerns then for tag,kern in next,kerns do kerns[tag]=pack_flat(kern) end end local math=description.math if math then local kerns=math.kerns if kerns then for tag,kern in next,kerns do kerns[tag]=pack_normal(kern) end end end local anchors=description.anchors if anchors then for what,anchor in next,anchors do if what=="baselig" then for _,a in next,anchor do for k=1,#a do a[k]=pack_indexed(a[k]) end end else for k,v in next,anchor do anchor[k]=pack_indexed(v) end end end end local altuni=description.altuni if altuni then for i=1,#altuni do altuni[i]=pack_flat(altuni[i]) end end end local lookups=data.lookups if lookups then for _,lookup in next,lookups do local rules=lookup.rules if rules then for i=1,#rules do local rule=rules[i] local r=rule.before if r then for i=1,#r do r[i]=pack_boolean(r[i]) end end local r=rule.after if r then for i=1,#r do r[i]=pack_boolean(r[i]) end end local r=rule.current if r then for i=1,#r do r[i]=pack_boolean(r[i]) end end local r=rule.replacements if r then rule.replacements=pack_flat (r) end local r=rule.lookups if r then rule.lookups=pack_indexed(r) end end end end end local anchor_to_lookup=resources.anchor_to_lookup if anchor_to_lookup then for anchor,lookup in next,anchor_to_lookup do anchor_to_lookup[anchor]=pack_normal(lookup) end end local lookup_to_anchor=resources.lookup_to_anchor if lookup_to_anchor then for lookup,anchor in next,lookup_to_anchor do lookup_to_anchor[lookup]=pack_normal(anchor) end end local sequences=resources.sequences if sequences then for feature,sequence in next,sequences do local flags=sequence.flags if flags then sequence.flags=pack_normal(flags) end local subtables=sequence.subtables if subtables then sequence.subtables=pack_normal(subtables) end local features=sequence.features if features then for script,feature in next,features do features[script]=pack_normal(feature) end end local order=sequence.order if order then sequence.order=pack_indexed(order) end local markclass=sequence.markclass if markclass then sequence.markclass=pack_boolean(markclass) end end end local lookups=resources.lookups if lookups then for name,lookup in next,lookups do local flags=lookup.flags if flags then lookup.flags=pack_normal(flags) end local subtables=lookup.subtables if subtables then lookup.subtables=pack_normal(subtables) end end end local features=resources.features if features then for _,what in next,glists do local list=features[what] if list then for feature,spec in next,list do list[feature]=pack_normal(spec) end end end end if not success(1,pass) then return end end if nt>0 then for pass=1,2 do if trace_packing then report_otf("start packing: stage 2, pass %s",pass) end local pack_normal,pack_indexed,pack_flat,pack_boolean,pack_mixed=packers(pass) for unicode,description in next,data.descriptions do local kerns=description.kerns if kerns then description.kerns=pack_normal(kerns) end local math=description.math if math then local kerns=math.kerns if kerns then math.kerns=pack_normal(kerns) end end local anchors=description.anchors if anchors then description.anchors=pack_normal(anchors) end local mlookups=description.mlookups if mlookups then for tag,mlookup in next,mlookups do mlookups[tag]=pack_normal(mlookup) end end local altuni=description.altuni if altuni then description.altuni=pack_normal(altuni) end end local lookups=data.lookups if lookups then for _,lookup in next,lookups do local rules=lookup.rules if rules then for i=1,#rules do local rule=rules[i] local r=rule.before if r then rule.before=pack_normal(r) end local r=rule.after if r then rule.after=pack_normal(r) end local r=rule.current if r then rule.current=pack_normal(r) end end end end end local sequences=resources.sequences if sequences then for feature,sequence in next,sequences do sequence.features=pack_normal(sequence.features) end end if not success(2,pass) then end end for pass=1,2 do local pack_normal,pack_indexed,pack_flat,pack_boolean,pack_mixed=packers(pass) for unicode,description in next,data.descriptions do local slookups=description.slookups if slookups then description.slookups=pack_normal(slookups) end local mlookups=description.mlookups if mlookups then description.mlookups=pack_normal(mlookups) end end end end end end local unpacked_mt={ __index=function(t,k) t[k]=false return k end } local function unpackdata(data) if data then local tables=data.tables if tables then local resources=data.resources local lookuptypes=resources.lookuptypes local unpacked={} setmetatable(unpacked,unpacked_mt) for unicode,description in next,data.descriptions do local tv=tables[description.boundingbox] if tv then description.boundingbox=tv end local slookups=description.slookups if slookups then local tv=tables[slookups] if tv then description.slookups=tv slookups=unpacked[tv] end if slookups then for tag,lookup in next,slookups do local what=lookuptypes[tag] if what=="pair" then local tv=tables[lookup[2]] if tv then lookup[2]=tv end local tv=tables[lookup[3]] if tv then lookup[3]=tv end elseif what~="substitution" then local tv=tables[lookup] if tv then slookups[tag]=tv end end end end end local mlookups=description.mlookups if mlookups then local tv=tables[mlookups] if tv then description.mlookups=tv mlookups=unpacked[tv] end if mlookups then for tag,list in next,mlookups do local tv=tables[list] if tv then mlookups[tag]=tv list=unpacked[tv] end if list then local what=lookuptypes[tag] if what=="pair" then for i=1,#list do local lookup=list[i] local tv=tables[lookup[2]] if tv then lookup[2]=tv end local tv=tables[lookup[3]] if tv then lookup[3]=tv end end elseif what~="substitution" then for i=1,#list do local tv=tables[list[i]] if tv then list[i]=tv end end end end end end end local kerns=description.kerns if kerns then local tm=tables[kerns] if tm then description.kerns=tm kerns=unpacked[tm] end if kerns then for k,kern in next,kerns do local tv=tables[kern] if tv then kerns[k]=tv end end end end local math=description.math if math then local kerns=math.kerns if kerns then local tm=tables[kerns] if tm then math.kerns=tm kerns=unpacked[tm] end if kerns then for k,kern in next,kerns do local tv=tables[kern] if tv then kerns[k]=tv end end end end end local anchors=description.anchors if anchors then local ta=tables[anchors] if ta then description.anchors=ta anchors=unpacked[ta] end if anchors then for tag,anchor in next,anchors do if tag=="baselig" then for _,list in next,anchor do for i=1,#list do local tv=tables[list[i]] if tv then list[i]=tv end end end else for a,data in next,anchor do local tv=tables[data] if tv then anchor[a]=tv end end end end end end local altuni=description.altuni if altuni then local altuni=tables[altuni] if altuni then description.altuni=altuni for i=1,#altuni do local tv=tables[altuni[i]] if tv then altuni[i]=tv end end end end end local lookups=data.lookups if lookups then for _,lookup in next,lookups do local rules=lookup.rules if rules then for i=1,#rules do local rule=rules[i] local before=rule.before if before then local tv=tables[before] if tv then rule.before=tv before=unpacked[tv] end if before then for i=1,#before do local tv=tables[before[i]] if tv then before[i]=tv end end end end local after=rule.after if after then local tv=tables[after] if tv then rule.after=tv after=unpacked[tv] end if after then for i=1,#after do local tv=tables[after[i]] if tv then after[i]=tv end end end end local current=rule.current if current then local tv=tables[current] if tv then rule.current=tv current=unpacked[tv] end if current then for i=1,#current do local tv=tables[current[i]] if tv then current[i]=tv end end end end local replacements=rule.replacements if replacements then local tv=tables[replacements] if tv then rule.replacements=tv end end local lookups=rule.lookups if lookups then local tv=tables[lookups] if tv then rule.lookups=tv end end end end end end local anchor_to_lookup=resources.anchor_to_lookup if anchor_to_lookup then for anchor,lookup in next,anchor_to_lookup do local tv=tables[lookup] if tv then anchor_to_lookup[anchor]=tv end end end local lookup_to_anchor=resources.lookup_to_anchor if lookup_to_anchor then for lookup,anchor in next,lookup_to_anchor do local tv=tables[anchor] if tv then lookup_to_anchor[lookup]=tv end end end local ls=resources.sequences if ls then for _,feature in next,ls do local flags=feature.flags if flags then local tv=tables[flags] if tv then feature.flags=tv end end local subtables=feature.subtables if subtables then local tv=tables[subtables] if tv then feature.subtables=tv end end local features=feature.features if features then local tv=tables[features] if tv then feature.features=tv features=unpacked[tv] end if features then for script,data in next,features do local tv=tables[data] if tv then features[script]=tv end end end end local order=feature.order if order then local tv=tables[order] if tv then feature.order=tv end end local markclass=feature.markclass if markclass then local tv=tables[markclass] if tv then feature.markclass=tv end end end end local lookups=resources.lookups if lookups then for _,lookup in next,lookups do local flags=lookup.flags if flags then local tv=tables[flags] if tv then lookup.flags=tv end end local subtables=lookup.subtables if subtables then local tv=tables[subtables] if tv then lookup.subtables=tv end end end end local features=resources.features if features then for _,what in next,glists do local feature=features[what] if feature then for tag,spec in next,feature do local tv=tables[spec] if tv then feature[tag]=tv end end end end end data.tables=nil end end end if otf.enhancers.register then otf.enhancers.register("pack",packdata) otf.enhancers.register("unpack",unpackdata) end otf.enhancers.unpack=unpackdata end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['luatex-fonts-lua']={ version=1.001, comment="companion to luatex-*.tex", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } if context then texio.write_nl("fatal error: this module is not for context") os.exit() end local fonts=fonts fonts.formats.lua="lua" function fonts.readers.lua(specification) local fullname=specification.filename or "" if fullname=="" then local forced=specification.forced or "" if forced~="" then fullname=specification.name.."."..forced else fullname=specification.name end end local fullname=resolvers.findfile(fullname) or "" if fullname~="" then local loader=loadfile(fullname) loader=loader and loader() return loader and loader(specification) end end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['font-def']={ version=1.001, comment="companion to font-ini.mkiv", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } local format,gmatch,match,find,lower,gsub=string.format,string.gmatch,string.match,string.find,string.lower,string.gsub local tostring,next=tostring,next local lpegmatch=lpeg.match local suffixonly,removesuffix=file.suffix,file.removesuffix local allocate=utilities.storage.allocate local trace_defining=false trackers .register("fonts.defining",function(v) trace_defining=v end) local directive_embedall=false directives.register("fonts.embedall",function(v) directive_embedall=v end) trackers.register("fonts.loading","fonts.defining","otf.loading","afm.loading","tfm.loading") trackers.register("fonts.all","fonts.*","otf.*","afm.*","tfm.*") local report_defining=logs.reporter("fonts","defining") local fonts=fonts local fontdata=fonts.hashes.identifiers local readers=fonts.readers local definers=fonts.definers local specifiers=fonts.specifiers local constructors=fonts.constructors local fontgoodies=fonts.goodies readers.sequence=allocate { 'otf','ttf','afm','tfm','lua' } local variants=allocate() specifiers.variants=variants definers.methods=definers.methods or {} local internalized=allocate() local lastdefined=nil local loadedfonts=constructors.loadedfonts local designsizes=constructors.designsizes local resolvefile=fontgoodies and fontgoodies.filenames and fontgoodies.filenames.resolve or function(s) return s end local splitter,splitspecifiers=nil,"" local P,C,S,Cc=lpeg.P,lpeg.C,lpeg.S,lpeg.Cc local left=P("(") local right=P(")") local colon=P(":") local space=P(" ") definers.defaultlookup="file" local prefixpattern=P(false) local function addspecifier(symbol) splitspecifiers=splitspecifiers..symbol local method=S(splitspecifiers) local lookup=C(prefixpattern)*colon local sub=left*C(P(1-left-right-method)^1)*right local specification=C(method)*C(P(1)^1) local name=C((1-sub-specification)^1) splitter=P((lookup+Cc(""))*name*(sub+Cc(""))*(specification+Cc(""))) end local function addlookup(str,default) prefixpattern=prefixpattern+P(str) end definers.addlookup=addlookup addlookup("file") addlookup("name") addlookup("spec") local function getspecification(str) return lpegmatch(splitter,str or "") end definers.getspecification=getspecification function definers.registersplit(symbol,action,verbosename) addspecifier(symbol) variants[symbol]=action if verbosename then variants[verbosename]=action end end local function makespecification(specification,lookup,name,sub,method,detail,size) size=size or 655360 if not lookup or lookup=="" then lookup=definers.defaultlookup end if trace_defining then report_defining("specification %a, lookup %a, name %a, sub %a, method %a, detail %a", specification,lookup,name,sub,method,detail) end local t={ lookup=lookup, specification=specification, size=size, name=name, sub=sub, method=method, detail=detail, resolved="", forced="", features={}, } return t end definers.makespecification=makespecification function definers.analyze(specification,size) local lookup,name,sub,method,detail=getspecification(specification or "") return makespecification(specification,lookup,name,sub,method,detail,size) end definers.resolvers=definers.resolvers or {} local resolvers=definers.resolvers function resolvers.file(specification) local name=resolvefile(specification.name) local suffix=lower(suffixonly(name)) if fonts.formats[suffix] then specification.forced=suffix specification.forcedname=name specification.name=removesuffix(name) else specification.name=name end end function resolvers.name(specification) local resolve=fonts.names.resolve if resolve then local resolved,sub=resolve(specification.name,specification.sub,specification) if resolved then specification.resolved=resolved specification.sub=sub local suffix=lower(suffixonly(resolved)) if fonts.formats[suffix] then specification.forced=suffix specification.forcedname=resolved specification.name=removesuffix(resolved) else specification.name=resolved end end else resolvers.file(specification) end end function resolvers.spec(specification) local resolvespec=fonts.names.resolvespec if resolvespec then local resolved,sub=resolvespec(specification.name,specification.sub,specification) if resolved then specification.resolved=resolved specification.sub=sub specification.forced=lower(suffixonly(resolved)) specification.forcedname=resolved specification.name=removesuffix(resolved) end else resolvers.name(specification) end end function definers.resolve(specification) if not specification.resolved or specification.resolved=="" then local r=resolvers[specification.lookup] if r then r(specification) end end if specification.forced=="" then specification.forced=nil specification.forcedname=nil end specification.hash=lower(specification.name..' @ '..constructors.hashfeatures(specification)) if specification.sub and specification.sub~="" then specification.hash=specification.sub..' @ '..specification.hash end return specification end function definers.applypostprocessors(tfmdata) local postprocessors=tfmdata.postprocessors if postprocessors then local properties=tfmdata.properties for i=1,#postprocessors do local extrahash=postprocessors[i](tfmdata) if type(extrahash)=="string" and extrahash~="" then extrahash=gsub(lower(extrahash),"[^a-z]","-") properties.fullname=format("%s-%s",properties.fullname,extrahash) end end end return tfmdata end local function checkembedding(tfmdata) local properties=tfmdata.properties local embedding if directive_embedall then embedding="full" elseif properties and properties.filename and constructors.dontembed[properties.filename] then embedding="no" else embedding="subset" end if properties then properties.embedding=embedding else tfmdata.properties={ embedding=embedding } end tfmdata.embedding=embedding end function definers.loadfont(specification) local hash=constructors.hashinstance(specification) local tfmdata=loadedfonts[hash] if not tfmdata then local forced=specification.forced or "" if forced~="" then local reader=readers[lower(forced)] tfmdata=reader and reader(specification) if not tfmdata then report_defining("forced type %a of %a not found",forced,specification.name) end else local sequence=readers.sequence for s=1,#sequence do local reader=sequence[s] if readers[reader] then if trace_defining then report_defining("trying (reader sequence driven) type %a for %a with file %a",reader,specification.name,specification.filename) end tfmdata=readers[reader](specification) if tfmdata then break else specification.filename=nil end end end end if tfmdata then tfmdata=definers.applypostprocessors(tfmdata) checkembedding(tfmdata) loadedfonts[hash]=tfmdata designsizes[specification.hash]=tfmdata.parameters.designsize end end if not tfmdata then report_defining("font with asked name %a is not found using lookup %a",specification.name,specification.lookup) end return tfmdata end function constructors.checkvirtualids() end function constructors.readanddefine(name,size) local specification=definers.analyze(name,size) local method=specification.method if method and variants[method] then specification=variants[method](specification) end specification=definers.resolve(specification) local hash=constructors.hashinstance(specification) local id=definers.registered(hash) if not id then local tfmdata=definers.loadfont(specification) if tfmdata then tfmdata.properties.hash=hash constructors.checkvirtualids(tfmdata) id=font.define(tfmdata) definers.register(tfmdata,id) else id=0 end end return fontdata[id],id end function definers.current() return lastdefined end function definers.registered(hash) local id=internalized[hash] return id,id and fontdata[id] end function definers.register(tfmdata,id) if tfmdata and id then local hash=tfmdata.properties.hash if not hash then report_defining("registering font, id %a, name %a, invalid hash",id,tfmdata.properties.filename or "?") elseif not internalized[hash] then internalized[hash]=id if trace_defining then report_defining("registering font, id %s, hash %a",id,hash) end fontdata[id]=tfmdata end end end function definers.read(specification,size,id) statistics.starttiming(fonts) if type(specification)=="string" then specification=definers.analyze(specification,size) end local method=specification.method if method and variants[method] then specification=variants[method](specification) end specification=definers.resolve(specification) local hash=constructors.hashinstance(specification) local tfmdata=definers.registered(hash) if tfmdata then if trace_defining then report_defining("already hashed: %s",hash) end else tfmdata=definers.loadfont(specification) if tfmdata then if trace_defining then report_defining("loaded and hashed: %s",hash) end tfmdata.properties.hash=hash if id then definers.register(tfmdata,id) end else if trace_defining then report_defining("not loaded and hashed: %s",hash) end end end lastdefined=tfmdata or id if not tfmdata then report_defining("unknown font %a, loading aborted",specification.name) elseif trace_defining and type(tfmdata)=="table" then local properties=tfmdata.properties or {} local parameters=tfmdata.parameters or {} report_defining("using %s font with id %a, name %a, size %a, bytes %a, encoding %a, fullname %a, filename %a", properties.format,id,properties.name,parameters.size,properties.encodingbytes, properties.encodingname,properties.fullname,file.basename(properties.filename)) end statistics.stoptiming(fonts) return tfmdata end function font.getfont(id) return fontdata[id] end callbacks.register('define_font',definers.read,"definition of fonts (tfmdata preparation)") end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['luatex-font-def']={ version=1.001, comment="companion to luatex-*.tex", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } if context then texio.write_nl("fatal error: this module is not for context") os.exit() end local fonts=fonts fonts.constructors.namemode="specification" function fonts.definers.getspecification(str) return "",str,"",":",str end local list={} local function issome () list.lookup='name' end local function isfile () list.lookup='file' end local function isname () list.lookup='name' end local function thename(s) list.name=s end local function issub (v) list.sub=v end local function iscrap (s) list.crap=string.lower(s) end local function iskey (k,v) list[k]=v end local function istrue (s) list[s]=true end local function isfalse(s) list[s]=false end local P,S,R,C=lpeg.P,lpeg.S,lpeg.R,lpeg.C local spaces=P(" ")^0 local namespec=(1-S("/:("))^0 local crapspec=spaces*P("/")*(((1-P(":"))^0)/iscrap)*spaces local filename_1=P("file:")/isfile*(namespec/thename) local filename_2=P("[")*P(true)/isname*(((1-P("]"))^0)/thename)*P("]") local fontname_1=P("name:")/isname*(namespec/thename) local fontname_2=P(true)/issome*(namespec/thename) local sometext=(R("az","AZ","09")+S("+-."))^1 local truevalue=P("+")*spaces*(sometext/istrue) local falsevalue=P("-")*spaces*(sometext/isfalse) local keyvalue=(C(sometext)*spaces*P("=")*spaces*C(sometext))/iskey local somevalue=sometext/istrue local subvalue=P("(")*(C(P(1-S("()"))^1)/issub)*P(")") local option=spaces*(keyvalue+falsevalue+truevalue+somevalue)*spaces local options=P(":")*spaces*(P(";")^0*option)^0 local pattern=(filename_1+filename_2+fontname_1+fontname_2)*subvalue^0*crapspec^0*options^0 local function colonized(specification) list={} lpeg.match(pattern,specification.specification) list.crap=nil if list.name then specification.name=list.name list.name=nil end if list.lookup then specification.lookup=list.lookup list.lookup=nil end if list.sub then specification.sub=list.sub list.sub=nil end specification.features.normal=fonts.handlers.otf.features.normalize(list) return specification end fonts.definers.registersplit(":",colonized,"cryptic") fonts.definers.registersplit("",colonized,"more cryptic") function fonts.definers.applypostprocessors(tfmdata) local postprocessors=tfmdata.postprocessors if postprocessors then for i=1,#postprocessors do local extrahash=postprocessors[i](tfmdata) if type(extrahash)=="string" and extrahash~="" then extrahash=string.gsub(lower(extrahash),"[^a-z]","-") tfmdata.properties.fullname=format("%s-%s",tfmdata.properties.fullname,extrahash) end end end return tfmdata end end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['luatex-fonts-ext']={ version=1.001, comment="companion to luatex-*.tex", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } if context then texio.write_nl("fatal error: this module is not for context") os.exit() end local fonts=fonts local otffeatures=fonts.constructors.newfeatures("otf") local function initializeitlc(tfmdata,value) if value then local parameters=tfmdata.parameters local italicangle=parameters.italicangle if italicangle and italicangle~=0 then local properties=tfmdata.properties local factor=tonumber(value) or 1 properties.hasitalics=true properties.autoitalicamount=factor*(parameters.uwidth or 40)/2 end end end otffeatures.register { name="itlc", description="italic correction", initializers={ base=initializeitlc, node=initializeitlc, } } local function initializeslant(tfmdata,value) value=tonumber(value) if not value then value=0 elseif value>1 then value=1 elseif value<-1 then value=-1 end tfmdata.parameters.slantfactor=value end otffeatures.register { name="slant", description="slant glyphs", initializers={ base=initializeslant, node=initializeslant, } } local function initializeextend(tfmdata,value) value=tonumber(value) if not value then value=0 elseif value>10 then value=10 elseif value<-10 then value=-10 end tfmdata.parameters.extendfactor=value end otffeatures.register { name="extend", description="scale glyphs horizontally", initializers={ base=initializeextend, node=initializeextend, } } fonts.protrusions=fonts.protrusions or {} fonts.protrusions.setups=fonts.protrusions.setups or {} local setups=fonts.protrusions.setups local function initializeprotrusion(tfmdata,value) if value then local setup=setups[value] if setup then local factor,left,right=setup.factor or 1,setup.left or 1,setup.right or 1 local emwidth=tfmdata.parameters.quad tfmdata.parameters.protrusion={ auto=true, } for i,chr in next,tfmdata.characters do local v,pl,pr=setup[i],nil,nil if v then pl,pr=v[1],v[2] end if pl and pl~=0 then chr.left_protruding=left*pl*factor end if pr and pr~=0 then chr.right_protruding=right*pr*factor end end end end end otffeatures.register { name="protrusion", description="shift characters into the left and or right margin", initializers={ base=initializeprotrusion, node=initializeprotrusion, } } fonts.expansions=fonts.expansions or {} fonts.expansions.setups=fonts.expansions.setups or {} local setups=fonts.expansions.setups local function initializeexpansion(tfmdata,value) if value then local setup=setups[value] if setup then local factor=setup.factor or 1 tfmdata.parameters.expansion={ stretch=10*(setup.stretch or 0), shrink=10*(setup.shrink or 0), step=10*(setup.step or 0), auto=true, } for i,chr in next,tfmdata.characters do local v=setup[i] if v and v~=0 then chr.expansion_factor=v*factor else chr.expansion_factor=factor end end end end end otffeatures.register { name="expansion", description="apply hz optimization", initializers={ base=initializeexpansion, node=initializeexpansion, } } function fonts.loggers.onetimemessage() end local byte=string.byte fonts.expansions.setups['default']={ stretch=2,shrink=2,step=.5,factor=1, [byte('A')]=0.5,[byte('B')]=0.7,[byte('C')]=0.7,[byte('D')]=0.5,[byte('E')]=0.7, [byte('F')]=0.7,[byte('G')]=0.5,[byte('H')]=0.7,[byte('K')]=0.7,[byte('M')]=0.7, [byte('N')]=0.7,[byte('O')]=0.5,[byte('P')]=0.7,[byte('Q')]=0.5,[byte('R')]=0.7, [byte('S')]=0.7,[byte('U')]=0.7,[byte('W')]=0.7,[byte('Z')]=0.7, [byte('a')]=0.7,[byte('b')]=0.7,[byte('c')]=0.7,[byte('d')]=0.7,[byte('e')]=0.7, [byte('g')]=0.7,[byte('h')]=0.7,[byte('k')]=0.7,[byte('m')]=0.7,[byte('n')]=0.7, [byte('o')]=0.7,[byte('p')]=0.7,[byte('q')]=0.7,[byte('s')]=0.7,[byte('u')]=0.7, [byte('w')]=0.7,[byte('z')]=0.7, [byte('2')]=0.7,[byte('3')]=0.7,[byte('6')]=0.7,[byte('8')]=0.7,[byte('9')]=0.7, } fonts.protrusions.setups['default']={ factor=1,left=1,right=1, [0x002C]={ 0,1 }, [0x002E]={ 0,1 }, [0x003A]={ 0,1 }, [0x003B]={ 0,1 }, [0x002D]={ 0,1 }, [0x2013]={ 0,0.50 }, [0x2014]={ 0,0.33 }, [0x3001]={ 0,1 }, [0x3002]={ 0,1 }, [0x060C]={ 0,1 }, [0x061B]={ 0,1 }, [0x06D4]={ 0,1 }, } fonts.handlers.otf.features.normalize=function(t) if t.rand then t.rand="random" end return t end function fonts.helpers.nametoslot(name) local t=type(name) if t=="string" then local tfmdata=fonts.hashes.identifiers[currentfont()] local shared=tfmdata and tfmdata.shared local fntdata=shared and shared.rawdata return fntdata and fntdata.resources.unicodes[name] elseif t=="number" then return n end end fonts.encodings=fonts.encodings or {} local reencodings={} fonts.encodings.reencodings=reencodings local function specialreencode(tfmdata,value) local encoding=value and reencodings[value] if encoding then local temp={} local char=tfmdata.characters for k,v in next,encoding do temp[k]=char[v] end for k,v in next,temp do char[k]=temp[k] end return string.format("reencoded:%s",value) end end local function reencode(tfmdata,value) tfmdata.postprocessors=tfmdata.postprocessors or {} table.insert(tfmdata.postprocessors, function(tfmdata) return specialreencode(tfmdata,value) end ) end otffeatures.register { name="reencode", description="reencode characters", manipulators={ base=reencode, node=reencode, } } end -- closure do -- begin closure to overcome local limits and interference if not modules then modules={} end modules ['luatex-fonts-cbk']={ version=1.001, comment="companion to luatex-*.tex", author="Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } if context then texio.write_nl("fatal error: this module is not for context") os.exit() end local fonts=fonts local nodes=nodes local traverse_id=node.traverse_id local glyph_code=nodes.nodecodes.glyph function nodes.handlers.characters(head) local fontdata=fonts.hashes.identifiers if fontdata then local usedfonts,done,prevfont={},false,nil for n in traverse_id(glyph_code,head) do local font=n.font if font~=prevfont then prevfont=font local used=usedfonts[font] if not used then local tfmdata=fontdata[font] if tfmdata then local shared=tfmdata.shared if shared then local processors=shared.processes if processors and #processors>0 then usedfonts[font]=processors done=true end end end end end end if done then for font,processors in next,usedfonts do for i=1,#processors do local h,d=processors[i](head,font,0) head,done=h or head,done or d end end end return head,true else return head,false end end function nodes.simple_font_handler(head) head=nodes.handlers.characters(head) nodes.injections.handler(head) nodes.handlers.protectglyphs(head) head=node.ligaturing(head) head=node.kerning(head) return head end end -- closure
gpl-2.0
Colettechan/darkstar
scripts/globals/spells/absorb-agi.lua
17
1366
-------------------------------------- -- Spell: Absorb-AGI -- Steals an enemy's agility. -------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) if (target:hasStatusEffect(EFFECT_AGI_DOWN) or caster:hasStatusEffect(EFFECT_AGI_BOOST)) then spell:setMsg(75); -- no effect else local dINT = caster:getStat(MOD_INT) - target:getStat(MOD_INT); local resist = applyResistance(caster,spell,target,dINT,37,0); if (resist <= 0.125) then spell:setMsg(85); else spell:setMsg(332); caster:addStatusEffect(EFFECT_AGI_BOOST,ABSORB_SPELL_AMOUNT*resist*((100+(caster:getMod(MOD_AUGMENTS_ABSORB)))/100), ABSORB_SPELL_TICK, ABSORB_SPELL_AMOUNT*ABSORB_SPELL_TICK,FLAG_DISPELABLE); -- caster gains AGI target:addStatusEffect(EFFECT_AGI_DOWN,ABSORB_SPELL_AMOUNT*resist*((100+(caster:getMod(MOD_AUGMENTS_ABSORB)))/100), ABSORB_SPELL_TICK, ABSORB_SPELL_AMOUNT*ABSORB_SPELL_TICK,FLAG_ERASBLE); -- target loses AGI end end return EFFECT_AGI_DOWN; end;
gpl-3.0
Colettechan/darkstar
scripts/globals/items/plate_of_patlican_salata.lua
18
1190
----------------------------------------- -- ID: 5582 -- Item: plate_of_patlican_salata -- Food Effect: 180Min, All Races ----------------------------------------- -- Agility 4 -- Vitality -1 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,10800,5582); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_AGI, 4); target:addMod(MOD_VIT, -1); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_AGI, 4); target:delMod(MOD_VIT, -1); end;
gpl-3.0
RJRetro/mame
3rdparty/genie/src/base/cmdline.lua
44
2186
-- -- cmdline.lua -- Functions to define and handle command line actions and options. -- Copyright (c) 2002-2011 Jason Perkins and the Premake project -- -- -- Built-in command line options -- newoption { trigger = "cc", value = "VALUE", description = "Choose a C/C++ compiler set", allowed = { { "gcc", "GNU GCC (gcc/g++)" }, { "ow", "OpenWatcom" }, { "ghs", "Green Hills Software" }, } } newoption { trigger = "dotnet", value = "VALUE", description = "Choose a .NET compiler set", allowed = { { "msnet", "Microsoft .NET (csc)" }, { "mono", "Novell Mono (mcs)" }, { "pnet", "Portable.NET (cscc)" }, } } newoption { trigger = "file", value = "FILE", description = "Read FILE as a Premake script; default is 'premake4.lua'" } newoption { trigger = "help", description = "Display this information" } newoption { trigger = "os", value = "VALUE", description = "Generate files for a different operating system", allowed = { { "bsd", "OpenBSD, NetBSD, or FreeBSD" }, { "linux", "Linux" }, { "macosx", "Apple Mac OS X" }, { "solaris", "Solaris" }, { "windows", "Microsoft Windows" }, } } newoption { trigger = "platform", value = "VALUE", description = "Add target architecture (if supported by action)", allowed = { { "x32", "32-bit" }, { "x64", "64-bit" }, { "universal", "Mac OS X Universal, 32- and 64-bit" }, { "universal32", "Mac OS X Universal, 32-bit only" }, { "universal64", "Mac OS X Universal, 64-bit only" }, { "ps3", "Playstation 3" }, { "orbis", "Playstation 4" }, { "xbox360", "Xbox 360" }, { "durango", "Xbox One" }, { "ARM", "ARM" }, { "PowerPC", "PowerPC" }, } } newoption { trigger = "scripts", value = "path", description = "Search for additional scripts on the given path" } newoption { trigger = "debug-profiler", description = "GENie script generation profiler." } newoption { trigger = "version", description = "Display version information" }
gpl-2.0
zynjec/darkstar
scripts/zones/Western_Adoulin/npcs/Kipligg.lua
11
2005
----------------------------------- -- Area: Western Adoulin -- NPC: Kipligg -- Type: Standard NPC and Mission NPC, -- Involved with Missions: '...Into the Fire', 'Done and Delivered' -- !pos -32 0 22 256 ----------------------------------- require("scripts/globals/missions"); ----------------------------------- function onTrade(player,npc,trade) end; function onTrigger(player,npc) local SOA_Mission = player:getCurrentMission(SOA); if (SOA_Mission < dsp.mission.id.soa.LIFE_ON_THE_FRONTIER) then -- Dialogue prior to joining colonization effort player:startEvent(571); elseif (SOA_Mission == dsp.mission.id.soa.INTO_THE_FIRE) then -- Finishes SOA Mission: '...Into the Fire' player:startEvent(155); elseif ((SOA_Mission >= dsp.mission.id.soa.MELVIEN_DE_MALECROIX) and (SOA_Mission <= dsp.mission.id.soa.COURIER_CATASTROPHE)) then -- Reminds player where to go for SOA Mission: 'Melvien de Malecroix' player:startEvent(162); elseif (SOA_Mission == dsp.mission.id.soa.DONE_AND_DELIVERED) then -- Finishes SOA Mission: 'Done and Delivered' player:startEvent(157); elseif (SOA_Mission == dsp.mission.id.soa.MINISTERIAL_WHISPERS) then -- Reminds player where to go for SOA Mission: 'Ministerial Whispers' player:startEvent(163); else -- Dialogue after joining colonization effort player:startEvent(589); end end; function onEventUpdate(player,csid,option) end; function onEventFinish(player,csid,option) if (csid == 155) then -- Finishes SOA Mission: '...Into the Fire' player:completeMission(SOA, dsp.mission.id.soa.INTO_THE_FIRE); player:addMission(SOA, dsp.mission.id.soa.MELVIEN_DE_MALECROIX); elseif (csid == 157) then -- Finishes SOA Mission: 'Done and Delivered' player:completeMission(SOA, dsp.mission.id.soa.DONE_AND_DELIVERED); player:addMission(SOA, dsp.mission.id.soa.MINISTERIAL_WHISPERS); end end;
gpl-3.0
zhaijialong/skynet
lualib/http/httpd.lua
101
3708
local internal = require "http.internal" local table = table local string = string local type = type local httpd = {} local http_status_msg = { [100] = "Continue", [101] = "Switching Protocols", [200] = "OK", [201] = "Created", [202] = "Accepted", [203] = "Non-Authoritative Information", [204] = "No Content", [205] = "Reset Content", [206] = "Partial Content", [300] = "Multiple Choices", [301] = "Moved Permanently", [302] = "Found", [303] = "See Other", [304] = "Not Modified", [305] = "Use Proxy", [307] = "Temporary Redirect", [400] = "Bad Request", [401] = "Unauthorized", [402] = "Payment Required", [403] = "Forbidden", [404] = "Not Found", [405] = "Method Not Allowed", [406] = "Not Acceptable", [407] = "Proxy Authentication Required", [408] = "Request Time-out", [409] = "Conflict", [410] = "Gone", [411] = "Length Required", [412] = "Precondition Failed", [413] = "Request Entity Too Large", [414] = "Request-URI Too Large", [415] = "Unsupported Media Type", [416] = "Requested range not satisfiable", [417] = "Expectation Failed", [500] = "Internal Server Error", [501] = "Not Implemented", [502] = "Bad Gateway", [503] = "Service Unavailable", [504] = "Gateway Time-out", [505] = "HTTP Version not supported", } local function readall(readbytes, bodylimit) local tmpline = {} local body = internal.recvheader(readbytes, tmpline, "") if not body then return 413 -- Request Entity Too Large end local request = assert(tmpline[1]) local method, url, httpver = request:match "^(%a+)%s+(.-)%s+HTTP/([%d%.]+)$" assert(method and url and httpver) httpver = assert(tonumber(httpver)) if httpver < 1.0 or httpver > 1.1 then return 505 -- HTTP Version not supported end local header = internal.parseheader(tmpline,2,{}) if not header then return 400 -- Bad request end local length = header["content-length"] if length then length = tonumber(length) end local mode = header["transfer-encoding"] if mode then if mode ~= "identity" and mode ~= "chunked" then return 501 -- Not Implemented end end if mode == "chunked" then body, header = internal.recvchunkedbody(readbytes, bodylimit, header, body) if not body then return 413 end else -- identity mode if length then if bodylimit and length > bodylimit then return 413 end if #body >= length then body = body:sub(1,length) else local padding = readbytes(length - #body) body = body .. padding end end end return 200, url, method, header, body end function httpd.read_request(...) local ok, code, url, method, header, body = pcall(readall, ...) if ok then return code, url, method, header, body else return nil, code end end local function writeall(writefunc, statuscode, bodyfunc, header) local statusline = string.format("HTTP/1.1 %03d %s\r\n", statuscode, http_status_msg[statuscode] or "") writefunc(statusline) if header then for k,v in pairs(header) do if type(v) == "table" then for _,v in ipairs(v) do writefunc(string.format("%s: %s\r\n", k,v)) end else writefunc(string.format("%s: %s\r\n", k,v)) end end end local t = type(bodyfunc) if t == "string" then writefunc(string.format("content-length: %d\r\n\r\n", #bodyfunc)) writefunc(bodyfunc) elseif t == "function" then writefunc("transfer-encoding: chunked\r\n") while true do local s = bodyfunc() if s then if s ~= "" then writefunc(string.format("\r\n%x\r\n", #s)) writefunc(s) end else writefunc("\r\n0\r\n\r\n") break end end else assert(t == "nil") writefunc("\r\n") end end function httpd.write_response(...) return pcall(writeall, ...) end return httpd
mit
abasshacker/ukown
plugins/all.lua
1321
4661
do data = load_data(_config.moderation.data) local function get_msgs_user_chat(user_id, chat_id) local user_info = {} local uhash = 'user:'..user_id local user = redis:hgetall(uhash) local um_hash = 'msgs:'..user_id..':'..chat_id user_info.msgs = tonumber(redis:get(um_hash) or 0) user_info.name = user_print_name(user)..' ['..user_id..']' return user_info end local function chat_stats(chat_id) local hash = 'chat:'..chat_id..':users' local users = redis:smembers(hash) local users_info = {} for i = 1, #users do local user_id = users[i] local user_info = get_msgs_user_chat(user_id, chat_id) table.insert(users_info, user_info) end table.sort(users_info, function(a, b) if a.msgs and b.msgs then return a.msgs > b.msgs end end) local text = 'Chat stats:\n' for k,user in pairs(users_info) do text = text..user.name..' = '..user.msgs..'\n' end return text end local function get_group_type(target) local data = load_data(_config.moderation.data) local group_type = data[tostring(target)]['group_type'] if not group_type or group_type == nil then return 'No group type available.' end return group_type end local function show_group_settings(target) local data = load_data(_config.moderation.data) if data[tostring(target)] then if data[tostring(target)]['settings']['flood_msg_max'] then NUM_MSG_MAX = tonumber(data[tostring(target)]['settings']['flood_msg_max']) print('custom'..NUM_MSG_MAX) else NUM_MSG_MAX = 5 end end local settings = data[tostring(target)]['settings'] local text = "Lock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nflood sensitivity : "..NUM_MSG_MAX return text end local function get_description(target) local data = load_data(_config.moderation.data) local data_cat = 'description' if not data[tostring(target)][data_cat] then return 'No description available.' end local about = data[tostring(target)][data_cat] return about end local function get_rules(target) local data = load_data(_config.moderation.data) local data_cat = 'rules' if not data[tostring(target)][data_cat] then return 'No rules available.' end local rules = data[tostring(target)][data_cat] return rules end local function modlist(target) local data = load_data(_config.moderation.data) local groups = 'groups' if not data[tostring(groups)] or not data[tostring(groups)][tostring(target)] then return 'Group is not added or is Realm.' end if next(data[tostring(target)]['moderators']) == nil then return 'No moderator in this group.' end local i = 1 local message = '\nList of moderators :\n' for k,v in pairs(data[tostring(target)]['moderators']) do message = message ..i..' - @'..v..' [' ..k.. '] \n' i = i + 1 end return message end local function get_link(target) local data = load_data(_config.moderation.data) local group_link = data[tostring(target)]['settings']['set_link'] if not group_link or group_link == nil then return "No link" end return "Group link:\n"..group_link end local function all(target, receiver) local text = "All the things I know about this group\n\n" local group_type = get_group_type(target) text = text.."Group Type: \n"..group_type local settings = show_group_settings(target) text = text.."\n\nGroup settings: \n"..settings local rules = get_rules(target) text = text.."\n\nRules: \n"..rules local description = get_description(target) text = text.."\n\nAbout: \n"..description local modlist = modlist(target) text = text.."\n\nMods: \n"..modlist local link = get_link(target) text = text.."\n\nLink: \n"..link local stats = chat_stats(target) text = text.."\n\n"..stats local ban_list = ban_list(target) text = text.."\n\n"..ban_list local file = io.open("./groups/all/"..target.."all.txt", "w") file:write(text) file:flush() file:close() send_document(receiver,"./groups/all/"..target.."all.txt", ok_cb, false) return end function run(msg, matches) if matches[1] == "all" and matches[2] and is_owner2(msg.from.id, matches[2]) then local receiver = get_receiver(msg) local target = matches[2] return all(target, receiver) end if not is_owner(msg) then return end if matches[1] == "all" and not matches[2] then local receiver = get_receiver(msg) if not is_owner(msg) then return end return all(msg.to.id, receiver) end end return { patterns = { "^[!/](all)$", "^[!/](all) (%d+)$" }, run = run } end
gpl-2.0
amir0858/telesuper1
plugins/write.lua
1
28420
local function run(msg, matches) if #matches < 2 then return "زیبا نویسی متن توسط @thisisCrazy کپی بدون ذکر منبع حرام میباشد:|" end if string.len(matches[2]) > 20 then return "فقط ۲۰ حرف مجاز است! @"..msg.from.username end local font_base = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,9,8,7,6,5,4,3,2,1,.,_" local font_hash = "z,y,x,w,v,u,t,s,r,q,p,o,n,m,l,k,j,i,h,g,f,e,d,c,b,a,Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C,B,A,0,1,2,3,4,5,6,7,8,9,.,_" local fonts = { "ⓐ,ⓑ,ⓒ,ⓓ,ⓔ,ⓕ,ⓖ,ⓗ,ⓘ,ⓙ,ⓚ,ⓛ,ⓜ,ⓝ,ⓞ,ⓟ,ⓠ,ⓡ,ⓢ,ⓣ,ⓤ,ⓥ,ⓦ,ⓧ,ⓨ,ⓩ,ⓐ,ⓑ,ⓒ,ⓓ,ⓔ,ⓕ,ⓖ,ⓗ,ⓘ,ⓙ,ⓚ,ⓛ,ⓜ,ⓝ,ⓞ,ⓟ,ⓠ,ⓡ,ⓢ,ⓣ,ⓤ,ⓥ,ⓦ,ⓧ,ⓨ,ⓩ,⓪,➈,➇,➆,➅,➄,➃,➂,➁,➀,●,_", "⒜,⒝,⒞,⒟,⒠,⒡,⒢,⒣,⒤,⒥,⒦,⒧,⒨,⒩,⒪,⒫,⒬,⒭,⒮,⒯,⒰,⒱,⒲,⒳,⒴,⒵,⒜,⒝,⒞,⒟,⒠,⒡,⒢,⒣,⒤,⒥,⒦,⒧,⒨,⒩,⒪,⒫,⒬,⒭,⒮,⒯,⒰,⒱,⒲,⒳,⒴,⒵,⓪,⑼,⑻,⑺,⑹,⑸,⑷,⑶,⑵,⑴,.,_", "α,в,c,∂,є,ƒ,g,н,ι,נ,к,ℓ,м,η,σ,ρ,q,я,ѕ,т,υ,ν,ω,χ,у,z,α,в,c,∂,є,ƒ,g,н,ι,נ,к,ℓ,м,η,σ,ρ,q,я,ѕ,т,υ,ν,ω,χ,у,z,0,9,8,7,6,5,4,3,2,1,.,_", "α,в,c,d,e,ғ,ɢ,н,ι,j,ĸ,l,м,ɴ,o,p,q,r,ѕ,т,υ,v,w,х,y,z,α,в,c,d,e,ғ,ɢ,н,ι,j,ĸ,l,м,ɴ,o,p,q,r,ѕ,т,υ,v,w,х,y,z,0,9,8,7,6,5,4,3,2,1,.,_", "α,в,¢,đ,e,f,g,ħ,ı,נ,κ,ł,м,и,ø,ρ,q,я,š,т,υ,ν,ω,χ,ч,z,α,в,¢,đ,e,f,g,ħ,ı,נ,κ,ł,м,и,ø,ρ,q,я,š,т,υ,ν,ω,χ,ч,z,0,9,8,7,6,5,4,3,2,1,.,_", "ą,ҍ,ç,ժ,ҽ,ƒ,ց,հ,ì,ʝ,ҟ,Ӏ,ʍ,ղ,օ,ք,զ,ɾ,ʂ,է,մ,ѵ,ա,×,վ,Հ,ą,ҍ,ç,ժ,ҽ,ƒ,ց,հ,ì,ʝ,ҟ,Ӏ,ʍ,ղ,օ,ք,զ,ɾ,ʂ,է,մ,ѵ,ա,×,վ,Հ,⊘,९,𝟠,7,Ϭ,Ƽ,५,Ӡ,ϩ,𝟙,.,_", "ค,ც,८,ძ,૯,Բ,૭,Һ,ɿ,ʆ,қ,Ն,ɱ,Ո,૦,ƿ,ҩ,Ր,ς,੮,υ,౮,ω,૪,ע,ઽ,ค,ც,८,ძ,૯,Բ,૭,Һ,ɿ,ʆ,қ,Ն,ɱ,Ո,૦,ƿ,ҩ,Ր,ς,੮,υ,౮,ω,૪,ע,ઽ,0,9,8,7,6,5,4,3,2,1,.,_", "α,ß,ς,d,ε,ƒ,g,h,ï,յ,κ,レ,m,η,⊕,p,Ω,r,š,†,u,∀,ω,x,ψ,z,α,ß,ς,d,ε,ƒ,g,h,ï,յ,κ,レ,m,η,⊕,p,Ω,r,š,†,u,∀,ω,x,ψ,z,0,9,8,7,6,5,4,3,2,1,.,_", "ค,๒,ς,๔,є,Ŧ,ɠ,ђ,เ,ן,к,l,๓,ภ,๏,թ,ợ,г,ร,t,ย,v,ฬ,x,ץ,z,ค,๒,ς,๔,є,Ŧ,ɠ,ђ,เ,ן,к,l,๓,ภ,๏,թ,ợ,г,ร,t,ย,v,ฬ,x,ץ,z,0,9,8,7,6,5,4,3,2,1,.,_", "ム,乃,ζ,Ð,乇,キ,Ǥ,ん,ノ,フ,ズ,レ,ᄊ,刀,Ծ,ア,Q,尺,ㄎ,イ,Ц,Џ,Щ,メ,リ,乙,ム,乃,ζ,Ð,乇,キ,Ǥ,ん,ノ,フ,ズ,レ,ᄊ,刀,Ծ,ア,q,尺,ㄎ,イ,Ц,Џ,Щ,メ,リ,乙,ᅙ,9,8,ᆨ,6,5,4,3,ᆯ,1,.,_", "α,β,c,δ,ε,Ŧ,ĝ,h,ι,j,κ,l,ʍ,π,ø,ρ,φ,Ʀ,$,†,u,υ,ω,χ,ψ,z,α,β,c,δ,ε,Ŧ,ĝ,h,ι,j,κ,l,ʍ,π,ø,ρ,φ,Ʀ,$,†,u,υ,ω,χ,ψ,z,0,9,8,7,6,5,4,3,2,1,.,_", "ձ,ъ,ƈ,ժ,ε,բ,ց,հ,ﻨ,յ,ĸ,l,ო,ռ,օ,թ,զ,г,ร,է,ս,ν,ա,×,ყ,২,ձ,ъ,ƈ,ժ,ε,բ,ց,հ,ﻨ,յ,ĸ,l,ო,ռ,օ,թ,զ,г,ร,է,ս,ν,ա,×,ყ,২,0,9,8,7,6,5,4,3,2,1,.,_", "Λ,ɓ,¢,Ɗ,£,ƒ,ɢ,ɦ,ĩ,ʝ,Қ,Ł,ɱ,ה,ø,Ṗ,Ҩ,Ŕ,Ş,Ŧ,Ū,Ɣ,ω,Ж,¥,Ẑ,Λ,ɓ,¢,Ɗ,£,ƒ,ɢ,ɦ,ĩ,ʝ,Қ,Ł,ɱ,ה,ø,Ṗ,Ҩ,Ŕ,Ş,Ŧ,Ū,Ɣ,ω,Ж,¥,Ẑ,0,9,8,7,6,5,4,3,2,1,.,_", "Λ,Б,Ͼ,Ð,Ξ,Ŧ,G,H,ł,J,К,Ł,M,Л,Ф,P,Ǫ,Я,S,T,U,V,Ш,Ж,Џ,Z,Λ,Б,Ͼ,Ð,Ξ,Ŧ,g,h,ł,j,К,Ł,m,Л,Ф,p,Ǫ,Я,s,t,u,v,Ш,Ж,Џ,z,0,9,8,7,6,5,4,3,2,1,.,_", "ɐ,q,ɔ,p,ǝ,ɟ,ɓ,ɥ,ı,ſ,ʞ,ๅ,ɯ,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,ɐ,q,ɔ,p,ǝ,ɟ,ɓ,ɥ,ı,ſ,ʞ,ๅ,ɯ,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,0,9,8,7,6,5,4,3,2,1,.,_", "ɒ,d,ɔ,b,ɘ,ʇ,ϱ,н,i,į,ʞ,l,м,и,o,q,p,я,ƨ,т,υ,v,w,x,γ,z,ɒ,d,ɔ,b,ɘ,ʇ,ϱ,н,i,į,ʞ,l,м,и,o,q,p,я,ƨ,т,υ,v,w,x,γ,z,0,9,8,7,6,5,4,3,2,1,.,_", "A̴,̴B̴,̴C̴,̴D̴,̴E̴,̴F̴,̴G̴,̴H̴,̴I̴,̴J̴,̴K̴,̴L̴,̴M̴,̴N̴,̴O̴,̴P̴,̴Q̴,̴R̴,̴S̴,̴T̴,̴U̴,̴V̴,̴W̴,̴X̴,̴Y̴,̴Z̴,̴a̴,̴b̴,̴c̴,̴d̴,̴e̴,̴f̴,̴g̴,̴h̴,̴i̴,̴j̴,̴k̴,̴l̴,̴m̴,̴n̴,̴o̴,̴p̴,̴q̴,̴r̴,̴s̴,̴t̴,̴u̴,̴v̴,̴w̴,̴x̴,̴y̴,̴z̴,̴0̴,̴9̴,̴8̴,̴7̴,̴6̴,̴5̴,̴4̴,̴3̴,̴2̴,̴1̴,̴.̴,̴_̴", "ⓐ,ⓑ,ⓒ,ⓓ,ⓔ,ⓕ,ⓖ,ⓗ,ⓘ,ⓙ,ⓚ,ⓛ,ⓜ,ⓝ,ⓞ,ⓟ,ⓠ,ⓡ,ⓢ,ⓣ,ⓤ,ⓥ,ⓦ,ⓧ,ⓨ,ⓩ,ⓐ,ⓑ,ⓒ,ⓓ,ⓔ,ⓕ,ⓖ,ⓗ,ⓘ,ⓙ,ⓚ,ⓛ,ⓜ,ⓝ,ⓞ,ⓟ,ⓠ,ⓡ,ⓢ,ⓣ,ⓤ,ⓥ,ⓦ,ⓧ,ⓨ,ⓩ,⓪,➈,➇,➆,➅,➄,➃,➂,➁,➀,●,_", "⒜,⒝,⒞,⒟,⒠,⒡,⒢,⒣,⒤,⒥,⒦,⒧,⒨,⒩,⒪,⒫,⒬,⒭,⒮,⒯,⒰,⒱,⒲,⒳,⒴,⒵,⒜,⒝,⒞,⒟,⒠,⒡,⒢,⒣,⒤,⒥,⒦,⒧,⒨,⒩,⒪,⒫,⒬,⒭,⒮,⒯,⒰,⒱,⒲,⒳,⒴,⒵,⓪,⑼,⑻,⑺,⑹,⑸,⑷,⑶,⑵,⑴,.,_", "α,в,c,∂,є,ƒ,g,н,ι,נ,к,ℓ,м,η,σ,ρ,q,я,ѕ,т,υ,ν,ω,χ,у,z,α,в,c,∂,є,ƒ,g,н,ι,נ,к,ℓ,м,η,σ,ρ,q,я,ѕ,т,υ,ν,ω,χ,у,z,0,9,8,7,6,5,4,3,2,1,.,_", "α,в,c,ɗ,є,f,g,н,ι,נ,к,Ɩ,м,η,σ,ρ,q,я,ѕ,т,υ,ν,ω,x,у,z,α,в,c,ɗ,є,f,g,н,ι,נ,к,Ɩ,м,η,σ,ρ,q,я,ѕ,т,υ,ν,ω,x,у,z,0,9,8,7,6,5,4,3,2,1,.,_", "α,в,c,d,e,ғ,ɢ,н,ι,j,ĸ,l,м,ɴ,o,p,q,r,ѕ,т,υ,v,w,х,y,z,α,в,c,d,e,ғ,ɢ,н,ι,j,ĸ,l,м,ɴ,o,p,q,r,ѕ,т,υ,v,w,х,y,z,0,9,8,7,6,5,4,3,2,1,.,_", "α,Ⴆ,ƈ,ԃ,ҽ,ϝ,ɠ,ԋ,ι,ʝ,ƙ,ʅ,ɱ,ɳ,σ,ρ,ϙ,ɾ,ʂ,ƚ,υ,ʋ,ɯ,x,ყ,ȥ,α,Ⴆ,ƈ,ԃ,ҽ,ϝ,ɠ,ԋ,ι,ʝ,ƙ,ʅ,ɱ,ɳ,σ,ρ,ϙ,ɾ,ʂ,ƚ,υ,ʋ,ɯ,x,ყ,ȥ,0,9,8,7,6,5,4,3,2,1,.,_", "α,в,¢,đ,e,f,g,ħ,ı,נ,κ,ł,м,и,ø,ρ,q,я,š,т,υ,ν,ω,χ,ч,z,α,в,¢,đ,e,f,g,ħ,ı,נ,κ,ł,м,и,ø,ρ,q,я,š,т,υ,ν,ω,χ,ч,z,0,9,8,7,6,5,4,3,2,1,.,_", "ą,ɓ,ƈ,đ,ε,∱,ɠ,ɧ,ï,ʆ,ҡ,ℓ,ɱ,ŋ,σ,þ,ҩ,ŗ,ş,ŧ,ų,√,щ,х,γ,ẕ,ą,ɓ,ƈ,đ,ε,∱,ɠ,ɧ,ï,ʆ,ҡ,ℓ,ɱ,ŋ,σ,þ,ҩ,ŗ,ş,ŧ,ų,√,щ,х,γ,ẕ,0,9,8,7,6,5,4,3,2,1,.,_", "ą,ҍ,ç,ժ,ҽ,ƒ,ց,հ,ì,ʝ,ҟ,Ӏ,ʍ,ղ,օ,ք,զ,ɾ,ʂ,է,մ,ѵ,ա,×,վ,Հ,ą,ҍ,ç,ժ,ҽ,ƒ,ց,հ,ì,ʝ,ҟ,Ӏ,ʍ,ղ,օ,ք,զ,ɾ,ʂ,է,մ,ѵ,ա,×,վ,Հ,⊘,९,𝟠,7,Ϭ,Ƽ,५,Ӡ,ϩ,𝟙,.,_", "მ,ჩ,ƈ,ძ,ε,բ,ց,հ,ἶ,ʝ,ƙ,l,ო,ղ,օ,ր,գ,ɾ,ʂ,է,մ,ν,ω,ჯ,ყ,z,მ,ჩ,ƈ,ძ,ε,բ,ց,հ,ἶ,ʝ,ƙ,l,ო,ղ,օ,ր,գ,ɾ,ʂ,է,մ,ν,ω,ჯ,ყ,z,0,Գ,Ց,Դ,6,5,Վ,Յ,Զ,1,.,_", "ค,ც,८,ძ,૯,Բ,૭,Һ,ɿ,ʆ,қ,Ն,ɱ,Ո,૦,ƿ,ҩ,Ր,ς,੮,υ,౮,ω,૪,ע,ઽ,ค,ც,८,ძ,૯,Բ,૭,Һ,ɿ,ʆ,қ,Ն,ɱ,Ո,૦,ƿ,ҩ,Ր,ς,੮,υ,౮,ω,૪,ע,ઽ,0,9,8,7,6,5,4,3,2,1,.,_", "α,ß,ς,d,ε,ƒ,g,h,ï,յ,κ,レ,m,η,⊕,p,Ω,r,š,†,u,∀,ω,x,ψ,z,α,ß,ς,d,ε,ƒ,g,h,ï,յ,κ,レ,m,η,⊕,p,Ω,r,š,†,u,∀,ω,x,ψ,z,0,9,8,7,6,5,4,3,2,1,.,_", "ª,b,¢,Þ,È,F,૬,ɧ,Î,j,Κ,Ļ,м,η,◊,Ƿ,ƍ,r,S,⊥,µ,√,w,×,ý,z,ª,b,¢,Þ,È,F,૬,ɧ,Î,j,Κ,Ļ,м,η,◊,Ƿ,ƍ,r,S,⊥,µ,√,w,×,ý,z,0,9,8,7,6,5,4,3,2,1,.,_", "Δ,Ɓ,C,D,Σ,F,G,H,I,J,Ƙ,L,Μ,∏,Θ,Ƥ,Ⴓ,Γ,Ѕ,Ƭ,Ʊ,Ʋ,Ш,Ж,Ψ,Z,λ,ϐ,ς,d,ε,ғ,ɢ,н,ι,ϳ,κ,l,ϻ,π,σ,ρ,φ,г,s,τ,υ,v,ш,ϰ,ψ,z,0,9,8,7,6,5,4,3,2,1,.,_", "ค,๒,ς,๔,є,Ŧ,ɠ,ђ,เ,ן,к,l,๓,ภ,๏,թ,ợ,г,ร,t,ย,v,ฬ,x,ץ,z,ค,๒,ς,๔,є,Ŧ,ɠ,ђ,เ,ן,к,l,๓,ภ,๏,թ,ợ,г,ร,t,ย,v,ฬ,x,ץ,z,0,9,8,7,6,5,4,3,2,1,.,_", "Λ,ß,Ƈ,D,Ɛ,F,Ɠ,Ĥ,Ī,Ĵ,Ҡ,Ŀ,M,И,♡,Ṗ,Ҩ,Ŕ,S,Ƭ,Ʊ,Ѵ,Ѡ,Ӿ,Y,Z,Λ,ß,Ƈ,D,Ɛ,F,Ɠ,Ĥ,Ī,Ĵ,Ҡ,Ŀ,M,И,♡,Ṗ,Ҩ,Ŕ,S,Ƭ,Ʊ,Ѵ,Ѡ,Ӿ,Y,Z,0,9,8,7,6,5,4,3,2,1,.,_", "ム,乃,ζ,Ð,乇,キ,Ǥ,ん,ノ,フ,ズ,レ,ᄊ,刀,Ծ,ア,Q,尺,ㄎ,イ,Ц,Џ,Щ,メ,リ,乙,ム,乃,ζ,Ð,乇,キ,Ǥ,ん,ノ,フ,ズ,レ,ᄊ,刀,Ծ,ア,q,尺,ㄎ,イ,Ц,Џ,Щ,メ,リ,乙,ᅙ,9,8,ᆨ,6,5,4,3,ᆯ,1,.,_", "α,β,c,δ,ε,Ŧ,ĝ,h,ι,j,κ,l,ʍ,π,ø,ρ,φ,Ʀ,$,†,u,υ,ω,χ,ψ,z,α,β,c,δ,ε,Ŧ,ĝ,h,ι,j,κ,l,ʍ,π,ø,ρ,φ,Ʀ,$,†,u,υ,ω,χ,ψ,z,0,9,8,7,6,5,4,3,2,1,.,_", "ค,๖,¢,໓,ē,f,ງ,h,i,ว,k,l,๓,ຖ,໐,p,๑,r,Ş,t,น,ง,ຟ,x,ฯ,ຊ,ค,๖,¢,໓,ē,f,ງ,h,i,ว,k,l,๓,ຖ,໐,p,๑,r,Ş,t,น,ง,ຟ,x,ฯ,ຊ,0,9,8,7,6,5,4,3,2,1,.,_", "ձ,ъ,ƈ,ժ,ε,բ,ց,հ,ﻨ,յ,ĸ,l,ო,ռ,օ,թ,զ,г,ร,է,ս,ν,ա,×,ყ,২,ձ,ъ,ƈ,ժ,ε,բ,ց,հ,ﻨ,յ,ĸ,l,ო,ռ,օ,թ,զ,г,ร,է,ս,ν,ա,×,ყ,২,0,9,8,7,6,5,4,3,2,1,.,_", "Â,ß,Ĉ,Ð,Є,Ŧ,Ǥ,Ħ,Ī,ʖ,Қ,Ŀ,♏,И,Ø,P,Ҩ,R,$,ƚ,Ц,V,Щ,X,¥,Ẕ,Â,ß,Ĉ,Ð,Є,Ŧ,Ǥ,Ħ,Ī,ʖ,Қ,Ŀ,♏,И,Ø,P,Ҩ,R,$,ƚ,Ц,V,Щ,X,¥,Ẕ,0,9,8,7,6,5,4,3,2,1,.,_", "Λ,ɓ,¢,Ɗ,£,ƒ,ɢ,ɦ,ĩ,ʝ,Қ,Ł,ɱ,ה,ø,Ṗ,Ҩ,Ŕ,Ş,Ŧ,Ū,Ɣ,ω,Ж,¥,Ẑ,Λ,ɓ,¢,Ɗ,£,ƒ,ɢ,ɦ,ĩ,ʝ,Қ,Ł,ɱ,ה,ø,Ṗ,Ҩ,Ŕ,Ş,Ŧ,Ū,Ɣ,ω,Ж,¥,Ẑ,0,9,8,7,6,5,4,3,2,1,.,_", "Λ,Б,Ͼ,Ð,Ξ,Ŧ,G,H,ł,J,К,Ł,M,Л,Ф,P,Ǫ,Я,S,T,U,V,Ш,Ж,Џ,Z,Λ,Б,Ͼ,Ð,Ξ,Ŧ,g,h,ł,j,К,Ł,m,Л,Ф,p,Ǫ,Я,s,t,u,v,Ш,Ж,Џ,z,0,9,8,7,6,5,4,3,2,1,.,_", "Թ,Յ,Շ,Ժ,ȝ,Բ,Գ,ɧ,ɿ,ʝ,ƙ,ʅ,ʍ,Ռ,Ծ,ρ,φ,Ր,Տ,Ե,Մ,ע,ա,Ճ,Վ,Հ,Թ,Յ,Շ,Ժ,ȝ,Բ,Գ,ɧ,ɿ,ʝ,ƙ,ʅ,ʍ,Ռ,Ծ,ρ,φ,Ր,Տ,Ե,Մ,ע,ա,Ճ,Վ,Հ,0,9,8,7,6,5,4,3,2,1,.,_", "Æ,þ,©,Ð,E,F,ζ,Ħ,Ї,¿,ズ,ᄂ,M,Ñ,Θ,Ƿ,Ø,Ґ,Š,τ,υ,¥,w,χ,y,շ,Æ,þ,©,Ð,E,F,ζ,Ħ,Ї,¿,ズ,ᄂ,M,Ñ,Θ,Ƿ,Ø,Ґ,Š,τ,υ,¥,w,χ,y,շ,0,9,8,7,6,5,4,3,2,1,.,_", "ɐ,q,ɔ,p,ǝ,ɟ,ɓ,ɥ,ı,ſ,ʞ,ๅ,ɯ,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,ɐ,q,ɔ,p,ǝ,ɟ,ɓ,ɥ,ı,ſ,ʞ,ๅ,ɯ,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,0,9,8,7,6,5,4,3,2,1,.,_", "ɒ,d,ɔ,b,ɘ,ʇ,ϱ,н,i,į,ʞ,l,м,и,o,q,p,я,ƨ,т,υ,v,w,x,γ,z,ɒ,d,ɔ,b,ɘ,ʇ,ϱ,н,i,į,ʞ,l,м,и,o,q,p,я,ƨ,т,υ,v,w,x,γ,z,0,9,8,7,6,5,4,3,2,1,.,_", "4,8,C,D,3,F,9,H,!,J,K,1,M,N,0,P,Q,R,5,7,U,V,W,X,Y,2,4,8,C,D,3,F,9,H,!,J,K,1,M,N,0,P,Q,R,5,7,U,V,W,X,Y,2,0,9,8,7,6,5,4,3,2,1,.,_", "Λ,M,X,ʎ,Z,ɐ,q,ɔ,p,ǝ,ɟ,ƃ,ɥ,ı,ɾ,ʞ,l,ա,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,Λ,M,X,ʎ,Z,ɐ,q,ɔ,p,ǝ,ɟ,ƃ,ɥ,ı,ɾ,ʞ,l,ա,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,0,9,8,7,6,5,4,3,2,1,.,‾", "A̴,̴B̴,̴C̴,̴D̴,̴E̴,̴F̴,̴G̴,̴H̴,̴I̴,̴J̴,̴K̴,̴L̴,̴M̴,̴N̴,̴O̴,̴P̴,̴Q̴,̴R̴,̴S̴,̴T̴,̴U̴,̴V̴,̴W̴,̴X̴,̴Y̴,̴Z̴,̴a̴,̴b̴,̴c̴,̴d̴,̴e̴,̴f̴,̴g̴,̴h̴,̴i̴,̴j̴,̴k̴,̴l̴,̴m̴,̴n̴,̴o̴,̴p̴,̴q̴,̴r̴,̴s̴,̴t̴,̴u̴,̴v̴,̴w̴,̴x̴,̴y̴,̴z̴,̴0̴,̴9̴,̴8̴,̴7̴,̴6̴,̴5̴,̴4̴,̴3̴,̴2̴,̴1̴,̴.̴,̴_̴", "A̱,̱Ḇ,̱C̱,̱Ḏ,̱E̱,̱F̱,̱G̱,̱H̱,̱I̱,̱J̱,̱Ḵ,̱Ḻ,̱M̱,̱Ṉ,̱O̱,̱P̱,̱Q̱,̱Ṟ,̱S̱,̱Ṯ,̱U̱,̱V̱,̱W̱,̱X̱,̱Y̱,̱Ẕ,̱a̱,̱ḇ,̱c̱,̱ḏ,̱e̱,̱f̱,̱g̱,̱ẖ,̱i̱,̱j̱,̱ḵ,̱ḻ,̱m̱,̱ṉ,̱o̱,̱p̱,̱q̱,̱ṟ,̱s̱,̱ṯ,̱u̱,̱v̱,̱w̱,̱x̱,̱y̱,̱ẕ,̱0̱,̱9̱,̱8̱,̱7̱,̱6̱,̱5̱,̱4̱,̱3̱,̱2̱,̱1̱,̱.̱,̱_̱", "A̲,̲B̲,̲C̲,̲D̲,̲E̲,̲F̲,̲G̲,̲H̲,̲I̲,̲J̲,̲K̲,̲L̲,̲M̲,̲N̲,̲O̲,̲P̲,̲Q̲,̲R̲,̲S̲,̲T̲,̲U̲,̲V̲,̲W̲,̲X̲,̲Y̲,̲Z̲,̲a̲,̲b̲,̲c̲,̲d̲,̲e̲,̲f̲,̲g̲,̲h̲,̲i̲,̲j̲,̲k̲,̲l̲,̲m̲,̲n̲,̲o̲,̲p̲,̲q̲,̲r̲,̲s̲,̲t̲,̲u̲,̲v̲,̲w̲,̲x̲,̲y̲,̲z̲,̲0̲,̲9̲,̲8̲,̲7̲,̲6̲,̲5̲,̲4̲,̲3̲,̲2̲,̲1̲,̲.̲,̲_̲", "Ā,̄B̄,̄C̄,̄D̄,̄Ē,̄F̄,̄Ḡ,̄H̄,̄Ī,̄J̄,̄K̄,̄L̄,̄M̄,̄N̄,̄Ō,̄P̄,̄Q̄,̄R̄,̄S̄,̄T̄,̄Ū,̄V̄,̄W̄,̄X̄,̄Ȳ,̄Z̄,̄ā,̄b̄,̄c̄,̄d̄,̄ē,̄f̄,̄ḡ,̄h̄,̄ī,̄j̄,̄k̄,̄l̄,̄m̄,̄n̄,̄ō,̄p̄,̄q̄,̄r̄,̄s̄,̄t̄,̄ū,̄v̄,̄w̄,̄x̄,̄ȳ,̄z̄,̄0̄,̄9̄,̄8̄,̄7̄,̄6̄,̄5̄,̄4̄,̄3̄,̄2̄,̄1̄,̄.̄,̄_̄", "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,9,8,7,6,5,4,3,2,1,.,_", "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,9,8,7,6,5,4,3,2,1,.,_", "@,♭,ḉ,ⓓ,℮,ƒ,ℊ,ⓗ,ⓘ,נ,ⓚ,ℓ,ⓜ,η,ø,℘,ⓠ,ⓡ,﹩,т,ⓤ,√,ω,ж,૪,ℨ,@,♭,ḉ,ⓓ,℮,ƒ,ℊ,ⓗ,ⓘ,נ,ⓚ,ℓ,ⓜ,η,ø,℘,ⓠ,ⓡ,﹩,т,ⓤ,√,ω,ж,૪,ℨ,0,➈,➑,➐,➅,➄,➃,➌,➁,➊,.,_", "@,♭,¢,ⅾ,ε,ƒ,ℊ,ℌ,ї,נ,к,ℓ,м,п,ø,ρ,ⓠ,ґ,﹩,⊥,ü,√,ω,ϰ,૪,ℨ,@,♭,¢,ⅾ,ε,ƒ,ℊ,ℌ,ї,נ,к,ℓ,м,п,ø,ρ,ⓠ,ґ,﹩,⊥,ü,√,ω,ϰ,૪,ℨ,0,9,8,7,6,5,4,3,2,1,.,_", "α,♭,ḉ,∂,ℯ,ƒ,ℊ,ℌ,ї,ʝ,ḱ,ℓ,м,η,ø,℘,ⓠ,я,﹩,⊥,ц,ṽ,ω,ჯ,૪,ẕ,α,♭,ḉ,∂,ℯ,ƒ,ℊ,ℌ,ї,ʝ,ḱ,ℓ,м,η,ø,℘,ⓠ,я,﹩,⊥,ц,ṽ,ω,ჯ,૪,ẕ,0,9,8,7,6,5,4,3,2,1,.,_", "@,ß,¢,ḓ,℮,ƒ,ℊ,ℌ,ї,נ,ḱ,ʟ,м,п,◎,℘,ⓠ,я,﹩,т,ʊ,♥️,ẘ,✄,૪,ℨ,@,ß,¢,ḓ,℮,ƒ,ℊ,ℌ,ї,נ,ḱ,ʟ,м,п,◎,℘,ⓠ,я,﹩,т,ʊ,♥️,ẘ,✄,૪,ℨ,0,9,8,7,6,5,4,3,2,1,.,_", "@,ß,¢,ḓ,℮,ƒ,ℊ,н,ḯ,נ,к,ℓμ,п,☺️,℘,ⓠ,я,﹩,⊥,υ,ṽ,ω,✄,૪,ℨ,@,ß,¢,ḓ,℮,ƒ,ℊ,н,ḯ,נ,к,ℓμ,п,☺️,℘,ⓠ,я,﹩,⊥,υ,ṽ,ω,✄,૪,ℨ,0,9,8,7,6,5,4,3,2,1,.,_", "@,ß,ḉ,ḓ,є,ƒ,ℊ,ℌ,ї,נ,ḱ,ʟ,ღ,η,◎,℘,ⓠ,я,﹩,⊥,ʊ,♥️,ω,ϰ,૪,ẕ,@,ß,ḉ,ḓ,є,ƒ,ℊ,ℌ,ї,נ,ḱ,ʟ,ღ,η,◎,℘,ⓠ,я,﹩,⊥,ʊ,♥️,ω,ϰ,૪,ẕ,0,9,8,7,6,5,4,3,2,1,.,_", "@,ß,ḉ,∂,ε,ƒ,ℊ,ℌ,ї,נ,ḱ,ł,ღ,и,ø,℘,ⓠ,я,﹩,т,υ,√,ω,ჯ,૪,ẕ,@,ß,ḉ,∂,ε,ƒ,ℊ,ℌ,ї,נ,ḱ,ł,ღ,и,ø,℘,ⓠ,я,﹩,т,υ,√,ω,ჯ,૪,ẕ,0,9,8,7,6,5,4,3,2,1,.,_", "α,♭,¢,∂,ε,ƒ,❡,н,ḯ,ʝ,ḱ,ʟ,μ,п,ø,ρ,ⓠ,ґ,﹩,т,υ,ṽ,ω,ж,૪,ẕ,α,♭,¢,∂,ε,ƒ,❡,н,ḯ,ʝ,ḱ,ʟ,μ,п,ø,ρ,ⓠ,ґ,﹩,т,υ,ṽ,ω,ж,૪,ẕ,0,9,8,7,6,5,4,3,2,1,.,_", "α,♭,ḉ,∂,℮,ⓕ,ⓖ,н,ḯ,ʝ,ḱ,ℓ,м,п,ø,ⓟ,ⓠ,я,ⓢ,ⓣ,ⓤ,♥️,ⓦ,✄,ⓨ,ⓩ,α,♭,ḉ,∂,℮,ⓕ,ⓖ,н,ḯ,ʝ,ḱ,ℓ,м,п,ø,ⓟ,ⓠ,я,ⓢ,ⓣ,ⓤ,♥️,ⓦ,✄,ⓨ,ⓩ,0,➒,➑,➐,➏,➄,➍,➂,➁,➀,.,_", "@,♭,ḉ,ḓ,є,ƒ,ⓖ,ℌ,ⓘ,נ,к,ⓛ,м,ⓝ,ø,℘,ⓠ,я,﹩,ⓣ,ʊ,√,ω,ჯ,૪,ⓩ,@,♭,ḉ,ḓ,є,ƒ,ⓖ,ℌ,ⓘ,נ,к,ⓛ,м,ⓝ,ø,℘,ⓠ,я,﹩,ⓣ,ʊ,√,ω,ჯ,૪,ⓩ,0,➒,➇,➆,➅,➄,➍,➌,➋,➀,.,_", "α,♭,ⓒ,∂,є,ⓕ,ⓖ,ℌ,ḯ,ⓙ,ḱ,ł,ⓜ,и,ⓞ,ⓟ,ⓠ,ⓡ,ⓢ,⊥,ʊ,ⓥ,ⓦ,ж,ⓨ,ⓩ,α,♭,ⓒ,∂,є,ⓕ,ⓖ,ℌ,ḯ,ⓙ,ḱ,ł,ⓜ,и,ⓞ,ⓟ,ⓠ,ⓡ,ⓢ,⊥,ʊ,ⓥ,ⓦ,ж,ⓨ,ⓩ,0,➒,➑,➆,➅,➎,➍,➌,➁,➀,.,_", "ⓐ,ß,ḉ,∂,℮,ⓕ,❡,ⓗ,ї,נ,ḱ,ł,μ,η,ø,ρ,ⓠ,я,﹩,ⓣ,ц,√,ⓦ,✖️,૪,ℨ,ⓐ,ß,ḉ,∂,℮,ⓕ,❡,ⓗ,ї,נ,ḱ,ł,μ,η,ø,ρ,ⓠ,я,﹩,ⓣ,ц,√,ⓦ,✖️,૪,ℨ,0,➒,➑,➐,➅,➄,➍,➂,➁,➊,.,_", "α,ß,ⓒ,ⅾ,ℯ,ƒ,ℊ,ⓗ,ї,ʝ,к,ʟ,ⓜ,η,ⓞ,℘,ⓠ,ґ,﹩,т,υ,ⓥ,ⓦ,ж,ⓨ,ẕ,α,ß,ⓒ,ⅾ,ℯ,ƒ,ℊ,ⓗ,ї,ʝ,к,ʟ,ⓜ,η,ⓞ,℘,ⓠ,ґ,﹩,т,υ,ⓥ,ⓦ,ж,ⓨ,ẕ,0,➈,➇,➐,➅,➎,➍,➌,➁,➊,.,_", "@,♭,ḉ,ⅾ,є,ⓕ,❡,н,ḯ,נ,ⓚ,ⓛ,м,ⓝ,☺️,ⓟ,ⓠ,я,ⓢ,⊥,υ,♥️,ẘ,ϰ,૪,ⓩ,@,♭,ḉ,ⅾ,є,ⓕ,❡,н,ḯ,נ,ⓚ,ⓛ,м,ⓝ,☺️,ⓟ,ⓠ,я,ⓢ,⊥,υ,♥️,ẘ,ϰ,૪,ⓩ,0,➒,➑,➆,➅,➄,➃,➂,➁,➀,.,_", "ⓐ,♭,ḉ,ⅾ,є,ƒ,ℊ,ℌ,ḯ,ʝ,ḱ,ł,μ,η,ø,ⓟ,ⓠ,ґ,ⓢ,т,ⓤ,√,ⓦ,✖️,ⓨ,ẕ,ⓐ,♭,ḉ,ⅾ,є,ƒ,ℊ,ℌ,ḯ,ʝ,ḱ,ł,μ,η,ø,ⓟ,ⓠ,ґ,ⓢ,т,ⓤ,√,ⓦ,✖️,ⓨ,ẕ,0,➈,➇,➐,➅,➄,➃,➂,➁,➀,.,_", "ձ,ъƈ,ժ,ε,բ,ց,հ,ﻨ,յ,ĸ,l,ო,ռ,օ,թ,զ,г,ร,է,ս,ν,ա,×,ყ,২,ձ,ъƈ,ժ,ε,բ,ց,հ,ﻨ,յ,ĸ,l,ო,ռ,օ,թ,զ,г,ร,է,ս,ν,ա,×,ყ,২,0,9,8,7,6,5,4,3,2,1,.,_", "λ,ϐ,ς,d,ε,ғ,ϑ,ɢ,н,ι,ϳ,κ,l,ϻ,π,σ,ρ,φ,г,s,τ,υ,v,ш,ϰ,ψ,z,λ,ϐ,ς,d,ε,ғ,ϑ,ɢ,н,ι,ϳ,κ,l,ϻ,π,σ,ρ,φ,г,s,τ,υ,v,ш,ϰ,ψ,z,0,9,8,7,6,5,4,3,2,1,.,_", "ค,๒,ς,๔,є,Ŧ,ɠ,ђ,เ,ן,к,l,๓,ภ,๏,թ,ợ,г,ร,t,ย,v,ฬ,x,ץ,z,ค,๒,ς,๔,є,Ŧ,ɠ,ђ,เ,ן,к,l,๓,ภ,๏,թ,ợ,г,ร,t,ย,v,ฬ,x,ץ,z,0,9,8,7,6,5,4,3,2,1,.,_", "მ,ჩ,ƈძ,ε,բ,ց,հ,ἶ,ʝ,ƙ,l,ო,ղ,օ,ր,գ,ɾ,ʂ,է,մ,ν,ω,ჯ,ყ,z,მ,ჩ,ƈძ,ε,բ,ց,հ,ἶ,ʝ,ƙ,l,ო,ղ,օ,ր,գ,ɾ,ʂ,է,մ,ν,ω,ჯ,ყ,z,0,Գ,Ց,Դ,6,5,Վ,Յ,Զ,1,.,_", "ค,ც,८,ძ,૯,Բ,૭,Һ,ɿ,ʆ,қ,Ն,ɱ,Ո,૦,ƿ,ҩ,Ր,ς,੮,υ,౮,ω,૪,ע,ઽ,ค,ც,८,ძ,૯,Բ,૭,Һ,ɿ,ʆ,қ,Ն,ɱ,Ո,૦,ƿ,ҩ,Ր,ς,੮,υ,౮,ω,૪,ע,ઽ,0,9,8,7,6,5,4,3,2,1,.,_", "Λ,Б,Ͼ,Ð,Ξ,Ŧ,g,h,ł,j,К,Ł,m,Л,Ф,p,Ǫ,Я,s,t,u,v,Ш,Ж,Џ,z,Λ,Б,Ͼ,Ð,Ξ,Ŧ,g,h,ł,j,К,Ł,m,Л,Ф,p,Ǫ,Я,s,t,u,v,Ш,Ж,Џ,z,0,9,8,7,6,5,4,3,2,1,.,_", "λ,ß,Ȼ,ɖ,ε,ʃ,Ģ,ħ,ί,ĵ,κ,ι,ɱ,ɴ,Θ,ρ,ƣ,ર,Ș,τ,Ʋ,ν,ώ,Χ,ϓ,Հ,λ,ß,Ȼ,ɖ,ε,ʃ,Ģ,ħ,ί,ĵ,κ,ι,ɱ,ɴ,Θ,ρ,ƣ,ર,Ș,τ,Ʋ,ν,ώ,Χ,ϓ,Հ,0,9,8,7,6,5,4,3,2,1,.,_", "ª,b,¢,Þ,È,F,૬,ɧ,Î,j,Κ,Ļ,м,η,◊,Ƿ,ƍ,r,S,⊥,µ,√,w,×,ý,z,ª,b,¢,Þ,È,F,૬,ɧ,Î,j,Κ,Ļ,м,η,◊,Ƿ,ƍ,r,S,⊥,µ,√,w,×,ý,z,0,9,8,7,6,5,4,3,2,1,.,_", "Թ,Յ,Շ,Ժ,ȝ,Բ,Գ,ɧ,ɿ,ʝ,ƙ,ʅ,ʍ,Ռ,Ծ,ρ,φ,Ր,Տ,Ե,Մ,ע,ա,Ճ,Վ,Հ,Թ,Յ,Շ,Ժ,ȝ,Բ,Գ,ɧ,ɿ,ʝ,ƙ,ʅ,ʍ,Ռ,Ծ,ρ,φ,Ր,Տ,Ե,Մ,ע,ա,Ճ,Վ,Հ,0,9,8,7,6,5,4,3,2,1,.,_", "Λ,Ϧ,ㄈ,Ð,Ɛ,F,Ɠ,н,ɪ,フ,Қ,Ł,௱,Л,Ø,þ,Ҩ,尺,ら,Ť,Ц,Ɣ,Ɯ,χ,Ϥ,Ẕ,Λ,Ϧ,ㄈ,Ð,Ɛ,F,Ɠ,н,ɪ,フ,Қ,Ł,௱,Л,Ø,þ,Ҩ,尺,ら,Ť,Ц,Ɣ,Ɯ,χ,Ϥ,Ẕ,0,9,8,7,6,5,4,3,2,1,.,_", "Ǟ,в,ट,D,ę,բ,g,৸,i,j,κ,l,ɱ,П,Φ,Р,q,Я,s,Ʈ,Ц,v,Щ,ж,ყ,ւ,Ǟ,в,ट,D,ę,բ,g,৸,i,j,κ,l,ɱ,П,Φ,Р,q,Я,s,Ʈ,Ц,v,Щ,ж,ყ,ւ,0,9,8,7,6,5,4,3,2,1,.,_", "ɒ,d,ɔ,b,ɘ,ʇ,ϱ,н,i,į,ʞ,l,м,и,o,q,p,я,ƨ,т,υ,v,w,x,γ,z,ɒ,d,ɔ,b,ɘ,ʇ,ϱ,н,i,į,ʞ,l,м,и,o,q,p,я,ƨ,т,υ,v,w,x,γ,z,0,9,8,7,6,5,4,3,2,1,.,_", "Æ,þ,©,Ð,E,F,ζ,Ħ,Ї,¿,ズ,ᄂ,M,Ñ,Θ,Ƿ,Ø,Ґ,Š,τ,υ,¥,w,χ,y,շ,Æ,þ,©,Ð,E,F,ζ,Ħ,Ї,¿,ズ,ᄂ,M,Ñ,Θ,Ƿ,Ø,Ґ,Š,τ,υ,¥,w,χ,y,շ,0,9,8,7,6,5,4,3,2,1,.,_", "ª,ß,¢,ð,€,f,g,h,¡,j,k,|,m,ñ,¤,Þ,q,®,$,t,µ,v,w,×,ÿ,z,ª,ß,¢,ð,€,f,g,h,¡,j,k,|,m,ñ,¤,Þ,q,®,$,t,µ,v,w,×,ÿ,z,0,9,8,7,6,5,4,3,2,1,.,_", "ɐ,q,ɔ,p,ǝ,ɟ,ɓ,ɥ,ı,ſ,ʞ,ๅ,ɯ,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,ɐ,q,ɔ,p,ǝ,ɟ,ɓ,ɥ,ı,ſ,ʞ,ๅ,ɯ,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,0,9,8,7,6,5,4,3,2,1,.,_", "⒜,⒝,⒞,⒟,⒠,⒡,⒢,⒣,⒤,⒥,⒦,⒧,⒨,⒩,⒪,⒫,⒬,⒭,⒮,⒯,⒰,⒱,⒲,⒳,⒴,⒵,⒜,⒝,⒞,⒟,⒠,⒡,⒢,⒣,⒤,⒥,⒦,⒧,⒨,⒩,⒪,⒫,⒬,⒭,⒮,⒯,⒰,⒱,⒲,⒳,⒴,⒵,⒪,⑼,⑻,⑺,⑹,⑸,⑷,⑶,⑵,⑴,.,_", "ɑ,ʙ,c,ᴅ,є,ɻ,მ,ʜ,ι,ɿ,ĸ,г,w,и,o,ƅϭ,ʁ,ƨ,⊥,n,ʌ,ʍ,x,⑃,z,ɑ,ʙ,c,ᴅ,є,ɻ,მ,ʜ,ι,ɿ,ĸ,г,w,и,o,ƅϭ,ʁ,ƨ,⊥,n,ʌ,ʍ,x,⑃,z,0,9,8,7,6,5,4,3,2,1,.,_", "4,8,C,D,3,F,9,H,!,J,K,1,M,N,0,P,Q,R,5,7,U,V,W,X,Y,2,4,8,C,D,3,F,9,H,!,J,K,1,M,N,0,P,Q,R,5,7,U,V,W,X,Y,2,0,9,8,7,6,5,4,3,2,1,.,_", "Λ,ßƇ,D,Ɛ,F,Ɠ,Ĥ,Ī,Ĵ,Ҡ,Ŀ,M,И,♡,Ṗ,Ҩ,Ŕ,S,Ƭ,Ʊ,Ѵ,Ѡ,Ӿ,Y,Z,Λ,ßƇ,D,Ɛ,F,Ɠ,Ĥ,Ī,Ĵ,Ҡ,Ŀ,M,И,♡,Ṗ,Ҩ,Ŕ,S,Ƭ,Ʊ,Ѵ,Ѡ,Ӿ,Y,Z,0,9,8,7,6,5,4,3,2,1,.,_", "α,в,¢,đ,e,f,g,ħ,ı,נ,κ,ł,м,и,ø,ρ,q,я,š,т,υ,ν,ω,χ,ч,z,α,в,¢,đ,e,f,g,ħ,ı,נ,κ,ł,м,и,ø,ρ,q,я,š,т,υ,ν,ω,χ,ч,z,0,9,8,7,6,5,4,3,2,1,.,_", "α,в,c,ɔ,ε,ғ,ɢ,н,ı,נ,κ,ʟ,м,п,σ,ρ,ǫ,я,ƨ,т,υ,ν,ш,х,ч,z,α,в,c,ɔ,ε,ғ,ɢ,н,ı,נ,κ,ʟ,м,п,σ,ρ,ǫ,я,ƨ,т,υ,ν,ш,х,ч,z,0,9,8,7,6,5,4,3,2,1,.,_", "【a】,【b】,【c】,【d】,【e】,【f】,【g】,【h】,【i】,【j】,【k】,【l】,【m】,【n】,【o】,【p】,【q】,【r】,【s】,【t】,【u】,【v】,【w】,【x】,【y】,【z】,【a】,【b】,【c】,【d】,【e】,【f】,【g】,【h】,【i】,【j】,【k】,【l】,【m】,【n】,【o】,【p】,【q】,【r】,【s】,【t】,【u】,【v】,【w】,【x】,【y】,【z】,【0】,【9】,【8】,【7】,【6】,【5】,【4】,【3】,【2】,【1】,.,_", "[̲̲̅̅a̲̅,̲̅b̲̲̅,̅c̲̅,̲̅d̲̲̅,̅e̲̲̅,̅f̲̲̅,̅g̲̅,̲̅h̲̲̅,̅i̲̲̅,̅j̲̲̅,̅k̲̅,̲̅l̲̲̅,̅m̲̅,̲̅n̲̅,̲̅o̲̲̅,̅p̲̅,̲̅q̲̅,̲̅r̲̲̅,̅s̲̅,̲̅t̲̲̅,̅u̲̅,̲̅v̲̅,̲̅w̲̅,̲̅x̲̅,̲̅y̲̅,̲̅z̲̅,[̲̲̅̅a̲̅,̲̅b̲̲̅,̅c̲̅,̲̅d̲̲̅,̅e̲̲̅,̅f̲̲̅,̅g̲̅,̲̅h̲̲̅,̅i̲̲̅,̅j̲̲̅,̅k̲̅,̲̅l̲̲̅,̅m̲̅,̲̅n̲̅,̲̅o̲̲̅,̅p̲̅,̲̅q̲̅,̲̅r̲̲̅,̅s̲̅,̲̅t̲̲̅,̅u̲̅,̲̅v̲̅,̲̅w̲̅,̲̅x̲̅,̲̅y̲̅,̲̅z̲̅,̲̅0̲̅,̲̅9̲̲̅,̅8̲̅,̲̅7̲̅,̲̅6̲̅,̲̅5̲̅,̲̅4̲̅,̲̅3̲̲̅,̅2̲̲̅,̅1̲̲̅̅],.,_", "[̺͆a̺͆͆,̺b̺͆͆,̺c̺͆,̺͆d̺͆,̺͆e̺͆,̺͆f̺͆͆,̺g̺͆,̺͆h̺͆,̺͆i̺͆,̺͆j̺͆,̺͆k̺͆,̺l̺͆͆,̺m̺͆͆,̺n̺͆͆,̺o̺͆,̺͆p̺͆͆,̺q̺͆͆,̺r̺͆͆,̺s̺͆͆,̺t̺͆͆,̺u̺͆͆,̺v̺͆͆,̺w̺͆,̺͆x̺͆,̺͆y̺͆,̺͆z̺,[̺͆a̺͆͆,̺b̺͆͆,̺c̺͆,̺͆d̺͆,̺͆e̺͆,̺͆f̺͆͆,̺g̺͆,̺͆h̺͆,̺͆i̺͆,̺͆j̺͆,̺͆k̺͆,̺l̺͆͆,̺m̺͆͆,̺n̺͆͆,̺o̺͆,̺͆p̺͆͆,̺q̺͆͆,̺r̺͆͆,̺s̺͆͆,̺t̺͆͆,̺u̺͆͆,̺v̺͆͆,̺w̺͆,̺͆x̺͆,̺͆y̺͆,̺͆z̺,̺͆͆0̺͆,̺͆9̺͆,̺͆8̺̺͆͆7̺͆,̺͆6̺͆,̺͆5̺͆,̺͆4̺͆,̺͆3̺͆,̺͆2̺͆,̺͆1̺͆],.,_", "̛̭̰̃ã̛̰̭,̛̭̰̃b̛̰̭̃̃,̛̭̰c̛̛̰̭̃̃,̭̰d̛̰̭̃,̛̭̰̃ḛ̛̭̃̃,̛̭̰f̛̰̭̃̃,̛̭̰g̛̰̭̃̃,̛̭̰h̛̰̭̃,̛̭̰̃ḭ̛̛̭̃̃,̭̰j̛̰̭̃̃,̛̭̰k̛̰̭̃̃,̛̭̰l̛̰̭,̛̭̰̃m̛̰̭̃̃,̛̭̰ñ̛̛̰̭̃,̭̰ỡ̰̭̃,̛̭̰p̛̰̭̃,̛̭̰̃q̛̰̭̃̃,̛̭̰r̛̛̰̭̃̃,̭̰s̛̰̭,̛̭̰̃̃t̛̰̭̃,̛̭̰̃ữ̰̭̃,̛̭̰ṽ̛̰̭̃,̛̭̰w̛̛̰̭̃̃,̭̰x̛̰̭̃,̛̭̰̃ỹ̛̰̭̃,̛̭̰z̛̰̭̃̃,̛̛̭̰ã̛̰̭,̛̭̰̃b̛̰̭̃̃,̛̭̰c̛̛̰̭̃̃,̭̰d̛̰̭̃,̛̭̰̃ḛ̛̭̃̃,̛̭̰f̛̰̭̃̃,̛̭̰g̛̰̭̃̃,̛̭̰h̛̰̭̃,̛̭̰̃ḭ̛̛̭̃̃,̭̰j̛̰̭̃̃,̛̭̰k̛̰̭̃̃,̛̭̰l̛̰̭,̛̭̰̃m̛̰̭̃̃,̛̭̰ñ̛̛̰̭̃,̭̰ỡ̰̭̃,̛̭̰p̛̰̭̃,̛̭̰̃q̛̰̭̃̃,̛̭̰r̛̛̰̭̃̃,̭̰s̛̰̭,̛̭̰̃̃t̛̰̭̃,̛̭̰̃ữ̰̭̃,̛̭̰ṽ̛̰̭̃,̛̭̰w̛̛̰̭̃̃,̭̰x̛̰̭̃,̛̭̰̃ỹ̛̰̭̃,̛̭̰z̛̰̭̃̃,̛̭̰0̛̛̰̭̃̃,̭̰9̛̰̭̃̃,̛̭̰8̛̛̰̭̃̃,̭̰7̛̰̭̃̃,̛̭̰6̛̰̭̃̃,̛̭̰5̛̰̭̃,̛̭̰̃4̛̰̭̃,̛̭̰̃3̛̰̭̃̃,̛̭̰2̛̰̭̃̃,̛̭̰1̛̰̭̃,.,_", "a,ะb,ะc,ะd,ะe,ะf,ะg,ะh,ะi,ะj,ะk,ะl,ะm,ะn,ะo,ะp,ะq,ะr,ะs,ะt,ะu,ะv,ะw,ะx,ะy,ะz,a,ะb,ะc,ะd,ะe,ะf,ะg,ะh,ะi,ะj,ะk,ะl,ะm,ะn,ะo,ะp,ะq,ะr,ะs,ะt,ะu,ะv,ะw,ะx,ะy,ะz,ะ0,ะ9,ะ8,ะ7,ะ6,ะ5,ะ4,ะ3,ะ2,ะ1ะ,.,_", "̑ȃ,̑b̑,̑c̑,̑d̑,̑ȇ,̑f̑,̑g̑,̑h̑,̑ȋ,̑j̑,̑k̑,̑l̑,̑m̑,̑n̑,̑ȏ,̑p̑,̑q̑,̑ȓ,̑s̑,̑t̑,̑ȗ,̑v̑,̑w̑,̑x̑,̑y̑,̑z̑,̑ȃ,̑b̑,̑c̑,̑d̑,̑ȇ,̑f̑,̑g̑,̑h̑,̑ȋ,̑j̑,̑k̑,̑l̑,̑m̑,̑n̑,̑ȏ,̑p̑,̑q̑,̑ȓ,̑s̑,̑t̑,̑ȗ,̑v̑,̑w̑,̑x̑,̑y̑,̑z̑,̑0̑,̑9̑,̑8̑,̑7̑,̑6̑,̑5̑,̑4̑,̑3̑,̑2̑,̑1̑,.,_", "~a,͜͝b,͜͝c,͜͝d,͜͝e,͜͝f,͜͝g,͜͝h,͜͝i,͜͝j,͜͝k,͜͝l,͜͝m,͜͝n,͜͝o,͜͝p,͜͝q,͜͝r,͜͝s,͜͝t,͜͝u,͜͝v,͜͝w,͜͝x,͜͝y,͜͝z,~a,͜͝b,͜͝c,͜͝d,͜͝e,͜͝f,͜͝g,͜͝h,͜͝i,͜͝j,͜͝k,͜͝l,͜͝m,͜͝n,͜͝o,͜͝p,͜͝q,͜͝r,͜͝s,͜͝t,͜͝u,͜͝v,͜͝w,͜͝x,͜͝y,͜͝z,͜͝0,͜͝9,͜͝8,͜͝7,͜͝6,͜͝5,͜͝4,͜͝3,͜͝2͜,͝1͜͝~,.,_", "̤̈ä̤,̤̈b̤̈,̤̈c̤̈̈,̤d̤̈,̤̈ë̤,̤̈f̤̈,̤̈g̤̈̈,̤ḧ̤̈,̤ï̤̈,̤j̤̈,̤̈k̤̈̈,̤l̤̈,̤̈m̤̈,̤̈n̤̈,̤̈ö̤,̤̈p̤̈,̤̈q̤̈,̤̈r̤̈,̤̈s̤̈̈,̤ẗ̤̈,̤ṳ̈,̤̈v̤̈,̤̈ẅ̤,̤̈ẍ̤,̤̈ÿ̤,̤̈z̤̈,̤̈ä̤,̤̈b̤̈,̤̈c̤̈̈,̤d̤̈,̤̈ë̤,̤̈f̤̈,̤̈g̤̈̈,̤ḧ̤̈,̤ï̤̈,̤j̤̈,̤̈k̤̈̈,̤l̤̈,̤̈m̤̈,̤̈n̤̈,̤̈ö̤,̤̈p̤̈,̤̈q̤̈,̤̈r̤̈,̤̈s̤̈̈,̤ẗ̤̈,̤ṳ̈,̤̈v̤̈,̤̈ẅ̤,̤̈ẍ̤,̤̈ÿ̤,̤̈z̤̈,̤̈0̤̈,̤̈9̤̈,̤̈8̤̈,̤̈7̤̈,̤̈6̤̈,̤̈5̤̈,̤̈4̤̈,̤̈3̤̈,̤̈2̤̈̈,̤1̤̈,.,_", "≋̮̑ȃ̮,̮̑b̮̑,̮̑c̮̑,̮̑d̮̑,̮̑ȇ̮,̮̑f̮̑,̮̑g̮̑,̮̑ḫ̑,̮̑ȋ̮,̮̑j̮̑,̮̑k̮̑,̮̑l̮̑,̮̑m̮̑,̮̑n̮̑,̮̑ȏ̮,̮̑p̮̑,̮̑q̮̑,̮̑r̮,̮̑̑s̮,̮̑̑t̮,̮̑̑u̮,̮̑̑v̮̑,̮̑w̮̑,̮̑x̮̑,̮̑y̮̑,̮̑z̮̑,≋̮̑ȃ̮,̮̑b̮̑,̮̑c̮̑,̮̑d̮̑,̮̑ȇ̮,̮̑f̮̑,̮̑g̮̑,̮̑ḫ̑,̮̑ȋ̮,̮̑j̮̑,̮̑k̮̑,̮̑l̮̑,̮̑m̮̑,̮̑n̮̑,̮̑ȏ̮,̮̑p̮̑,̮̑q̮̑,̮̑r̮,̮̑̑s̮,̮̑̑t̮,̮̑̑u̮,̮̑̑v̮̑,̮̑w̮̑,̮̑x̮̑,̮̑y̮̑,̮̑z̮̑,̮̑0̮̑,̮̑9̮̑,̮̑8̮̑,̮̑7̮̑,̮̑6̮̑,̮̑5̮̑,̮̑4̮̑,̮̑3̮̑,̮̑2̮̑,̮̑1̮̑≋,.,_", "a̮,̮b̮̮,c̮̮,d̮̮,e̮̮,f̮̮,g̮̮,ḫ̮,i̮,j̮̮,k̮̮,l̮,̮m̮,̮n̮̮,o̮,̮p̮̮,q̮̮,r̮̮,s̮,̮t̮̮,u̮̮,v̮̮,w̮̮,x̮̮,y̮̮,z̮̮,a̮,̮b̮̮,c̮̮,d̮̮,e̮̮,f̮̮,g̮̮,ḫ̮i,̮̮,j̮̮,k̮̮,l̮,̮m̮,̮n̮̮,o̮,̮p̮̮,q̮̮,r̮̮,s̮,̮t̮̮,u̮̮,v̮̮,w̮̮,x̮̮,y̮̮,z̮̮,0̮̮,9̮̮,8̮̮,7̮̮,6̮̮,5̮̮,4̮̮,3̮̮,2̮̮,1̮,.,_", "A̲,̲B̲,̲C̲,̲D̲,̲E̲,̲F̲,̲G̲,̲H̲,̲I̲,̲J̲,̲K̲,̲L̲,̲M̲,̲N̲,̲O̲,̲P̲,̲Q̲,̲R̲,̲S̲,̲T̲,̲U̲,̲V̲,̲W̲,̲X̲,̲Y̲,̲Z̲,̲a̲,̲b̲,̲c̲,̲d̲,̲e̲,̲f̲,̲g̲,̲h̲,̲i̲,̲j̲,̲k̲,̲l̲,̲m̲,̲n̲,̲o̲,̲p̲,̲q̲,̲r̲,̲s̲,̲t̲,̲u̲,̲v̲,̲w̲,̲x̲,̲y̲,̲z̲,̲0̲,̲9̲,̲8̲,̲7̲,̲6̲,̲5̲,̲4̲,̲3̲,̲2̲,̲1̲,̲.̲,̲_̲", "Â,ß,Ĉ,Ð,Є,Ŧ,Ǥ,Ħ,Ī,ʖ,Қ,Ŀ,♏,И,Ø,P,Ҩ,R,$,ƚ,Ц,V,Щ,X,¥,Ẕ,Â,ß,Ĉ,Ð,Є,Ŧ,Ǥ,Ħ,Ī,ʖ,Қ,Ŀ,♏,И,Ø,P,Ҩ,R,$,ƚ,Ц,V,Щ,X,¥,Ẕ,0,9,8,7,6,5,4,3,2,1,.,_", } -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- local result = {} i=0 for k=1,#fonts do i=i+1 local tar_font = fonts[i]:split(",") local text = matches[2] local text = text:gsub("A",tar_font[1]) local text = text:gsub("B",tar_font[2]) local text = text:gsub("C",tar_font[3]) local text = text:gsub("D",tar_font[4]) local text = text:gsub("E",tar_font[5]) local text = text:gsub("F",tar_font[6]) local text = text:gsub("G",tar_font[7]) local text = text:gsub("H",tar_font[8]) local text = text:gsub("I",tar_font[9]) local text = text:gsub("J",tar_font[10]) local text = text:gsub("K",tar_font[11]) local text = text:gsub("L",tar_font[12]) local text = text:gsub("M",tar_font[13]) local text = text:gsub("N",tar_font[14]) local text = text:gsub("O",tar_font[15]) local text = text:gsub("P",tar_font[16]) local text = text:gsub("Q",tar_font[17]) local text = text:gsub("R",tar_font[18]) local text = text:gsub("S",tar_font[19]) local text = text:gsub("T",tar_font[20]) local text = text:gsub("U",tar_font[21]) local text = text:gsub("V",tar_font[22]) local text = text:gsub("W",tar_font[23]) local text = text:gsub("X",tar_font[24]) local text = text:gsub("Y",tar_font[25]) local text = text:gsub("Z",tar_font[26]) local text = text:gsub("a",tar_font[27]) local text = text:gsub("b",tar_font[28]) local text = text:gsub("c",tar_font[29]) local text = text:gsub("d",tar_font[30]) local text = text:gsub("e",tar_font[31]) local text = text:gsub("f",tar_font[32]) local text = text:gsub("g",tar_font[33]) local text = text:gsub("h",tar_font[34]) local text = text:gsub("i",tar_font[35]) local text = text:gsub("j",tar_font[36]) local text = text:gsub("k",tar_font[37]) local text = text:gsub("l",tar_font[38]) local text = text:gsub("m",tar_font[39]) local text = text:gsub("n",tar_font[40]) local text = text:gsub("o",tar_font[41]) local text = text:gsub("p",tar_font[42]) local text = text:gsub("q",tar_font[43]) local text = text:gsub("r",tar_font[44]) local text = text:gsub("s",tar_font[45]) local text = text:gsub("t",tar_font[46]) local text = text:gsub("u",tar_font[47]) local text = text:gsub("v",tar_font[48]) local text = text:gsub("w",tar_font[49]) local text = text:gsub("x",tar_font[50]) local text = text:gsub("y",tar_font[51]) local text = text:gsub("z",tar_font[52]) local text = text:gsub("0",tar_font[53]) local text = text:gsub("9",tar_font[54]) local text = text:gsub("8",tar_font[55]) local text = text:gsub("7",tar_font[56]) local text = text:gsub("6",tar_font[57]) local text = text:gsub("5",tar_font[58]) local text = text:gsub("4",tar_font[59]) local text = text:gsub("3",tar_font[60]) local text = text:gsub("2",tar_font[61]) local text = text:gsub("1",tar_font[62]) table.insert(result, text) end local result_text = "📝انواع فونت هایہ کلمہ🖋⬅️ "..matches[2].."\n🔠صَد فونت زیبا"..tostring(#fonts).." \n_____________________________" a=0 for v=1,#result do a=a+1 result_text = result_text..a.."- "..result[a].."\n\n" end return result_text.."Creator: @telesuper1_channel !" end return { description = "Fantasy Writer", usagehtm = '<tr><td align="center">write </td><td align="right">By @thisiscrazy !</td></tr>', usage = {"write [text] : زیبا نویسی",}, patterns = { "^([Ww]rite) (.*)", "^([Ww]rite)$", }, run = run }
agpl-3.0
Vadavim/jsr-darkstar
scripts/globals/items/loach_soup.lua
18
1667
----------------------------------------- -- ID: 5671 -- Item: loach_soup -- Food Effect: 4Hour,Group Food, All Races ----------------------------------------- -- Dexterity 4 -- Agility 4 -- Accuracy % 7 -- Accuracy Cap 50 -- HP % 7 -- HP Cap 50 -- Evasion 5 -- (Did Not Add Group Food Effect) ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,14400,5671); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_DEX, 4); target:addMod(MOD_AGI, 4); target:addMod(MOD_FOOD_ACCP, 7); target:addMod(MOD_FOOD_ACC_CAP, 50); target:addMod(MOD_FOOD_HPP, 7); target:addMod(MOD_FOOD_HP_CAP, 50); target:addMod(MOD_EVA, 5); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_DEX, 4); target:delMod(MOD_AGI, 4); target:delMod(MOD_FOOD_ACCP, 7); target:delMod(MOD_FOOD_ACC_CAP, 50); target:delMod(MOD_FOOD_HPP, 7); target:delMod(MOD_FOOD_HP_CAP, 50); target:delMod(MOD_EVA, 5); end;
gpl-3.0
Colettechan/darkstar
scripts/globals/items/loach_soup.lua
18
1667
----------------------------------------- -- ID: 5671 -- Item: loach_soup -- Food Effect: 4Hour,Group Food, All Races ----------------------------------------- -- Dexterity 4 -- Agility 4 -- Accuracy % 7 -- Accuracy Cap 50 -- HP % 7 -- HP Cap 50 -- Evasion 5 -- (Did Not Add Group Food Effect) ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,14400,5671); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_DEX, 4); target:addMod(MOD_AGI, 4); target:addMod(MOD_FOOD_ACCP, 7); target:addMod(MOD_FOOD_ACC_CAP, 50); target:addMod(MOD_FOOD_HPP, 7); target:addMod(MOD_FOOD_HP_CAP, 50); target:addMod(MOD_EVA, 5); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_DEX, 4); target:delMod(MOD_AGI, 4); target:delMod(MOD_FOOD_ACCP, 7); target:delMod(MOD_FOOD_ACC_CAP, 50); target:delMod(MOD_FOOD_HPP, 7); target:delMod(MOD_FOOD_HP_CAP, 50); target:delMod(MOD_EVA, 5); end;
gpl-3.0
Vadavim/jsr-darkstar
scripts/zones/Bibiki_Bay/mobs/Shen.lua
17
1234
----------------------------------- -- Area: Bibiki Bay -- MOB: Shen ----------------------------------- ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) end; ----------------------------------- -- onMobFight Action ----------------------------------- function onMobFight(mob,target) local Shen = mob:getID(); if (mob:getBattleTime() % 45 == 0) then if (GetMobAction(Shen+1) == 0) then SpawnMob(Shen+1):updateEnmity(target); elseif (GetMobAction(Shen+2) == 0) then SpawnMob(Shen+2):updateEnmity(target); end end end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob, player, isKiller) end; ----------------------------------- -- onMonsterMagicPrepare ----------------------------------- function onMonsterMagicPrepare(mob,target) -- casts Water IV, Waterga III, Flood, Drown rnd = math.random(); if (rnd < 0.5) then return 201; -- waterga 3 elseif (rnd < 0.7) then return 172; -- water 4 elseif (rnd < 0.9) then return 214; -- flood else return 240; -- drown end end;
gpl-3.0
JarnoVgr/InfectedWars
entities/effects/rico_trace_black/init.lua
1
1548
--[[----------------------------------------------------------------------------- * Infected Wars, an open source Garry's Mod game-mode. * * Infected Wars is the work of multiple authors, * a full list can be found in CONTRIBUTORS.md. * For more information, visit https://github.com/JarnoVgr/InfectedWars * * Infected Wars is free software: you can redistribute it and/or modify * it under the terms of the MIT License. * * A full copy of the MIT License can be found in LICENSE.txt. -----------------------------------------------------------------------------]] EFFECT.Mat = Material( "effects/infectedwars/black_tracer" ) function EFFECT:Init( data ) self.StartPos = data:GetStart() self.EndPos = data:GetOrigin() self.Alpha = 255 self.Entity:SetRenderBoundsWS( self.StartPos, self.EndPos ) WorldSound("Bullets.DefaultNearmiss", self.StartPos, 70, math.random(110, 180)) end function EFFECT:Think( ) self.Alpha = self.Alpha - FrameTime() * 256 if (self.Alpha < 0) then return false end return true end function EFFECT:Render( ) if ( self.Alpha < 1 ) then return end self.Length = (self.StartPos - self.EndPos):Length() render.SetMaterial( self.Mat ) local texcoord = math.Rand( 0, 1 ) for i=1, 6 do render.DrawBeam( self.StartPos, // Start self.EndPos, // End 3, // Width texcoord, // Start tex coord texcoord + self.Length / 128, // End tex coord Color( 255, 1, 1, self.Alpha ) ) // Color (optional) end end
mit
Colettechan/darkstar
scripts/zones/RuLude_Gardens/npcs/Crooked_Arrow.lua
13
1384
----------------------------------- -- Area: Ru'Lud Gardens -- NPC: Crooked Arrow -- Standard Info NPC ----------------------------------- package.loaded["scripts/zones/RuLude_Gardens/TextIDs"] = nil; ----------------------------------- require("scripts/zones/RuLude_Gardens/TextIDs"); require("scripts/globals/quests"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local WildcatJeuno = player:getVar("WildcatJeuno"); if (player:getQuestStatus(JEUNO,LURE_OF_THE_WILDCAT_JEUNO) == QUEST_ACCEPTED and player:getMaskBit(WildcatJeuno,1) == false) then player:startEvent(10090); else player:startEvent(0x0095); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); if (csid == 10090) then player:setMaskBit(player:getVar("WildcatJeuno"),"WildcatJeuno",1,true); end end;
gpl-3.0
Colettechan/darkstar
scripts/globals/spells/bluemagic/hysteric_barrage.lua
36
1734
----------------------------------------- -- Spell: Hysteric Barrage -- Delivers a fivefold attack. Damage varies with TP -- Spell cost: 61 MP -- Monster Type: Beastmen -- Spell Type: Physical (Hand-to-Hand) -- Blue Magic Points: 5 -- Stat Bonus: DEX+2, AGI+1 -- Level: 69 -- Casting Time: 0.5 seconds -- Recast Time: 28.5 seconds -- Skillchain Element: Wind (can open Scission or Gravitation; can close Detonation) -- Combos: Evasion Bonus ----------------------------------------- require("scripts/globals/magic"); require("scripts/globals/status"); require("scripts/globals/bluemagic"); ----------------------------------------- -- OnMagicCastingCheck ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; ----------------------------------------- -- OnSpellCast ----------------------------------------- function onSpellCast(caster,target,spell) local params = {}; -- This data should match information on http://wiki.ffxiclopedia.org/wiki/Calculating_Blue_Magic_Damage params.tpmod = TPMOD_DAMAGE; params.dmgtype = DMGTYPE_H2H; params.scattr = SC_DETONATION; params.numhits = 5; params.multiplier = 1.25; params.tp150 = 1.625; params.tp300 = 1.75; params.azuretp = 1.875; params.duppercap = 80; -- D upper >=69 params.str_wsc = 0.0; params.dex_wsc = 0.3; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0; damage = BluePhysicalSpell(caster, target, spell, params); damage = BlueFinalAdjustments(caster, target, spell, damage, params); return damage; end;
gpl-3.0
Colettechan/darkstar
scripts/zones/East_Sarutabaruta/npcs/Sama_Gohjima.lua
13
1487
----------------------------------- -- Area: East Sarutabaruta -- NPC: Sama Gohjima -- Involved in Mission: The Horutoto Ruins Experiment (optional) -- @pos 377 -13 98 116 ----------------------------------- package.loaded["scripts/zones/East_Sarutabaruta/TextIDs"] = nil; ----------------------------------- require("scripts/globals/missions"); require("scripts/zones/East_Sarutabaruta/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getCurrentMission(WINDURST) == THE_HORUTOTO_RUINS_EXPERIMENT and player:getVar("MissionStatus") == 1) then player:showText(npc,SAMA_GOHJIMA_PREDIALOG); elseif (player:getCurrentMission(WINDURST) == THE_HORUTOTO_RUINS_EXPERIMENT and player:getVar("MissionStatus") ~= 1) then player:messageSpecial(SAMA_GOHJIMA_POSTDIALOG); else player:startEvent(0x002b); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
sumory/lor
lib/lor/lib/utils/utils.lua
2
3411
local type = type local pairs = pairs local setmetatable = setmetatable local mrandom = math.random local sreverse = string.reverse local sfind = string.find local sgsub = string.gsub local smatch = string.match local table_insert = table.insert local json = require("cjson") local _M = {} function _M.clone(o) local lookup_table = {} local function _copy(object) if type(object) ~= "table" then return object elseif lookup_table[object] then return lookup_table[object] end local new_object = {} lookup_table[object] = new_object for key, value in pairs(object) do new_object[_copy(key)] = _copy(value) end return setmetatable(new_object, getmetatable(object)) end return _copy(o) end function _M.clear_slash(s) local r, _ = sgsub(s, "(/+)", "/") return r end function _M.is_table_empty(t) if t == nil or _G.next(t) == nil then return true else return false end end function _M.table_is_array(t) if type(t) ~= "table" then return false end local i = 0 for _ in pairs(t) do i = i + 1 if t[i] == nil then return false end end return true end function _M.mixin(a, b) if a and b then for k, _ in pairs(b) do a[k] = b[k] end end return a end function _M.random() return mrandom(0, 10000) end function _M.json_encode(data, empty_table_as_object) local json_value if json.encode_empty_table_as_object then -- empty table encoded as array default json.encode_empty_table_as_object(empty_table_as_object or false) end if require("ffi").os ~= "Windows" then json.encode_sparse_array(true) end pcall(function(d) json_value = json.encode(d) end, data) return json_value end function _M.json_decode(str) local ok, data = pcall(json.decode, str) if ok then return data end end function _M.start_with(str, substr) if str == nil or substr == nil then return false end if sfind(str, substr) ~= 1 then return false else return true end end function _M.end_with(str, substr) if str == nil or substr == nil then return false end local str_reverse = sreverse(str) local substr_reverse = sreverse(substr) if sfind(str_reverse, substr_reverse) ~= 1 then return false else return true end end function _M.is_match(uri, pattern) if not pattern then return false end local ok = smatch(uri, pattern) if ok then return true else return false end end function _M.trim_prefix_slash(s) local str, _ = sgsub(s, "^(//*)", "") return str end function _M.trim_suffix_slash(s) local str, _ = sgsub(s, "(//*)$", "") return str end function _M.trim_path_spaces(path) if not path or path == "" then return path end return sgsub(path, "( *)", "") end function _M.slim_path(path) if not path or path == "" then return path end return sgsub(path, "(//*)", "/") end function _M.split(str, delimiter) if not str or str == "" then return {} end if not delimiter or delimiter == "" then return { str } end local result = {} for match in (str .. delimiter):gmatch("(.-)" .. delimiter) do table_insert(result, match) end return result end return _M
mit
zynjec/darkstar
scripts/zones/Apollyon/mobs/Earth_Elemental.lua
9
2117
----------------------------------- -- Area: Apollyon SW -- Mob: Earth Elemental ----------------------------------- require("scripts/globals/limbus"); ----------------------------------- function onMobDeath(mob, player, isKiller) end; function onMobDespawn(mob) local mobID = mob:getID(); -- print(mobID); local mobX = mob:getXPos(); local mobY = mob:getYPos(); local mobZ = mob:getZPos(); local elementalday = GetServerVariable("[SW_Apollyon]ElementalTrigger") - 1; local correctelement=false; switch (elementalday): caseof { [0] = function (x) if (mobID==16932913 or mobID==16932921 or mobID==16932929) then correctelement=true; end end , [1] = function (x) if (mobID==16932912 or mobID==16932920 or mobID==16932928 ) then correctelement=true; end end , [2] = function (x) if (mobID==16932916 or mobID==16932924 or mobID==16932932 ) then correctelement=true; end end , [3] = function (x) if (mobID==16932910 or mobID==16932918 or mobID==16932926 ) then correctelement=true; end end , [4] = function (x) if (mobID==16932914 or mobID==16932922 or mobID==16932930 ) then correctelement=true; end end , [5] = function (x) if (mobID==16932917 or mobID==16932925 or mobID==16932933 ) then correctelement=true; end end , [6] = function (x) if (mobID==16932931 or mobID==16932915 or mobID==16932923 ) then correctelement=true; end end , [7] = function (x) if (mobID==16932911 or mobID==16932919 or mobID==16932927 ) then correctelement=true; end end , }; if (correctelement==true and IselementalDayAreDead() == true) then GetNPCByID(16932864+313):setPos(mobX,mobY,mobZ); GetNPCByID(16932864+313):setStatus(dsp.status.NORMAL); end end;
gpl-3.0
lcf8858/Sample_Lua
frameworks/cocos2d-x/cocos/scripting/lua-bindings/auto/api/Skin.lua
10
2198
-------------------------------- -- @module Skin -- @extend Sprite -- @parent_module ccs -------------------------------- -- -- @function [parent=#Skin] getBone -- @param self -- @return Bone#Bone ret (return value: ccs.Bone) -------------------------------- -- -- @function [parent=#Skin] getNodeToWorldTransformAR -- @param self -- @return mat4_table#mat4_table ret (return value: mat4_table) -------------------------------- -- -- @function [parent=#Skin] initWithFile -- @param self -- @param #string filename -- @return bool#bool ret (return value: bool) -------------------------------- -- -- @function [parent=#Skin] getDisplayName -- @param self -- @return string#string ret (return value: string) -------------------------------- -- -- @function [parent=#Skin] updateArmatureTransform -- @param self -------------------------------- -- -- @function [parent=#Skin] initWithSpriteFrameName -- @param self -- @param #string spriteFrameName -- @return bool#bool ret (return value: bool) -------------------------------- -- -- @function [parent=#Skin] setBone -- @param self -- @param #ccs.Bone bone -------------------------------- -- @overload self, string -- @overload self -- @function [parent=#Skin] create -- @param self -- @param #string pszFileName -- @return Skin#Skin ret (return value: ccs.Skin) -------------------------------- -- -- @function [parent=#Skin] createWithSpriteFrameName -- @param self -- @param #string pszSpriteFrameName -- @return Skin#Skin ret (return value: ccs.Skin) -------------------------------- -- -- @function [parent=#Skin] updateTransform -- @param self -------------------------------- -- -- @function [parent=#Skin] getNodeToWorldTransform -- @param self -- @return mat4_table#mat4_table ret (return value: mat4_table) -------------------------------- -- -- @function [parent=#Skin] draw -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table transform -- @param #unsigned int flags -------------------------------- -- js ctor -- @function [parent=#Skin] Skin -- @param self return nil
mit
Vadavim/jsr-darkstar
scripts/globals/weaponskills/piercing_arrow.lua
1
2495
----------------------------------- -- Piercing Arrow -- Archery weapon skill -- Skill level: 40 -- Ignores enemy's defense. Amount ignored varies with TP. -- The amount of defense ignored is 0% with 100TP, 35% with 200TP and 50% with 300TP. -- Typically does less damage than Flaming Arrow. -- Aligned with the Snow Gorget & Light Gorget. -- Aligned with the Snow Belt & Light Belt. -- Element: None -- Modifiers: STR:20% ; AGI:50% -- 100%TP 200%TP 300%TP -- 1.00 1.00 1.00 ----------------------------------- require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function onUseWeaponSkill(player, target, wsID, tp, primary, action, taChar) local params = {}; params.numHits = 1; params.ftp100 = 1.5; params.ftp200 = 1.5; params.ftp300 = 1.5; params.str_wsc = 0.16; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.25; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0; params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0; params.canCrit = false; params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0; params.atkmulti = 1; -- Defense ignored is 0%, 35%, 50% as per wiki.bluegartr.com params.ignoresDef = true; params.ignored100 = 0.15; params.ignored200 = 0.40; params.ignored300 = 0.80; if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then params.str_wsc = 0.0; params.agi_wsc = 1.25; end local damage, criticalHit, tpHits, extraHits = doRangedWeaponskill(player, target, wsID, params, tp, primary); -- dispels beneficial defense spells local resist = applyResistanceWeaponskill(player, target, params, tp, ELE_LIGHT, SKILL_ARC); if (damage > 0 and resist > 0.125) then target:delStatusEffect(EFFECT_PROTECT); target:delStatusEffect(EFFECT_SHELL); target:delStatusEffect(EFFECT_MAGIC_DEF_BOOST); target:delStatusEffect(EFFECT_DEFENSE_BOOST); target:delStatusEffect(EFFECT_PHALANX); target:delStatusEffect(EFFECT_STONESKIN); target:delStatusEffect(EFFECT_BLINK); target:delStatusEffect(EFFECT_BLAZE_SPIKES); target:delStatusEffect(EFFECT_SHOCK_SPIKES); target:delStatusEffect(EFFECT_ICE_SPIKES); target:delStatusEffect(EFFECT_DREAD_SPIKES); target:delStatusEffect(EFFECT_EVASION_BOOST); end return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
Vadavim/jsr-darkstar
scripts/zones/Oldton_Movalpolos/npcs/Mining_Point.lua
17
1092
----------------------------------- -- Area: Oldton Movalpolos -- NPC: Mining Point ----------------------------------- package.loaded["scripts/zones/Oldton_Movalpolos/TextIDs"] = nil; ------------------------------------- require("scripts/globals/mining"); require("scripts/zones/Oldton_Movalpolos/TextIDs"); ----------------------------------- -- onTrade ----------------------------------- function onTrade(player,npc,trade) startMining(player,player:getZoneID(),npc,trade,0x000B); end; ----------------------------------- -- onTrigger ----------------------------------- function onTrigger(player,npc) player:messageSpecial(MINING_IS_POSSIBLE_HERE,605); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
Colettechan/darkstar
scripts/zones/Pashhow_Marshlands/npcs/Stone_Monument.lua
13
1285
----------------------------------- -- Area: Pashhow Marshlands -- NPC: Stone Monument -- Involved in quest "An Explorer's Footsteps" -- @pos -300.672 21.620 304.179 109 ----------------------------------- package.loaded["scripts/zones/Pashhow_Marshlands/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Pashhow_Marshlands/TextIDs"); ----------------------------------- -- onTrigger ----------------------------------- function onTrigger(player,npc) player:startEvent(0x0384); end; ----------------------------------- -- onTrade ----------------------------------- function onTrade(player,npc,trade) if (trade:getItemCount() == 1 and trade:hasItemQty(571,1)) then player:tradeComplete(); player:addItem(570); player:messageSpecial(ITEM_OBTAINED,570); player:setVar("anExplorer-CurrentTablet",0x00100); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
reaperrr/OpenRA
mods/ra/maps/top-o-the-world/top-o-the-world.lua
7
14024
--[[ Copyright 2007-2022 The OpenRA Developers (see AUTHORS) This file is part of OpenRA, which is free software. It is made available to you under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. For more information, see COPYING. ]] --All timers have been reduced by 40% because time was flying 40% faster than reality in the original game. --That's why instead of having an hour to complete the mission you only have 36 minutes. --Unit Groups Setup USSRDie01 = { USSRGrenadier01, USSRGrenadier02, USSRGrenadier03, USSRFlame01, USSRFlame03 } USSRDie02 = { USSRGrenadier04, USSRGrenadier05, USSRFlame02, USSRFlame04 } USSRDie03 = { USSRHTank01, USSRHTank02 } USSRDie04 = { USSRDog01, USSRDog03 } USSRDie05 = { USSRDog02, USSRDog04 } USSRDie06 = { USSRV202, USSRV203 } AlliedSquad01 = { AlliedSquad01RocketInf01, AlliedSquad01RocketInf02, AlliedSquad01RocketInf03, AlliedSquad01RocketInf04, AlliedSquad01RocketInf05 } AlliedSquad02 = { AlliedSquad02RifleInf01, AlliedSquad02RifleInf02, AlliedSquad02RifleInf03, AlliedSquad02RifleInf04, AlliedSquad02RifleInf05, AlliedSquad02RifleInf06, AlliedSquad02RifleInf07, AlliedSquad02RifleInf08, AlliedSquad02RifleInf09 } AlliedSquad03 = { AlliedSquad03LTank01, AlliedSquad03RocketInf01, AlliedSquad03RocketInf02, AlliedSquad03RocketInf03 } AlliedSquad04 = { AlliedSquad04MGG01, AlliedSquad04MTank01, AlliedSquad04MTank02, AlliedSquad04MTank03, AlliedSquad04MTank04, AlliedSquad04MTank05, AlliedSquad04Arty01, AlliedSquad04Arty02, AlliedSquad04Arty03 } AlliedTanksReinforcement = { "2tnk", "2tnk" } if Difficulty == "easy" then AlliedHuntingParty = { "1tnk" } elseif Difficulty == "normal" then AlliedHuntingParty = { "1tnk", "1tnk" } elseif Difficulty == "hard" then AlliedHuntingParty = { "1tnk", "1tnk", "1tnk" } end --Building Group Setup AlliedAAGuns = { AAGun01, AAGun02, AAGun03, AAGun04, AAGun05, AAGun06 } --Area Triggers Setup WaystationTrigger = { CPos.New(61, 37), CPos.New(62, 37), CPos.New(63, 37), CPos.New(64, 37), CPos.New(65, 37), CPos.New(66, 37), CPos.New(67, 37), CPos.New(68, 37), CPos.New(69, 37), CPos.New(70, 37), CPos.New(71, 37), CPos.New(72, 37), CPos.New(73, 37), CPos.New(74, 37), CPos.New(75, 37), CPos.New(61, 38), CPos.New(62, 38), CPos.New(63, 38), CPos.New(64, 38), CPos.New(65, 38), CPos.New(66, 38), CPos.New(67, 38), CPos.New(68, 38), CPos.New(69, 38), CPos.New(70, 38), CPos.New(71, 38), CPos.New(72, 38), CPos.New(73, 38), CPos.New(74, 38), CPos.New(75, 38), CPos.New(61, 39), CPos.New(62, 39), CPos.New(63, 39), CPos.New(64, 39), CPos.New(65, 39), CPos.New(66, 39), CPos.New(67, 39), CPos.New(68, 39), CPos.New(69, 39), CPos.New(70, 39), CPos.New(71, 39), CPos.New(72, 39), CPos.New(73, 39), CPos.New(74, 39), CPos.New(75, 39) } Inf01Trigger = { CPos.New(81, 90), CPos.New(81, 91), CPos.New(81, 92), CPos.New(81, 93), CPos.New(81, 94), CPos.New(81, 95), CPos.New(82, 90), CPos.New(82, 91), CPos.New(82, 92), CPos.New(82, 93), CPos.New(82, 94), CPos.New(82, 95) } Inf02Trigger = { CPos.New(85, 90), CPos.New(85, 91), CPos.New(85, 92), CPos.New(85, 93), CPos.New(85, 94), CPos.New(85, 95), CPos.New(86, 90), CPos.New(86, 91), CPos.New(86, 92), CPos.New(86, 93), CPos.New(86, 94), CPos.New(86, 95) } RevealBridgeTrigger = { CPos.New(74, 52), CPos.New(75, 52), CPos.New(76, 52), CPos.New(77, 52), CPos.New(78, 52), CPos.New(79, 52), CPos.New(80, 52), CPos.New(81, 52), CPos.New(82, 52), CPos.New(83, 52), CPos.New(84, 52), CPos.New(85, 52), CPos.New(86, 52), CPos.New(87, 52), CPos.New(88, 52), CPos.New(76, 53), CPos.New(77, 53), CPos.New(78, 53), CPos.New(79, 53), CPos.New(80, 53), CPos.New(81, 53), CPos.New(82, 53), CPos.New(83, 53), CPos.New(84, 53), CPos.New(85, 53), CPos.New(86, 53), CPos.New(87, 53) } --Mission Variables Setup DateTime.TimeLimit = DateTime.Minutes(36) BridgeIsIntact = true --Mission Functions Setup HuntObjectiveTruck = function(a) if a.HasProperty("Hunt") then if a.Owner == greece or a.Owner == goodguy then Trigger.OnIdle(a, function(a) if a.IsInWorld and not ObjectiveTruck01.IsDead then a.AttackMove(ObjectiveTruck01.Location, 2) elseif a.IsInWorld then a.Hunt() end end) end end end HuntEnemyUnits = function(a) if a.HasProperty("Hunt") then Trigger.OnIdle(a, function(a) if a.IsInWorld then a.Hunt() end end) end end AlliedGroundPatrols = function(a) if a.HasProperty("Hunt") then if a.IsInWorld then a.Patrol({ AlliedHuntingPartyWP02.Location, AlliedHuntingPartyWP03.Location, AlliedHuntingPartyWP04.Location, AlliedHuntingPartyWP05.Location, AlliedHuntingPartyWP06.Location, AlliedHuntingPartyWP07.Location }, false, 50) end end end SpawnAlliedHuntingParty = function() Trigger.AfterDelay(DateTime.Minutes(3), function() if BridgeIsIntact then local tanks = Reinforcements.Reinforce(greece, AlliedHuntingParty, { AlliedHuntingPartySpawn.Location, AlliedHuntingPartyWP01.Location,AlliedHuntingPartyWP03.Location, AlliedHuntingPartyWP05.Location }, 0) Utils.Do(tanks, function(units) HuntObjectiveTruck(units) end) SpawnAlliedHuntingParty() end end) end WorldLoaded = function() --Players Setup player = Player.GetPlayer("USSR") greece = Player.GetPlayer("Greece") goodguy = Player.GetPlayer("GoodGuy") badguy = Player.GetPlayer("BadGuy") neutral = Player.GetPlayer("Neutral") creeps = Player.GetPlayer("Creeps") Camera.Position = DefaultCameraPosition.CenterPosition --Objectives Setup InitObjectives(player) BringSupplyTruck = player.AddObjective("Bring the supply truck to the waystation.") ProtectWaystation = player.AddObjective("The waystation must not be destroyed.") DestroyAAGuns = player.AddObjective("Destroy all the AA Guns to enable air support.", "Secondary", false) PreventAlliedIncursions = player.AddObjective("Find and destroy the bridge the allies are using\nto bring their reinforcements in the area.", "Secondary", false) Trigger.OnKilled(USSRTechCenter01, function() player.MarkFailedObjective(ProtectWaystation) end) Trigger.OnKilled(ObjectiveTruck01, function() player.MarkFailedObjective(BringSupplyTruck) end) Trigger.OnEnteredFootprint(WaystationTrigger, function(unit, id) if unit == ObjectiveTruck01 then Trigger.RemoveFootprintTrigger(id) player.MarkCompletedObjective(BringSupplyTruck) player.MarkCompletedObjective(ProtectWaystation) end end) Trigger.OnAllKilled(AlliedAAGuns, function() player.MarkCompletedObjective(DestroyAAGuns) Media.PlaySpeechNotification(player, "ObjectiveMet") Trigger.AfterDelay(DateTime.Seconds(2), function() Actor.Create("powerproxy.spyplane", true, { Owner = player }) Actor.Create("powerproxy.parabombs", true, { Owner = player }) Media.DisplayMessage("Very good comrade general! Our air units just took off\nand should be in your area in approximately three minutes.") end) end) --Triggers Setup SpawnAlliedHuntingParty() Trigger.AfterDelay(0, function() local playerrevealcam = Actor.Create("camera", true, { Owner = player, Location = PlayerStartLocation.Location }) Trigger.AfterDelay(1, function() if playerrevealcam.IsInWorld then playerrevealcam.Destroy() end end) end) Trigger.OnEnteredFootprint(Inf01Trigger, function(unit, id) if unit.Owner == player then if not AlliedGNRLHouse.IsDead then Reinforcements.Reinforce(greece, { "gnrl" }, { AlliedGNRLSpawn.Location, AlliedGNRLDestination.Location }, 0, function(unit) HuntEnemyUnits(unit) end) end Utils.Do(AlliedSquad01, HuntEnemyUnits) local alliedgnrlcamera = Actor.Create("scamera", true, { Owner = player, Location = AlliedGNRLSpawn.Location }) Trigger.AfterDelay(DateTime.Seconds(6), function() if alliedgnrlcamera.IsInWorld then alliedgnrlcamera.Destroy() end end) Trigger.RemoveFootprintTrigger(id) end end) Trigger.OnEnteredFootprint(Inf02Trigger, function(unit, id) if unit.Owner == player then Utils.Do(AlliedSquad02, HuntEnemyUnits) Trigger.RemoveFootprintTrigger(id) end end) Utils.Do(AlliedSquad03, function(actor) Trigger.OnDamaged(actor, function(unit, attacker) if attacker.Owner == player then Utils.Do(AlliedSquad03, HuntEnemyUnits) end end) end) Trigger.OnEnteredFootprint(RevealBridgeTrigger, function(unit, id) if unit.Owner == player then local bridgecamera01 = Actor.Create("camera", true, { Owner = player, Location = AlliedHuntingPartySpawn.Location }) local bridgecamera02 = Actor.Create("camera", true, { Owner = player, Location = AlliedHuntingPartyWP01.Location }) Trigger.AfterDelay(DateTime.Seconds(6), function() if bridgecamera01.IsInWorld then bridgecamera01.Destroy() end if bridgecamera02.IsInWorld then bridgecamera02.Destroy() end end) if Difficulty == "normal" then Reinforcements.Reinforce(goodguy, { "dd" }, { AlliedDestroyer01Spawn.Location, AlliedDestroyer01WP01.Location, AlliedDestroyer01WP02.Location }, 0, function(unit) unit.Stance = "Defend" end) end if Difficulty == "hard" then Reinforcements.Reinforce(goodguy, { "dd" }, { AlliedDestroyer01Spawn.Location, AlliedDestroyer01WP01.Location, AlliedDestroyer01WP02.Location }, 0, function(unit) unit.Stance = "Defend" end) Reinforcements.Reinforce(goodguy, { "dd" }, { AlliedDestroyer02Spawn.Location, AlliedDestroyer02WP01.Location, AlliedDestroyer02WP02.Location }, 0, function(unit) unit.Stance = "Defend" end) end Trigger.RemoveFootprintTrigger(id) end end) Trigger.AfterDelay(DateTime.Minutes(9), function() local powerproxy01 = Actor.Create("powerproxy.paratroopers", true, { Owner = greece }) local aircraft01 = powerproxy01.TargetParatroopers(AlliedParadropLZ01.CenterPosition, Angle.SouthWest) Utils.Do(aircraft01, function(a) Trigger.OnPassengerExited(a, function(t, p) HuntObjectiveTruck(p) end) end) local powerproxy02 = Actor.Create("powerproxy.paratroopers", true, { Owner = goodguy }) local aircraft02 = powerproxy02.TargetParatroopers(AlliedParadropLZ02.CenterPosition, Angle.SouthWest) Utils.Do(aircraft02, function(a) Trigger.OnPassengerExited(a, function(t, p) HuntObjectiveTruck(p) end) end) end) Trigger.AfterDelay(0, function() BridgeEnd = Map.ActorsInBox(AlliedHuntingPartySpawn.CenterPosition, AlliedHuntingPartyWP01.CenterPosition, function(self) return self.Type == "br2" end)[1] Trigger.OnKilled(BridgeEnd, function() BridgeIsIntact = false if not BridgeBarrel01.IsDead then BridgeBarrel01.Kill() end if not BridgeBarrel03.IsDead then BridgeBarrel03.Kill() end player.MarkCompletedObjective(PreventAlliedIncursions) Media.PlaySpeechNotification(player, "ObjectiveMet") Trigger.AfterDelay(DateTime.Seconds(2), function() Media.DisplayMessage("This should stop the allied forces from getting their ground based reinforcements.") end) end) end) Trigger.OnAnyKilled({ BridgeBarrel01, BridgeBarrel03 }, function() if not BridgeEnd.IsDead then BridgeEnd.Kill() end end) Trigger.OnAnyKilled(AlliedSquad04, function() if BridgeIsIntact then local tanks = Reinforcements.Reinforce(greece, AlliedTanksReinforcement, { AlliedHuntingPartySpawn.Location, AlliedHuntingPartyWP01.Location }, 0, function(units) AlliedGroundPatrols(units) end) Trigger.OnAllKilled(tanks, function() if BridgeIsIntact then Reinforcements.Reinforce(greece, AlliedTanksReinforcement, { AlliedHuntingPartySpawn.Location, AlliedHuntingPartyWP01.Location }, 0, function(units) AlliedGroundPatrols(units) end) end end) end end) Trigger.OnAllKilled(AlliedSquad04, function() if BridgeIsIntact then local tanks = Reinforcements.Reinforce(greece, AlliedTanksReinforcement, { AlliedHuntingPartySpawn.Location, AlliedHuntingPartyWP01.Location }, 0, function(units) AlliedGroundPatrols(units) end) Trigger.OnAllKilled(tanks, function() if BridgeIsIntact then Reinforcements.Reinforce(greece, AlliedTanksReinforcement, { AlliedHuntingPartySpawn.Location, AlliedHuntingPartyWP01.Location }, 0, function(units) AlliedGroundPatrols(units) end) end end) end end) --Units Death Setup Trigger.AfterDelay(DateTime.Seconds(660), function() Utils.Do(USSRDie01, function(actor) if not actor.IsDead then actor.Kill("DefaultDeath") end end) end) Trigger.AfterDelay(DateTime.Seconds(744), function() Utils.Do(USSRDie02, function(actor) if not actor.IsDead then actor.Kill("DefaultDeath") end end) end) Trigger.AfterDelay(DateTime.Seconds(1122), function() if not USSRHTank03.IsDead then USSRHTank03.Kill("DefaultDeath") end end) Trigger.AfterDelay(DateTime.Seconds(1230), function() Utils.Do(USSRDie03, function(actor) if not actor.IsDead then actor.Kill("DefaultDeath") end end) end) Trigger.AfterDelay(DateTime.Seconds(1338), function() Utils.Do(USSRDie04, function(actor) if not actor.IsDead then actor.Kill("DefaultDeath") end end) end) Trigger.AfterDelay(DateTime.Seconds(1416), function() Utils.Do(USSRDie05, function(actor) if not actor.IsDead then actor.Kill("DefaultDeath") end end) end) Trigger.AfterDelay(DateTime.Seconds(1668), function() if not USSRV201.IsDead then USSRV201.Kill("DefaultDeath") end end) Trigger.AfterDelay(DateTime.Seconds(1746), function() Utils.Do(USSRDie06, function(actor) if not actor.IsDead then actor.Kill("DefaultDeath") end end) end) Trigger.AfterDelay(DateTime.Seconds(2034), function() if not USSRMTank02.IsDead then USSRMTank02.Kill("DefaultDeath") end end) Trigger.AfterDelay(DateTime.Seconds(2142), function() if not USSRMTank01.IsDead then USSRMTank01.Kill("DefaultDeath") end end) Trigger.OnTimerExpired(function() if not ObjectiveTruck01.IsDead then ObjectiveTruck01.Kill("DefaultDeath") -- Set the limit to one so that the timer displays 0 and never ends -- (which would display the game time instead of 0) DateTime.TimeLimit = 1 end end) end
gpl-3.0
Vadavim/jsr-darkstar
scripts/globals/spells/dia.lua
27
2184
----------------------------------------- -- Spell: Dia -- Lowers an enemy's defense and gradually deals light elemental damage. ----------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) --calculate raw damage local basedmg = caster:getSkillLevel(ENFEEBLING_MAGIC_SKILL) / 4; local dmg = calculateMagicDamage(basedmg,1,caster,spell,target,ENFEEBLING_MAGIC_SKILL,MOD_INT,false); -- Softcaps at 2, should always do at least 1 dmg = utils.clamp(dmg, 1, 2); --get resist multiplier (1x if no resist) local resist = applyResistance(caster,spell,target,caster:getStat(MOD_INT)-target:getStat(MOD_INT),ENFEEBLING_MAGIC_SKILL,1.0); --get the resisted damage dmg = dmg*resist; --add on bonuses (staff/day/weather/jas/mab/etc all go in this function) dmg = addBonuses(caster,spell,target,dmg); --add in target adjustment dmg = adjustForTarget(target,dmg,spell:getElement()); --add in final adjustments including the actual damage dealt local final = finalMagicAdjustments(caster,target,spell,dmg); -- Calculate duration and bonus. local duration = 60; local dotBonus = 0; if (caster:hasStatusEffect(EFFECT_SABOTEUR)) then duration = duration * 2; end caster:delStatusEffect(EFFECT_SABOTEUR); dotBonus = dotBonus+caster:getMod(MOD_DIA_DOT); -- Dia Wand -- Check for Bio. local bio = target:getStatusEffect(EFFECT_BIO); -- Do it! if (DIA_OVERWRITE == 0 or (DIA_OVERWRITE == 1 and bio == nil)) then target:addStatusEffect(EFFECT_DIA,1+dotBonus,3,duration,FLAG_ERASABLE, 5); spell:setMsg(2); else spell:setMsg(75); end -- Try to kill same tier Bio if (BIO_OVERWRITE == 1 and bio ~= nil) then if (bio:getPower() == 1) then target:delStatusEffect(EFFECT_BIO); end end return final; end;
gpl-3.0
sumory/lor
spec/cases/path_params_spec.lua
2
5244
before_each(function() lor = _G.lor app = lor({ debug = true }) Request = _G.request Response = _G.response req = Request:new() res = Response:new() end) after_each(function() lor = nil app = nil Request = nil Response = nil req = nil res = nil end) describe("test about variables parsed from path", function() describe("path variables should be correct after parsed", function() it("test case 1.", function() app:use("/user", function(req, res, next) req.params.default_var = "user" next() end) app:get("/user/:id/visit", function(req, res, next) next() end) req.path = "/user/3/visit" req.method = "get" app:handle(req, res) assert.is.equals('3', req.params.id) assert.is.equals("user", req.params.default_var) end) it("test case 2.", function() app:use("/user", function(req, res, next) assert.is.equals("3", req.params.id) next() end) app:get("/user/:id/visit", function(req, res, next) req.params.id = 5 next() end) req.path = "/user/3/visit" req.method = "get" app:handle(req, res) assert.is.equals(5, req.params.id) end) it("test case 3.", function() app:get("/user/:id/visit", function(req, res, next) error("error occurs") req.params.id = '2' end) app:erroruse("/user/:id/visit", function(err, req, res, next) assert.is_not_nil(err) req.params.id = 'error' end) req.path = "/user/3/visit" req.method = "get" app:handle(req, res) assert.is.equals('error', req.params.id) end) it("test case 4.", function() app:use("/user", function(req, res, next) req.params.id = '1' next() req.params.id = 'return' end) app:get("/user/:id/visit", function(req, res, next) error("error occurs") req.params.id = '2' end) app:erroruse("/user/:id/visit", function(err, req, res, next) req.params.id = 'error' end) req.path = "/user/3/visit" req.method = "get" app:handle(req, res) assert.is.equals('return', req.params.id) end) it("test case 5.", function() app:use("/user", function(req, res, next) req.params.id = '1' next() req.params.id = 'return' end) app:get("/user/:id/visit", function(req, res, next) error("error occurs") req.params.id = '2' end) app:erroruse("/user/:id/visit", function(err, req, res, next) req.params.id = 'error' end) req.path = "/user/3/visit" req.method = "get" app:handle(req, res, function(err) req.params.id = "from final handler" end) assert.is.equals('return', req.params.id) end) end) describe("path variables should be correctly parsed when the next request comes", function() it("test case 1.", function() app:use("/todo", function(req, res, next) if req.params.id == "33" then req.params.id = '3' elseif req.params.id == "44" then req.params.id = "4" elseif req.params.id == "55" then req.params.id = "5" end next() end) app:post("/todo/delete/:id", function(req, res, next) --print(req.params.id) end) req.path = "/todo/delete/33" req.method = "post" app:handle(req, res) assert.is.equals('3', req.params.id) req.path = "/todo/delete/44" req.method = "post" app:handle(req, res) assert.is.equals('4', req.params.id) req.url = "/todo/delete/55" req.path = req.url req.method = "post" app:handle(req, res) assert.is.equals('5', req.params.id) end) it("test case 2.", function() app:use("/todo", function(req, res, next) next() end) app:post("/todo/view/:id/:name", function(req, res, next) end) req.path = "/todo/view/44/two" req.method = "post" app:handle(req, res) assert.is.equals('44', req.params.id) assert.is.equals('two', req.params.name) req.path = "/todo/view/55/three" req.method = "post" app:handle(req, res) assert.is.equals('55', req.params.id) assert.is.equals('three', req.params.name) end) end) end)
mit
zynjec/darkstar
scripts/zones/Mhaura/npcs/Kotan-Purutan.lua
9
2147
----------------------------------- -- Area: Mhaura -- NPC: Kotan-Purutan -- Involved in Quest: Overnight Delivery -- !pos 40.323 -8.999 44.242 249 ----------------------------------- local ID = require("scripts/zones/Mhaura/IDs") require("scripts/globals/keyitems") require("scripts/globals/quests") ----------------------------------- function onTrade(player,npc,trade) end; function onTrigger(player,npc) local OvernightDelivery = player:getQuestStatus(WINDURST,dsp.quest.id.windurst.OVERNIGHT_DELIVERY); local KenapaOvernight = player:getCharVar("Kenapa_Overnight_var"); -- Variable to track progress for Overnight Delivery local KenapaOvernightDay = player:getCharVar("Kenapa_Overnight_Day_var"); -- Variable to track the day the quest is started. local KenapaOvernightHour = player:getCharVar("Kenapa_Overnight_Hour_var"); -- Variable to track the hour the quest is started. local HourOfTheDay = VanadielHour(); if (OvernightDelivery == QUEST_ACCEPTED and player:hasKeyItem(dsp.ki.SMALL_BAG) == false and (KenapaOvernight >= 4 and KenapaOvernight <= 7) and (HourOfTheDay < 6 or HourOfTheDay >= 18)) then player:startEvent(141); -- Gives Key Item at correct times of night elseif (OvernightDelivery == QUEST_ACCEPTED and player:hasKeyItem(dsp.ki.SMALL_BAG) == false and (KenapaOvernight >= 4 and KenapaOvernight <= 7) and (HourOfTheDay >= 6 or HourOfTheDay < 18)) then player:startEvent(144); -- Only at night elseif (player:hasKeyItem(dsp.ki.SMALL_BAG) == true) then player:startEvent(142); -- Reminder Dialogue elseif (OvernightDelivery == QUEST_COMPLETED) then player:startEvent(143); -- Post quest else player:startEvent(140); -- Standard end end; function onEventUpdate(player,csid,option) end; function onEventFinish(player,csid,option) if (csid == 141) then player:addKeyItem(dsp.ki.SMALL_BAG); player:setCharVar("Kenapa_Overnight_Day_var",VanadielDayOfTheYear()); player:setCharVar("Kenapa_Overnight_Hour_var",VanadielHour()); player:messageSpecial(ID.text.KEYITEM_OBTAINED,dsp.ki.SMALL_BAG); end end;
gpl-3.0
Colettechan/darkstar
scripts/zones/Windurst_Waters/npcs/Upih_Khachla.lua
12
2150
----------------------------------- -- Area: Windurst Waters -- NPC: Upih Khachla -- Standard Merchant NPC -- Confirmed shop stock, August 2013 ----------------------------------- require("scripts/globals/events/harvest_festivals") require("scripts/globals/shop"); require("scripts/globals/conquest"); package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil; require("scripts/zones/Windurst_Waters/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) onHalloweenTrade(player,trade,npc); end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc,UPIHKHACHLA_SHOP_DIALOG); stock = { 0x43A1, 1107,1, --Grenade 0x1010, 837,1, --Potion 0x03B7, 108,1, --Wijnruit 0x027C, 119,2, --Chamomile 0x1037, 736,2, --Echo Drops 0x1020, 4445,2, --Ether 0x1034, 290,3, --Antidote 0x0764, 3960,3, --Desalinator 0x026E, 44,3, --Dried Marjoram 0x1036, 2387,3, --Eye Drops 0x025D, 180,3, --Pickaxe 0x0765, 3960,3, --Salinator 0x03FC, 276,3, --Sickle 0x04D9, 354,3 --Twinkle Powder } rank = getNationRank(WINDURST); if (rank ~= 1) then table.insert(stock,0x03fe); --Thief's Tools table.insert(stock,3643); table.insert(stock,3); end if (rank == 3) then table.insert(stock,0x03ff); --Living Key table.insert(stock,5520); table.insert(stock,3); end showNationShop(player, WINDURST, stock); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
Colettechan/darkstar
scripts/globals/spells/vivacious_etude.lua
45
1815
----------------------------------------- -- Spell: Vivacious Etude -- Static VIT Boost, BRD 30 ----------------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) local sLvl = caster:getSkillLevel(SKILL_SNG); -- Gets skill level of Singing local iLvl = caster:getWeaponSkillLevel(SLOT_RANGED); local power = 0; if (sLvl+iLvl <= 181) then power = 3; elseif ((sLvl+iLvl >= 182) and (sLvl+iLvl <= 235)) then power = 4; elseif ((sLvl+iLvl >= 236) and (sLvl+iLvl <= 288)) then power = 5; elseif ((sLvl+iLvl >= 289) and (sLvl+iLvl <= 342)) then power = 6; elseif ((sLvl+iLvl >= 343) and (sLvl+iLvl <= 396)) then power = 7; elseif ((sLvl+iLvl >= 397) and (sLvl+iLvl <= 449)) then power = 8; elseif (sLvl+iLvl >= 450) then power = 9; end local iBoost = caster:getMod(MOD_ETUDE_EFFECT) + caster:getMod(MOD_ALL_SONGS_EFFECT); power = power + iBoost; if (caster:hasStatusEffect(EFFECT_SOUL_VOICE)) then power = power * 2; elseif (caster:hasStatusEffect(EFFECT_MARCATO)) then power = power * 1.5; end caster:delStatusEffect(EFFECT_MARCATO); local duration = 120; duration = duration * ((iBoost * 0.1) + (caster:getMod(MOD_SONG_DURATION_BONUS)/100) + 1); if (caster:hasStatusEffect(EFFECT_TROUBADOUR)) then duration = duration * 2; end if not (target:addBardSong(caster,EFFECT_ETUDE,power,0,duration,caster:getID(),MOD_VIT,1)) then spell:setMsg(75); end return EFFECT_ETUDE; end;
gpl-3.0
actboy168/MoeHero
scripts/maps/hero/时崎狂三/七之弹.lua
1
4796
local mt = ac.skill['七之弹'] mt{ --初始等级 level = 0, --技能图标 art = [[model\Kurumi\BTNKurumiW.blp]], --技能说明 title = '七之弹', tip = [[ 召唤分身,将目标区域的敌人|cffffcc00时停|r并拖入影空间,持续%pause_time%秒。随后造成%damage_base%(+%damage_plus%)伤害。 |cffff8811七之弹[刻]|r: 敌人离开影空间后会继续被时停%power_time%秒。 ]], --目标类型 target_type = function(self, hero) if hero:find_buff '四之弹-时' then return ac.skill.TARGET_TYPE_NONE else return ac.skill.TARGET_TYPE_POINT end end, area = function(self, hero) if hero:find_buff '四之弹-时' then return 600 else return 250 end end, cost = {120, 80}, charge_cool = {18, 14}, charge_max_stack = 1, cooldown_mode = 1, show_stack = 0, show_charge = 0, --施法距离 range = 800, --施法动画 cast_animation = 'spell two', cast_animation_speed = 2.5, --施法前摇 cast_start_time = 0.8, cast_finish_time = 0.5, -- 弹道飞行速度 speed = 2000, -- 时停时间 pause_time = {1.2, 1.6}, -- 伤害 damage_base = {80, 200}, damage_plus = function(self, hero) return hero:get_ad() * 1.2 end, damage = function(self, hero) return self.damage_base + self.damage_plus end, -- 额外时停 power_time = {0.5, 0.9}, } function mt:on_cast_start() local hero = self.owner local buff = hero:find_buff '四之弹-时' if buff then self.target = buff.cent ac.wait(0, function() hero:set_facing(hero:get_point() / self.target) end) end end function mt:on_cast_shot() local hero = self.owner local skill = self local start = hero:get_launch_point() local target = self.target local power1 = hero:find_buff '四之弹' local power2 = hero:find_buff '四之弹-时' local mover = nil if power1 then power1:remove() end if power2 then mover = ac.mover.line { source = hero, start = start, skill = self, target = target, speed = self.speed, model = [[model\kurumi\ball_big.mdl]], high = 220, size = 2, } else mover = ac.mover.line { source = hero, start = start, skill = self, target = target, speed = self.speed, model = [[model\kurumi\ball.mdl]], size = 2, } end if not mover then return end local function deal_damage(u) u:add_effect('chest', [[model\kurumi\ball.mdl]]):remove() u:damage { source = hero, skill = self, damage = self.damage, aoe = true, attack = true, } end function mover:on_finish() local g = ac.selector() : in_range(target, skill.area) : is_enemy(hero) : get() local dummys = {} for i, u in ipairs(g) do if not u:is_type('建筑') then u:add_restriction '时停' u:add_restriction '阿卡林' u:add_restriction '无敌' local dummy = hero:create_unit('e00O', u:get_point(), u:get_facing()) dummys[i] = dummy local size = u:get_slk('modelScale', 0) * u:get_size() dummy:set_size(size) dummy:set_high(200 * size) dummy:add_effect('origin', u:get_slk('file', '')) local time = skill.pause_time - 0.3 dummy:add_buff '高度' { skill = skill, speed = - 200 * size / time, time = time, } else deal_damage(u) end end ac.wait(skill.pause_time * 1000 - 300, function() for i, u in ipairs(g) do local dummy = dummys[i] if dummy then local size = u:get_slk('modelScale', 0) * u:get_size() local distance = math.random(100, 300) local mover = ac.mover.line { source = hero, mover = dummy, target_high = 200 * size, height = 200 * size, speed = distance / 0.3, distance = distance, angle = math.random(360), skill = skill, } if not mover then u:set_position(dummy:get_point()) u:remove_restriction '时停' u:remove_restriction '阿卡林' u:remove_restriction '无敌' dummy:remove() deal_damage(u) return end function mover:on_remove() u:set_position(dummy:get_point()) if power1 then ac.wait(skill.power_time * 1000, function() u:remove_restriction '时停' end) else u:remove_restriction '时停' end u:remove_restriction '阿卡林' u:remove_restriction '无敌' dummy:remove() deal_damage(u) end end end end) ac.wait(skill.pause_time * 1000, function() hero:force_cast('八之弹', target, {call_back = function(_, dummy) dummy:set_animation 'spell channel two' dummy:add_animation 'stand' dummy:set_size(0) ac.wait(100, function() dummy:set_size(1) end) dummy:add_restriction '缴械' ac.wait(600, function() dummy:remove_restriction '缴械' end) end}) end) end end
gpl-3.0
Colettechan/darkstar
scripts/globals/items/dish_of_spaghetti_pescatora_+1.lua
18
1656
----------------------------------------- -- ID: 5200 -- Item: dish_of_spaghetti_pescatora_+1 -- Food Effect: 60Min, All Races ----------------------------------------- -- Health % 15 -- Health Cap 160 -- Vitality 3 -- Mind -1 -- Defense % 22 -- Defense Cap 70 -- Store TP 6 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,3600,5200); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_FOOD_HPP, 15); target:addMod(MOD_FOOD_HP_CAP, 160); target:addMod(MOD_VIT, 3); target:addMod(MOD_MND, -1); target:addMod(MOD_FOOD_DEFP, 22); target:addMod(MOD_FOOD_DEF_CAP, 70); target:addMod(MOD_STORETP, 6); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_FOOD_HPP, 15); target:delMod(MOD_FOOD_HP_CAP, 160); target:delMod(MOD_VIT, 3); target:delMod(MOD_MND, -1); target:delMod(MOD_FOOD_DEFP, 22); target:delMod(MOD_FOOD_DEF_CAP, 70); target:delMod(MOD_STORETP, 6); end;
gpl-3.0
Vadavim/jsr-darkstar
scripts/globals/quests.lua
20
45133
require("scripts/globals/log_ids"); ----------------------------------- -- Nation IDs ----------------------------------- NATION_SANDORIA = 0; NATION_BASTOK = 1; NATION_WINDURST = 2; ----------------------------------- -- -- QUESTS ID -- ----------------------------------- QUEST_AVAILABLE = 0; QUEST_ACCEPTED = 1; QUEST_COMPLETED = 2; ----------------------------------- -- San d'Oria - 0 ----------------------------------- A_SENTRY_S_PERIL = 0; -- ± -- WATER_OF_THE_CHEVAL = 1; -- ± -- ROSEL_THE_ARMORER = 2; -- ± -- THE_PICKPOCKET = 3; -- ± -- FATHER_AND_SON = 4; -- + -- THE_SEAMSTRESS = 5; -- + -- THE_DISMAYED_CUSTOMER = 6; -- + -- THE_TRADER_IN_THE_FOREST = 7; -- + -- THE_SWEETEST_THINGS = 8; -- + -- THE_VICASQUE_S_SERMON = 9; -- + -- A_SQUIRE_S_TEST = 10; -- + -- GRAVE_CONCERNS = 11; -- ± -- THE_BRUGAIRE_CONSORTIUM = 12; -- + -- LIZARD_SKINS = 15; -- + -- FLYERS_FOR_REGINE = 16; -- + -- GATES_TO_PARADISE = 18; -- + -- A_SQUIRE_S_TEST_II = 19; -- + -- TO_CURE_A_COUGH = 20; -- + -- TIGER_S_TEETH = 23; -- ± -- UNDYING_FLAMES = 26; -- + -- A_PURCHASE_OF_ARMS = 27; -- + -- A_KNIGHT_S_TEST = 29; -- + -- THE_MEDICINE_WOMAN = 30; -- + -- BLACK_TIGER_SKINS = 31; -- + -- GROWING_FLOWERS = 58; -- ± -- TRIAL_BY_ICE = 59; -- + -- THE_GENERAL_S_SECRET = 60; -- ± -- THE_RUMOR = 61; -- ± -- HER_MAJESTY_S_GARDEN = 62; -- + -- INTRODUCTION_TO_TEAMWORK = 63; INTERMEDIATE_TEAMWORK = 64; ADVANCED_TEAMWORK = 65; GRIMY_SIGNPOSTS = 66; -- + -- A_JOB_FOR_THE_CONSORTIUM = 67; TROUBLE_AT_THE_SLUICE = 68; -- + -- THE_MERCHANT_S_BIDDING = 69; -- ± -- UNEXPECTED_TREASURE = 70; BLACKMAIL = 71; -- + -- THE_SETTING_SUN = 72; -- + -- DISTANT_LOYALTIES = 74; THE_RIVALRY = 75; -- ± -- THE_COMPETITION = 76; -- ± -- STARTING_A_FLAME = 77; -- ± -- FEAR_OF_THE_DARK = 78; -- + -- WARDING_VAMPIRES = 79; -- + -- SLEEPLESS_NIGHTS = 80; -- ± -- LUFET_S_LAKE_SALT = 81; -- ± -- HEALING_THE_LAND = 82; -- ± -- SORCERY_OF_THE_NORTH = 83; -- ± -- THE_CRIMSON_TRIAL = 84; -- ± -- ENVELOPED_IN_DARKNESS = 85; -- ± -- PEACE_FOR_THE_SPIRIT = 86; -- ± -- MESSENGER_FROM_BEYOND = 87; -- ± -- PRELUDE_OF_BLACK_AND_WHITE = 88; -- ± -- PIEUJE_S_DECISION = 89; -- + -- SHARPENING_THE_SWORD = 90; -- ± -- A_BOY_S_DREAM = 91; -- ± -- UNDER_OATH = 92; THE_HOLY_CREST = 93; -- + -- A_CRAFTSMAN_S_WORK = 94; -- ± -- CHASING_QUOTAS = 95; -- + -- KNIGHT_STALKER = 96; -- + -- ECO_WARRIOR_SAN = 97; METHODS_CREATE_MADNESS = 98; SOULS_IN_SHADOW = 99; A_TASTE_FOR_MEAT = 100; -- ± -- EXIT_THE_GAMBLER = 101; -- ± -- OLD_WOUNDS = 102; ESCORT_FOR_HIRE_SAN_D_ORIA = 103; A_DISCERNING_EYE_SAN_D_ORIA = 104; A_TIMELY_VISIT = 105; FIT_FOR_A_PRINCE = 106; TRIAL_SIZE_TRIAL_BY_ICE = 107; -- + -- SIGNED_IN_BLOOD = 108; -- + -- TEA_WITH_A_TONBERRY = 109; SPICE_GALS = 110; OVER_THE_HILLS_AND_FAR_AWAY = 112; LURE_OF_THE_WILDCAT_SAN_D_ORIA = 113; -- ± -- ATELLOUNE_S_LAMENT = 114; THICK_SHELLS = 117; -- ± -- FOREST_FOR_THE_TREES = 118; ----------------------------------- -- Bastok - 1 ----------------------------------- THE_SIREN_S_TEAR = 0; -- ± -- BEAUTY_AND_THE_GALKA = 1; -- ± -- WELCOME_TO_BASTOK = 2; -- + -- GUEST_OF_HAUTEUR = 3; THE_QUADAV_S_CURSE = 4; -- ± -- OUT_OF_ONE_S_SHELL = 5; -- ± -- HEARTS_OF_MYTHRIL = 6; -- ± -- THE_ELEVENTH_S_HOUR = 7; -- ± -- SHADY_BUSINESS = 8; -- ± -- A_FOREMAN_S_BEST_FRIEND = 9; -- ± -- BREAKING_STONES = 10; -- + -- THE_COLD_LIGHT_OF_DAY = 11; -- + -- GOURMET = 12; -- ± -- THE_ELVAAN_GOLDSMITH = 13; -- ± -- A_FLASH_IN_THE_PAN = 14; -- ± -- SMOKE_ON_THE_MOUNTAIN = 15; -- ± -- STAMP_HUNT = 16; -- + -- FOREVER_TO_HOLD = 17; -- ± -- TILL_DEATH_DO_US_PART = 18; -- ± -- FALLEN_COMRADES = 19; -- ± -- RIVALS = 20; -- + -- MOM_THE_ADVENTURER = 21; -- + -- THE_SIGNPOST_MARKS_THE_SPOT = 22; -- + -- PAST_PERFECT = 23; -- ± -- STARDUST = 24; -- + -- MEAN_MACHINE = 25; -- ± -- CID_S_SECRET = 26; -- ± -- THE_USUAL = 27; -- ± -- BLADE_OF_DARKNESS = 28; -- ± -- FATHER_FIGURE = 29; -- ± -- THE_RETURN_OF_THE_ADVENTURER = 30; -- ± -- DRACHENFALL = 31; -- + -- VENGEFUL_WRATH = 32; -- ± -- BEADEAUX_SMOG = 33; -- + -- THE_CURSE_COLLECTOR = 34; -- + -- FEAR_OF_FLYING = 35; -- + -- THE_WISDOM_OF_ELDERS = 36; -- ± -- GROCERIES = 37; -- ± -- THE_BARE_BONES = 38; -- ± -- MINESWEEPER = 39; -- ± -- THE_DARKSMITH = 40; -- ± -- BUCKETS_OF_GOLD = 41; -- ± -- THE_STARS_OF_IFRIT = 42; -- ± -- LOVE_AND_ICE = 43; -- ± -- BRYGID_THE_STYLIST = 44; -- ± -- THE_GUSTABERG_TOUR = 45; BITE_THE_DUST = 46; -- ± -- BLADE_OF_DEATH = 47; -- + -- SILENCE_OF_THE_RAMS = 48; -- ± -- ALTANA_S_SORROW = 49; -- + -- A_LADY_S_HEART = 50; -- ± -- GHOSTS_OF_THE_PAST = 51; -- ± -- THE_FIRST_MEETING = 52; -- ± -- TRUE_STRENGTH = 53; -- ± -- THE_DOORMAN = 54; -- ± -- THE_TALEKEEPER_S_TRUTH = 55; -- ± -- THE_TALEKEEPER_S_GIFT = 56; -- ± -- DARK_LEGACY = 57; -- ± -- DARK_PUPPET = 58; -- ± -- BLADE_OF_EVIL = 59; -- ± -- AYAME_AND_KAEDE = 60; -- ± -- TRIAL_BY_EARTH = 61; -- ± -- A_TEST_OF_TRUE_LOVE = 62; -- ± -- LOVERS_IN_THE_DUSK = 63; -- ± -- WISH_UPON_A_STAR = 64; ECO_WARRIOR_BAS = 65; THE_WEIGHT_OF_YOUR_LIMITS = 66; SHOOT_FIRST_ASK_QUESTIONS_LATER = 67; INHERITANCE = 68; THE_WALLS_OF_YOUR_MIND = 69; ESCORT_FOR_HIRE_BASTOK = 70; A_DISCERNING_EYE_BASTOK = 71; TRIAL_SIZE_TRIAL_BY_EARTH = 72; -- + -- FADED_PROMISES = 73; BRYGID_THE_STYLIST_RETURNS = 74; -- ± -- OUT_OF_THE_DEPTHS = 75; ALL_BY_MYSELF = 76; A_QUESTION_OF_FAITH = 77; RETURN_OF_THE_DEPTHS = 78; TEAK_ME_TO_THE_STARS = 79; HYPER_ACTIVE = 80; THE_NAMING_GAME = 81; CHIPS = 82; BAIT_AND_SWITCH = 83; LURE_OF_THE_WILDCAT_BASTOK = 84; ACHIEVING_TRUE_POWER = 85; TOO_MANY_CHEFS = 86; A_PROPER_BURIAL = 87; FULLY_MENTAL_ALCHEMIST = 88; SYNERGUSTIC_PURSUITS = 89; THE_WONDROUS_WHATCHAMACALLIT = 90; ----------------------------------- -- Windurst - 2 ----------------------------------- HAT_IN_HAND = 0; -- + -- A_FEATHER_IN_ONE_S_CAP = 1; -- + -- A_CRISIS_IN_THE_MAKING = 2; -- + -- MAKING_AMENDS = 3; -- + -- MAKING_THE_GRADE = 4; -- + -- IN_A_PICKLE = 5; -- + -- WONDERING_MINSTREL = 6; -- + -- A_POSE_BY_ANY_OTHER_NAME = 7; -- + -- MAKING_AMENS = 8; -- + -- THE_MOONLIT_PATH = 9; -- + -- STAR_STRUCK = 10; -- ± -- BLAST_FROM_THE_PAST = 11; -- + -- A_SMUDGE_ON_ONE_S_RECORD = 12; -- ± -- CHASING_TALES = 13; -- + -- FOOD_FOR_THOUGHT = 14; -- + -- OVERNIGHT_DELIVERY = 15; -- + -- WATER_WAY_TO_GO = 16; -- + -- BLUE_RIBBON_BLUES = 17; -- + -- THE_ALL_NEW_C_3000 = 18; -- + -- THE_POSTMAN_ALWAYS_KO_S_TWICE = 19; -- + -- EARLY_BIRD_CATCHES_THE_BOOKWORM = 20; -- + -- CATCH_IT_IF_YOU_CAN = 21; -- + -- ALL_AT_SEA = 23; THE_ALL_NEW_C_2000 = 24; -- ± -- MIHGO_S_AMIGO = 25; -- + -- ROCK_RACKETTER = 26; -- + -- CHOCOBILIOUS = 27; -- + -- TEACHER_S_PET = 28; -- + -- REAP_WHAT_YOU_SOW = 29; -- + -- GLYPH_HANGER = 30; -- + -- THE_FANGED_ONE = 31; -- + -- CURSES_FOILED_AGAIN_1 = 32; -- + -- CURSES_FOILED_AGAIN_2 = 33; -- + -- MANDRAGORA_MAD = 34; -- + -- TO_BEE_OR_NOT_TO_BEE = 35; -- + -- TRUTH_JUSTICE_AND_THE_ONION_WAY = 36; -- + -- MAKING_HEADLINES = 37; -- + -- SCOOPED = 38; CREEPY_CRAWLIES = 39; -- + -- KNOW_ONE_S_ONIONS = 40; -- + -- INSPECTOR_S_GADGET = 41; -- + -- ONION_RINGS = 42; -- + -- A_GREETING_CARDIAN = 43; -- + -- LEGENDARY_PLAN_B = 44; -- + -- IN_A_STEW = 45; -- + -- LET_SLEEPING_DOGS_LIE = 46; CAN_CARDIANS_CRY = 47; -- + -- WONDER_WANDS = 48; -- + -- HEAVEN_CENT = 49; SAY_IT_WITH_FLOWERS = 50; -- + -- HOIST_THE_JELLY_ROGER = 51; -- + -- SOMETHING_FISHY = 52; -- + -- TO_CATCH_A_FALLIHG_STAR = 53; -- + -- PAYING_LIP_SERVICE = 60; -- + -- THE_AMAZIN_SCORPIO = 61; -- + -- TWINSTONE_BONDING = 62; -- + -- CURSES_FOILED_A_GOLEM = 63; -- + -- ACTING_IN_GOOD_FAITH = 64; -- ± -- FLOWER_CHILD = 65; -- ± -- THE_THREE_MAGI = 66; -- ± -- RECOLLECTIONS = 67; -- ± -- THE_ROOT_OF_THE_PROBLEM = 68; THE_TENSHODO_SHOWDOWN = 69; -- + -- AS_THICK_AS_THIEVES = 70; -- + -- HITTING_THE_MARQUISATE = 71; -- + -- SIN_HUNTING = 72; -- + -- FIRE_AND_BRIMSTONE = 73; -- + -- UNBRIDLED_PASSION = 74; -- + -- I_CAN_HEAR_A_RAINBOW = 75; -- + -- CRYING_OVER_ONIONS = 76; -- + -- WILD_CARD = 77; -- + -- THE_PROMISE = 78; -- + -- NOTHING_MATTERS = 79; TORAIMARAI_TURMOIL = 80; -- + -- THE_PUPPET_MASTER = 81; -- + -- CLASS_REUNION = 82; -- + -- CARBUNCLE_DEBACLE = 83; -- + -- ECO_WARRIOR_WIN = 84; -- + -- FROM_SAPLINGS_GROW = 85; ORASTERY_WOES = 86; BLOOD_AND_GLORY = 87; ESCORT_FOR_HIRE_WINDURST = 88; A_DISCERNING_EYE_WINDURST = 89; TUNING_IN = 90; TUNING_OUT = 91; ONE_GOOD_DEED = 92; WAKING_DREAMS = 93; -- + -- LURE_OF_THE_WILDCAT_WINDURST = 94; BABBAN_NY_MHEILLEA = 95; ----------------------------------- -- Jeuno - 3 ----------------------------------- CREST_OF_DAVOI = 0; -- + -- SAVE_MY_SISTER = 1; -- + -- A_CLOCK_MOST_DELICATE = 2; -- + -- SAVE_THE_CLOCK_TOWER = 3; -- + -- CHOCOBO_S_WOUNDS = 4; -- + -- SAVE_MY_SON = 5; -- + -- A_CANDLELIGHT_VIGIL = 6; -- + -- THE_WONDER_MAGIC_SET = 7; -- + -- THE_KIND_CARDIAN = 8; -- + -- YOUR_CRYSTAL_BALL = 9; -- + -- COLLECT_TARUT_CARDS = 10; -- + -- THE_OLD_MONUMENT = 11; -- + -- A_MINSTREL_IN_DESPAIR = 12; -- + -- RUBBISH_DAY = 13; -- + -- NEVER_TO_RETURN = 14; -- + -- COMMUNITY_SERVICE = 15; -- + -- COOK_S_PRIDE = 16; -- + -- TENSHODO_MEMBERSHIP = 17; -- + -- THE_LOST_CARDIAN = 18; -- + -- PATH_OF_THE_BEASTMASTER = 19; -- + -- PATH_OF_THE_BARD = 20; -- + -- THE_CLOCKMASTER = 21; -- + -- CANDLE_MAKING = 22; -- + -- CHILD_S_PLAY = 23; -- + -- NORTHWARD = 24; -- + -- THE_ANTIQUE_COLLECTOR = 25; -- + -- DEAL_WITH_TENSHODO = 26; -- + -- THE_GOBBIEBAG_PART_I = 27; -- + -- THE_GOBBIEBAG_PART_II = 28; -- + -- THE_GOBBIEBAG_PART_III = 29; -- + -- THE_GOBBIEBAG_PART_IV = 30; -- + -- MYSTERIES_OF_BEADEAUX_I = 31; -- + -- MYSTERIES_OF_BEADEAUX_II = 32; -- + -- MYSTERY_OF_FIRE = 33; MYSTERY_OF_WATER = 34; MYSTERY_OF_EARTH = 35; MYSTERY_OF_WIND = 36; MYSTERY_OF_ICE = 37; MYSTERY_OF_LIGHTNING = 38; MYSTERY_OF_LIGHT = 39; MYSTERY_OF_DARKNESS = 40; FISTFUL_OF_FURY = 41; -- + -- THE_GOBLIN_TAILOR = 42; -- + -- PRETTY_LITTLE_THINGS = 43; -- ± -- BORGHERTZ_S_WARRING_HANDS = 44; -- + -- BORGHERTZ_S_STRIKING_HANDS = 45; -- + -- BORGHERTZ_S_HEALING_HANDS = 46; -- + -- BORGHERTZ_S_SORCEROUS_HANDS = 47; -- + -- BORGHERTZ_S_VERMILLION_HANDS = 48; -- + -- BORGHERTZ_S_SNEAKY_HANDS = 49; -- + -- BORGHERTZ_S_STALWART_HANDS = 50; -- + -- BORGHERTZ_S_SHADOWY_HANDS = 51; -- + -- BORGHERTZ_S_WILD_HANDS = 52; -- + -- BORGHERTZ_S_HARMONIOUS_HANDS = 53; -- + -- BORGHERTZ_S_CHASING_HANDS = 54; -- + -- BORGHERTZ_S_LOYAL_HANDS = 55; -- + -- BORGHERTZ_S_LURKING_HANDS = 56; -- + -- BORGHERTZ_S_DRAGON_HANDS = 57; -- + -- BORGHERTZ_S_CALLING_HANDS = 58; -- + -- AXE_THE_COMPETITION = 59; WINGS_OF_GOLD = 60; -- ± -- SCATTERED_INTO_SHADOW = 61; -- ± -- A_NEW_DAWN = 62; PAINFUL_MEMORY = 63; -- + -- THE_REQUIEM = 64; -- + -- THE_CIRCLE_OF_TIME = 65; -- + -- SEARCHING_FOR_THE_RIGHT_WORDS = 66; BEAT_AROUND_THE_BUSHIN = 67; -- + -- DUCAL_HOSPITALITY = 68; IN_THE_MOOD_FOR_LOVE = 69; EMPTY_MEMORIES = 70; HOOK_LINE_AND_SINKER = 71; A_CHOCOBO_S_TALE = 72; A_REPUTATION_IN_RUINS = 73; THE_GOBBIEBAG_PART_V = 74; -- + -- THE_GOBBIEBAG_PART_VI = 75; -- + -- BEYOND_THE_SUN = 76; UNLISTED_QUALITIES = 77; GIRL_IN_THE_LOOKING_GLASS = 78; MIRROR_MIRROR = 79; -- + -- PAST_REFLECTIONS = 80; BLIGHTED_GLOOM = 81; BLESSED_RADIANCE = 82; MIRROR_IMAGES = 83; CHAMELEON_CAPERS = 84; REGAINING_TRUST = 85; STORMS_OF_FATE = 86; MIXED_SIGNALS = 87; SHADOWS_OF_THE_DEPARTED = 88; APOCALYPSE_NIGH = 89; LURE_OF_THE_WILDCAT_JEUNO = 90; -- ± -- THE_ROAD_TO_AHT_URHGAN = 91; -- + -- CHOCOBO_ON_THE_LOOSE = 92; THE_GOBBIEBAG_PART_VII = 93; -- + -- THE_GOBBIEBAG_PART_VIII = 94; -- + -- LAKESIDE_MINUET = 95; THE_UNFINISHED_WALTZ = 96; -- ± -- THE_ROAD_TO_DIVADOM = 97; COMEBACK_QUEEN = 98; A_FURIOUS_FINALE = 99; THE_MIRACULOUS_DALE = 100; CLASH_OF_THE_COMRADES = 101; UNLOCKING_A_MYTH_WARRIOR = 102; UNLOCKING_A_MYTH_MONK = 103; UNLOCKING_A_MYTH_WHITE_MAGE = 104; UNLOCKING_A_MYTH_BLACK_MAGE = 105; UNLOCKING_A_MYTH_RED_MAGE = 106; UNLOCKING_A_MYTH_THIEF = 107; UNLOCKING_A_MYTH_PALADIN = 108; UNLOCKING_A_MYTH_DARK_KNIGHT = 109; UNLOCKING_A_MYTH_BEASTMASTER = 110; UNLOCKING_A_MYTH_BARD = 111; UNLOCKING_A_MYTH_RANGER = 112; UNLOCKING_A_MYTH_SAMURAI = 113; UNLOCKING_A_MYTH_NINJA = 114; UNLOCKING_A_MYTH_DRAGOON = 115; UNLOCKING_A_MYTH_SUMMONER = 116; UNLOCKING_A_MYTH_BLUE_MAGE = 117; UNLOCKING_A_MYTH_CORSAIR = 118; UNLOCKING_A_MYTH_PUPPETMASTER = 119; UNLOCKING_A_MYTH_DANCER = 120; UNLOCKING_A_MYTH_SCHOLAR = 121; THE_GOBBIEBAG_PART_IX = 123; -- + -- THE_GOBBIEBAG_PART_X = 124; -- + -- IN_DEFIANT_CHALLENGE = 128; -- + -- ATOP_THE_HIGHEST_MOUNTAINS = 129; -- + -- WHENCE_BLOWS_THE_WIND = 130; -- + -- RIDING_ON_THE_CLOUDS = 131; -- + -- SHATTERING_STARS = 132; -- + -- NEW_WORLDS_AWAIT = 133; EXPANDING_HORIZONS = 134; BEYOND_THE_STARS = 135; DORMANT_POWERS_DISLODGED = 136; BEYOND_INFINITY = 137; A_TRIAL_IN_TANDEM = 160; A_TRIAL_IN_TANDEM_REDUX = 161; YET_ANOTHER_TRIAL_IN_TANDEM = 162; A_QUATERNARY_TRIAL_IN_TANDEM = 163; A_TRIAL_IN_TANDEM_REVISITED = 164; ALL_IN_THE_CARDS = 166; MARTIAL_MASTERY = 167; VW_OP_115_VALKURM_DUSTER = 168; VW_OP_118_BUBURIMU_SQUALL = 169; PRELUDE_TO_PUISSANCE = 170; ----------------------------------- -- Other Areas - 4 ----------------------------------- RYCHARDE_THE_CHEF = 0; -- + -- WAY_OF_THE_COOK = 1; -- + -- UNENDING_CHASE = 2; -- + -- HIS_NAME_IS_VALGEIR = 3; -- + -- EXPERTISE = 4; -- + -- THE_CLUE = 5; -- + -- THE_BASICS = 6; -- + -- ORLANDO_S_ANTIQUES = 7; -- + -- THE_SAND_CHARM = 8; -- + -- A_POTTER_S_PREFERENCE = 9; -- + -- THE_OLD_LADY = 10; -- + -- FISHERMAN_S_HEART = 11; DONATE_TO_RECYCLING = 16; -- + -- UNDER_THE_SEA = 17; -- + -- ONLY_THE_BEST = 18; -- + -- EN_EXPLORER_S_FOOTSTEPS = 19; -- + -- CARGO = 20; -- + -- THE_GIFT = 21; -- + -- THE_REAL_GIFT = 22; -- + -- THE_RESCUE = 23; -- + -- ELDER_MEMORIES = 24; -- + -- TEST_MY_METTLE = 25; INSIDE_THE_BELLY = 26; -- ± -- TRIAL_BY_LIGHTNING = 27; -- ± -- TRIAL_SIZE_TRIAL_BY_LIGHTNING = 28; -- + -- IT_S_RAINING_MANNEQUINS = 29; RECYCLING_RODS = 30; PICTURE_PERFECT = 31; WAKING_THE_BEAST = 32; SURVIVAL_OF_THE_WISEST = 33; A_HARD_DAY_S_KNIGHT = 64; X_MARKS_THE_SPOT = 65; A_BITTER_PAST = 66; THE_CALL_OF_THE_SEA = 67; PARADISE_SALVATION_AND_MAPS = 68; GO_GO_GOBMUFFIN = 69; THE_BIG_ONE = 70; FLY_HIGH = 71; UNFORGIVEN = 72; SECRETS_OF_OVENS_LOST = 73; PETALS_FOR_PARELBRIAUX = 74; ELDERLY_PURSUITS = 75; IN_THE_NAME_OF_SCIENCE = 76; BEHIND_THE_SMILE = 77; KNOCKING_ON_FORBIDDEN_DOORS = 78; CONFESSIONS_OF_A_BELLMAKER = 79; IN_SEARCH_OF_THE_TRUTH = 80; UNINVITED_GUESTS = 81; TANGO_WITH_A_TRACKER = 82; REQUIEM_OF_SIN = 83; VW_OP_026_TAVNAZIAN_TERRORS = 84; VW_OP_004_BIBIKI_BOMBARDMENT = 85; BOMBS_AWAY = 96; MITHRAN_DELICACIES = 97; GIVE_A_MOOGLE_A_BREAK = 100; THE_MOOGLE_PICNIC = 101; MOOGLE_IN_THE_WILD = 102; MISSIONARY_MOBLIN = 103; FOR_THE_BIRDS = 104; BETTER_THE_DEMON_YOU_KNOW = 105; AN_UNDERSTANDING_OVERLORD = 106; AN_AFFABLE_ADAMANTKING = 107; A_MORAL_MANIFEST = 108; A_GENEROUS_GENERAL = 109; RECORDS_OF_EMINENCE = 110; UNITY_CONCORD = 111; ----------------------------------- -- Outlands - 5 ----------------------------------- -- Kazham (1-15) THE_FIREBLOOM_TREE = 1; GREETINGS_TO_THE_GUARDIAN = 2; -- + -- A_QUESTION_OF_TASTE = 3; EVERYONES_GRUDGING = 4; YOU_CALL_THAT_A_KNIFE = 6; MISSIONARY_MAN = 7; -- ± -- GULLIBLES_TRAVELS = 8; -- + -- EVEN_MORE_GULLIBLES_TRAVELS = 9; -- + -- PERSONAL_HYGIENE = 10; -- + -- THE_OPO_OPO_AND_I = 11; -- + -- TRIAL_BY_FIRE = 12; -- ± -- CLOAK_AND_DAGGER = 13; A_DISCERNING_EYE_KAZHAM = 14; TRIAL_SIZE_TRIAL_BY_FIRE = 15; -- + -- -- Voidwatch (100-105) VOIDWATCH_OPS_BORDER_CROSSING = 100; VW_OP_054_ELSHIMO_LIST = 101; VW_OP_101_DETOUR_TO_ZEPWELL = 102; VW_OP_115_LI_TELOR_VARIANT = 103; SKYWARD_HO_VOIDWATCHER = 104; -- Norg (128-149) THE_SAHAGINS_KEY = 128; -- ± -- FORGE_YOUR_DESTINY = 129; -- ± -- BLACK_MARKET = 130; MAMA_MIA = 131; STOP_YOUR_WHINING = 132; -- + -- TRIAL_BY_WATER = 133; -- + -- EVERYONES_GRUDGE = 134; SECRET_OF_THE_DAMP_SCROLL = 135; -- ± -- THE_SAHAGINS_STASH = 136; -- + -- ITS_NOT_YOUR_VAULT = 137; -- + -- LIKE_A_SHINING_SUBLIGAR = 138; -- + -- LIKE_A_SHINING_LEGGINGS = 139; -- + -- THE_SACRED_KATANA = 140; -- ± -- YOMI_OKURI = 141; -- ± -- A_THIEF_IN_NORG = 142; -- ± -- TWENTY_IN_PIRATE_YEARS = 143; -- ± -- I_LL_TAKE_THE_BIG_BOX = 144; -- ± -- TRUE_WILL = 145; -- ± -- THE_POTENTIAL_WITHIN = 146; BUGI_SODEN = 147; TRIAL_SIZE_TRIAL_BY_WATER = 148; -- + -- AN_UNDYING_PLEDGE = 149; -- Misc (160-165) WRATH_OF_THE_OPO_OPOS = 160; WANDERING_SOULS = 161; SOUL_SEARCHING = 162; DIVINE_MIGHT = 163; -- ± -- DIVINE_MIGHT_REPEAT = 164; -- ± -- OPEN_SESAME = 165; -- Rabao (192-201) DONT_FORGET_THE_ANTIDOTE = 192; -- ± -- THE_MISSING_PIECE = 193; -- ± -- TRIAL_BY_WIND = 194; -- ± -- THE_KUFTAL_TOUR = 195; THE_IMMORTAL_LU_SHANG = 196; -- ± -- TRIAL_SIZE_TRIAL_BY_WIND = 197; -- ± -- CHASING_DREAMS = 199; -- CoP Quest THE_SEARCH_FOR_GOLDMANE = 200; -- CoP Quest INDOMITABLE_SPIRIT = 201; -- ± -- ----------------------------------- -- Aht Urhgan - 6 ----------------------------------- KEEPING_NOTES = 0; ARTS_AND_CRAFTS = 1; OLDUUM = 2; -- + -- GOT_IT_ALL = 3; -- + -- GET_THE_PICTURE = 4; AN_EMPTY_VESSEL = 5; -- + -- LUCK_OF_THE_DRAW = 6; -- ± -- NO_STRINGS_ATTACHED = 7; -- + -- FINDING_FAULTS = 8; GIVE_PEACE_A_CHANCE = 9; THE_ART_OF_WAR = 10; na = 11; A_TASTE_OF_HONEY = 12; SUCH_SWEET_SORROW = 13; FEAR_OF_THE_DARK_II = 14; -- + -- COOK_A_ROON = 15; THE_DIE_IS_CAST = 16; TWO_HORN_THE_SAVAGE = 17; TOTOROONS_TREASURE_HUNT = 18; WHAT_FRIENDS_ARE_FOR = 19; ROCK_BOTTOM = 20; BEGINNINGS = 21; OMENS = 22; TRANSFORMATIONS = 23; EQUIPED_FOR_ALL_OCCASIONS = 24; -- + -- NAVIGATING_THE_UNFRIENDLY_SEAS = 25; -- + -- AGAINST_ALL_ODDS = 26; THE_WAYWARD_AUTOMATION = 27; OPERATION_TEATIME = 28; PUPPETMASTER_BLUES = 29; MOMENT_OF_TRUTH = 30; THREE_MEN_AND_A_CLOSET = 31; -- + -- FIVE_SECONDS_OF_FAME = 32; DELIVERING_THE_GOODS = 61; -- + -- VANISHING_ACT = 62; -- + -- STRIKING_A_BALANCE = 63; NOT_MEANT_TO_BE = 64; -- + -- LED_ASTRAY = 65; RAT_RACE = 66; -- + -- THE_PRINCE_AND_THE_HOPPER = 67; VW_OP_050_AHT_URGAN_ASSAULT = 68; VW_OP_068_SUBTERRAINEAN_SKIRMISH= 69; AN_IMPERIAL_HEIST = 70; DUTIES_TASKS_AND_DEEDS = 71; FORGING_A_NEW_MYTH = 72; COMING_FULL_CIRCLE = 73; WAKING_THE_COLLOSSUS = 74; DIVINE_INTERFERANCE = 75; THE_RIDER_COMETH = 76; UNWAVERING_RESOLVE = 77; A_STYGIAN_PACT = 78; ----------------------------------- -- Crystal War - 7 ----------------------------------- LOST_IN_TRANSLOCATION = 0; MESSAGE_ON_THE_WINDS = 1; THE_WEEKLY_ADVENTURER = 2; HEALING_HERBS = 3; REDEEMING_ROCKS = 4; THE_DAWN_OF_DELECTABILITY = 5; A_LITTLE_KNOWLEDGE = 6; -- + -- THE_FIGHTING_FOURTH = 7; SNAKE_ON_THE_PLAINS = 8; -- + -- STEAMED_RAMS = 9; -- + -- SEEING_SPOTS = 10; -- + -- THE_FLIPSIDE_OF_THINGS = 11; BETTER_PART_OF_VALOR = 12; FIRES_OF_DISCONTENT = 13; HAMMERING_HEARTS = 14; GIFTS_OF_THE_GRIFFON = 15; CLAWS_OF_THE_GRIFFON = 16; THE_TIGRESS_STIRS = 17; -- + -- THE_TIGRESS_STRIKES = 18; LIGHT_IN_THE_DARKNESS = 19; BURDEN_OF_SUSPICION = 20; EVIL_AT_THE_INLET = 21; THE_FUMBLING_FRIAR = 22; REQUIEM_FOR_THE_DEPARTED = 23; BOY_AND_THE_BEAST = 24; WRATH_OF_THE_GRIFFON = 25; THE_LOST_BOOK = 26; KNOT_QUITE_THERE = 27; A_MANIFEST_PROBLEM = 28; BEANS_AHOY = 29; -- + -- BEAST_FROM_THE_EAST = 30; THE_SWARM = 31; ON_SABBATICAL = 32; DOWNWARD_HELIX = 33; SEEING_BLOOD_RED = 34; STORM_ON_THE_HORIZON = 35; FIRE_IN_THE_HOLE = 36; PERILS_OF_THE_GRIFFON = 37; IN_A_HAZE_OF_GLORY = 38; WHEN_ONE_MAN_IS_NOT_ENOUGH = 39; A_FEAST_FOR_GNATS = 40; SAY_IT_WITH_A_HANDBAG = 41; QUELLING_THE_STORM = 42; HONOR_UNDER_FIRE = 43; THE_PRICE_OF_VALOR = 44; BONDS_THAT_NEVER_DIE = 45; THE_LONG_MARCH_NORTH = 46; THE_FORBIDDEN_PATH = 47; A_JEWELERS_LAMENT = 48; BENEATH_THE_MASK = 49; WHAT_PRICE_LOYALTY = 50; SONGBIRDS_IN_A_SNOWSTORM = 51; BLOOD_OF_HEROES = 52; SINS_OF_THE_MOTHERS = 53; HOWL_FROM_THE_HEAVENS = 54; SUCCOR_TO_THE_SIDHE = 55; THE_YOUNG_AND_THE_THREADLESS = 56; SON_AND_FATHER = 57; THE_TRUTH_LIES_HID = 58; BONDS_OF_MYTHRIL = 59; CHASING_SHADOWS = 60; FACE_OF_THE_FUTURE = 61; MANIFEST_DESTINY = 62; AT_JOURNEYS_END = 63; HER_MEMORIES_HOMECOMING_QUEEN = 64; HER_MEMORIES_OLD_BEAN = 65; HER_MEMORIES_THE_FAUX_PAS = 66; HER_MEMORIES_THE_GRAVE_RESOLVE = 67; HER_MEMORIES_OPERATION_CUPID = 68; HER_MEMORIES_CARNELIAN_FOOTFALLS = 69; HER_MEMORIES_AZURE_FOOTFALLS = 70; HER_MEMORIES_VERDURE_FOOTFALLS = 71; HER_MEMORIES_OF_MALIGN_MALADIES = 72; GUARDIAN_OF_THE_VOID = 80; DRAFTED_BY_THE_DUCHY = 81; BATTLE_ON_A_NEW_FRONT = 82; VOIDWALKER_OP_126 = 83; A_CAIT_CALLS = 84; THE_TRUTH_IS_OUT_THERE = 85; REDRAFTED_BY_THE_DUCHY = 86; A_NEW_MENACE = 87; NO_REST_FOR_THE_WEARY = 88; A_WORLD_IN_FLUX = 89; BETWEEN_A_ROCK_AND_RIFT = 90; A_FAREWELL_TO_FELINES = 91; THIRD_TOUR_OF_DUCHY = 92; GLIMMER_OF_HOPE = 93; BRACE_FOR_THE_UNKNOWN = 94; PROVENANCE = 95; CRYSTAL_GUARDIAN = 96; ENDINGS_AND_BEGINNINGS = 97; AD_INFINITUM = 98; ----------------------------------- -- Abyssea - 8 ----------------------------------- -- For some reason these did not match dat file order, -- had to adjust IDs >120 after using @addquest CATERING_CAPERS = 0; GIFT_OF_LIGHT = 1; FEAR_OF_THE_DARK_III = 2; AN_EYE_FOR_REVENGE = 3; UNBREAK_HIS_HEART = 4; EXPLOSIVE_ENDEAVORS = 5; THE_ANGLING_ARMORER = 6; WATER_OF_LIFE = 7; OUT_OF_TOUCH = 8; LOST_MEMORIES = 9; HOPE_BLOOMS_ON_THE_BATTLEFIELD = 10; OF_MALNOURISHED_MARTELLOS = 11; ROSE_ON_THE_HEATH = 12; FULL_OF_HIMSELF_ALCHEMIST = 13; THE_WALKING_WOUNDED = 14; SHADY_BUSINESS_REDUX = 15; ADDLED_MIND_UNDYING_DREAMS = 16; THE_SOUL_OF_THE_MATTER = 17; SECRET_AGENT_MAN = 18; PLAYING_PAPARAZZI = 19; HIS_BOX_HIS_BELOVED = 20; WEAPONS_NOT_WORRIES = 21; CLEANSING_THE_CANYON = 22; SAVORY_SALVATION = 23; BRINGING_DOWN_THE_MOUNTAIN = 24; A_STERLING_SPECIMEN = 25; FOR_LOVE_OF_A_DAUGHTER = 26; SISTERS_IN_CRIME = 27; WHEN_GOOD_CARDIANS_GO_BAD = 28; TANGLING_WITH_TONGUE_TWISTERS = 29; A_WARD_TO_END_ALL_WARDS = 30; THE_BOXWATCHERS_BEHEST = 31; HIS_BRIDGE_HIS_BELOVED = 32; BAD_COMMUNICATION = 33; FAMILY_TIES = 34; AQUA_PURA = 35; AQUA_PURAGA = 36; WHITHER_THE_WHISKER = 37; SCATTERED_SHELLS_SCATTERED_MIND = 38; WAYWARD_WARES = 39; LOOKING_FOR_LOOKOUTS = 40; FLOWN_THE_COOP = 41; THREADBARE_TRIBULATIONS = 42; AN_OFFER_YOU_CANT_REFUSE = 43; SOMETHING_IN_THE_AIR = 44; AN_ACRIDIDAEN_ANODYNE = 45; HAZY_PROSPECTS = 46; FOR_WANT_OF_A_POT = 47; MISSING_IN_ACTION = 48; I_DREAM_OF_FLOWERS = 49; DESTINY_ODYSSEY = 50; UNIDENTIFIED_RESEARCH_OBJECT = 51; COOKBOOK_OF_HOPE_RESTORING = 52; SMOKE_OVER_THE_COAST = 53; SOIL_AND_GREEN = 54; DROPPING_THE_BOMB = 55; WANTED_MEDICAL_SUPPLIES = 56; VOICES_FROM_BEYOND = 57; BENEVOLENCE_LOST = 58; BRUGAIRES_AMBITION = 59; CHOCOBO_PANIC = 60; THE_EGG_ENTHUSIAST = 61; GETTING_LUCKY = 62; HER_FATHERS_LEGACY = 63; THE_MYSTERIOUS_HEAD_PATROL = 64; MASTER_MISSING_MASTER_MISSED = 65; THE_PERILS_OF_KORORO = 66; LET_THERE_BE_LIGHT = 67; LOOK_OUT_BELOW = 68; HOME_HOME_ON_THE_RANGE = 69; IMPERIAL_ESPIONAGE = 70; IMPERIAL_ESPIONAGE_II = 71; BOREAL_BLOSSOMS = 72; BROTHERS_IN_ARMS = 73; SCOUTS_ASTRAY = 74; FROZEN_FLAME_REDUX = 75; SLIP_SLIDIN_AWAY = 76; CLASSROOMS_WITHOUT_BORDERS = 77; THE_SECRET_INGREDIENT = 78; HELP_NOT_WANTED = 79; THE_TITUS_TOUCH = 80; SLACKING_SUBORDINATES = 81; MOTHERLY_LOVE = 82; LOOK_TO_THE_SKY = 83; THE_UNMARKED_TOMB = 84; PROOF_OF_THE_LION = 85; BRYGID_THE_STYLIST_STRIKES_BACK = 86; DOMINION_OP_01_ALTEPA = 87; DOMINION_OP_02_ALTEPA = 88; DOMINION_OP_03_ALTEPA = 89; DOMINION_OP_04_ALTEPA = 90; DOMINION_OP_05_ALTEPA = 91; DOMINION_OP_06_ALTEPA = 92; DOMINION_OP_07_ALTEPA = 93; DOMINION_OP_08_ALTEPA = 94; DOMINION_OP_09_ALTEPA = 95; DOMINION_OP_10_ALTEPA = 96; DOMINION_OP_11_ALTEPA = 97; DOMINION_OP_12_ALTEPA = 98; DOMINION_OP_13_ALTEPA = 99; DOMINION_OP_14_ALTEPA = 100; DOMINION_OP_01_ULEGUERAND = 101; DOMINION_OP_02_ULEGUERAND = 102; DOMINION_OP_03_ULEGUERAND = 103; DOMINION_OP_04_ULEGUERAND = 104; DOMINION_OP_05_ULEGUERAND = 105; DOMINION_OP_06_ULEGUERAND = 106; DOMINION_OP_07_ULEGUERAND = 107; DOMINION_OP_08_ULEGUERAND = 108; DOMINION_OP_09_ULEGUERAND = 109; DOMINION_OP_10_ULEGUERAND = 110; DOMINION_OP_11_ULEGUERAND = 111; DOMINION_OP_12_ULEGUERAND = 112; DOMINION_OP_13_ULEGUERAND = 113; DOMINION_OP_14_ULEGUERAND = 114; DOMINION_OP_01_GRAUBERG = 115; DOMINION_OP_02_GRAUBERG = 116; DOMINION_OP_03_GRAUBERG = 117; DOMINION_OP_04_GRAUBERG = 118; DOMINION_OP_05_GRAUBERG = 119; DOMINION_OP_06_GRAUBERG = 120; DOMINION_OP_07_GRAUBERG = 121; DOMINION_OP_08_GRAUBERG = 122; DOMINION_OP_09_GRAUBERG = 123; WARD_WARDEN_I_ATTOHWA = 124; WARD_WARDEN_I_MISAREAUX = 125; WARD_WARDEN_I_VUNKERL = 126; WARD_WARDEN_II_ATTOHWA = 127; WARD_WARDEN_II_MISAREAUX = 128; WARD_WARDEN_II_VUNKERL = 129; DESERT_RAIN_I_ATTOHWA = 130; DESERT_RAIN_I_MISAREAUX = 131; DESERT_RAIN_I_VUNKERL = 132; DESERT_RAIN_II_ATTOHWA = 133; DESERT_RAIN_II_MISAREAUX = 134; DESERT_RAIN_II_VUNKERL = 135; CRIMSON_CARPET_I_ATTOHWA = 136; CRIMSON_CARPET_I_MISAREAUX = 137; CRIMSON_CARPET_I_VUNKERL = 138; CRIMSON_CARPET_II_ATTOHWA = 139; CRIMSON_CARPET_II_MISAREAUX = 140; CRIMSON_CARPET_II_VUNKERL = 141; REFUEL_AND_REPLENISH_LA_THEINE = 142; REFUEL_AND_REPLENISH_KONSCHTAT = 143; REFUEL_AND_REPLENISH_TAHRONGI = 144; REFUEL_AND_REPLENISH_ATTOHWA = 145; REFUEL_AND_REPLENISH_MISAREAUX = 146; REFUEL_AND_REPLENISH_VUNKERL = 147; REFUEL_AND_REPLENISH_ALTEPA = 148; REFUEL_AND_REPLENISH_ULEGUERAND = 149; REFUEL_AND_REPLENISH_GRAUBERG = 150; A_MIGHTIER_MARTELLO_LA_THEINE = 151; A_MIGHTIER_MARTELLO_KONSCHTAT = 152; A_MIGHTIER_MARTELLO_TAHRONGI = 153; A_MIGHTIER_MARTELLO_ATTOHWA = 154; A_MIGHTIER_MARTELLO_MISAREAUX = 155; A_MIGHTIER_MARTELLO_VUNKERL = 156; A_MIGHTIER_MARTELLO_ALTEPA = 157; A_MIGHTIER_MARTELLO_ULEGUERAND = 158; A_MIGHTIER_MARTELLO_GRAUBERG = 159; A_JOURNEY_BEGINS = 160; -- + -- THE_TRUTH_BECKONS = 161; -- + -- DAWN_OF_DEATH = 162; A_GOLDSTRUCK_GIGAS = 163; TO_PASTE_A_PEISTE = 164; MEGADRILE_MENACE = 165; THE_FORBIDDEN_FRONTIER = 166; FIRST_CONTACT = 167; AN_OFFICER_AND_A_PIRATE = 168; HEART_OF_MADNESS = 169; TENUOUS_EXISTENCE = 170; CHAMPIONS_OF_ABYSSEA = 171; THE_BEAST_OF_BASTORE = 172; A_DELECTABLE_DEMON = 173; A_FLUTTERY_FIEND = 174; SCARS_OF_ABYSSEA = 175; A_BEAKED_BLUSTERER = 176; A_MAN_EATING_MITE = 177; AN_ULCEROUS_URAGNITE = 178; HEROES_OF_ABYSSEA = 179; A_SEA_DOGS_SUMMONS = 180; DEATH_AND_REBIRTH = 181; EMISSARIES_OF_GOD = 182; BENEATH_A_BLOOD_RED_SKY = 183; THE_WYRM_GOD = 184; MEANWHILE_BACK_ON_ABYSSEA = 185; A_MOONLIGHT_REQUITE = 186; DOMINION_OP_10_GRAUBERG = 187; DOMINION_OP_11_GRAUBERG = 188; DOMINION_OP_12_GRAUBERG = 189; DOMINION_OP_13_GRAUBERG = 190; DOMINION_OP_14_GRAUBERG = 191; ----------------------------------- -- Adoulin - 9 ----------------------------------- -- These also do not match the DAT file order, had -- discrepencies and swapped orders from the start. TWITHERYM_DUST = 0; TO_CATCH_A_PREDATOR = 1; EMPTY_NEST = 2; DONT_CLAM_UP_ON_ME_NOW = 5; HOP_TO_IT = 6; BOILING_OVER = 9; POISONING_THE_WELL = 10; UNSULLIED_LANDS = 12; NO_RIME_LIKE_THE_PRESENT = 16; A_GEOTHERMAL_EXPEDITION = 18; ENDEAVORING_TO_AWAKEN = 22; FORGING_NEW_BONDS = 23; LEGACIES_LOST_AND_FOUND = 24; DESTINYS_DEVICE = 25; GRANDDADDY_DEAREST = 26; WAYWARD_WAYPOINTS = 27; ONE_GOOD_TURN = 28; FAILURE_IS_NOT_AN_OPTION = 29; ORDER_UP = 30; IT_NEVER_GOES_OUT_OF_STYLE = 31; WATER_WATER_EVERYWHERE = 32; DIRT_CHEAP = 33; FLOWER_POWER = 34; ELEMENTARY_MY_DEAR_SYLVIE = 35; FOR_WHOM_THE_BELL_TOLLS = 36; THE_BLOODLINE_OF_ZACARIAH = 37; THE_COMMUNION = 38; FLAVORS_OF_OUR_LIVES = 46; WESTERN_WAYPOINTS_HO = 50; WESEASTERN_WAYPOINTS_HO = 51; GRIND_TO_SAWDUST = 53; BREAKING_THE_ICE = 54; IM_ON_A_BOAT = 55; A_STONES_THROW_AWAY = 56; HIDE_AND_GO_PEAK = 57; THE_WHOLE_PLACE_IS_ABUZZ = 58; OROBON_APPETIT = 59; TALK_ABOUT_WRINKLY_SKIN = 60; NO_LOVE_LOST = 61; DID_YOU_FEEL_THAT = 62; DONT_EVER_LEAF_ME = 70; KEEP_YOUR_BLOOMERS_ON_ERISA = 71; SCAREDYCATS = 72; RAPTOR_RAPTURE = 73; EXOTIC_DELICACIES = 74; -- + -- A_PIONEERS_BEST_IMAGINARY_FRIEND= 75; -- + -- HUNGER_STRIKES = 76; -- + -- THE_OLD_MAN_AND_THE_HARPOON = 77; -- + -- A_CERTAIN_SUBSTITUTE_PATROLMAN = 78; -- + -- IT_SETS_MY_HEART_AFLUTTER = 79; TRANSPORTING = 82; THE_STARVING = 84; -- + -- FERTILE_GROUND = 85; ALWAYS_MORE_QUOTH_THE_RAVENOUS = 88; -- + -- MEGALOMANIAC = 89; THE_LONGEST_WAY_ROUND = 91; A_GOOD_PAIR_OF_CROCS = 93; CAFETERIA = 94; A_SHOT_IN_THE_DARK = 96; OPEN_THE_FLOODGATES = 100; NO_LAUGHING_MATTER = 102; ALL_THE_WAY_TO_THE_BANK = 103; TO_LAUGH_IS_TO_LOVE = 104; A_BARREL_OF_LAUGHS = 105; VEGETABLE_VEGETABLE_REVOLUTION = 108; VEGETABLE_VEGETABLE_EVOLUTION = 109; VEGETABLE_VEGETABLE_CRISIS = 110; VEGETABLE_VEGETABLE_FRUSTRATION = 111; A_THIRST_FOR_THE_AGES = 114; A_THIRST_FOR_THE_EONS = 115; A_THIRST_FOR_ETERNITY = 116; A_THIRST_BEFORE_TIME = 117; DANCES_WITH_LUOPANS = 118; CHILDREN_OF_THE_RUNE = 119; FLOWERS_FOR_SVENJA = 120; THORN_IN_THE_SIDE = 121; DO_NOT_GO_INTO_THE_LIGHT = 122; VELKKOVERT_OPERATIONS = 123; HYPOCRITICAL_OATH = 124; THE_GOOD_THE_BAD_THE_CLEMENT = 125; LERENES_LAMENT = 126; THE_SECRET_TO_SUCCESS = 127; NO_MERCY_FOR_THE_WICKED = 128; MISTRESS_OF_CEREMONIES = 129; SAVED_BY_THE_BELL = 131; QUIESCENCE = 132; SICK_AND_TIRED = 133; GEOMANCERRIFIC = 134; RUNE_FENCING_THE_NIGHT_AWAY = 135; THE_WEATHERSPOON_INQUISITION = 136; EYE_OF_THE_BEHOLDER = 137; THE_CURIOUS_CASE_OF_MELVIEN = 138; NOTSOCLEAN_BILL = 139; IN_THE_LAND_OF_THE_BLIND = 140; THE_WEATHERSPOON_WAR = 141; TREASURES_OF_THE_EARTH = 142; EPIPHANY = 143; ----------------------------------- -- Coalition - 10 ----------------------------------- -- Also slightly incongruent with DAT file order PROCURE_CEIZAK_BATTLEGROUNDS = 0; PROCURE_FORET_DE_HENNETIEL = 1; PROCURE_MORIMAR_BASALT_FIELDS = 2; PROCURE_YORCIA_WEALD = 3; PROCURE_MARJAMI_RAVINE = 4; PROCURE_KAMIHR_DRIFTS = 5; PROCURE_CIRDAS_CAVERNS = 6; PROCURE_OUTER_RAKAZNAR = 7; CLEAR_CEIZAK_BATTLEGROUNDS = 8; CLEAR_FORET_DE_HENNETIEL = 9; CLEAR_MORIMAR_BASALT_FIELDS = 10; CLEAR_YORCIA_WEALD = 11; CLEAR_MARJAMI_RAVINE = 12; CLEAR_KAMIHR_DRIFTS = 13; CLEAR_CIRDAS_CAVERNS = 14; CLEAR_OUTER_RAKAZNAR = 15; PROVIDE_FORET_DE_HENNETIEL = 16; PROVIDE_MORIMAR_BASALT_FIELDS = 17; PROVIDE_YORCIA_WEALD = 18; PROVIDE_MARJAMI_RAVINE = 19; PROVIDE_KAMIHR_DRIFTS = 20; DELIVER_FORET_DE_HENNETIEL = 21; DELIVER_MORIMAR_BASALT_FIELDS = 22; DELIVER_YORCIA_WEALD = 23; DELIVER_MARJAMI_RAVINE = 24; DELIVER_KAMIHR_DRIFTS = 25; SUPPORT_CEIZAK_BATTLEGROUNDS = 26; SUPPORT_FORET_DE_HENNETIEL = 27; SUPPORT_MORIMAR_BASALT_FIELDS = 28; SUPPORT_YORCIA_WEALD = 29; SUPPORT_MARJAMI_RAVINE = 30; SUPPORT_KAMIHR_DRIFTS = 31; GATHER_RALA_WATERWAYS = 32; GATHER_CEIZAK_BATTLEGROUNDS = 33; GATHER_YAHSE_HUNTING_GROUNDS = 34; GATHER_FORET_DE_HENNETIEL = 35; GATHER_MORIMAR_BASALT_FIELDS = 36; GATHER_YORCIA_WEALD = 37; GATHER_MARJAMI_RAVINE = 38; GATHER_KAMIHR_DRIFTS = 39; GATHER_SIH_GATES = 40; GATHER_MOH_GATES = 41; GATHER_CIRDAS_CAVERNS = 42; GATHER_DHO_GATES = 43; GATHER_WOH_GATES = 44; GATHER_OUTER_RAKAZNAR = 45; GATHER_RAKAZNAR_INNER_COURT = 46; -- GATHER = 47; -- Blank Gather: assignment SURVEY_CEIZAK_BATTLEGROUNDS = 48; SURVEY_FORET_DE_HENNETIEL = 49; SURVEY_MORIMAR_BASALT_FIELDS = 50; SURVEY_YORCIA_WEALD = 51; SURVEY_MARJAMI_RAVINE = 52; SURVEY_KAMIHR_DRIFTS = 53; SURVEY_SIH_GATES = 54; SURVEY_CIRDAS_CAVERNS = 55; SURVEY_DHO_GATES = 56; ANALYZE_FORET_DE_HENNETIEL = 57; ANALYZE_MORIMAR_BASALT_FIELDS = 58; ANALYZE_YORCIA_WEALD = 59; ANALYZE_MARJAMI_RAVINE = 60; ANALYZE_KAMIHR_DRIFTS = 61; ANALYZE_CIRDAS_CAVERNS = 62; ANALYZE_OUTER_RAKAZNAR = 63; PRESERVE_CEIZAK_BATTLEGROUNDS = 64; PRESERVE_YAHSE_HUNTING_GROUNDS = 65; PRESERVE_FORET_DE_HENNETIEL = 66; PRESERVE_MORIMAR_BASALT_FIELDS = 67; PRESERVE_YORCIA_WEALD = 68; PRESERVE_MARJAMI_RAVINE = 69; PRESERVE_KAMIHR_DRIFTS = 70; PRESERVE_CIRDAS_CAVERNS = 71; PRESERVE_OUTER_RAKAZNAR = 72; PATROL_RALA_WATERWAYS = 73; PATROL_SIH_GATES = 74; PATROL_MOH_GATES = 75; PATROL_CIRDAS_CAVERNS = 76; PATROL_DHO_GATES = 77; PATROL_WOH_GATES = 78; PATROL_OUTER_RAKAZNAR = 79; RECOVER_CEIZAK_BATTLEGROUNDS = 80; RECOVER_FORET_DE_HENNETIEL = 81; RECOVER_MORIMAR_BASALT_FIELDS = 82; RECOVER_YORCIA_WEALD = 83; RECOVER_MARJAMI_RAVINE = 84; RECOVER_KAMIHR_DRIFTS = 85; RESEARCH_RALA_WATERWAYS = 86; RESEARCH_CEIZAK_BATTLEGROUNDS = 87; RESEARCH_FORET_DE_HENNETIEL = 88; RESEARCH_MORIMAR_BASALT_FIELDS = 89; RESEARCH_YORCIA_WEALD = 90; RESEARCH_MARJAMI_RAVINE = 91; RESEARCH_KAMIHR_DRIFTS = 92; BOOST_FORET_DE_HENNETIEL = 93; BOOST_MARJAMI_RAVINE = 94; BOOST_KAMIHR_DRIFTS = 95;
gpl-3.0
Vadavim/jsr-darkstar
scripts/zones/Port_Jeuno/npcs/qm1.lua
14
2509
----------------------------------- -- Area: Port Jeuno -- NPC: ??? -- Finish Quest: Borghertz's Hands (AF Hands, Many job) -- @zone 246 -- @pos -51 8 -4 ----------------------------------- package.loaded["scripts/zones/Port_Jeuno/TextIDs"] = nil; package.loaded["scripts/globals/settings"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/shop"); require("scripts/globals/quests"); require("scripts/zones/Port_Jeuno/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) OldGauntlets = player:hasKeyItem(OLD_GAUNTLETS); ShadowFlames = player:hasKeyItem(SHADOW_FLAMES); BorghertzCS = player:getVar("BorghertzCS"); if (OldGauntlets == true and ShadowFlames == false and BorghertzCS == 1) then player:startEvent(0x0014); elseif (OldGauntlets == true and ShadowFlames == false and BorghertzCS == 2) then player:startEvent(0x0031); elseif (OldGauntlets == true and ShadowFlames == true) then player:startEvent(0x0030); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x0014 and option == 1) then player:setVar("BorghertzCS",2); elseif (csid == 0x0030) then NumQuest = 43 + player:getVar("BorghertzAlreadyActiveWithJob"); NumHands = 13960 + player:getVar("BorghertzAlreadyActiveWithJob"); if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,NumHands); else player:addItem(NumHands); player:messageSpecial(ITEM_OBTAINED,NumHands); player:delKeyItem(OLD_GAUNTLETS); player:delKeyItem(SHADOW_FLAMES); player:setVar("BorghertzCS",0); player:setVar("BorghertzAlreadyActiveWithJob",0); player:addFame(JEUNO,30); player:completeQuest(JEUNO,NumQuest); end end end;
gpl-3.0
zynjec/darkstar
scripts/globals/weaponskills/vidohunir.lua
10
1857
----------------------------------- -- Vidohunir -- Staff weapon skill -- Skill Level: N/A -- Lowers target's magic defense. Duration of effect varies with TP. Laevateinn: Aftermath effect varies with TP. -- Reduces enemy's magic defense by 10%. -- Available only after completing the Unlocking a Myth (Black Mage) quest. -- Aligned with the Breeze Gorget, Thunder Gorget, Aqua Gorget & Snow Gorget. -- Aligned with the Breeze Belt, Thunder Belt, Aqua Belt & Snow Belt. -- Element: Darkness -- Modifiers: INT:30% -- 100%TP 200%TP 300%TP -- 1.75 1.75 1.75 ----------------------------------- require("scripts/globals/aftermath") require("scripts/globals/magic") require("scripts/globals/settings") require("scripts/globals/status") require("scripts/globals/weaponskills") ----------------------------------- function onUseWeaponSkill(player, target, wsID, tp, primary, action, taChar) local params = {} params.ftp100 = 1.75 params.ftp200 = 1.75 params.ftp300 = 1.75 params.str_wsc = 0.0 params.dex_wsc = 0.0 params.vit_wsc = 0.0 params.agi_wsc = 0.0 params.int_wsc = 0.3 params.mnd_wsc = 0.0 params.chr_wsc = 0.0 params.ele = dsp.magic.ele.DARK params.skill = dsp.skill.STAFF params.includemab = true if USE_ADOULIN_WEAPON_SKILL_CHANGES then params.int_wsc = 0.8 end local damage, criticalHit, tpHits, extraHits = doMagicWeaponskill(player, target, wsID, params, tp, action, primary) if damage > 0 then local duration = tp / 1000 * 60 if not target:hasStatusEffect(dsp.effect.MAGIC_DEF_DOWN) then target:addStatusEffect(dsp.effect.MAGIC_DEF_DOWN, 10, 0, duration) end -- Apply aftermath dsp.aftermath.addStatusEffect(player, tp, dsp.slot.MAIN, dsp.aftermath.type.MYTHIC) end return tpHits, extraHits, criticalHit, damage end
gpl-3.0
hedgewars/hw
share/hedgewars/Data/Scripts/RopeKnocking.lua
1
11949
HedgewarsScriptLoad("/Scripts/Locale.lua") HedgewarsScriptLoad("/Scripts/Utils.lua") local hhs = {} local deadHogs = {} local missionWon = nil local endTimer = 1000 local hogsKilled = 0 local totalEnemies = 0 local finishTime local playerFail = false local ropeGear = nil local endGameCalled = false local missionEndHandled = false local valkyriesTimer = -1 local valkyriesDuration = 20000 local timeBonus = 6000 local killBonus = 6000 local playValkyries = false local extraTime local playerTeamName local missionName = loc("Rope-knocking Challenge") -- Mission type: -- 0 = none (no special handling) -- 1 = challenge (saves mission vars) local missionType = 1 local function getKillScore() return div(hogsKilled * killBonus, totalEnemies) end local function protectEnemies() -- Protect enemy hogs for i=1, totalEnemies do if hhs[i] and GetHealth(hhs[i]) then SetEffect(hhs[i], heInvulnerable, 1) SetEffect(hhs[i], heResurrectable, 1) end end end local function killStr(killed, total, score) if total == 16 then return string.format(loc("You have killed %d of 16 hedgehogs (+%d points)."), killed, score) else return string.format(loc("You have killed %d of %d hedgehogs (+%d points)."), killed, total, score) end end local function gameOver() StopMusicSound(sndRideOfTheValkyries) valkyriesTimer = -1 missionWon = false SendStat(siGameResult, loc("Challenge over!")) local score = getKillScore() SendStat(siCustomAchievement, killStr(hogsKilled, totalEnemies, score)) SendStat(siPointType, "!POINTS") SendStat(siPlayerKills, tostring(score), playerTeamName) protectEnemies() if not endGameCalled then EndGame() endGameCalled = true end if missionType == 1 then -- Update highscore updateChallengeRecord("Highscore", score) end end local function victory(onVictory) missionWon = true local e = 0 if extraTime then e = extraTime end local totalTime = TurnTime + e * totalEnemies local completeTime = (totalTime - finishTime) / 1000 ShowMission(missionName, loc("Challenge completed!"), loc("Congratulations!") .. "|" .. string.format(loc("Completion time: %.2fs"), completeTime), 0, 0) PlaySound(sndHomerun) -- Protect player hog if hhs[0] and GetHealth(hhs[0]) then SetEffect(hhs[0], heInvulnerable, 1) SetEffect(hhs[0], heResurrectable, 1) end SendStat(siGameResult, loc("Challenge completed!")) local hogScore = getKillScore() local timeScore = div(finishTime * timeBonus, totalTime) local score = hogScore + timeScore SendStat(siCustomAchievement, killStr(hogsKilled, totalEnemies, hogScore)) SendStat(siCustomAchievement, string.format(loc("You have completed this challenge in %.2f s (+%d points)."), completeTime, timeScore)) SendStat(siPointType, "!POINTS") SendStat(siPlayerKills, tostring(score), playerTeamName) SetTeamLabel(playerTeamName, tostring(score)) SetTurnTimeLeft(MAX_TURN_TIME) if missionType == 1 then -- Update highscore updateChallengeRecord("Highscore", score) end if onVictory then onVictory() end end local function knockTaunt() local r = math.random(0,23) local taunt if r == 0 then taunt = loc("%s has been knocked out.") elseif r == 1 then taunt = loc("%s hit the ground.") elseif r == 2 then taunt = loc("%s splatted.") elseif r == 3 then taunt = loc("%s was smashed.") elseif r == 4 then taunt = loc("%s felt unstable.") elseif r == 5 then taunt = loc("%s exploded.") elseif r == 6 then taunt = loc("%s fell from a high cliff.") elseif r == 7 then taunt = loc("%s goes the way of the lemming.") elseif r == 8 then taunt = loc("%s was knocked away.") elseif r == 9 then taunt = loc("%s was really unlucky.") elseif r == 10 then taunt = loc("%s felt victim to rope-knocking.") elseif r == 11 then taunt = loc("%s had no chance.") elseif r == 12 then taunt = loc("%s was a good target.") elseif r == 13 then taunt = loc("%s spawned at a really bad position.") elseif r == 14 then taunt = loc("%s was doomed from the beginning.") elseif r == 15 then taunt = loc("%s has fallen victim to gravity.") elseif r == 16 then taunt = loc("%s hates Newton.") -- Isaac Newton elseif r == 17 then taunt = loc("%s had it coming.") elseif r == 18 then taunt = loc("%s is eliminated!") elseif r == 19 then taunt = loc("%s fell too fast.") elseif r == 20 then taunt = loc("%s flew like a rock.") elseif r == 21 then taunt = loc("%s stumbled.") elseif r == 22 then taunt = loc("%s was shoved away.") elseif r == 23 then taunt = loc("%s didn't expect that.") end return taunt end local function declareEnemyKilled(gear, onVictory) if deadHogs[gear] or playerFail then return end deadHogs[gear] = true hogsKilled = hogsKilled + 1 -- Award extra time, if available if extraTime and extraTime ~= 0 then SetTurnTimeLeft(TurnTimeLeft + extraTime) AddCaption(string.format(loc("+%d seconds!"), div(extraTime, 1000)), 0xFFFFFFFF, capgrpMessage2) end SetTeamLabel(playerTeamName, tostring(getKillScore())) if hogsKilled == totalEnemies - 1 then if playValkyries then PlayMusicSound(sndRideOfTheValkyries) valkyriesTimer = valkyriesDuration end elseif hogsKilled == totalEnemies then finishTime = TurnTimeLeft victory(onVictory) end end --[[ RopeKnocking function! This creates a rope-knocking challenge. The player spawns with one hog and a rope and must kill all other hogs by rope-knocking before the time runs out. The player wins points for each kill and gets a time bonus for killing all enemies. params is a table with all the required parameters. Fields of the params table: MANDATORY: - map: Map name - theme: Theme name - turnTime: Turn time - playerTeam: Player team info: { x, y: Start position faceLeft: If true, hog faces left } - enemyTeams: Table of enemy team tables. each enemy team table has this format: { name: Team name flag: Flag hogs: Hogs table: { x, y: Position faceLeft: If true, hog faces left hat: Hat name name: Hog name } } OPTIONAL: - missionName: Mission name - missionType: 0: None/other: No special handling 1: Challenge: Will save mission variables at end (default) - killBonus: Score for killing all hogs (one hog scores ca. (killBonus/<number of enemies)) (default: 6000) - timeBonus: Maximum theoretically possible time bonus (default: 6000) - gameFlags: List of game flags, if you want to set your own - extraTime: Extra time awarded for each kill, in milliseconds (default: 0) - valkyries: If true, play "Ride of the Valkyries" at final enemy (default: false) - onGameInit: Custom onGameInit callback - onGameStart: Custom onGameStart callback - onVictory: Function that is called when the mission is won. Hint: Use onGameInit and onGameStart to place custom gears and girders Hint: Use onVictory to save campaign variables if using this in a campaign ]] function RopeKnocking(params) if params.missionName then missionName = params.missionName end if params.extraTime then extraTime = params.extraTime end if params.valkyries then playValkyries = params.valkyries end if params.missionType then missionType = params.missionType end if params.killBonus then killBonus = params.killBonus end if params.timeBonus then timeBonus = params.timeBonus end _G.onGameInit = function() if params.gameFlags then for g=1, #params.gameFlags do EnableGameFlags(params.gameFlags[g]) end end EnableGameFlags(gfBorder, gfSolidLand) TurnTime = params.turnTime Delay = 500 Map = params.map Theme = params.theme -- Disable Sudden Death WaterRise = 0 HealthDecrease = 0 CaseFreq = 0 MinesNum = 0 Explosives = 0 -- Player team playerTeamName = AddMissionTeam(-1) hhs[0] = AddMissionHog(1) SetGearPosition(hhs[0], params.playerTeam.x, params.playerTeam.y) if params.playerTeam.faceLeft == true then HogTurnLeft(hhs[0], true) end -- Enemy teams for t=1, #params.enemyTeams do local team = params.enemyTeams[t] params.enemyTeams[t].name = AddTeam(team.name, -2, "Simple", "Tank", "Default_qau", team.flag) for h=1, #team.hogs do local hogData = team.hogs[h] local name = hogData.name local hat = hogData.hat if not hat then hat = "NoHat" end local hog = AddHog(name, 0, 1, hat) SetGearPosition(hog, hogData.x, hogData.y) if hogData.faceLeft == true then HogTurnLeft(hog, true) end table.insert(hhs, hog) totalEnemies = totalEnemies + 1 end end if params.onGameInit then params.onGameInit() end end _G.onGameStart = function() SendHealthStatsOff() local timeTxt = "" local displayTime = 4000 if extraTime and extraTime ~= 0 then timeTxt = string.format(loc("For each kill you win %d seconds."), div(extraTime, 1000)) displayTime = 5000 end local recordInfo = getReadableChallengeRecord("Highscore") if recordInfo == nil then recordInfo = "" else recordInfo = "|" .. recordInfo end ShowMission( missionName, loc("Challenge"), loc("Use the rope to knock your enemies to their doom.") .. "|" .. loc("Finish this challenge as fast as possible to earn bonus points.") .. "|" .. timeTxt .. recordInfo, -amRope, displayTime) SetTeamLabel(playerTeamName, "0") if params.onGameStart then params.onGameStart() end end _G.onGameTick = function() if (TurnTimeLeft == 1) and (missionWon == nil) then PlaySound(sndBoring, CurrentHedgehog) gameOver() end if missionWon ~= nil then endTimer = endTimer - 1 if endTimer == 1 then if not endGameCalled then EndGame() endGameCalled = true end end if not missionEndHandled then if missionWon == true then AddCaption(loc("Victory!"), 0xFFFFFFFF, capgrpGameState) if missionType == 1 then SaveMissionVar("Won", "true") end else AddCaption(loc("Challenge over!"), 0xFFFFFFFF, capgrpGameState) end missionEndHandled = true end end end _G.onGameTick20 = function() if (valkyriesTimer > 0) then valkyriesTimer = valkyriesTimer - 20 if valkyriesTimer <= 0 then StopMusicSound(sndRideOfTheValkyries) end end local drown = (hhs[0]) and (band(GetState(hhs[0]), gstDrowning) ~= 0) if drown and missionWon == nil then -- Player hog drowns playerFail = true return end for i=1, totalEnemies do local hog = hhs[i] drown = (hog) and (not deadHogs[hog]) and (band(GetState(hhs[i]), gstDrowning) ~= 0) if drown then declareEnemyKilled(hog, params.onVictory) end end if ropeGear and not missionWon and band(GetState(ropeGear), gstCollision) ~= 0 then -- Hide mission on first rope attach HideMission() end end _G.onGearDamage = function(gear, damage) if gear == hhs[0] then -- Player hog hurts itself playerFail = true StopMusicSound(sndRideOfTheValkyries) valkyriesTimer = -1 protectEnemies() end if gear ~= hhs[0] and GetGearType(gear) == gtHedgehog and not deadHogs[gear] and missionWon == nil and playerFail == false then -- Enemy hog took damage AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false) DeleteGear(gear) PlaySound(sndExplosion) AddCaption(string.format(knockTaunt(), GetHogName(gear)), 0xFFFFFFFF, capgrpMessage) declareEnemyKilled(gear, params.onVictory) end end _G.onGearAdd = function(gear) if GetGearType(gear) == gtRope then ropeGear = gear end end _G.onGearDelete = function(gear) if (gear == hhs[0]) and (missionWon == nil) then playerFail = true gameOver() end if GetGearType(gear) == gtHedgehog and gear ~= hhs[0] and not deadHogs[gear] then declareEnemyKilled(gear, params.onVictory) end if GetGearType(gear) == gtRope then ropeGear = nil end end if params.onAmmoStoreInit then _G.onAmmoStoreInit = params.onAmmoStoreInit else _G.onAmmoStoreInit = function() SetAmmo(amRope, 9, 0, 0, 0) end _G.onNewTurn = function() SetWeapon(amRope) end end end
gpl-2.0
Colettechan/darkstar
scripts/zones/King_Ranperres_Tomb/Zone.lua
13
2309
----------------------------------- -- -- Zone: King_Ranperres_Tomb (190) -- ----------------------------------- package.loaded["scripts/zones/King_Ranperres_Tomb/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/zone"); require("scripts/zones/King_Ranperres_Tomb/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) local tomes = {17555963,17555964,17555965,17555966}; SetGroundsTome(tomes); zone:registerRegion(1,-84.302,6.5,-120.997,-77,7.5,-114); -- Used for stairs teleport -85.1,7,-119.9 -- Vrtra SetRespawnTime(17555890, 86400, 259200); UpdateTreasureSpawnPoint(17555951); end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) local cs = -1; if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then player:setPos(242.012,5.305,340.059,121); end return cs; end; ----------------------------------- -- onConquestUpdate ----------------------------------- function onConquestUpdate(zone, updatetype) local players = zone:getPlayers(); for name, player in pairs(players) do conquestUpdate(zone, player, updatetype, CONQUEST_BASE); end end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) if (region:GetRegionID() == 1) then player:startEvent(0x0009); end end; ----------------------------------- -- onRegionLeave ----------------------------------- function onRegionLeave(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
dkogan/notion-scripts
statusd/statusd_cpufreq.lua
2
1189
-- statusd_cpufreq.lua -- -- Public domain -- -- Use the key "cpufreq_[KMG]" to get the current CPU frequency in -- K/M/GHz, according to /sys/devices/system/cpu/cpuX/cpufreq/. (This -- has the advantage of being a much "rounder" number than the one in -- /proc/cpuinfo, as provided by statusd_cpuspeed.lua.) -- -- The "cpu" option to the statusd settings for cpufreq modifies which -- cpu we look at. local defaults={ update_interval=2*1000, cpu=0 } local settings=table.join(statusd.get_config("cpufreq"), defaults) function get_cpufreq() local f=io.open('/sys/devices/system/cpu/cpu'.. settings.cpu ..'/cpufreq/scaling_cur_freq') local cpufreq_K = f:read('*a') f:close() local cpufreq_M = cpufreq_K / 1000 local cpufreq_G = cpufreq_M / 1000 return tostring(cpufreq_K), tostring(cpufreq_M), tostring(cpufreq_G) end function update_cpufreq() local cpufreq_K, cpufreq_M, cpufreq_G = get_cpufreq() statusd.inform("cpufreq_K", cpufreq_K) statusd.inform("cpufreq_M", cpufreq_M) statusd.inform("cpufreq_G", cpufreq_G) cpufreq_timer:set(settings.update_interval, update_cpufreq) end cpufreq_timer = statusd.create_timer() update_cpufreq()
gpl-3.0
Colettechan/darkstar
scripts/zones/Bibiki_Bay/npcs/qm1.lua
13
1380
----------------------------------- -- Area: Bibiki Bay -- NPC: ??? (qm1) -- Notes: Used to spawn Shen -- @pos -115.108 0.300 -724.664 4 ----------------------------------- package.loaded["scripts/zones/Bibiki_Bay/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Bibiki_Bay/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) local Shen = 16793859; -- Trade Shrimp Lantern if (GetMobAction(Shen) == 0 and trade:hasItemQty(1823,1) and trade:getItemCount() == 1) then player:tradeComplete(); SpawnMob(Shen,180):updateClaim(player); SpawnMob(Shen+1,180):updateClaim(player); SpawnMob(Shen+2,180):updateClaim(player); end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:messageSpecial(NOTHING_OUT_OF_ORDINARY); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
tsdfsetatata/xserver
config/server/Guidecondition.lua
1
3437
local Guidecondition = { [510101] = { ['ID'] = 510101, --索引 ['targetid'] = 1, --引导的id(支线触发1—50)(主线触发51—70)(等级触发71—90)(功能触发91-) ['Tasktype'] = 2, --0功能1-主线2-支线 ['Level'] = 0, --等级触发引导 ['EquipId'] = 0, --必需拥有装备ID ['MaterialId'] = 0, --必需拥有道具ID ['Num'] = 0, --必需拥有个数 ['PartnerNum'] = 0, --上阵伙伴数量 ['FunctionID'] = 0 --功能ID }, [510102] = { ['ID'] = 510102, ['targetid'] = 2, ['Tasktype'] = 2, ['Level'] = 0, ['EquipId'] = 263100001, ['MaterialId'] = 201061001, ['Num'] = 1, ['PartnerNum'] = 0, ['FunctionID'] = 0 }, [510103] = { ['ID'] = 510103, ['targetid'] = 3, ['Tasktype'] = 2, ['Level'] = 0, ['EquipId'] = 0, ['MaterialId'] = 0, ['Num'] = 0, ['PartnerNum'] = 0, ['FunctionID'] = 0 }, [510104] = { ['ID'] = 510104, ['targetid'] = 4, ['Tasktype'] = 2, ['Level'] = 0, ['EquipId'] = 0, ['MaterialId'] = 0, ['Num'] = 0, ['PartnerNum'] = 0, ['FunctionID'] = 0 }, [510105] = { ['ID'] = 510105, ['targetid'] = 5, ['Tasktype'] = 2, ['Level'] = 0, ['EquipId'] = 0, ['MaterialId'] = 0, ['Num'] = 0, ['PartnerNum'] = 0, ['FunctionID'] = 0 }, [510106] = { ['ID'] = 510106, ['targetid'] = 6, ['Tasktype'] = 2, ['Level'] = 0, ['EquipId'] = 0, ['MaterialId'] = 0, ['Num'] = 0, ['PartnerNum'] = 0, ['FunctionID'] = 291040007 }, [510107] = { ['ID'] = 510107, ['targetid'] = 7, ['Tasktype'] = 2, ['Level'] = 0, ['EquipId'] = 0, ['MaterialId'] = 0, ['Num'] = 0, ['PartnerNum'] = 0, ['FunctionID'] = 0 }, [510108] = { ['ID'] = 510108, ['targetid'] = 8, ['Tasktype'] = 2, ['Level'] = 0, ['EquipId'] = 0, ['MaterialId'] = 0, ['Num'] = 0, ['PartnerNum'] = 0, ['FunctionID'] = 0 }, [510109] = { ['ID'] = 510109, ['targetid'] = 9, ['Tasktype'] = 2, ['Level'] = 0, ['EquipId'] = 0, ['MaterialId'] = 0, ['Num'] = 0, ['PartnerNum'] = 0, ['FunctionID'] = 0 }, [510110] = { ['ID'] = 510110, ['targetid'] = 10, ['Tasktype'] = 1, ['Level'] = 0, ['EquipId'] = 0, ['MaterialId'] = 0, ['Num'] = 0, ['PartnerNum'] = 0, ['FunctionID'] = 0 }, [510111] = { ['ID'] = 510111, ['targetid'] = 11, ['Tasktype'] = 2, ['Level'] = 0, ['EquipId'] = 0, ['MaterialId'] = 0, ['Num'] = 0, ['PartnerNum'] = 0, ['FunctionID'] = 0 }, [510171] = { ['ID'] = 510171, ['targetid'] = 71, ['Tasktype'] = 0, ['Level'] = 5, ['EquipId'] = 0, ['MaterialId'] = 0, ['Num'] = 0, ['PartnerNum'] = 0, ['FunctionID'] = 0 }, [510172] = { ['ID'] = 510172, ['targetid'] = 72, ['Tasktype'] = 0, ['Level'] = 0, ['EquipId'] = 0, ['MaterialId'] = 0, ['Num'] = 0, ['PartnerNum'] = 0, ['FunctionID'] = 291040008 }, [510173] = { ['ID'] = 510173, ['targetid'] = 73, ['Tasktype'] = 0, ['Level'] = 0, ['EquipId'] = 0, ['MaterialId'] = 0, ['Num'] = 0, ['PartnerNum'] = 0, ['FunctionID'] = 291010009 }, [510151] = { ['ID'] = 510151, ['targetid'] = 51, ['Tasktype'] = 1, ['Level'] = 0, ['EquipId'] = 0, ['MaterialId'] = 0, ['Num'] = 0, ['PartnerNum'] = 0, ['FunctionID'] = 0 } } return Guidecondition
gpl-3.0
Vadavim/jsr-darkstar
scripts/zones/Metalworks/npcs/_6lg.lua
14
1311
----------------------------------- -- Area: Metalworks -- Door: _6lg (Cornelia's Room) -- @pos 114 -20 -7 237 ----------------------------------- package.loaded["scripts/zones/Metalworks/TextIDs"] = nil; ----------------------------------- require("scripts/globals/missions"); require("scripts/zones/Metalworks/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:hasCompletedMission(BASTOK,ON_MY_WAY) and player:getVar("[B7-2]Cornelia") == 0) then player:startEvent(0x026e); else player:messageSpecial(ITS_LOCKED); end return 1; end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x026e) then player:setVar("[B7-2]Cornelia", 1); end end;
gpl-3.0
zynjec/darkstar
scripts/zones/Windurst_Waters/npcs/Gantineux.lua
11
2047
----------------------------------- -- Area: Windurst Waters -- NPC: Gantineux -- Starts Quest: Acting in Good Faith -- !pos -83 -9 3 238 ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/shop"); require("scripts/globals/quests"); local ID = require("scripts/zones/Windurst_Waters/IDs"); ----------------------------------- function onTrade(player,npc,trade) end; function onTrigger(player,npc) ActingInGoodFaith = player:getQuestStatus(WINDURST,dsp.quest.id.windurst.ACTING_IN_GOOD_FAITH); if (ActingInGoodFaith == QUEST_AVAILABLE and player:getFameLevel(WINDURST) >= 4 and player:getMainLvl() >= 10) then player:startEvent(10019); -- Start quest "Acting in Good Faith" elseif (ActingInGoodFaith == QUEST_ACCEPTED) then if (player:hasKeyItem(dsp.ki.SPIRIT_INCENSE) == true) then player:startEvent(10020); -- During quest "Acting in Good Faith" (with Spirit Incense KI) elseif (player:hasKeyItem(dsp.ki.GANTINEUXS_LETTER) == true) then player:startEvent(10022); -- During quest "Acting in Good Faith" (with Gantineux's Letter) else player:startEvent(10021); -- During quest "Acting in Good Faith" (before Gantineux's Letter) end elseif (ActingInGoodFaith == QUEST_COMPLETED) then player:startEvent(10023); -- New standard dialog after "Acting in Good Faith" else player:startEvent(10018); -- Standard dialog end end; function onEventUpdate(player,csid,option) end; function onEventFinish(player,csid,option) if (csid == 10019 and option == 0) then player:addQuest(WINDURST,dsp.quest.id.windurst.ACTING_IN_GOOD_FAITH); player:addKeyItem(dsp.ki.SPIRIT_INCENSE); player:messageSpecial(ID.text.KEYITEM_OBTAINED,dsp.ki.SPIRIT_INCENSE); elseif (csid == 10021) then player:addKeyItem(dsp.ki.GANTINEUXS_LETTER); player:messageSpecial(ID.text.KEYITEM_OBTAINED,dsp.ki.GANTINEUXS_LETTER); end end;
gpl-3.0
Vadavim/jsr-darkstar
scripts/zones/The_Garden_of_RuHmet/mobs/Kf_ghrah_whm.lua
23
1894
----------------------------------- -- Area: Grand Palace of Hu'Xzoi -- MOB: Kf'ghrah WHM ----------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); -- no spells are currently set due to lack of info ----------------------------------- -- onMobSpawn -- Set core Skin and mob elemental bonus ----------------------------------- function onMobSpawn(mob) mob:AnimationSub(0); mob:setLocalVar("roamTime", os.time()); mob:setModelId(1167); -- light end; ----------------------------------- -- onMobRoam -- AutochangeForm ----------------------------------- function onMobRoam(mob) local roamTime = mob:getLocalVar("roamTime"); local roamForm; if (os.time() - roamTime > 60) then roamForm = math.random(1,3) -- forms 2 and 3 are spider and bird; can change forms at will if (roamForm == 1) then roamForm = 0; -- We don't want form 1 as that's humanoid - make it 0 for ball end; mob:AnimationSub(roamForm); mob:setLocalVar("roamTime", os.time()); end; end; ----------------------------------- -- onMobEngaged ----------------------------------- function onMobEngaged(mob,target) end; ----------------------------------- -- onMobFight -- Free form change between ball, spider, and bird. ----------------------------------- function onMobFight(mob,target) local changeTime = mob:getLocalVar("changeTime"); local battleForm; if (mob:getBattleTime() - changeTime > 60) then battleForm = math.random(1,3) -- same deal as above if (battleForm == 1) then battleForm = 0; end; mob:AnimationSub(battleForm); mob:setLocalVar("changeTime", mob:getBattleTime()); end; end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob, player, isKiller) end;
gpl-3.0
kulla/mfnf-lua-scripts
src/Node.lua
1
1749
local Node = {} Node.__index = Node function Node:new() return setmetatable({parent = nil, children = {}}, Node) end function Node:add_child(child) self.children[#self.children + 1] = child child.parent = self end function Node:root() if self.parent then return self.parent:root() else return self end end function Node:last_child() return self.children[#self.children] end function Node:level() return (self.parent and self.parent:level() + 1) or 0 end function Node:iter() -- Returns an iterator which returns the tree iterator for each child. function iter_child_iterators() local next_child, _, i = ipairs(self.children) local child = nil return function() i, child = next_child(self.children, i) if child then return child:iter() else return nil end end end local next_child_iterator = nil local child_iterator = nil -- The actual iterator return function() if next_child_iterator then if child_iterator then local result = child_iterator() if result then return result else child_iterator = next_child_iterator() if child_iterator then return child_iterator() end end end else -- Iterator is called for the first time next_child_iterator = iter_child_iterators() child_iterator = next_child_iterator() return self end end end function Node:find(predicate_fn) for node in self:iter() do if predicate_fn(node) then return node end end end function Node:find_parent(predicate_fn) if predicate_fn(self) then return self elseif self.parent then return self.parent:find_parent(predicate_fn) else return nil end end return Node
gpl-3.0
zynjec/darkstar
scripts/zones/Abyssea-Grauberg/npcs/Dominion_Tactician.lua
12
3893
----------------------------------- -- Area: Abyssea - Grauberg -- NPC: Dominion Tactician ----------------------------------- local ID = require("scripts/zones/Abyssea-Grauberg/IDs") require("scripts/globals/abyssea") ----------------------------------- function onTrade(player,npc,trade) end function onTrigger(player,npc) local DM = player:getDominionNotes() local Trophies = 0 -- Max all Trophy = 4294967295 sort out its bit mask later. player:startEvent(120, DM, 0, 0, 0, 0, Trophies) end function onEventUpdate(player,csid,option) end function onEventFinish(player,csid,option) local Price = 0 local TempItem = false local ItemID = 0 local aug1 = 0 local aug2 = 0 local aug3 = 0 local aug4 = 0 local a1 = 0 local a2 = 0 local a3 = 0 local a4 = 0 local v1 = 0 local v2 = 0 local v3 = 0 local v4 = 0 -- Spending Dominion Notes if option == 257 then -- Unkai Domaru Price = 1500 ItemID = 12039 elseif option == 258 then -- Petrify Screen Price = 300 TempItem = true ItemID = 5876 elseif option == 259 then -- Augmented Yataghan Price = 2500 ItemID = 16485 -- Work out augment selection via math.random -- (see Lower Jeuno Tenshodo Coffer script) elseif option == 513 then -- Inga Ningi Price = 1500 ItemID = 12040 elseif option == 514 then -- Terror Screen Price = 300 TempItem = true ItemID = 5877 elseif option == 515 then -- Augmented Doom Tabar Price = 2500 ItemID = 16660 -- Aug crap here elseif option == 769 then -- Lancer's Plackart Price = 1500 ItemID = 12041 elseif option == 770 then -- Amnesia Screen Price = 300 TempItem = true ItemID = 5878 elseif option == 771 then -- Augmented Yukitsugu Price = 2500 ItemID = 16971 -- Aug crap here elseif option == 1025 then -- Caller's Doublet Price = 1500 ItemID = 12042 elseif option == 1026 then -- Doom Screen Price = 300 TempItem = true ItemID = 5879 elseif option == 1281 then -- Mavi Mintan Price = 1500 ItemID = 12043 elseif option == 1282 then -- Poison Screen Price = 300 TempItem = true ItemID = 5880 elseif option == 1537 then -- Navarch's Frac Price = 1500 ItemID = 12044 elseif option == 1793 then -- Cirque Farsetto Price = 1500 ItemID = 12045 elseif option == 2049 then -- Charis Casaque Price = 1500 ItemID = 12046 elseif option == 2305 then -- Savant's Gown Price = 1500 ItemID = 12047 elseif option == 2561 then -- Incredescent Shade Price = 300 ItemID = 3295 elseif option == 2817 then -- Decredescent Shade Price = 300 ItemID = 3296 end if option > 256 and option < 2818 then if player:getDominionNotes() > Price then if TempItem then if player:addTempItem(ItemID,1) then player:delCurrency("dominion_note",Price) player:messageSpecial(ID.text.ITEM_OBTAINED,ItemID) else player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,ItemID) end else if player:addItem(ItemID,1,a1,v1,a2,v2,a3,v3,a4,v4) then player:delCurrency("dominion_note",Price) player:messageSpecial(ID.text.ITEM_OBTAINED,ItemID) else player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,ItemID) end end end end -- Trophy trades for gear -- if option == 65796 then -- . -- elseif option == -- . -- end end
gpl-3.0
Colettechan/darkstar
scripts/globals/items/crawler_egg.lua
18
1180
----------------------------------------- -- ID: 4357 -- Item: crawler_egg -- Food Effect: 5Min, All Races ----------------------------------------- -- Health 10 -- Magic 10 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,300,4357); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_HP, 10); target:addMod(MOD_MP, 10); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_HP, 10); target:delMod(MOD_MP, 10); end;
gpl-3.0
Colettechan/darkstar
scripts/globals/items/persikos.lua
18
1174
----------------------------------------- -- ID: 4274 -- Item: persikos -- Food Effect: 5Min, All Races ----------------------------------------- -- Agility -7 -- Intelligence 5 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,300,4274); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_AGI, -7); target:addMod(MOD_INT, 5); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_AGI, -7); target:delMod(MOD_INT, 5); end;
gpl-3.0
Stanzilla/clink
clink/test/test.lua
4
8243
-- -- Copyright (c) 2012 Martin Ridgers -- -- 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. -- -------------------------------------------------------------------------------- clink.test = {} clink.test.functions = {} local all_passed = true local scripts_path = get_cwd() local test_fs_path = os.getenv("tmp") local temp_fs_list = {} local test_sid = 0 local test_id = 0 -------------------------------------------------------------------------------- local test_fs = { "file1", "file2", "case_map-1", "case_map_2", dir1 = { "only", "file1", "file2", }, dir2 = {} } -------------------------------------------------------------------------------- local function colour(x) if no_colour ~= 0 then return "" end if not x then x = -30 end return "\x1b["..tostring(30 + x).."m" end -------------------------------------------------------------------------------- local _print = print local function print(x) _print(tostring(x)..colour()) end -------------------------------------------------------------------------------- local function create_fs(path, fs_table) local cwd = get_cwd() mk_dir(path) ch_dir(path) if type(fs_table) ~= "table" then fs_table = { fs_table } end for k, v in pairs(fs_table) do if type(k) == "number" then io.open(tostring(v), "wb"):close() else create_fs(path.."/"..k, v) end end ch_dir(cwd) end -------------------------------------------------------------------------------- local function print_result(name, passed) result = colour(2).."pass" if not passed then result = colour(1).."fail" end local out = " "..test_sid.."."..test_id.." " local function cat(x) out = out..x end cat(name) for i = 1, 48 - #out, 1 do cat(".") end cat(result) print(out) end -------------------------------------------------------------------------------- local function call_readline_outer(input, flattened) if flattened == nil then flattened = {} end if type(input) == "table" then local output local matches for _, i in ipairs(input) do output, matches = call_readline_outer(i, flattened) end return output, matches, flattened end table.insert(flattened, input) local output, matches = call_readline(input) return output, matches, flattened end -------------------------------------------------------------------------------- local function test_runner(name, input, expected_out, expected_matches) test_id = test_id + 1 -- Skip test? if specific_test ~= "" then local should_run = false local tid = tostring(test_sid) if specific_test == tid then should_run = true end tid = tid.."."..tostring(test_id) if specific_test == tid then should_run = true end if not should_run then return end end clear_history() local passed = true local output, matches, input = call_readline_outer(input) -- Check Readline's output. if expected_out and expected_out ~= output then passed = false end -- Check Readline's generated matches. if expected_matches then table.sort(expected_matches) table.sort(matches) passed = passed and (#matches == #expected_matches) for _, i in ipairs(matches) do local found = false for _, j in ipairs(expected_matches) do if i == j then found = true break end end if found == false then passed = false break end end end print_result(name, passed) -- Output some context if the test failed. if not passed or verbose ~= 0 then print(colour(5).."\n -- Results --") print(colour(5).." Cwd: "..get_cwd()) for _, i in ipairs(input) do print(colour(5).." Input: "..i:gsub("\t", "<TAB>").."_") end print(colour(5).." Output: "..output.."_") for _, i in ipairs(matches) do print(colour(5).." Matches: "..i) end print(colour(5).."\n -- Expected --") print(colour(5).." Output: "..(expected_out or "<no_test>").."_") for _, i in ipairs(expected_matches or {}) do print(colour(5).." Matches: "..i) end print("") error("Test failed...") end end -------------------------------------------------------------------------------- function clink.test.test_fs(fs_table, secret) local path = test_fs_path..os.tmpname() create_fs(path, fs_table) table.insert(temp_fs_list, path) ch_dir(path) return path end -------------------------------------------------------------------------------- local function pcall_test_runner(name, input, out, matches) local ok = pcall(test_runner, name, input, out, matches) if not ok then all_passed = false end end -------------------------------------------------------------------------------- function clink.test.test_output(name, input, expected) pcall_test_runner(name, input, expected, nil) end -------------------------------------------------------------------------------- function clink.test.test_matches(name, input, expected) if not expected then expected = test_fs end pcall_test_runner(name, input, nil, expected) end -------------------------------------------------------------------------------- function clink.test.run() -- Create FS and flatten it's source table. test_fs_path = clink.test.test_fs(test_fs) local t = {} for k, v in pairs(test_fs) do if type(k) ~= "number" then v = k.."\\" end table.insert(t, v) end test_fs = t -- Fake the host to be cmd.exe (by default at least) clink.get_host_process = function() return "cmd.exe" end -- Copy clink table's functions so they can be restored. for n, f in pairs(clink) do if type(f) == "function" then clink.test.functions[n] = f end end local function run_test(str) test_sid = test_sid + 1 test_id = 0 ch_dir(test_fs_path) for n, f in pairs(clink.test.functions) do clink[n] = f end print(colour(6).."Tests: "..str) dofile(scripts_path.."/"..str..".lua") print("") if #temp_fs_list > 1 then for i = 2, #temp_fs_list, 1 do rm_dir(temp_fs_list[i]) end end end run_test("test_core") run_test("test_basic") run_test("test_quotes") run_test("test_dir") run_test("test_set") run_test("test_exec") run_test("test_env") run_test("test_args") run_test("test_merge") run_test("test_history") ch_dir(scripts_path) rm_dir(test_fs_path) return all_passed end -- vim: expandtab
gpl-3.0
Vadavim/jsr-darkstar
scripts/zones/Sea_Serpent_Grotto/npcs/qm2.lua
14
1491
----------------------------------- -- Area: Sea Serpent Grotto -- NPC: ??? Used for Norg quest "The Sahagin's Stash" -- @zone 176 -- @pos 295.276 27.129 213.043 ----------------------------------- package.loaded["scripts/zones/Sea_Serpent_Grotto/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/zones/Sea_Serpent_Grotto/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) SahaginStash = player:getQuestStatus(OUTLANDS,THE_SAHAGINS_STASH); if (SahaginStash == QUEST_ACCEPTED and player:hasKeyItem(296) == false) then player:startEvent(0x0001); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x0001) then player:addKeyItem(296); player:messageSpecial(KEYITEM_OBTAINED,296); end end;
gpl-3.0
Colettechan/darkstar
scripts/zones/Gusgen_Mines/npcs/_5ga.lua
13
1357
----------------------------------- -- Area: Gusgen Mines -- NPC: _5ga (Lever C) -- @pos 44 -40.561 -54.199 196 ----------------------------------- package.loaded["scripts/zones/Gusgen_Mines/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Gusgen_Mines/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) --local nID = npc:getID(); --printf("id: %u", nID); local Lever = npc:getID(); npc:openDoor(2); -- Lever animation if (GetNPCByID(Lever-6):getAnimation() == 9) then GetNPCByID(Lever-6):setAnimation(8);--open door C (_5g0) GetNPCByID(Lever-5):setAnimation(9);--close door B (_5g1) GetNPCByID(Lever-4):setAnimation(9);--close door A (_5g2) end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
Vadavim/jsr-darkstar
scripts/zones/Qufim_Island/npcs/Hieroglyphics.lua
7
2274
----------------------------------- -- Area: Qufim_Island -- NPC: Hieroglyphics -- Dynamis Qufim Entrance -- @pos 117 -10 133 172 118 ----------------------------------- package.loaded["scripts/zones/Qufim_Island/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/dynamis"); require("scripts/globals/missions"); require("scripts/zones/Qufim_Island/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:hasCompletedMission(COP,DARKNESS_NAMED) or FREE_COP_DYNAMIS == 1) then local firstDyna = 0; local realDay = os.time(); local dynaWaitxDay = player:getVar("dynaWaitxDay"); if (player:getMainLvl() < DYNA_LEVEL_MIN) then player:messageSpecial(PLAYERS_HAVE_NOT_REACHED_LEVEL,DYNA_LEVEL_MIN); elseif ((dynaWaitxDay + (BETWEEN_2DYNA_WAIT_TIME * 24 * 60 * 60)) < realDay or player:getVar("DynamisID") == GetServerVariable("[DynaQufim]UniqueID")) then player:startEvent(0x0003,9,0,0,BETWEEN_2DYNA_WAIT_TIME,32,VIAL_OF_SHROUDED_SAND,4236,4237); else dayRemaining = math.floor(((dynaWaitxDay + (BETWEEN_2DYNA_WAIT_TIME * 24 * 60 * 60)) - realDay)/3456); --printf("dayRemaining : %u",dayRemaining ); player:messageSpecial(YOU_CANNOT_ENTER_DYNAMIS,dayRemaining,8); end else player:messageSpecial(MYSTERIOUS_VOICE); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("updateRESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("finishRESULT: %u",option); if (csid == 0x0003 and option == 0) then player:setPos(-19,-17,104,253,41); end end;
gpl-3.0
adminerror/22222222
plugins/id.lua
17
4403
do local function user_print_name(user) if user.print_name then return user.print_name end local text = '' if user.first_name then text = user.last_name..' ' end if user.lastname then text = text..user.last_name end return text end local function scan_name(extra, success, result) local founds = {} for k,member in pairs(result.members) do local fields = {'first_name', 'print_name', 'username'} for k,field in pairs(fields) do if member[field] and type(member[field]) == 'string' then if member[field]:match(extra.user) then local id = tostring(member.id) founds[id] = member end end end end if next(founds) == nil then -- Empty table send_msg(extra.receiver, extra.user..' not found on this chat.', ok_cb, false) else local text = '' for k,user in pairs(founds) do local first_name = user.first_name or '' local print_name = user.print_name or '' local user_name = user.user_name or '' local id = user.id or '' -- This would be funny text = text..'First name: '..first_name..'\n' ..'Print name: '..print_name..'\n' ..'User name: '..user_name..'\n' ..'ID: '..id..'\n\n' end send_msg(extra.receiver, text, ok_cb, false) end end local function res_user_callback(extra, success, result) if success == 1 then send_msg(extra.receiver, 'ID for '..extra.user..' is: '..result.id, ok_cb, false) else send_msg(extra.receiver, extra.user..' not found on this chat.', ok_cb, false) end end local function action_by_reply(extra, success, result) local text = 'Name : '..(result.from.first_name or '')..' '..(result.from.last_name or '')..'\n' ..'User name: @'..(result.from.username or '')..'\n' ..'ID : '..result.from.id send_msg(extra.receiver, text, ok_cb, true) end local function returnids(extra, success, result) local text = '['..result.id..'] '..result.title..'.\n' ..result.members_num..' members.\n\n' i = 0 for k,v in pairs(result.members) do i = i+1 if v.last_name then last_name = ' '..v.last_name else last_name = '' end if v.username then user_name = ' @'..v.username else user_name = '' end text = text..i..'. ['..v.id..'] '..user_name..' '..v.first_name..last_name..'\n' end send_large_msg(extra.receiver, text) end local function run(msg, matches) local receiver = get_receiver(msg) local user = matches[1] local text = 'ID for '..user..' is: ' if msg.to.type == 'chat' then if msg.text == '!id' then if msg.reply_id then msgr = get_message(msg.reply_id, action_by_reply, {receiver=receiver}) else local text = 'Name : '..(msg.from.first_name or '')..' '..(msg.from.last_name or '')..'\n' ..'ID : ' .. msg.from.id local text = text..'\n\nYou are in group ' ..msg.to.title..' (ID: '..msg.to.id..')' return text end elseif matches[1] == 'chat' then if matches[2] and is_sudo(msg) then local chat = 'chat#id'..matches[2] chat_info(chat, returnids, {receiver=receiver}) else chat_info(receiver, returnids, {receiver=receiver}) end elseif string.match(user, '^@.+$') then username = string.gsub(user, '@', '') msgr = res_user(username, res_user_callback, {receiver=receiver, user=user, text=text}) else user = string.gsub(user, ' ', '_') chat_info(receiver, scan_name, {receiver=receiver, user=user, text=text}) end else return 'You are not in a group.' end end return { description = 'Know your id or the id of a chat members.', usage = { '!id: Return your ID and the chat id if you are in one.', '!id: Return ID of replied user if used by reply.', '!id chat: Return the IDs of the current chat members.', '!id chat <chat_id>: Return the IDs of the current <chat_id> members.', '!id <id>: Return the IDs of the <id>.', '!id @<user_name>: Return the member @<user_name> ID from the current chat.', '!id <text>: Search for users with <text> on print_name on current chat.' }, patterns = { "^!id$", "^!id (chat) (%d+)$", "^!id (.*)$", "^!id (%d+)$" }, moderated = true, run = run } end
gpl-2.0
xiaq/luarocks
src/luarocks/fetch/svn.lua
14
2187
--- Fetch back-end for retrieving sources from Subversion. --module("luarocks.fetch.svn", package.seeall) local svn = {} local unpack = unpack or table.unpack local fs = require("luarocks.fs") local dir = require("luarocks.dir") local util = require("luarocks.util") --- Download sources for building a rock, using Subversion. -- @param rockspec table: The rockspec table -- @param extract boolean: Unused in this module (required for API purposes.) -- @param dest_dir string or nil: If set, will extract to the given directory. -- @return (string, string) or (nil, string): The absolute pathname of -- the fetched source tarball and the temporary directory created to -- store it; or nil and an error message. function svn.get_sources(rockspec, extract, dest_dir) assert(type(rockspec) == "table") assert(type(dest_dir) == "string" or not dest_dir) local svn_cmd = rockspec.variables.SVN local ok, err_msg = fs.is_tool_available(svn_cmd, "--version", "Subversion") if not ok then return nil, err_msg end local name_version = rockspec.name .. "-" .. rockspec.version local module = rockspec.source.module or dir.base_name(rockspec.source.url) local url = rockspec.source.url:gsub("^svn://", "") local command = {svn_cmd, "checkout", url, module} if rockspec.source.tag then table.insert(command, 5, "-r") table.insert(command, 6, rockspec.source.tag) end local store_dir if not dest_dir then store_dir = fs.make_temp_dir(name_version) if not store_dir then return nil, "Failed creating temporary directory." end util.schedule_function(fs.delete, store_dir) else store_dir = dest_dir end local ok, err = fs.change_dir(store_dir) if not ok then return nil, err end if not fs.execute(unpack(command)) then return nil, "Failed fetching files from Subversion." end ok, err = fs.change_dir(module) if not ok then return nil, err end for _, d in ipairs(fs.find(".")) do if dir.base_name(d) == ".svn" then fs.delete(dir.path(store_dir, module, d)) end end fs.pop_dir() fs.pop_dir() return module, store_dir end return svn
mit
Colettechan/darkstar
scripts/zones/Metalworks/npcs/Ghemp.lua
20
2071
----------------------------------- -- Area: Metalworks -- NPC: Ghemp -- Type: Smithing Guild Master -- @pos -109 2 27 237 ----------------------------------- package.loaded["scripts/zones/Metalworks/TextIDs"] = nil; ----------------------------------- require("scripts/globals/status"); require("scripts/globals/crafting"); require("scripts/zones/Metalworks/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) local newRank = tradeTestItem(player,npc,trade,SKILL_SMITHING); if (newRank ~= 0) then player:setSkillRank(SKILL_SMITHING,newRank); player:startEvent(0x0066,0,0,0,0,newRank); end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local getNewRank = 0; local craftSkill = player:getSkillLevel(SKILL_SMITHING); local testItem = getTestItem(player,npc,SKILL_SMITHING); local guildMember = isGuildMember(player,8); if (guildMember == 1) then guildMember = 150995375; end if (canGetNewRank(player,craftSkill,SKILL_SMITHING) == 1) then getNewRank = 100; end player:startEvent(0x0065,testItem,getNewRank,30,guildMember,44,0,0,0); end; -- 0x038c 0x038d 0x038e 0x0398 0x039f 0x0065 0x0066 ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x0065 and option == 1) then if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,4096); else player:addItem(4096); player:messageSpecial(ITEM_OBTAINED,4096); -- Fire Crystal signupGuild(player,256); end end end;
gpl-3.0
Colettechan/darkstar
scripts/zones/Yuhtunga_Jungle/npcs/Mahol_IM.lua
13
3317
----------------------------------- -- Area: Yuhtunga Jungle -- NPC: Mahol, I.M. -- Outpost Conquest Guards -- @pos -242.487 -1 -402.772 123 ----------------------------------- package.loaded["scripts/zones/Yuhtunga_Jungle/TextIDs"] = nil; ----------------------------------- require("scripts/globals/conquest"); require("scripts/zones/Yuhtunga_Jungle/TextIDs"); local guardnation = BASTOK; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno local guardtype = 3; -- 1: city, 2: foreign, 3: outpost, 4: border local region = ELSHIMOLOWLANDS; local csid = 0x7ff9; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) tradeConquestGuard(player,npc,trade,guardnation,guardtype); end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:hasKeyItem(getSupplyKey(region)) and player:getNation() == guardnation) then if (supplyRunFresh(player) == 1) then player:startEvent(csid,16,0,0,0,1,0,0,255); -- you have brought us supplies ! else player:showText(npc, CONQUEST - 1); -- "Hmm... These supplies you have brought us are too old to be of any use." player:delKeyItem(getSupplyKey(region)); player:messageSpecial(KEYITEM_OBTAINED + 1, getSupplyKey(region)); player:setVar("supplyQuest_region",0); end else local arg1 = getArg1(guardnation, player) - 1; if (arg1 >= 1792) then -- foreign, non-allied player:startEvent(csid,1808,0,0,0,0,player:getRank(),0,0); else -- citizen or allied player:startEvent(csid,arg1,0,0x3F0000,0,0,getArg6(player),0,0); end end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("OPTION: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("OPTION: %u",option); if (option == 1) then local duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600; player:delStatusEffect(EFFECT_SIGIL); player:delStatusEffect(EFFECT_SANCTION); player:delStatusEffect(EFFECT_SIGNET); player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet elseif (option == 2) then player:delKeyItem(getSupplyKey(region)); player:addCP(supplyReward[region + 1]) player:messageSpecial(CONQUEST); -- "You've earned conquest points!" if (hasOutpost(player, region+5) == 0) then supply_quests = 2^(region+5); player:addNationTeleport(guardnation,supply_quests); player:setVar("supplyQuest_region",0); end elseif (option == 4) then if (player:delGil(giltosetHP(guardnation,player))) then player:setHomePoint(); player:messageSpecial(CONQUEST + 94); -- "Your home point has been set." else player:messageSpecial(CONQUEST + 95); -- "You do not have enough gil to set your home point here." end end end;
gpl-3.0
zevv/lgi
samples/console.lua
6
11383
#! /usr/bin/env lua -- Lua console implemented using Gtk widgets. local lgi = require 'lgi' local Gio = lgi.Gio local Gtk = lgi.require('Gtk', '3.0') local Gdk = lgi.require('Gdk', '3.0') local Pango = lgi.Pango local GtkSource = lgi.GtkSource -- Creates new console instance. local function Console() -- Define console object actions. local actions = { execute = Gtk.Action { name = 'execute', stock_id = Gtk.STOCK_OK, is_important = true, label = "_Execute", tooltip = "Execute", }, multiline = Gtk.ToggleAction { name = 'multiline', stock_id = Gtk.STOCK_JUSTIFY_LEFT, is_important = true, label = "_Multiline", tooltip = "Switches command entry to multiline mode", }, up = Gtk.Action { name = 'up', stock_id = Gtk.STOCK_GO_UP, label = "_Previous", tooltip = "Previous command in history", sensitive = false, }, down = Gtk.Action { name = 'down', stock_id = Gtk.STOCK_GO_DOWN, label = "_Next", tooltip = "Next command in history", sensitive = false, }, clear = Gtk.Action { name = 'clear', stock_id = Gtk.STOCK_CLEAR, label = "_Clear", tooltip = "Clear output window", }, about = Gtk.Action { name = 'about', stock_id = Gtk.STOCK_ABOUT, label = "_About", tooltip = "About", }, quit = Gtk.Action { name = 'quit', stock_id = Gtk.STOCK_QUIT, label = "_Quit", tooltip = "Quit", }, } -- Define the widget tree. local widget = Gtk.Grid { orientation = Gtk.Orientation.VERTICAL, Gtk.Toolbar { Gtk.ToolButton { related_action = actions.clear }, Gtk.SeparatorToolItem {}, Gtk.ToolItem { Gtk.FontButton { id = 'font_button' } }, Gtk.SeparatorToolItem {}, Gtk.ToolButton { related_action = actions.about }, Gtk.ToolButton { related_action = actions.quit }, }, Gtk.Paned { orientation = Gtk.Orientation.VERTICAL, { Gtk.ScrolledWindow { shadow_type = Gtk.ShadowType.IN, Gtk.TextView { id = 'output', expand = true, buffer = Gtk.TextBuffer { tag_table = Gtk.TextTagTable { Gtk.TextTag { name = 'command', foreground = 'blue' }, Gtk.TextTag { name = 'log' }, Gtk.TextTag { name = 'result', style = Pango.Style.ITALIC }, Gtk.TextTag { name = 'error', weight = Pango.Weight.BOLD, foreground = 'red' }, } } } }, resize = true }, { Gtk.Grid { orientation = Gtk.Orientation.HORIZONTAL, { Gtk.ScrolledWindow { shadow_type = Gtk.ShadowType.IN, GtkSource.View { id = 'entry', hexpand = true, wrap_mode = Gtk.WrapMode.CHAR, auto_indent = true, tab_width = 4, buffer = GtkSource.Buffer { language = GtkSource.LanguageManager.get_default(): get_language('lua'), }, } }, height = 2 }, Gtk.Toolbar { orientation = Gtk.Orientation.VERTICAL, toolbar_style = Gtk.ToolbarStyle.ICONS, vexpand = true, Gtk.ToolButton { related_action = actions.execute }, Gtk.ToggleToolButton { related_action = actions.multiline }, Gtk.SeparatorToolItem {}, Gtk.ToolButton { related_action = actions.up }, Gtk.ToolButton { related_action = actions.down }, }, { Gtk.Label { id = 'indicator', label = '1:1', single_line_mode = true, justify = Gtk.Justification.RIGHT, }, left_attach = 1, top_attach = 1 }, }, resize = true } } } -- Cache important widgets in local variables local entry = widget.child.entry local output = widget.child.output local indicator = widget.child.indicator local font_button = widget.child.font_button -- When font changes, apply it to both views. font_button.on_notify['font-name'] = function(button) local desc = Pango.FontDescription.from_string(button.font_name) output:override_font(desc) entry:override_font(desc) end -- Initialize font. Get preferred font from system settings, if -- they are installed. GSettings crash the application if the -- schema is not found, so better check first if we can use it. font_button.font_name = 'Monospace' for _, schema in pairs(Gio.Settings.list_schemas()) do if schema == 'org.gnome.desktop.interface' then font_button.font_name = Gio.Settings( { schema = schema }):get_string('monospace-font-name') break end end -- Change indicator text when position in the entry changes. entry.buffer.on_notify['cursor-position'] = function(buffer) local iter = buffer:get_iter_at_mark(buffer:get_insert()) indicator.label = iter:get_line() + 1 .. ':' .. iter:get_line_offset() + 1 end local output_end_mark = output.buffer:create_mark( nil, output.buffer:get_end_iter(), false) -- Appends text to the output window, optionally with specified tag. local function append_output(text, tag) -- Append the text. local end_iter = output.buffer:get_end_iter() local offset = end_iter:get_offset() output.buffer:insert(end_iter, text, -1) end_iter = output.buffer:get_end_iter() -- Apply proper tag. tag = output.buffer.tag_table.tag[tag] if tag then output.buffer:apply_tag(tag, output.buffer:get_iter_at_offset(offset), end_iter) end -- Scroll so that the end of the buffer is visible, but only in -- case that cursor is at the very end of the view. This avoids -- autoscroll when user tries to select something in the output -- view. local cursor = output.buffer:get_iter_at_mark(output.buffer:get_insert()) if end_iter:get_offset() == cursor:get_offset() then output:scroll_mark_onscreen(output_end_mark) end end -- Define history buffer and operations with it. local history = { '', position = 1 } local function history_select(new_position) history[history.position] = entry.buffer.text history.position = new_position entry.buffer.text = history[history.position] entry.buffer:place_cursor(entry.buffer:get_end_iter()) actions.up.sensitive = history.position > 1 actions.down.sensitive = history.position < #history end -- History navigation actions. function actions.up:on_activate() history_select(history.position - 1) end function actions.down:on_activate() history_select(history.position + 1) end -- Execute Lua command from entry and log result into output. function actions.execute:on_activate() -- Get contents of the entry. local text = entry.buffer.text:gsub('^%s?(=)%s*', 'return ') if text == '' then return end -- Add command to the output view. append_output(text:gsub('\n*$', '\n', 1), 'command') -- Try to execute the command. local chunk, answer = (loadstring or load)(text, '=stdin') local tag = 'error' if not chunk then answer = answer:gsub('\n*$', '\n', 1) else (function(ok, ...) if not ok then answer = tostring(...):gsub('\n*$', '\n', 1) else -- Stringize the results. answer = {} for i = 1, select('#', ...) do answer[#answer + 1] = tostring(select(i, ...)) end answer = #answer > 0 and table.concat(answer, '\t') .. '\n' tag = 'result' end end)(pcall(chunk)) end -- Add answer to the output pane. if answer then append_output(answer, tag) end if tag == 'error' then -- Try to parse the error and find line to place the cursor local line = answer:match('^stdin:(%d+):') if line then entry.buffer:place_cursor(entry.buffer:get_iter_at_line_offset( line - 1, 0)) end else -- Store current text as the last item in the history, but -- avoid duplicating items. history[#history] = (history[#history - 1] ~= text) and text or nil -- Add new empty item to the history, point position to it. history.position = #history + 1 history[history.position] = '' -- Enable/disable history navigation actions. actions.up.sensitive = history.position > 1 actions.down.sensitive = false -- Clear contents of the entry buffer. entry.buffer.text = '' end end -- Intercept assorted keys in order to implement history -- navigation. Ideally, this should be implemented using -- Gtk.BindingKey mechanism, but lgi still lacks possibility to -- derive classes and install new signals, which is needed in order -- to implement this. local keytable = { [Gdk.KEY_Return] = actions.execute, [Gdk.KEY_Up] = actions.up, [Gdk.KEY_Down] = actions.down, } function entry:on_key_press_event(event) -- Lookup action to be activated for specified key combination. local action = keytable[event.keyval] local state = event.state local without_control = not state.CONTROL_MASK if not action or state.SHIFT_MASK or actions.multiline.active == without_control then return false end -- Ask textview whether it still wants to consume the key. if self:im_context_filter_keypress(event) then return true end -- Activate specified action. action:activate() -- Do not continue distributing the signal to the view. return true end function actions.about:on_activate() local about = Gtk.AboutDialog { program_name = 'LGI Lua Console', copyright = '(C) Copyright 2011 Pavel Holejšovský', authors = { 'Pavel Holejšovský' }, } about.license_type = Gtk.License.MIT_X11 about:run() about:hide() end function actions.clear:on_activate() output.buffer.text = '' end -- Return public object. return { widget = widget, output = output, entry = entry, actions = actions, append_output = append_output } end local old_print = print local old_write = io.write -- On activation, create and wire the whole widget hierarchy. local app = Gtk.Application { application_id = 'org.lgi.gtkconsole' } function app:on_activate() -- Create console. local console = Console() -- Create application window with console widget in it. console.window = Gtk.Window { application = app, title = "LGI Lua Console", default_width = 800, default_height = 600, console.widget } -- Make everything visible console.entry.has_focus = true console.window:show_all() -- Map quit action to window destroy. function console.actions.quit:on_activate() console.window:destroy() end -- Inject 'lgi' symbol into global namespace, for convenience. -- Also add 'console' table containing important elements of this -- console, so that it can be manipulated live. _G.lgi = lgi _G.console = console -- Override global 'print' and 'io.write' handlers, so that output -- goes to our output window (with special text style). function _G.print(...) local outs = {} for i = 1, select('#', ...) do outs[#outs + 1] = tostring(select(i, ...)) end console.append_output(table.concat(outs, '\t') .. '\n', 'log') end function _G.io.write(...) for i = 1, select('#', ...) do console.append_output(select(i, ...), 'log') end end end -- Run the whole application app:run { arg[0], ... } -- Revert to old printing routines. print = old_print io.write = old_write
mit
Colettechan/darkstar
scripts/zones/Inner_Horutoto_Ruins/npcs/_5cq.lua
13
2583
----------------------------------- -- Area: Inner Horutoto Ruins -- NPC: _5cq (Magical Gizmo) #2 -- Involved In Mission: The Horutoto Ruins Experiment ----------------------------------- package.loaded["scripts/zones/Inner_Horutoto_Ruins/TextIDs"] = nil; ----------------------------------- require("scripts/globals/missions"); require("scripts/zones/Inner_Horutoto_Ruins/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) -- The Magical Gizmo Number, this number will be compared to the random -- value created by the mission The Horutoto Ruins Experiment, when you -- reach the Gizmo Door and have the cutscene local magical_gizmo_no = 2; -- of the 6 -- Check if we are on Windurst Mission 1-1 if (player:getCurrentMission(WINDURST) == THE_HORUTOTO_RUINS_EXPERIMENT and player:getVar("MissionStatus") == 2) then -- Check if we found the correct Magical Gizmo or not if (player:getVar("MissionStatus_rv") == magical_gizmo_no) then player:startEvent(0x0032); else if (player:getVar("MissionStatus_op2") == 2) then -- We've already examined this player:messageSpecial(EXAMINED_RECEPTACLE); else -- Opened the wrong one player:startEvent(0x0033); end end end return 1; end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); -- If we just finished the cutscene for Windurst Mission 1-1 -- The cutscene that we opened the correct Magical Gizmo if (csid == 0x0032) then player:setVar("MissionStatus",3); player:setVar("MissionStatus_rv", 0); player:addKeyItem(CRACKED_MANA_ORBS); player:messageSpecial(KEYITEM_OBTAINED,CRACKED_MANA_ORBS); elseif (csid == 0x0033) then -- Opened the wrong one player:setVar("MissionStatus_op2", 2); -- Give the message that thsi orb is not broken player:messageSpecial(NOT_BROKEN_ORB); end end;
gpl-3.0
Colettechan/darkstar
scripts/zones/Bastok_Mines/npcs/Aulavia.lua
12
1545
----------------------------------- -- Area: Bastok Mines -- NPC: Aulavia -- Regional Marchant NPC -- Only sells when Bastok controls Vollbow. ----------------------------------- require("scripts/globals/events/harvest_festivals"); require("scripts/globals/shop"); require("scripts/globals/conquest"); package.loaded["scripts/zones/Bastok_Mines/TextIDs"] = nil; require("scripts/zones/Bastok_Mines/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) onHalloweenTrade(player,trade,npc) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) RegionOwner = GetRegionOwner(VOLLBOW); if (RegionOwner ~= BASTOK) then player:showText(npc,AULAVIA_CLOSED_DIALOG); else player:showText(npc,AULAVIA_OPEN_DIALOG); stock = { 0x27c, 119, --Chamomile 0x360, 88, --Fish Scales 0x3a8, 14, --Rock Salt 0x582, 1656 --Sweet William } showShop(player,BASTOK,stock); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
mortezamosavy999/otouto
plugins/hackernews.lua
16
1401
local command = 'hackernews' local doc = [[``` Returns four (if group) or eight (if private message) top stories from Hacker News. Alias: /hn ```]] local triggers = { '^/hackernews[@'..bot.username..']*', '^/hn[@'..bot.username..']*' } local action = function(msg) sendChatAction(msg.chat.id, 'typing') local jstr, res = HTTPS.request('https://hacker-news.firebaseio.com/v0/topstories.json') if res ~= 200 then sendReply(msg, config.errors.connection) return end local jdat = JSON.decode(jstr) local res_count = 4 if msg.chat.id == msg.from.id then res_count = 8 end local output = '*Hacker News:*\n' for i = 1, res_count do local res_url = 'https://hacker-news.firebaseio.com/v0/item/' .. jdat[i] .. '.json' jstr, res = HTTPS.request(res_url) if res ~= 200 then sendReply(msg, config.errors.connection) return end local res_jdat = JSON.decode(jstr) local title = res_jdat.title:gsub('%[.+%]', ''):gsub('%(.+%)', ''):gsub('&amp;', '&') if title:len() > 48 then title = title:sub(1, 45) .. '...' end local url = res_jdat.url if url:find('%(') then output = output .. '• ' .. title .. '\n' .. url:gsub('_', '\\_') .. '\n' else output = output .. '• [' .. title .. '](' .. url .. ')\n' end end sendMessage(msg.chat.id, output, true, nil, true) end return { action = action, triggers = triggers, doc = doc, command = command }
gpl-2.0
asmantarik/MAGIC-BOT
plugins/meme.lua
637
5791
local helpers = require "OAuth.helpers" local _file_memes = './data/memes.lua' local _cache = {} local function post_petition(url, arguments) local response_body = {} local request_constructor = { url = url, method = "POST", sink = ltn12.sink.table(response_body), headers = {}, redirect = false } local source = arguments if type(arguments) == "table" then local source = helpers.url_encode_arguments(arguments) end request_constructor.headers["Content-Type"] = "application/x-www-form-urlencoded" request_constructor.headers["Content-Length"] = tostring(#source) request_constructor.source = ltn12.source.string(source) local ok, response_code, response_headers, response_status_line = http.request(request_constructor) if not ok then return nil end response_body = json:decode(table.concat(response_body)) return response_body end local function upload_memes(memes) local base = "http://hastebin.com/" local pet = post_petition(base .. "documents", memes) if pet == nil then return '', '' end local key = pet.key return base .. key, base .. 'raw/' .. key end local function analyze_meme_list() local function get_m(res, n) local r = "<option.*>(.*)</option>.*" local start = string.find(res, "<option.*>", n) if start == nil then return nil, nil end local final = string.find(res, "</option>", n) + #"</option>" local sub = string.sub(res, start, final) local f = string.match(sub, r) return f, final end local res, code = http.request('http://apimeme.com/') local r = "<option.*>(.*)</option>.*" local n = 0 local f, n = get_m(res, n) local ult = {} while f ~= nil do print(f) table.insert(ult, f) f, n = get_m(res, n) end return ult end local function get_memes() local memes = analyze_meme_list() return { last_time = os.time(), memes = memes } end local function load_data() local data = load_from_file(_file_memes) if not next(data) or data.memes == {} or os.time() - data.last_time > 86400 then data = get_memes() -- Upload only if changed? link, rawlink = upload_memes(table.concat(data.memes, '\n')) data.link = link data.rawlink = rawlink serialize_to_file(data, _file_memes) end return data end local function match_n_word(list1, list2) local n = 0 for k,v in pairs(list1) do for k2, v2 in pairs(list2) do if v2:find(v) then n = n + 1 end end end return n end local function match_meme(name) local _memes = load_data() local name = name:lower():split(' ') local max = 0 local id = nil for k,v in pairs(_memes.memes) do local n = match_n_word(name, v:lower():split(' ')) if n > 0 and n > max then max = n id = v end end return id end local function generate_meme(id, textup, textdown) local base = "http://apimeme.com/meme" local arguments = { meme=id, top=textup, bottom=textdown } return base .. "?" .. helpers.url_encode_arguments(arguments) end local function get_all_memes_names() local _memes = load_data() local text = 'Last time: ' .. _memes.last_time .. '\n-----------\n' for k, v in pairs(_memes.memes) do text = text .. '- ' .. v .. '\n' end text = text .. '--------------\n' .. 'You can see the images here: http://apimeme.com/' return text end local function callback_send(cb_extra, success, data) if success == 0 then send_msg(cb_extra.receiver, "Something wrong happened, probably that meme had been removed from server: " .. cb_extra.url, ok_cb, false) end end local function run(msg, matches) local receiver = get_receiver(msg) if matches[1] == 'list' then local _memes = load_data() return 'I have ' .. #_memes.memes .. ' meme names.\nCheck this link to see all :)\n' .. _memes.link elseif matches[1] == 'listall' then if not is_sudo(msg) then return "You can't list this way, use \"!meme list\"" else return get_all_memes_names() end elseif matches[1] == "search" then local meme_id = match_meme(matches[2]) if meme_id == nil then return "I can't match that search with any meme." end return "With that search your meme is " .. meme_id end local searchterm = string.gsub(matches[1]:lower(), ' ', '') local meme_id = _cache[searchterm] or match_meme(matches[1]) if not meme_id then return 'I don\'t understand the meme name "' .. matches[1] .. '"' end _cache[searchterm] = meme_id print("Generating meme: " .. meme_id .. " with texts " .. matches[2] .. ' and ' .. matches[3]) local url_gen = generate_meme(meme_id, matches[2], matches[3]) send_photo_from_url(receiver, url_gen, callback_send, {receiver=receiver, url=url_gen}) return nil end return { description = "Generate a meme image with up and bottom texts.", usage = { "!meme search (name): Return the name of the meme that match.", "!meme list: Return the link where you can see the memes.", "!meme listall: Return the list of all memes. Only admin can call it.", '!meme [name] - [text_up] - [text_down]: Generate a meme with the picture that match with that name with the texts provided.', '!meme [name] "[text_up]" "[text_down]": Generate a meme with the picture that match with that name with the texts provided.', }, patterns = { "^!meme (search) (.+)$", '^!meme (list)$', '^!meme (listall)$', '^!meme (.+) "(.*)" "(.*)"$', '^!meme "(.+)" "(.*)" "(.*)"$', "^!meme (.+) %- (.*) %- (.*)$" }, run = run }
gpl-2.0
Murii/CLove
opt/examples/lua/example2.lua
3
1697
--[[ -- --Read pixel information from an image and do something with it ;) -- --]] -- local t = {} function spawn(x,y) table.insert(t,{x=x,y=y}) end local dr = nil function love.load() --love.graphics.scale(2.4) --read each pixel color and something based on that local im = love.image.newImageData("map.png") for y = 1, im:getHeight() do for x = 1, im:getWidth() do -- pixel coordinates range from 0 to image width - 1 / height - 1 local r, g, b, a, pixel= im:getPixel( x, y) if r == 55 and g == 50 and b == 227 then --print(x .. " " .. y) spawn(x,y) end end end -- set pixels to a custom color local data = love.image.newImageData(132,132) for i=1,data:getHeight() do for k=1,data:getWidth() do data:setPixel(i,k,155,255,355,255) end end data:setPixel(60,60,255,0,0,255) data:setPixel(61,60,255,0,0,255) data:setPixel(60,61,255,0,0,255) data:setPixel(61,61,255,0,0,255) data:encode("tga","testga.tga") data:encode("png","testpng.png") data:encode("bmp","testbmp.bmp") data:encode("hdr","testhdr.hdr") --load the newly made texture with custom colors and size and draw to it --love.draw dr = love.graphics.newImage(data) dr:setFilter("nearest","nearest") end function love.update(dt) local mx = love.mouse.getX() local my = love.mouse.getY() if love.keyboard.isDown("esc") then love.event.quit() end end function love.draw() for i,v in ipairs(t) do love.graphics.rectangle("fill",v.x*16,v.y*16,16,16) end love.graphics.draw(dr,200,100) love.graphics.print(""..love.timer.getFPS(),10,10) end function love.keypressed(k) end function love.quit() end function love.mousepressed(x,y,b) end function love.wheelmoved(y) end
mit
zynjec/darkstar
scripts/zones/Port_Jeuno/Zone.lua
9
3114
----------------------------------- -- -- Zone: Port_Jeuno (246) -- ----------------------------------- local ID = require("scripts/zones/Port_Jeuno/IDs") require("scripts/globals/conquest") require("scripts/globals/settings") require("scripts/globals/chocobo") require("scripts/globals/quests") require("scripts/globals/zone") ----------------------------------- function onInitialize(zone) dsp.chocobo.initZone(zone) end; function onZoneIn(player,prevZone) local cs = -1; local month = tonumber(os.date("%m")); local day = tonumber(os.date("%d")); -- Retail start/end dates vary, I am going with Dec 5th through Jan 5th. if ((month == 12 and day >= 5) or (month == 1 and day <= 5)) then player:ChangeMusic(0,239); player:ChangeMusic(1,239); -- No need for an 'else' to change it back outside these dates as a re-zone will handle that. end if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then if (prevZone == dsp.zone.SAN_DORIA_JEUNO_AIRSHIP) then cs = 10018; player:setPos(-87.000, 12.000, 116.000, 128); elseif (prevZone == dsp.zone.BASTOK_JEUNO_AIRSHIP) then cs = 10020; player:setPos(-50.000, 12.000, -116.000, 0); elseif (prevZone == dsp.zone.WINDURST_JEUNO_AIRSHIP) then cs = 10019; player:setPos(16.000, 12.000, -117.000, 0); elseif (prevZone == dsp.zone.KAZHAM_JEUNO_AIRSHIP) then cs = 10021; player:setPos(-24.000, 12.000, 116.000, 128); else local position = math.random(1,3) - 2; player:setPos(-192.5 ,-5,position,0); if (player:getMainJob() ~= player:getCharVar("PlayerMainJob")) then cs = 30004; end player:setCharVar("PlayerMainJob",0); end elseif (ENABLE_ABYSSEA == 1 and player:getMainLvl() >= 30 and player:getQuestStatus(ABYSSEA, dsp.quest.id.abyssea.A_JOURNEY_BEGINS) == QUEST_AVAILABLE) then cs = 324; end return cs end; function onConquestUpdate(zone, updatetype) dsp.conq.onConquestUpdate(zone, updatetype) end; function onTransportEvent(player,transport) if (transport == 223) then player:startEvent(10010); elseif (transport == 224) then player:startEvent(10012); elseif (transport == 225) then player:startEvent(10011); elseif (transport == 226) then player:startEvent(10013); end end; function onEventUpdate(player,csid,option) end; function onEventFinish(player,csid,option) if (csid == 10010) then player:setPos(0,0,0,0,223); elseif (csid == 10011) then player:setPos(0,0,0,0,225); elseif (csid == 10012) then player:setPos(0,0,0,0,224); elseif (csid == 10013) then player:setPos(0,0,0,0,226); elseif (csid == 30004 and option == 0) then player:setHomePoint(); player:messageSpecial(ID.text.HOMEPOINT_SET); elseif (csid == 324) then player:addQuest(ABYSSEA, dsp.quest.id.abyssea.A_JOURNEY_BEGINS); end end;
gpl-3.0
zynjec/darkstar
scripts/zones/The_Sanctuary_of_ZiTah/npcs/qm2.lua
9
1128
----------------------------------- -- Area: The Sanctuary of ZiTah -- NPC: qm2 (???) -- Involved in Quest: Forge Your Destiny -- !pos 639 -1 -151 121 ----------------------------------- local ID = require("scripts/zones/The_Sanctuary_of_ZiTah/IDs") require("scripts/globals/npc_util") require("scripts/globals/quests") ----------------------------------- function onTrade(player, npc, trade) if player:getQuestStatus(OUTLANDS, dsp.quest.id.outlands.FORGE_YOUR_DESTINY) == QUEST_ACCEPTED then if npcUtil.tradeHas(trade, 1021) and not player:hasItem(1153) and npcUtil.popFromQM(player, npc, ID.mob.GUARDIAN_TREANT, {hide = 0}) then player:confirmTrade() elseif npcUtil.tradeHas(trade, 1198) and player:getCharVar("ForgeYourDestiny_killed") == 1 and npcUtil.giveItem(player, 1153) then player:confirmTrade() player:setCharVar("ForgeYourDestiny_killed", 0) end end end function onTrigger(player, npc) player:messageSpecial(ID.text.STURDY_BRANCH, 1021) end function onEventUpdate(player, csid, option) end function onEventFinish(player, csid, option) end
gpl-3.0
Colettechan/darkstar
scripts/zones/Al_Zahbi/npcs/Gajaad.lua
18
2556
----------------------------------- -- Area: Al Zahbi -- NPC: Gajaad -- Type: Donation Taker -- @pos 40.781 -1.398 116.261 48 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Al_Zahbi/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) local walahraCoinCount = player:getVar("walahraCoinCount"); local TradeCount = trade:getItemQty(2184); if (TradeCount > 0 and TradeCount == trade:getItemCount()) then if (walahraCoinCount + TradeCount > 1000) then -- give player turban, donated over 1000 if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,15270); else player:addItem(15270); player:messageSpecial(ITEM_OBTAINED,15270); player:setVar("walahraCoinCount", walahraCoinCount - (1000 - TradeCount)); player:tradeComplete(); player:startEvent(0x0066, 2184, 0, TradeCount); end else -- turning in less than the amount needed to finish the quest if (TradeCount >= 100) then -- give bonus walahra water - only one water per trade, regardless of the amount. player:tradeComplete(); player:setVar("walahraCoinCount", walahraCoinCount + TradeCount); player:addItem(5354); player:messageSpecial(ITEM_OBTAINED,5354); player:startEvent(0x0066, 2184, 0, TradeCount); else player:tradeComplete(); player:setVar("walahraCoinCount", walahraCoinCount + TradeCount); player:startEvent(0x0066, 2184, 0, TradeCount); end end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) -- TODO beseige result can effect if this npc will accept trades player:startEvent(0x0066, 2184); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
zeromq/lzmq
test/test_threads_sync.lua
12
1090
local TEST_FFI = ("ffi" == os.getenv("LZMQ")) local LZMQ = "lzmq" .. (TEST_FFI and ".ffi" or "") local zmq = require (LZMQ) local zthreads = require (LZMQ .. ".threads" ) local ctx = zmq:context() local thread, skt = zthreads.fork(ctx, string.dump(function(skt) local ztimer = require "lzmq.timer" local function assert_equal(name, a, b, ...) if a == b then return b, ... end print(name .. " Fail! Expected `" .. tostring(a) .. "` got `" .. tostring(b) .. "`") os.exit(1) end local function assert_not_nil(name, a, ...) if a ~= nil then return a, ... end print(name .. " Fail! Expected not nil value but got it.") os.exit(1) end skt:send("") while true do local msg, err = skt:recv() if not msg then assert_not_nil("Error", err) assert_equal("Error", "ETERM", err:mnemo()) break end end -- wait to ensure ztimer.sleep(5000) print("Done!") os.exit(0) end)) thread:start() skt:recv() -- we should wait until socket in thread not closed ctx:destroy() print('Sync does not work.') os.exit(2)
mit
AliKhodadad/wild-man
plugins/search_youtube.lua
674
1270
do local google_config = load_from_file('data/google.lua') local function httpsRequest(url) print(url) local res,code = https.request(url) if code ~= 200 then return nil end return json:decode(res) end local function searchYoutubeVideos(text) local url = 'https://www.googleapis.com/youtube/v3/search?' url = url..'part=snippet'..'&maxResults=4'..'&type=video' url = url..'&q='..URL.escape(text) if google_config.api_keys then local i = math.random(#google_config.api_keys) local api_key = google_config.api_keys[i] if api_key then url = url.."&key="..api_key end end local data = httpsRequest(url) if not data then print("HTTP Error") return nil elseif not data.items then return nil end return data.items end local function run(msg, matches) local text = '' local items = searchYoutubeVideos(matches[1]) if not items then return "Error!" end for k,item in pairs(items) do text = text..'http://youtu.be/'..item.id.videoId..' '.. item.snippet.title..'\n\n' end return text end return { description = "Search video on youtube and send it.", usage = "!youtube [term]: Search for a youtube video and send it.", patterns = { "^!youtube (.*)" }, run = run } end
gpl-2.0
Arashbrsh/cccdpay
plugins/search_youtube.lua
674
1270
do local google_config = load_from_file('data/google.lua') local function httpsRequest(url) print(url) local res,code = https.request(url) if code ~= 200 then return nil end return json:decode(res) end local function searchYoutubeVideos(text) local url = 'https://www.googleapis.com/youtube/v3/search?' url = url..'part=snippet'..'&maxResults=4'..'&type=video' url = url..'&q='..URL.escape(text) if google_config.api_keys then local i = math.random(#google_config.api_keys) local api_key = google_config.api_keys[i] if api_key then url = url.."&key="..api_key end end local data = httpsRequest(url) if not data then print("HTTP Error") return nil elseif not data.items then return nil end return data.items end local function run(msg, matches) local text = '' local items = searchYoutubeVideos(matches[1]) if not items then return "Error!" end for k,item in pairs(items) do text = text..'http://youtu.be/'..item.id.videoId..' '.. item.snippet.title..'\n\n' end return text end return { description = "Search video on youtube and send it.", usage = "!youtube [term]: Search for a youtube video and send it.", patterns = { "^!youtube (.*)" }, run = run } end
gpl-2.0
c10ud/CHDK
CHDK/LUALIB/binstr.lua
5
1846
--[[ module for converting between numbers and binary strings usage: bs=require('binstr') wbdata=bs.unpack(get_prop_str(0x10d,0x1c)) -- return propset 3 white balance as 7 ints ]] local binstr = {} --[[ convert number or array of numbers into a binary string size specifies the number of bytes to use from each number, default 4 ]] binstr.pack = function(val,size) if size == nil then size = 4 elseif size < 1 or size > 4 then error('invalid size') end if type(val) ~= 'table' then val = {tonumber(val)} end local bytes = {} for i,num in ipairs(val) do for j = 1, size do table.insert(bytes,bitand(num,0xFF)) num = bitshru(num,8) end end return string.char(unpack(bytes)) end --[[ read a single number of the specified size from str defaults to 4 bytes at start does not handle negative pos does not sign extend < 32 bit size ]] binstr.getnum = function(str,size,pos) if pos == nil then pos = 1 elseif pos < 1 then error('invalid pos') end if size == nil then size = 4 elseif size > 4 or size < 1 then error('invalid size') end local e = pos + size - 1 if string.len(str) < e then return end local bytes = {string.byte(str,pos,e)} local num = 0 for i=1,#bytes do num = bitor(num,bitshl(bytes[i],8*(i-1))) end return num end --[[ convert a string to an array of numbers size specifies the size of the numbers in the packed array, default 4 ]] binstr.unpack = function(str,size) if size == nil then size = 4 elseif size < 1 or size > 4 then error('invalid size') end if type(str) ~= 'string' then error('expected string') end if (string.len(str)/size)*size ~= string.len(str) then error('string lenght not multiple of size') end local i = 1 local r = {} while i <= string.len(str) do table.insert(r,binstr.getnum(str,size,i)) i = i+size end return r end return binstr
gpl-2.0
xiaq/luarocks
src/luarocks/build/make.lua
17
3465
--- Build back-end for using Makefile-based packages. --module("luarocks.build.make", package.seeall) local make = {} local unpack = unpack or table.unpack local fs = require("luarocks.fs") local util = require("luarocks.util") local cfg = require("luarocks.cfg") --- Call "make" with given target and variables -- @param make_cmd string: the make command to be used (typically -- configured through variables.MAKE in the config files, or -- the appropriate platform-specific default). -- @param pass boolean: If true, run make; if false, do nothing. -- @param target string: The make target; an empty string indicates -- the default target. -- @param variables table: A table containing string-string key-value -- pairs representing variable assignments to be passed to make. -- @return boolean: false if any errors occurred, true otherwise. local function make_pass(make_cmd, pass, target, variables) assert(type(pass) == "boolean") assert(type(target) == "string") assert(type(variables) == "table") local assignments = {} for k,v in pairs(variables) do table.insert(assignments, k.."="..v) end if pass then return fs.execute(make_cmd.." "..target, unpack(assignments)) else return true end end --- Driver function for the "make" build back-end. -- @param rockspec table: the loaded rockspec. -- @return boolean or (nil, string): true if no errors ocurred, -- nil and an error message otherwise. function make.run(rockspec) assert(type(rockspec) == "table") local build = rockspec.build if build.build_pass == nil then build.build_pass = true end if build.install_pass == nil then build.install_pass = true end build.build_variables = build.build_variables or {} build.install_variables = build.install_variables or {} build.build_target = build.build_target or "" build.install_target = build.install_target or "install" local makefile = build.makefile or cfg.makefile if makefile then -- Assumes all make's accept -f. True for POSIX make, GNU make and Microsoft nmake. build.build_target = "-f "..makefile.." "..build.build_target build.install_target = "-f "..makefile.." "..build.install_target end if build.variables then for var, val in pairs(build.variables) do build.build_variables[var] = val build.install_variables[var] = val end end util.warn_if_not_used(build.build_variables, { CFLAGS=true }, "variable %s was not passed in build_variables") util.variable_substitutions(build.build_variables, rockspec.variables) util.variable_substitutions(build.install_variables, rockspec.variables) local auto_variables = { "CC" } for _, variable in pairs(auto_variables) do if not build.build_variables[variable] then build.build_variables[variable] = rockspec.variables[variable] end if not build.install_variables[variable] then build.install_variables[variable] = rockspec.variables[variable] end end -- backwards compatibility local make_cmd = cfg.make or rockspec.variables.MAKE local ok = make_pass(make_cmd, build.build_pass, build.build_target, build.build_variables) if not ok then return nil, "Failed building." end ok = make_pass(make_cmd, build.install_pass, build.install_target, build.install_variables) if not ok then return nil, "Failed installing." end return true end return make
mit
dkogan/notion-scripts
scripts/bindsearch.lua
2
2567
-- bindsearch.lua -- -- Canaan Hadley-Voth. -- -- Bindings are spread across distant files, some are created -- dynamically, and some are negated by others. I use this to -- tell me exactly what is bound right now. -- -- Search (in all sections) for bound keys or bound commands. -- There can be multiple search terms separated by spaces, but -- they would have to appear in the specified order. Output -- is a WMessage with a section of the bindings table. -- --[[ Example: bindsearch("K X") yields: WIonWS [kcb] = Mod1+K [action] = kpress [submap] = table: 0x8254478 [cmd] = WIonWS.unsplit_at(_, _sub) [action] = kpress [kcb] = AnyModifier+X [func] = function: 0x80de2d0 cmdsearch("unsplit") would have found the same thing. A search for " " shows all bindings. --]] -- In versions older than 20051210, print() is not defined to send wmessages. -- Uncommenting this next line might be necessary. -- local function print(msg) mod_query.message( ioncore.region_list("WScreen")[1], tostring(msg) ) end local function strtable(tabl, f) local msg="" if not f then f=function(x) return x end end n=#tabl if n>0 then msg=tostring(n).." objects:" end for i in pairs(tabl) do msg=msg.." ["..tostring(i).."] = "..tostring(f(tabl[i])).."\n" end return msg end -- Possible fields are "kcb" (default), "cmd", and "class". function bindsearch(str, field) local btabl = table.copy(ioncore.getbindings(), true) local fullmsg="" local fullkcb="" local class="" str=string.gsub(str, "%+", "%%%+") str=string.gsub(str, " ", ".*") --string.gsub(str, "@", "%%%@") local function domap(class, t, msg, kcb, show_all) local found for index,bind in pairs(t) do found=false if bind.area then fullkcb=kcb.." "..bind.kcb.."@"..bind.area else fullkcb=kcb.." "..bind.kcb end fullkcb=string.gsub(fullkcb, "AnyModifier", " ") if (field==nil or field=="kcb") and string.find(fullkcb, str) then found=true elseif field=="cmd" and bind.cmd and string.find(string.lower(bind.cmd), string.lower(str)) then found=true elseif field=="class" and class==str then found=true end if bind.submap then domap(class, bind.submap, msg..strtable(bind), fullkcb, found) elseif found or show_all then fullmsg=fullmsg..msg..strtable(bind) end end end for class, bindings in pairs(btabl) do domap(class, bindings, class.."\n", "", false) end print(fullmsg) end function cmdsearch(str) bindsearch(str, "cmd") end
gpl-3.0
aleksijuvani/premake-core
modules/gmake2/tests/test_gmake2_target_rules.lua
3
1060
-- -- test_gmake2_target_rules.lua -- Validate the makefile target building rules. -- (c) 2016-2017 Jason Perkins, Blizzard Entertainment and the Premake project -- local p = premake local suite = test.declare("gmake2_target_rules") local p = premake local gmake2 = p.modules.gmake2 local project = p.project -- -- Setup -- local wks, prj function suite.setup() wks, prj = test.createWorkspace() end local function prepare() local cfg = test.getconfig(prj, "Debug") gmake2.cpp.allRules(cfg) end -- -- Check the default, normal format of the rules. -- function suite.defaultRules() prepare() test.capture [[ all: prebuild prelink $(TARGET) | $(TARGETDIR) $(OBJDIR) @: ]] end -- -- Check rules for an OS X Cocoa application. -- function suite.osxWindowedAppRules() system "MacOSX" kind "WindowedApp" prepare() test.capture [[ all: prebuild prelink $(TARGET) $(dir $(TARGETDIR))PkgInfo $(dir $(TARGETDIR))Info.plist | $(TARGETDIR) $(OBJDIR) @: $(dir $(TARGETDIR))PkgInfo: $(dir $(TARGETDIR))Info.plist: ]] end
bsd-3-clause
tsdfsetatata/xserver
Server/dump_srv/lua/protobuf/containers.lua
15
2284
-- -------------------------------------------------------------------------------- -- FILE: containers.lua -- DESCRIPTION: protoc-gen-lua -- Google's Protocol Buffers project, ported to lua. -- https://code.google.com/p/protoc-gen-lua/ -- -- Copyright (c) 2010 , 林卓毅 (Zhuoyi Lin) netsnail@gmail.com -- All rights reserved. -- -- Use, modification and distribution are subject to the "New BSD License" -- as listed at <url: http://www.opensource.org/licenses/bsd-license.php >. -- -- COMPANY: NetEase -- CREATED: 2010年08月02日 16时15分42秒 CST -------------------------------------------------------------------------------- -- local setmetatable = setmetatable local table = table local rawset = rawset local error = error module "containers" local _RCFC_meta = { add = function(self) local value = self._message_descriptor._concrete_class() local listener = self._listener rawset(self, #self + 1, value) value:_SetListener(listener) if listener.dirty == false then listener:Modified() end return value end, remove = function(self, key) local listener = self._listener table.remove(self, key) listener:Modified() end, __newindex = function(self, key, value) error("RepeatedCompositeFieldContainer Can't set value directly") end } _RCFC_meta.__index = _RCFC_meta function RepeatedCompositeFieldContainer(listener, message_descriptor) local o = { _listener = listener, _message_descriptor = message_descriptor } return setmetatable(o, _RCFC_meta) end local _RSFC_meta = { append = function(self, value) self._type_checker(value) rawset(self, #self + 1, value) self._listener:Modified() end, remove = function(self, key) table.remove(self, key) self._listener:Modified() end, __newindex = function(self, key, value) error("RepeatedCompositeFieldContainer Can't set value directly") end } _RSFC_meta.__index = _RSFC_meta function RepeatedScalarFieldContainer(listener, type_checker) local o = {} o._listener = listener o._type_checker = type_checker return setmetatable(o, _RSFC_meta) end
gpl-3.0
whirm/awesomerc
themes/whirm/theme.lua
1
6564
local print = print path="/home/whirm/.config/awesome/themes" local theme_dir=path.."/whirm" local function rgb(red, green, blue) if type(red) == "number" or type(green) == "number" or type(blue) == "number" then return "#"..string.format("%02x",red)..string.format("%02x",green)..string.format("%02x",blue) else return nil end end local function rgba(red, green, blue, alpha) if type(red) == "number" or type(green) == "number" or type(blue) == "number" or type(alpha) == "number" then return "#"..string.format("%02x",red)..string.format("%02x",green)..string.format("%02x",blue)..string.format("%02x",alpha * 255) else return nil end end --colors local bordeaux= rgb(47,28,28) local light_bordeaux = rgba(191,64,64,0.6) local grey = "#444444ff" local light_grey = "#555555" local white = "#ffffff" local light_white = "#999999" local black = "#000000" local light_black = "#232323" local theme = {} theme.font = "terminus 8" theme.bg_normal = "#3F3F3F" theme.bg_focus = "#8b4500" theme.bg_alternate = "#2B2B2B" theme.bg_urgent = "#8b1a1a" theme.bg_minimize = light_grey theme.bg_systray = theme.bg_normal theme.fg_normal = "#DCDCCC" theme.fg_focus = "#F0DFAF" theme.fg_urgent = "#CC9393" theme.fg_minimize = light_white theme.useless_gap = 0 theme.border_width = 1 theme.border_normal = "#000000" theme.border_focus = "#535d6c" theme.border_marked = "#91231c" -- There are other variable sets -- overriding the default one when -- defined, the sets are: -- taglist_[bg|fg]_[focus|urgent|occupied|empty] -- tasklist_[bg|fg]_[focus|urgent] -- titlebar_[bg|fg]_[normal|focus] -- tooltip_[font|opacity|fg_color|bg_color|border_width|border_color] -- mouse_finder_[color|timeout|animate_timeout|radius|factor] -- Example: --theme.taglist_bg_focus = "#ff0000" -- Display the taglist squares theme.taglist_squares_sel = theme_dir.."/taglist/squarefz.png" theme.taglist_squares_unsel = theme_dir.."/taglist/squarez.png" --theme.taglist_squares_resize = "false" -- Variables set for theming the menu: -- menu_[bg|fg]_[normal|focus] -- menu_[border_color|border_width] theme.menu_border_width = 3 theme.menu_border_color = theme.bg_normal theme.menu_submenu_icon = theme_dir.."/submenu.png" theme.menu_height = 15 theme.menu_width = 100 -- You can add as many variables as -- you wish and access them by using -- beautiful.variable in your rc.lua --theme.fg_widget = "#AECF96" --theme.fg_center_widget = "#88A175" --theme.fg_end_widget = "#FF5656" --theme.bg_widget = "#494B4F" --theme.border_widget = "#3F3F3F" theme.fg_sb_hi = "#cfcfff" theme.fg_batt_mid = "#00cb00" theme.fg_batt_low = "#e6f21d" theme.fg_batt_crit = "#f8700a" theme.cpu_end = "#243367" theme.cpu_mid = "#285577" theme.cpu_st = "#AEC6D8" theme.vol_bg = "#000033" -- {{{ Borders theme.border_width = "1" theme.border_normal = "#111111" theme.border_focus = "#6F1111" theme.border_marked = "#CC9393" -- }}} -- {{{ Titlebars theme.titlebar_bg_focus = "#3F3F3F" theme.titlebar_bg_normal = "#3F3F3F" -- }}} theme.tasklist_bg_focus = "#455b1f" theme.tasklist_fg_focus = "#Bdbdbd" --theme.taglist_bg_normal= "#333333" --theme.titlebar_bg_normal = --theme.titlebar_bg_focus = -- Define the image to load theme.titlebar_close_button_normal = theme_dir.."/titlebar/close_normal.png" theme.titlebar_close_button_focus = theme_dir.."/titlebar/close_focus.png" theme.titlebar_minimize_button_normal = theme_dir.."/titlebar/minimize_normal.png" theme.titlebar_minimize_button_focus = theme_dir.."/titlebar/minimize_focus.png" theme.titlebar_ontop_button_normal_inactive = theme_dir.."/titlebar/ontop_normal_inactive.png" theme.titlebar_ontop_button_focus_inactive = theme_dir.."/titlebar/ontop_focus_inactive.png" theme.titlebar_ontop_button_normal_active = theme_dir.."/titlebar/ontop_normal_active.png" theme.titlebar_ontop_button_focus_active = theme_dir.."/titlebar/ontop_focus_active.png" theme.titlebar_sticky_button_normal_inactive = theme_dir.."/titlebar/sticky_normal_inactive.png" theme.titlebar_sticky_button_focus_inactive = theme_dir.."/titlebar/sticky_focus_inactive.png" theme.titlebar_sticky_button_normal_active = theme_dir.."/titlebar/sticky_normal_active.png" theme.titlebar_sticky_button_focus_active = theme_dir.."/titlebar/sticky_focus_active.png" theme.titlebar_floating_button_normal_inactive = theme_dir.."/titlebar/floating_normal_inactive.png" theme.titlebar_floating_button_focus_inactive = theme_dir.."/titlebar/floating_focus_inactive.png" theme.titlebar_floating_button_normal_active = theme_dir.."/titlebar/floating_normal_active.png" theme.titlebar_floating_button_focus_active = theme_dir.."/titlebar/floating_focus_active.png" theme.titlebar_maximized_button_normal_inactive = theme_dir.."/titlebar/maximized_normal_inactive.png" theme.titlebar_maximized_button_focus_inactive = theme_dir.."/titlebar/maximized_focus_inactive.png" theme.titlebar_maximized_button_normal_active = theme_dir.."/titlebar/maximized_normal_active.png" theme.titlebar_maximized_button_focus_active = theme_dir.."/titlebar/maximized_focus_active.png" theme.wallpaper = theme_dir.."/background.png" -- You can use your own layout icons like this: theme.layout_fairh = theme_dir.."/layouts/fairh.png" theme.layout_fairv = theme_dir.."/layouts/fairv.png" theme.layout_floating = theme_dir.."/layouts/floating.png" theme.layout_magnifier = theme_dir.."/layouts/magnifier.png" theme.layout_max = theme_dir.."/layouts/max.png" theme.layout_fullscreen = theme_dir.."/layouts/fullscreen.png" theme.layout_tilebottom = theme_dir.."/layouts/tilebottom.png" theme.layout_tileleft = theme_dir.."/layouts/tileleft.png" theme.layout_tile = theme_dir.."/layouts/tile.png" theme.layout_tiletop = theme_dir.."/layouts/tiletop.png" theme.layout_spiral = theme_dir.."/layouts/spiral.png" theme.layout_dwindle = theme_dir.."/layouts/dwindle.png" theme.layout_cornernw = theme_dir.."/layouts/cornernww.png" theme.layout_cornerne = theme_dir.."/layouts/cornernew.png" theme.layout_cornersw = theme_dir.."/layouts/cornersww.png" theme.layout_cornerse = theme_dir.."/layouts/cornersew.png" theme.awesome_icon = theme_dir.."/awesome-icon.png" -- Define the icon theme for application icons. If not set then the icons -- from /usr/share/icons and /usr/share/icons/hicolor will be used. theme.icon_theme = nil return theme -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
unlicense
zynjec/darkstar
scripts/zones/Port_Windurst/npcs/Kunchichi.lua
9
1034
----------------------------------- -- Area: Port Windurst -- NPC: Kunchichi -- Type: Standard NPC -- !pos -115.933 -4.25 109.533 240 ----------------------------------- require("scripts/globals/npc_util") require("scripts/globals/settings") require("scripts/globals/quests") require("scripts/globals/magic") ----------------------------------- function onSpawn(npc) npcUtil.castingAnimation(npc, dsp.magic.spellGroup.BLACK, 16) end function onTrade(player,npc,trade) end function onTrigger(player,npc) local WildcatWindurst = player:getCharVar("WildcatWindurst") if player:getQuestStatus(WINDURST,dsp.quest.id.windurst.LURE_OF_THE_WILDCAT) == QUEST_ACCEPTED and player:getMaskBit(WildcatWindurst,15) == false then player:startEvent(623) else player:startEvent(228) end end function onEventUpdate(player,csid,option) end function onEventFinish(player,csid,option) if (csid == 623) then player:setMaskBit(player:getCharVar("WildcatWindurst"),"WildcatWindurst",15,true) end end
gpl-3.0
Vadavim/jsr-darkstar
scripts/zones/PsoXja/npcs/_i99.lua
17
3621
----------------------------------- -- Area: Pso'Xja -- NPC: Stone Gate ----------------------------------- package.loaded["scripts/zones/PsoXja/TextIDs"] = nil; ----------------------------------- require("scripts/globals/missions"); require("scripts/zones/PsoXja/TextIDs"); require("scripts/globals/keyitems"); ----------------------------------- -- onTrade ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger ----------------------------------- function onTrigger(player,npc) if (player:getCurrentMission(COP) == THE_ENDURING_TUMULT_OF_WAR and player:getVar("PromathiaStatus")==4) then player:startEvent(0x0002); elseif (player:getCurrentMission(COP) == DESIRES_OF_EMPTINESS and player:getVar("PromathiaStatus")==3) then player:startEvent(0x006A); -- Start Floor 1, 3 elseif (player:getCurrentMission(COP) == DESIRES_OF_EMPTINESS and player:getVar("PromathiaStatus")==5) then player:startEvent(0x006D); -- Start Floor 1, 3 or 4 elseif (player:hasCompletedMission(COP,DESIRES_OF_EMPTINESS) or (player:getCurrentMission(COP) == DESIRES_OF_EMPTINESS and player:getVar("PromathiaStatus")==7)) then player:startEvent(0x0070); -- Start Floor 1, 3, 4, or 5 elseif (player:hasCompletedMission(COP,THE_ENDURING_TUMULT_OF_WAR)or player:hasCompletedMission(COP,THE_LAST_VERSE)) then player:startEvent(0x0032); -- Start Floor 1 else player:messageSpecial(DOOR_LOCKED); end return 1; end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- Retail packet captures have been marked {R}. Please don't change them. if (csid == 0x0002 and option == 1 ) then player:setVar("PromathiaStatus",0); player:completeMission(COP,THE_ENDURING_TUMULT_OF_WAR); player:addMission(COP,DESIRES_OF_EMPTINESS); player:addKeyItem(LIGHT_OF_VAHZL); player:messageSpecial(LIGHT_OF_VAHZL); player:setPos(-14.744,0.036,-119.736,1,22); -- To Floor 1 {R} elseif (csid == 0x0032 and option == 1) then player:setPos(-14.744,0.036,-119.736,1,22); -- To Floor 1 {R} elseif (csid == 0x006A) then if (option == 1) then player:setPos(-14.744,0.036,-119.736,1,22); -- To Floor 1 {R} elseif (option == 2) then player:setPos(183.546,0,-59.906,0,22); -- To Floor 3 (Propagator) {R} end elseif (csid == 0x006D) then if (option == 1) then player:setPos(-14.744,0.036,-119.736,1,22); -- To Floor 1 {R} elseif (option == 2) then --floor 3 player:setPos(183.546,0,-59.906,0,22); -- To Floor 3 (Propagator) {R} elseif (option == 2) then player:setPos(415.757,0,139.977,128,22); -- To Floor 4 (Solicitor) {R} end elseif (csid == 0x0070) then if (option == 1) then player:setPos(-14.744,0.036,-119.736,1,22); -- To Floor 1 {R} elseif (option == 2) then --floor 3 player:setPos(183.546,0,-59.906,0,22); -- To Floor 3 (Propagator) {R} elseif (option == 3) then player:setPos(415.757,0,139.977,128,22); -- To Floor 4 (Solicitor) {R} elseif (option == 4) then player:setPos(-336.001,0,139.815,0,22); -- To Floor 5 (Ponderer) {R} end end end;
gpl-3.0
Vadavim/jsr-darkstar
scripts/zones/Abyssea-Tahrongi/npcs/qm6.lua
14
1343
----------------------------------- -- Zone: Abyssea-Tahrongi -- NPC: qm6 (???) -- Spawns Gancanagh -- @pos ? ? ? 45 ----------------------------------- require("scripts/globals/status"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) --[[ if (trade:hasItemQty(2920,1) and trade:getItemCount() == 1) then -- Player has all the required items. if (GetMobAction(16961922) == ACTION_NONE) then -- Mob not already spawned from this SpawnMob(16961922):updateClaim(player); -- Spawn NM, Despawn after inactive for 5 minutes (pt has to reclaim within 5 of a wipe) player:tradeComplete(); end end ]] end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(1010, 2920); -- Inform payer what items they need. end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0