Name | Type | is_array | initial_value |
SpecialShop | unit | No |
library FrameLoader initializer init_function
// in 1.31 and upto 1.32.9 PTR (when I wrote this). Frames are not correctly saved and loaded, breaking the game.
// This library runs all functions added to it with a 0s delay after the game was loaded.
// function FrameLoaderAdd takes code func returns nothing
// func runs when the game is loaded.
globals
private trigger eventTrigger = CreateTrigger()
private trigger actionTrigger = CreateTrigger()
private timer t = CreateTimer()
endglobals
function FrameLoaderAdd takes code func returns nothing
call TriggerAddAction(actionTrigger, func)
endfunction
private function timerAction takes nothing returns nothing
call TriggerExecute(actionTrigger)
endfunction
private function eventAction takes nothing returns nothing
call TimerStart(t, 0, false, function timerAction)
endfunction
private function init_function takes nothing returns nothing
call TriggerRegisterGameEvent(eventTrigger, EVENT_GAME_LOADED)
call TriggerAddAction(eventTrigger, function eventAction)
endfunction
endlibrary
library RaceSounds initializer init_function
globals
sound array SoundNoGold
sound array SoundNoLumber
endglobals
private function init_function takes nothing returns nothing
local integer index
set index = GetHandleId(RACE_HUMAN)
set SoundNoGold[index] = CreateSound("Sound\\Interface\\Warning\\Human\\KnightNoGold1.wav", false, false, false, 10, 10, "")
call SetSoundParamsFromLabel(SoundNoGold[index], "NoGoldHuman")
call SetSoundDuration(SoundNoGold[index], 1618)
set SoundNoLumber[index] = CreateSound("Sound\\Interface\\Warning\\Human\\KnightNoLumber1.wav", false, false, false, 10, 10, "")
call SetSoundParamsFromLabel(SoundNoLumber[index], "NoLumberHuman")
call SetSoundDuration(SoundNoLumber[index], 1903)
set index = GetHandleId(ConvertRace(11))
set SoundNoGold[index] = CreateSound("Sound\\Interface\\Warning\\Naga\\NagaNoGold1.wav", false, false, false, 10, 10, "")
call SetSoundParamsFromLabel(SoundNoGold[index], "NoGoldNaga")
call SetSoundDuration(SoundNoGold[index], 2690)
set SoundNoLumber[index] = CreateSound("Sound\\Interface\\Warning\\Naga\\NagaNoLumber1.wav", false, false, false, 10, 10, "")
call SetSoundParamsFromLabel(SoundNoLumber[index], "NoLumberNaga")
call SetSoundDuration(SoundNoLumber[index], 2011)
set index = GetHandleId(RACE_ORC)
set SoundNoGold[index] = CreateSound("Sound\\Interface\\Warning\\Orc\\GruntNoGold1.wav", false, false, false, 10, 10, "")
call SetSoundParamsFromLabel(SoundNoGold[index], "NoGoldOrc")
call SetSoundDuration(SoundNoGold[index], 1450)
set SoundNoLumber[index] = CreateSound("Sound\\Interface\\Warning\\Orc\\GruntNoLumber1.wav", false, false, false, 10, 10, "")
call SetSoundParamsFromLabel(SoundNoLumber[index], "NoLumberOrc")
call SetSoundDuration(SoundNoLumber[index], 1219)
set index = GetHandleId(RACE_NIGHTELF)
set SoundNoGold[index] = CreateSound("Sound\\Interface\\Warning\\NightElf\\SentinelNoGold1.wav", false, false, false, 10, 10, "")
call SetSoundParamsFromLabel(SoundNoGold[index], "NoGoldNightElf")
call SetSoundDuration(SoundNoGold[index], 1229)
set SoundNoLumber[index] = CreateSound("Sound\\Interface\\Warning\\NightElf\\SentinelNoLumber1.wav", false, false, false, 10, 10, "")
call SetSoundParamsFromLabel(SoundNoLumber[index], "NoLumberNightElf")
call SetSoundDuration(SoundNoLumber[index], 1454)
set index = GetHandleId(RACE_UNDEAD)
set SoundNoGold[index] = CreateSound("Sound\\Interface\\Warning\\Undead\\NecromancerNoGold1.wav", false, false, false, 10, 10, "")
call SetSoundParamsFromLabel(SoundNoGold[index], "NoGoldUndead")
call SetSoundDuration(SoundNoGold[index], 2005)
set SoundNoLumber[index] = CreateSound("Sound\\Interface\\Warning\\Undead\\NecromancerNoLumber1.wav", false, false, false, 10, 10, "")
call SetSoundParamsFromLabel(SoundNoLumber[index], "NoLumberUndead")
call SetSoundDuration(SoundNoLumber[index], 2005)
endfunction
endlibrary
library IsRightClick requires optional FrameLoader
// function IsRightClick takes player p returns boolean
// tells you if the last click was current a rightclick, meant to be used inside a FrameEventMouseUp
globals
private boolean array isRight
private trigger frameTrigger
endglobals
function IsRightClick takes player p returns boolean
return isRight[GetPlayerId(p)]
endfunction
private function Action takes nothing returns nothing
set isRight[GetPlayerId(GetTriggerPlayer())] = BlzGetTriggerPlayerMouseButton() == MOUSE_BUTTON_TYPE_RIGHT
endfunction
private function FrameAction takes nothing returns nothing
// when the game is paused reset the lastClick Flag. This has to be done because EVENT_PLAYER_MOUSE_UP does not trigger during Pause
local integer i = 0
loop
set isRight[i] = false
set i = i + 1
exitwhen i == bj_MAX_PLAYERS
endloop
endfunction
private function FrameInit takes nothing returns nothing
call BlzTriggerRegisterFrameEvent(frameTrigger, BlzGetFrameByName("PauseButton", 0), FRAMEEVENT_CONTROL_CLICK)
endfunction
private module Init
private static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
set frameTrigger = CreateTrigger()
call TriggerAddAction(frameTrigger, function FrameAction)
call TriggerAddAction(t, function Action)
loop
call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_MOUSE_UP)
set i = i + 1
exitwhen i == bj_MAX_PLAYERS
endloop
static if LIBRARY_FrameLoader then
call FrameLoaderAdd(function FrameInit)
endif
endmethod
endmodule
// Dummy struct that's only used for initialization purposes
private struct S extends array
implement Init
endstruct
endlibrary
library SimpleTooltip
function CreateSimpleTooltip takes framehandle frame, string text returns framehandle
// this FRAME is important when the Box is outside of 4:3 it can be limited to 4:3.
local framehandle toolTipParent = BlzCreateFrameByType("FRAME", "", frame, "", 0)
local framehandle toolTipBox = BlzCreateFrame("EscMenuControlBackdropTemplate", toolTipParent, 0, 0)
local framehandle toolTip = BlzCreateFrame("TasButtonTextTemplate", toolTipBox, 0, 0)
call BlzFrameSetPoint(toolTip, FRAMEPOINT_BOTTOM, frame, FRAMEPOINT_TOP, 0, 0.008)
call BlzFrameSetPoint(toolTipBox, FRAMEPOINT_TOPLEFT, toolTip, FRAMEPOINT_TOPLEFT, -0.008, 0.008)
call BlzFrameSetPoint(toolTipBox, FRAMEPOINT_BOTTOMRIGHT, toolTip, FRAMEPOINT_BOTTOMRIGHT, 0.008, -0.008)
call BlzFrameSetText(toolTip, text)
call BlzFrameSetTooltip(frame, toolTipParent)
return toolTip
endfunction
endlibrary
library TasItemCost
//function TasItemCaclCost takes integer itemCode returns nothing
//function TasItemGetCostGold takes integer itemCode returns integer
//function TasItemGetCostLumber takes integer itemCode returns integer
globals
private unit shop
// defines position of a hidden shop to get item costs
// the size is used to clear up bought items
private real shopRectSize = 1000
private real shopRectX = 180
private real shopRectY = -340
private rect shopRect
private player shopOwner = Player(bj_PLAYER_NEUTRAL_EXTRA)
private integer array Test
private integer TestCount = 0
private integer HASH_GOLD = StringHash("GOLD")
private integer HASH_LUMBER = StringHash("LUMBER")
private integer HASH_CHARGE = StringHash("CHARGE")
hashtable TasItemHash = InitHashtable()
endglobals
private function ClearItem takes nothing returns nothing
//call BJDebugMsg("Enum " + GetItemName(GetEnumItem()))
call RemoveItem(GetEnumItem())
endfunction
private function ClearItemStart takes nothing returns nothing
//call BJDebugMsg("ClearItemStart")
call EnumItemsInRect(shopRect, null, function ClearItem)
endfunction
private function TasItemCalcDestroy takes nothing returns nothing
call ClearItemStart()
call ShowUnit(shop, true)
call RemoveUnit(shop)
call RemoveRect(shopRect)
endfunction
private function Start takes nothing returns nothing
local integer itemCode = Test[1]
local integer gold
local integer lumber
local item i
call AddItemToStock(shop, itemCode, 1, 1)
call SetPlayerState(shopOwner, PLAYER_STATE_RESOURCE_GOLD, 99999999)
call SetPlayerState(shopOwner, PLAYER_STATE_RESOURCE_LUMBER, 99999999)
set gold = GetPlayerState(shopOwner, PLAYER_STATE_RESOURCE_GOLD)
set lumber = GetPlayerState(shopOwner, PLAYER_STATE_RESOURCE_LUMBER)
call IssueNeutralImmediateOrderById(shopOwner, shop, itemCode)
call SaveInteger(TasItemHash, itemCode, HASH_GOLD, gold - GetPlayerState(shopOwner, PLAYER_STATE_RESOURCE_GOLD))
call SaveInteger(TasItemHash, itemCode, HASH_LUMBER, lumber - GetPlayerState(shopOwner, PLAYER_STATE_RESOURCE_LUMBER))
set i = CreateItem(itemCode,0,0)
call SaveInteger(TasItemHash, itemCode, HASH_CHARGE, GetItemCharges(i))
call RemoveItem(i)
set i = null
call RemoveItemFromStock(shop, itemCode)
// testing order does not matter much, simple reindex
set Test[1] = Test[TestCount]
set TestCount = TestCount - 1
call ClearItemStart()
if TestCount > 0 then
call Start()
else
//call TimerStart(t, 1, false, function ClearItemStart)
endif
endfunction
function TasItemCaclCost takes integer itemCode returns nothing
local item i
// if there is already data for that itemcode, skip it
if not HaveSavedInteger(TasItemHash, itemCode, HASH_GOLD) then
// is this a valid itemCode? Create it, if that fails skip testing it
set i = CreateItem(itemCode, 0, 0)
if GetHandleId(i) > 0 then
call RemoveItem(i)
set TestCount = TestCount + 1
set Test[TestCount] = itemCode
endif
if TestCount > 0 then
call Start()
endif
set i = null
endif
endfunction
function TasItemGetCostGold takes integer itemCode returns integer
call TasItemCaclCost(itemCode)
return LoadInteger(TasItemHash, itemCode, HASH_GOLD)
endfunction
function TasItemGetCostLumber takes integer itemCode returns integer
call TasItemCaclCost(itemCode)
return LoadInteger(TasItemHash, itemCode, HASH_LUMBER)
endfunction
function TasItemGetCharges takes integer itemCode returns integer
call TasItemCaclCost(itemCode)
return LoadInteger(TasItemHash, itemCode, HASH_CHARGE)
endfunction
private module Init
private static method onInit takes nothing returns nothing
set shopRect = Rect(0, 0, shopRectSize, shopRectSize)
set shop = CreateUnit(shopOwner, 'nmrk', shopRectX, shopRectY, 0)
call SetUnitX(shop, shopRectX)
call SetUnitY(shop, shopRectY)
call MoveRectTo(shopRect, shopRectX, shopRectY)
call UnitAddAbility(shop, 'AInv')
call IssueNeutralTargetOrder(shopOwner, shop, "smart", shop)
call ShowUnit(shop, false)
endmethod
endmodule
// Dummy struct that's only used for initialization purposes
private struct S extends array
implement Init
endstruct
endlibrary
library String initializer Init
//String functions v1.04
//made by MaskedPoptart
//--------------------IMPORTANT FUNCTIONS------------------------
function FindIndexFrom takes string mainString, string stringToFind, integer startingIndex returns integer
local integer msLength = StringLength(mainString)
local integer sfLength = StringLength(stringToFind)
local integer i = startingIndex
if(sfLength > msLength or i < 0)then
return -1
endif
loop
exitwhen i > msLength - sfLength
if(SubString(mainString, i, i+sfLength) == stringToFind)then
return i
endif
set i = i + 1
endloop
return -1
endfunction
function FindIndex takes string mainString, string stringToFind returns integer
return FindIndexFrom(mainString, stringToFind, 0)
endfunction
function FindLastIndexFrom takes string mainString, string stringToFind, integer startingIndex returns integer
local integer msLength = StringLength(mainString)
local integer sfLength = StringLength(stringToFind)
local integer i = msLength-sfLength
if(startingIndex < i)then
set i = startingIndex
endif
if(sfLength > msLength)then
return -1
endif
loop
exitwhen i < 0
if(SubString(mainString, i, i+sfLength) == stringToFind)then
return i
endif
set i = i - 1
endloop
return -1
endfunction
function FindLastIndex takes string mainString, string stringToFind returns integer
return FindLastIndexFrom(mainString, stringToFind, 2147483647)
endfunction
//-----------------------COLOR FUNCTIONS ------------------------
globals
private playercolor array PLAYER_COLORS
private string array PLAYER_COLOR_STRINGS
private constant string HEX_CHARS = "0123456789abcdef"
private string COLOR_ENDING = "|r"
endglobals
private function Init takes nothing returns nothing
local integer i = 0
loop
exitwhen i >= 12
set PLAYER_COLORS[i] = ConvertPlayerColor(i)
set i = i + 1
endloop
set PLAYER_COLOR_STRINGS[0] = "|cffff0303"
set PLAYER_COLOR_STRINGS[1] = "|cff0042ff"
set PLAYER_COLOR_STRINGS[2] = "|cff1ce6b9"
set PLAYER_COLOR_STRINGS[3] = "|cff540081"
set PLAYER_COLOR_STRINGS[4] = "|cfffffc01"
set PLAYER_COLOR_STRINGS[5] = "|cfffe8a0e"
set PLAYER_COLOR_STRINGS[6] = "|cff20c000"
set PLAYER_COLOR_STRINGS[7] = "|cffe55bb0"
set PLAYER_COLOR_STRINGS[8] = "|cff959697"
set PLAYER_COLOR_STRINGS[9] = "|cff7ebff1"
set PLAYER_COLOR_STRINGS[10] = "|cff106246"
set PLAYER_COLOR_STRINGS[11] = "|cff4e2a04"
set PLAYER_COLOR_STRINGS[12] = "|cff272727"
set PLAYER_COLOR_STRINGS[13] = "|cff272727"
set PLAYER_COLOR_STRINGS[14] = "|cff272727"
endfunction
function PlayerColor2ColorString takes playercolor pc returns string
local integer i = 0
loop
exitwhen i >= 12
if(PLAYER_COLORS[i] == pc)then
return PLAYER_COLOR_STRINGS[i]
endif
set i = i + 1
endloop
return PLAYER_COLOR_STRINGS[12]
endfunction
function GetPlayerColorString takes player p returns string
return PlayerColor2ColorString(GetPlayerColor(p))
endfunction
function GetPlayerNameColored takes player p returns string
return GetPlayerColorString(p)+GetPlayerName(p)+COLOR_ENDING
endfunction
//please use responsibly
function RemoveColorCode takes string mainString returns string
local integer msLength = StringLength(mainString)
if(msLength<12)then
return mainString
endif
return SubString(mainString, 10, msLength-2)
endfunction
function IBase2S takes integer base10Num, integer newBase returns string
local integer placeNum //number at current place
local string newBaseString = ""
loop
exitwhen base10Num == 0
set placeNum = ModuloInteger(base10Num, newBase)
set newBaseString = SubString(HEX_CHARS, placeNum, placeNum+1) + newBaseString
set base10Num = base10Num / newBase
endloop
if(newBaseString == "")then
return "0"
endif
return newBaseString
endfunction
function SBase2I takes string oldBaseString, integer oldBase returns integer
local integer base10Num = 0
local integer placeNum //number at current place
local integer placeIndex = 0 //index of current place. 0 = one's place, etc.
local integer i = StringLength(oldBaseString)-1
loop
exitwhen i < 0
set placeNum = FindLastIndexFrom(HEX_CHARS, SubString(oldBaseString, i, i+1), oldBase-1)
set base10Num = base10Num + placeNum*R2I(Pow(oldBase, placeIndex))
set placeIndex = placeIndex + 1
set i = i - 1
endloop
return base10Num
endfunction
function ConvertRGBToColorString takes integer red, integer green, integer blue returns string
local string RR
local string GG
local string BB
if(red>255)then
set red = 255
endif
if(green>255)then
set green = 255
endif
if(blue>255)then
set blue = 255
endif
set RR = IBase2S(red, 16)
set GG = IBase2S(green, 16)
set BB = IBase2S(blue, 16)
if(StringLength(RR)<2)then
set RR = "0"+RR
endif
if(StringLength(GG)<2)then
set GG = "0"+GG
endif
if(StringLength(BB)<2)then
set BB = "0"+BB
endif
return "|cff"+RR+GG+BB
endfunction
function GetColoredString takes string str, integer r, integer g, integer b returns string
return ConvertRGBToColorString(r,g,b)+str+COLOR_ENDING
endfunction
//----------------------CHAT EVENT FUNCTIONS------------------------------
function RemoveString takes string mainString, string toRemove returns string
local integer i = 0
local string currentString
local integer msLength = StringLength(mainString)
local integer trLength = StringLength(toRemove)
if(trLength > msLength)then
return mainString
endif
loop
exitwhen i+trLength > msLength
set currentString = SubString(mainString, i, i+trLength)
if(currentString == toRemove)then
if(i+trLength <= msLength)then
set mainString = SubString(mainString, 0, i)+SubString(mainString, i+trLength, msLength)
else
set mainString = SubString(mainString, 0, i)
endif
set i = i - trLength
endif
set i = i + 1
endloop
return mainString
endfunction
function NumOccurances takes string mainString, string stringToFind returns integer
local integer count = 0
local integer i = 0
local integer msLength = StringLength(mainString)
local integer sfLength = StringLength(stringToFind)
loop
exitwhen (i+sfLength) > msLength
if(SubString(mainString, i, i+sfLength) == stringToFind)then
set count = count + 1
endif
set i = i + 1
endloop
return count
endfunction
function S2B takes string word returns boolean
if(word == "true")then
return true
endif
return false
endfunction
function S2Player takes string word returns player
return Player(S2I(SubString(word, 1, StringLength(word))))
endfunction
globals
private integer MIN_RAW_CODE = ' ' //32
private string RAW_CHARS = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
endglobals
function S2RawCode takes string str returns integer
local integer rawCode = 0
local integer placeNum //number at current place
local integer placeIndex = 0 //index of current place. 0 = one's place, etc.
local integer i = StringLength(str)-1
loop
exitwhen i < 0
set placeNum = MIN_RAW_CODE + FindIndex(RAW_CHARS, SubString(str, i, i+1))
//the char at index 0 of RAW_CHARS has ASCII value 32, so we need to offset each FindIndex by 32.
set rawCode = rawCode + placeNum*R2I(Pow(256., placeIndex))
set placeIndex = placeIndex + 1
set i = i - 1
endloop
return rawCode
endfunction
//-----------------------DEBUG FUNCTIONS-------------------------
function B2S takes boolean bool returns string
if(bool)then
return "true"
endif
return "false"
endfunction
function Player2S takes player p returns string
return "Player("+I2S(GetPlayerId(p))+")"
endfunction
function Unit2S takes unit u returns string
return GetUnitName(u)+ "_"+I2S(GetHandleId(u)-0x100000)
endfunction
function RawCode2S takes integer rawCode returns string
local integer placeNum //number at current place
local string str = ""
if(rawCode < MIN_RAW_CODE)then
return str
endif
loop
exitwhen rawCode == 0
set placeNum = ModuloInteger(rawCode, 256) - MIN_RAW_CODE
set str = SubString(RAW_CHARS, placeNum, placeNum+1) + str
set rawCode = rawCode / 256
endloop
return str
endfunction
endlibrary
native GetUnitGoldCost takes integer rawCode returns integer
native GetUnitWoodCost takes integer rawCode returns integer
library TasButtonList initializer Init uses String, IsRightClick, optional FrameLoader, optional SimpleTooltip
// TasButtonList10c (CC) by Tasyen
//function CreateTasButtonList10 takes string buttonName, integer cols, integer rows, framehandle parent, code buttonAction, code rightClickAction, code updateAction, code searchAction, code filterAction, code asyncAction, code asyncRigthAction, real colGap, real rowGap returns integer
//function CreateTasButtonListEx takes string buttonName, integer cols, integer rows, framehandle parent, code buttonAction, code rightClickAction, code updateAction, code searchAction, code filterAction returns integer
//create a new List
//parent is the container of this Frame it will attach itself to its TOP.
//the given functions are called over Triggers
//buttonAction is the function that executes when an option is clicked.
//when your data are unit-RawCodes then you can skip updateAction & searchAction.
//updateAction runs for each Button and is used to set the diplayed content.
//searchAction is a function that returns true if the current data matches the searchText.
//filterAction is meant to be used when one wants an addtional non text based filtering, with returning true allowing data or false rejecting it.
//searchAction , udateAction & filterAction are async this functions should not do anything that alters the game state/flow.
//function CreateTasButtonList takes integer buttonCount, framehandle parent, code buttonAction, code updateAction, code searchAction, code filterAction returns integer
// wrapper for CreateTasButtonListEx, 1 col, buttonCount rows.
//function CreateTasButtonListV2 takes integer rowCount, framehandle parent, code buttonAction, code updateAction, code searchAction, code filterAction returns integer
// 2 Buttons each Row, takes more Height then the other Versions
//function CreateTasButtonListV3 takes integer rowCount, framehandle parent, code buttonAction, code updateAction, code searchAction, code filterAction returns integer
// 3 Buttons each Row, only Icon, and Costs
//function TasButtonListClearDataEx takes integer listIndex, integer playerIndex returns nothing
//function TasButtonListClearData takes integer listIndex returns nothing
// remove all data
//function TasButtonListRemoveDataEx takes integer listIndex, integer data, integer playerIndex returns nothing
//function TasButtonListRemoveData takes integer listIndex, integer data returns nothing
// search for data and remove it
//function TasButtonListAddDataEx takes integer listIndex, integer data, integer playerIndex returns nothing
//function TasButtonListAddData takes integer listIndex, integer data returns nothing
// add data for one Button
//function TasButtonListCopyDataEx takes integer writeObject, integer readObject, integer playerIndex returns nothing
//function TasButtonListCopyData takes integer writeObject, integer readObject returns nothing
// writeObject uses the same data as readObject and calls UpdateButtonList.
//function UpdateTasButtonList takes integer listIndex returns nothing
// update the displayed Content should be done after Data was added or removed was used.
//function TasButtonListSearch takes integer listIndex, string text returns nothing
// The buttonList will search it's data for the given text, if nil is given as text it will search for what the user currently has in its box.
// This will also update the buttonList
globals
//args for custom user actions
integer TasButtonListData = 0
string TasButtonListText = ""
boolean TasButtonListIsSearching = false
integer TasButtonListIndex = 0
framehandle TasButtonListFrame = null
// System
public hashtable Hash = InitHashtable()
private integer Counter = 0 //amount of Lists created, each index is one List
private trigger SyncTrigger = CreateTrigger()
private trigger ButtonTrigger = CreateTrigger()
private trigger SearchTrigger = CreateTrigger()
private trigger ButtonScrollTrigger = CreateTrigger()
private trigger SliderTrigger = CreateTrigger()
private trigger SyncRightTrigger = CreateTrigger()
private trigger ButtonRightTrigger = CreateTrigger()
private sound RightClickSound
// ButtonLists
framehandle array TasButtonListSlider
framehandle array TasButtonListSliderText
framehandle array TasButtonListParent
framehandle array TasButtonListInputFrame
framehandle array TasButtonListSyncFrame
framehandle array TasButtonListSyncFrameRight
integer array TasButtonListButtonCount
integer array TasButtonListCreateContext
string array TasButtonListButtonName
integer array TasButtonListStepSize
trigger array TasButtonListButtonAction
trigger array TasButtonListRightAction
trigger array TasButtonListUpdateAction
trigger array TasButtonListSearchAction
trigger array TasButtonListFilterAction
trigger array TasButtonListAsyncAction
trigger array TasButtonListAsyncRightAction
integer array TasButtonListViewPoint
location array TasButtonListDataList
location array TasButtonListDataListFiltered
real TasButtonListGapCol = 0.0
real TasButtonListGapRow = 0.0
public integer CreateContextCounter = 0
endglobals
// update the shown content
function UpdateTasButtonList takes integer listIndex returns nothing
local integer dataHash = GetHandleId(LoadLocationHandle(Hash, GetHandleId(TasButtonListDataList[listIndex]), GetPlayerId(GetLocalPlayer())))
local integer filteredDataHash = GetHandleId(TasButtonListDataListFiltered[listIndex])
local integer dataFilteredCount = LoadInteger(Hash, filteredDataHash, 0)
local integer i = 1
set TasButtonListIndex = listIndex
call BlzFrameSetVisible(TasButtonListSlider[listIndex], dataFilteredCount > TasButtonListButtonCount[listIndex])
loop
exitwhen i > TasButtonListButtonCount[listIndex]
set TasButtonListFrame = BlzGetFrameByName(TasButtonListButtonName[listIndex], TasButtonListCreateContext[listIndex] + i)
if dataFilteredCount >= i then
set TasButtonListData = LoadInteger(Hash, dataHash, LoadInteger(Hash, filteredDataHash, i + TasButtonListViewPoint[listIndex]))
call TriggerEvaluate(TasButtonListUpdateAction[listIndex])
call BlzFrameSetVisible(TasButtonListFrame, true)
else
call BlzFrameSetVisible(TasButtonListFrame, false)
endif
set i = i + 1
endloop
endfunction
function TasButtonListSearch takes integer listIndex, string text returns nothing
local integer filteredDataHash = GetHandleId(TasButtonListDataListFiltered[listIndex])
local integer dataHash = GetHandleId(LoadLocationHandle(Hash, GetHandleId(TasButtonListDataList[listIndex]), GetPlayerId(GetLocalPlayer())))
local integer filteredDataCount
local integer i
local integer iEnd
if text == null or text == "" then
set text = BlzFrameGetText(TasButtonListInputFrame[listIndex])
endif
if GetLocalPlayer() == GetTriggerPlayer() then
set TasButtonListText = text
set TasButtonListIndex = listIndex
call FlushChildHashtable(Hash, filteredDataHash)
set filteredDataCount = 0
if text != "" then
set TasButtonListIsSearching = true
set iEnd = LoadInteger(Hash, dataHash, 0)
set i = 1
loop
exitwhen i > iEnd
set TasButtonListData = LoadInteger(Hash, dataHash, i)
if TriggerEvaluate(TasButtonListSearchAction[listIndex]) and TriggerEvaluate(TasButtonListFilterAction[listIndex]) then
set filteredDataCount = filteredDataCount + 1
call SaveInteger(Hash, filteredDataHash, filteredDataCount, i)
endif
set i = i + 1
endloop
call SaveInteger(Hash, filteredDataHash, 0, filteredDataCount)
else
set TasButtonListIsSearching = false
set iEnd = LoadInteger(Hash, dataHash, 0)
set i = 1
loop
exitwhen i > iEnd
set TasButtonListData = LoadInteger(Hash, dataHash, i)
if TriggerEvaluate(TasButtonListFilterAction[listIndex]) then
set filteredDataCount = filteredDataCount + 1
call SaveInteger(Hash, filteredDataHash, filteredDataCount, i)
endif
set i = i + 1
endloop
call SaveInteger(Hash, filteredDataHash, 0, filteredDataCount)
endif
//update Slider, with that also update
call BlzFrameSetMinMaxValue(TasButtonListSlider[listIndex], TasButtonListButtonCount[listIndex], filteredDataCount)
call BlzFrameSetValue(TasButtonListSlider[listIndex], 999999)
endif
endfunction
function TasButtonListTriggerActionSync takes nothing returns nothing
local integer listIndex = LoadInteger(Hash, GetHandleId(BlzGetTriggerFrame()), 0)
local integer dataIndex = R2I(BlzGetTriggerFrameValue() + 0.5)
set TasButtonListData = LoadInteger(Hash, GetHandleId(LoadLocationHandle(Hash, GetHandleId(TasButtonListDataList[listIndex]), GetPlayerId(GetTriggerPlayer()))), dataIndex)
set TasButtonListIndex = listIndex
call TriggerExecute(TasButtonListButtonAction[listIndex])
call UpdateTasButtonList(listIndex)
endfunction
function TasButtonListTriggerActionButton takes nothing returns nothing
local framehandle frame = BlzGetTriggerFrame()
local integer buttonIndex = LoadInteger(Hash, GetHandleId(frame), 1)
local integer listIndex = LoadInteger(Hash, GetHandleId(frame), 0)
local integer dataIndex = LoadInteger(Hash, GetHandleId(TasButtonListDataListFiltered[listIndex]), buttonIndex + TasButtonListViewPoint[listIndex])
local integer data = LoadInteger(Hash, GetHandleId(LoadLocationHandle(Hash, GetHandleId(TasButtonListDataList[listIndex]), GetPlayerId(GetTriggerPlayer()))), dataIndex)
call BlzFrameSetEnable(frame, false)
call BlzFrameSetEnable(frame, true)
set TasButtonListData = data
set TasButtonListIndex = listIndex
set TasButtonListFrame = frame
if GetLocalPlayer() == GetTriggerPlayer() then
call TriggerEvaluate(TasButtonListAsyncAction[listIndex])
call BlzFrameSetValue(TasButtonListSyncFrame[listIndex], dataIndex)
endif
set frame = null
endfunction
function TasButtonListTriggerActionSearch takes nothing returns nothing
call TasButtonListSearch(LoadInteger(Hash, GetHandleId(BlzGetTriggerFrame()), 0), null)
endfunction
// scrolling while pointing on Buttons
function TasButtonListTriggerActionButtonScroll takes nothing returns nothing
local integer listIndex = LoadInteger(Hash, GetHandleId(BlzGetTriggerFrame()), 0)
local framehandle frame = TasButtonListSlider[listIndex]
if GetLocalPlayer() == GetTriggerPlayer() then
if BlzGetTriggerFrameValue() > 0 then
call BlzFrameSetValue(frame, BlzFrameGetValue(frame) + TasButtonListStepSize[listIndex])
else
call BlzFrameSetValue(frame, BlzFrameGetValue(frame) - TasButtonListStepSize[listIndex])
endif
endif
set frame = null
endfunction
// scrolling while pointing on slider aswell as calling
function TasButtonListTriggerActionSlider takes nothing returns nothing
local integer listIndex = LoadInteger(Hash, GetHandleId(BlzGetTriggerFrame()), 0)
local integer filteredDataHash = GetHandleId(TasButtonListDataListFiltered[listIndex])
local integer dataFilteredCount = LoadInteger(Hash, filteredDataHash, 0)
local framehandle frame = BlzGetTriggerFrame()
if GetLocalPlayer() == GetTriggerPlayer() then
if BlzGetTriggerFrameEvent() == FRAMEEVENT_MOUSE_WHEEL then
if BlzGetTriggerFrameValue() > 0 then
call BlzFrameSetValue(frame, BlzFrameGetValue(frame) + TasButtonListStepSize[listIndex])
else
call BlzFrameSetValue(frame, BlzFrameGetValue(frame) - TasButtonListStepSize[listIndex])
endif
else
// when there is enough data use viewPoint. the Viewpoint is reduced from the data to make top being top.
if dataFilteredCount > TasButtonListButtonCount[listIndex] then
set TasButtonListViewPoint[listIndex] = dataFilteredCount - R2I(BlzGetTriggerFrameValue())
else
set TasButtonListViewPoint[listIndex] = 0
endif
if TasButtonListSliderText[listIndex] != null then
call BlzFrameSetText(TasButtonListSliderText[listIndex], I2S(R2I(0.5 + dataFilteredCount - BlzFrameGetValue(frame))) + "/" + I2S(R2I(0.5 + dataFilteredCount - TasButtonListButtonCount[listIndex])))
endif
call UpdateTasButtonList(listIndex)
endif
endif
set frame = null
endfunction
// runs once for each button shown
function UpdateTasButtonListDefaultObject takes nothing returns nothing
//TasButtonListFrame
//TasButtonListData
//TasButtonListIndex
local integer frameHandle = GetHandleId(TasButtonListFrame)
local integer data = TasButtonListData
local integer buttonIndex = LoadInteger(Hash, frameHandle, 1)
local integer listIndex = LoadInteger(Hash, frameHandle, 0)
local integer lumber
local integer gold
local integer context = TasButtonListCreateContext[listIndex] + buttonIndex
call BlzFrameSetTexture(BlzGetFrameByName("TasButtonIcon", context), BlzGetAbilityIcon(data), 0, false)
call BlzFrameSetText(BlzGetFrameByName("TasButtonText", context), GetObjectName(data))
call BlzFrameSetTexture(BlzGetFrameByName("TasButtonListTooltipIcon", context), BlzGetAbilityIcon(data), 0, false)
call BlzFrameSetText(BlzGetFrameByName("TasButtonListTooltipName", context), GetObjectName(data))
call BlzFrameSetText(BlzGetFrameByName("TasButtonListTooltipText", context), BlzGetAbilityExtendedTooltip(data, 0))
if not IsUnitIdType(data, UNIT_TYPE_HERO) then
// GetUnitWoodCost GetUnitGoldCost CRASH with heroes
set lumber = GetUnitWoodCost(data)
set gold = GetUnitGoldCost(data)
if GetPlayerState(GetLocalPlayer(), PLAYER_STATE_RESOURCE_GOLD) >= gold then
call BlzFrameSetText(BlzGetFrameByName("TasButtonTextGold", context), I2S(GetUnitGoldCost(data)))
else
call BlzFrameSetText(BlzGetFrameByName("TasButtonTextGold", context), "|cffff2010" + I2S(GetUnitGoldCost(data)))
endif
if GetPlayerState(GetLocalPlayer(), PLAYER_STATE_RESOURCE_LUMBER) >= lumber then
call BlzFrameSetText(BlzGetFrameByName("TasButtonTextLumber", context), I2S(GetUnitWoodCost(data)))
else
call BlzFrameSetText(BlzGetFrameByName("TasButtonTextLumber", context), "|cffff2010" + I2S(GetUnitWoodCost(data)))
endif
else
call BlzFrameSetText(BlzGetFrameByName("TasButtonTextLumber", context), "0")
call BlzFrameSetText(BlzGetFrameByName("TasButtonTextGold", context), "0")
endif
endfunction
function SearchTasButtonListDefaultObject takes nothing returns boolean
//TasButtonListText
//TasButtonListData
//TasButtonListIndex
return FindIndex(GetObjectName(TasButtonListData), TasButtonListText) >= 0
endfunction
function InitTasButtonListObject8c takes framehandle parent, code buttonAction, code rightClickAction, code updateAction, code searchAction, code filterAction, code asyncAction, code asyncRigthAction returns integer
local framehandle frame
local integer playerIndex = 0
set Counter = Counter + 1
// the locations are created to have an unique slot in the hash which are used as something like a Lua table.
set TasButtonListDataList[Counter] = Location(0, 0) //
// each player also got an own list
loop
call SaveLocationHandle(Hash, GetHandleId(TasButtonListDataList[Counter]), playerIndex, Location(0,0))
set playerIndex = playerIndex + 1
exitwhen playerIndex == bj_MAX_PLAYER_SLOTS
endloop
set TasButtonListDataListFiltered[Counter] = Location(0, 0) //
set TasButtonListParent[Counter] = parent
set TasButtonListViewPoint[Counter] = 0
set TasButtonListButtonAction[Counter] = CreateTrigger() //call this inside the SyncAction after a button is clicked
set TasButtonListUpdateAction[Counter] = CreateTrigger() //function defining how to display stuff (async)
set TasButtonListFilterAction[Counter] = CreateTrigger() //function to return the searched Text (async)
set TasButtonListSearchAction[Counter] = CreateTrigger()
set TasButtonListRightAction[Counter] = CreateTrigger()
set TasButtonListAsyncAction[Counter] = CreateTrigger()
set TasButtonListAsyncRightAction[Counter] = CreateTrigger()
call TriggerAddAction(TasButtonListButtonAction[Counter], buttonAction)
if rightClickAction != null then
call TriggerAddAction(TasButtonListRightAction[Counter], rightClickAction)
endif
// update is a condition with it can be run with TriggerEvaluate in localPlayer code. TriggerExecute would desync
if updateAction == null then
call TriggerAddCondition(TasButtonListUpdateAction[Counter], Filter(function UpdateTasButtonListDefaultObject))
else
call TriggerAddCondition(TasButtonListUpdateAction[Counter], Filter(updateAction))
endif
if searchAction == null then
call TriggerAddCondition(TasButtonListSearchAction[Counter], Filter(function SearchTasButtonListDefaultObject))
else
call TriggerAddCondition(TasButtonListSearchAction[Counter], Filter(searchAction))
endif
if filterAction != null then
call TriggerAddCondition(TasButtonListFilterAction[Counter], Filter(filterAction))
endif
if asyncAction != null then
call TriggerAddCondition(TasButtonListAsyncAction[Counter], Filter(asyncAction))
endif
if asyncRigthAction != null then
call TriggerAddCondition(TasButtonListAsyncRightAction[Counter], Filter(asyncRigthAction))
endif
set frame = BlzCreateFrameByType("SLIDER", "", parent, "", 0)
set TasButtonListSyncFrame[Counter] = frame
call BlzFrameSetMinMaxValue(frame, 0, 9999999)
call BlzFrameSetStepSize(frame, 1.0)
call BlzTriggerRegisterFrameEvent(SyncTrigger, frame, FRAMEEVENT_SLIDER_VALUE_CHANGED)
call BlzFrameSetVisible(frame, false)
call SaveInteger(Hash, GetHandleId(frame), 0, Counter)
set frame = BlzCreateFrameByType("SLIDER", "", parent, "", 0)
set TasButtonListSyncFrameRight[Counter] = frame
call BlzFrameSetMinMaxValue(frame, 0, 9999999)
call BlzFrameSetStepSize(frame, 1.0)
call BlzTriggerRegisterFrameEvent(SyncRightTrigger, frame, FRAMEEVENT_SLIDER_VALUE_CHANGED)
call BlzFrameSetVisible(frame, false)
call SaveInteger(Hash, GetHandleId(frame), 0, Counter)
set frame = BlzCreateFrame("TasEditBox", parent, 0, 0)
set TasButtonListInputFrame[Counter] = frame
call BlzTriggerRegisterFrameEvent(SearchTrigger, frame, FRAMEEVENT_EDITBOX_TEXT_CHANGED)
call BlzFrameSetPoint(frame, FRAMEPOINT_TOPRIGHT, parent, FRAMEPOINT_TOPRIGHT, 0, 0)
call SaveInteger(Hash, GetHandleId(frame), 0, Counter)
set frame = null
return Counter
endfunction
// this should have beend called InitTasButtonListObject8
function InitTasButtonListObjectEx takes framehandle parent, code buttonAction, code rightClickAction, code updateAction, code searchAction, code filterAction returns integer
return InitTasButtonListObject8c(parent, buttonAction, rightClickAction, updateAction, searchAction, filterAction, null, null)
endfunction
function InitTasButtonListObject takes framehandle parent, code buttonAction, code updateAction, code searchAction, code filterAction returns integer
return InitTasButtonListObjectEx(parent, buttonAction, null, updateAction, searchAction, filterAction)
endfunction
function InitTasButtonListSlider10a takes integer listIndex, integer stepSize, integer rowCount, real colGap, real rowGap returns nothing
local framehandle frame = BlzCreateFrameByType("SLIDER", "FrameListSlider", TasButtonListParent[listIndex], "QuestMainListScrollBar", 0)
local framehandle buttonFrame = BlzGetFrameByName(TasButtonListButtonName[listIndex], TasButtonListCreateContext[listIndex] + stepSize)
set TasButtonListSlider[listIndex] = frame
call SaveInteger(Hash, GetHandleId(frame), 0, listIndex) // the slider nows the TasButtonListobject
set TasButtonListStepSize[listIndex] = stepSize
call BlzFrameSetStepSize(frame, stepSize)
call BlzFrameClearAllPoints(frame)
call BlzFrameSetVisible(frame, true)
call BlzFrameSetMinMaxValue(frame, 0, 0)
call BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, buttonFrame, FRAMEPOINT_TOPRIGHT, 0, 0)
call BlzFrameSetSize(frame, 0.012, BlzFrameGetHeight(buttonFrame) * rowCount + rowGap * (rowCount - 1))
call BlzTriggerRegisterFrameEvent(SliderTrigger, frame , FRAMEEVENT_SLIDER_VALUE_CHANGED)
call BlzTriggerRegisterFrameEvent(SliderTrigger, frame , FRAMEEVENT_MOUSE_WHEEL)
static if LIBRARY_SimpleTooltip then
set TasButtonListSliderText[listIndex] = CreateSimpleTooltip(TasButtonListSlider[listIndex], "1000/1000")
call BlzFrameClearAllPoints(TasButtonListSliderText[listIndex])
call BlzFrameSetPoint(TasButtonListSliderText[listIndex], FRAMEPOINT_BOTTOMRIGHT, TasButtonListSlider[listIndex], FRAMEPOINT_TOPLEFT, 0, 0)
endif
endfunction
function InitTasButtonListSlider takes integer listIndex, integer stepSize, integer rowCount returns nothing
call InitTasButtonListSlider10a(listIndex, stepSize, rowCount, 0, 0)
endfunction
//Demo Creators
function CreateTasButtonTooltip takes framehandle frameButton, framehandle parent, integer createContext returns nothing
local framehandle frameParent = BlzCreateFrame("TasButtonListTooltipBoxFrame", frameButton, 0, createContext)
local framehandle frame = BlzGetFrameByName("TasButtonListTooltipBox", createContext)
local framehandle frameText = BlzGetFrameByName("TasButtonListTooltipText", createContext)
call BlzGetFrameByName("TasButtonListTooltipIcon", createContext)
call BlzGetFrameByName("TasButtonListTooltipName", createContext)
call BlzGetFrameByName("TasButtonListTooltipSeperator", createContext)
call BlzFrameSetTooltip(frameButton, frameParent)
call BlzFrameSetPoint(frameText, FRAMEPOINT_TOPRIGHT, parent, FRAMEPOINT_TOPLEFT, -0.001, -0.052)
call BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, BlzGetFrameByName("TasButtonListTooltipIcon", createContext), FRAMEPOINT_TOPLEFT, -0.005, 0.005)
call BlzFrameSetPoint(frame, FRAMEPOINT_BOTTOMRIGHT, frameText, FRAMEPOINT_BOTTOMRIGHT, 0.005, -0.005)
endfunction
function CreateTasButtonList10 takes string buttonName, integer cols, integer rows, framehandle parent, code buttonAction, code rightClickAction, code updateAction, code searchAction, code filterAction, code asyncAction, code asyncRigthAction, real colGap, real rowGap returns integer
local integer buttonCount = rows*cols
local integer listIndex = InitTasButtonListObject8c(parent, buttonAction, rightClickAction, updateAction, searchAction, filterAction, asyncAction, asyncRigthAction)
local integer i = 1
local framehandle frame
local integer frameHandle
local integer rowRemain = cols
set TasButtonListButtonName[listIndex] = buttonName
set TasButtonListCreateContext[listIndex] = CreateContextCounter
set TasButtonListButtonCount[listIndex] = buttonCount
loop
exitwhen i > buttonCount
set CreateContextCounter = CreateContextCounter + 1
set frame = BlzCreateFrame(buttonName, parent, 0, CreateContextCounter)
set frameHandle = GetHandleId(frame)
if frameHandle == 0 then
call BJDebugMsg("TasButtonList - Error - can't create Button:" + buttonName)
//return 0
endif
call SaveInteger(Hash, frameHandle, 1, i)
call SaveInteger(Hash, frameHandle, 0, listIndex)
call BlzFrameSetText(frame, I2S(i))
// for some reason in a lan test with same Pc the BlzFrameGetText was not set for the second User.
// restarting warcraft 3 fixed it.
//call BJDebugMsg("TasButtonList " + I2S(i) + " "+ BlzFrameGetText(frame))
//call SaveInteger(Hash, frameHandle, 2, CreateContextCounter)
call BlzTriggerRegisterFrameEvent(ButtonTrigger, frame, FRAMEEVENT_CONTROL_CLICK)
call BlzTriggerRegisterFrameEvent(ButtonRightTrigger, frame, FRAMEEVENT_MOUSE_UP)
call BlzTriggerRegisterFrameEvent(ButtonScrollTrigger, frame, FRAMEEVENT_MOUSE_WHEEL)
//give these handleIds to no desync when calling them in a async manner
call BlzGetFrameByName("TasButtonIcon", CreateContextCounter)
call BlzGetFrameByName("TasButtonText", CreateContextCounter)
call BlzGetFrameByName("TasButtonIconGold", CreateContextCounter)
call BlzGetFrameByName("TasButtonTextGold", CreateContextCounter)
call BlzGetFrameByName("TasButtonIconLumber", CreateContextCounter)
call BlzGetFrameByName("TasButtonTextLumber", CreateContextCounter)
call CreateTasButtonTooltip(frame, parent, CreateContextCounter)
if i > 1 then
if rowRemain == 0 then
call BlzFrameSetPoint(frame, FRAMEPOINT_TOP, BlzGetFrameByName(buttonName, CreateContextCounter - cols), FRAMEPOINT_BOTTOM, 0, -rowGap)
set rowRemain = cols
else
//call BlzFrameSetPoint(frame, FRAMEPOINT_RIGHT, BlzGetFrameByName(buttonName, CreateContextCounter - 1), FRAMEPOINT_LEFT, -colGap, 0)
call BlzFrameSetPoint(frame, FRAMEPOINT_LEFT, BlzGetFrameByName(buttonName, CreateContextCounter - 1), FRAMEPOINT_RIGHT, colGap, 0)
endif
else
call BlzFrameSetPoint(frame, FRAMEPOINT_TOPRIGHT, TasButtonListInputFrame[listIndex], FRAMEPOINT_BOTTOMRIGHT, -BlzFrameGetWidth(frame)*cols - colGap*(cols-1), 0)
//call BlzFrameSetPoint(frame, FRAMEPOINT_TOPRIGHT, TasButtonListInputFrame[listIndex], FRAMEPOINT_BOTTOMRIGHT, 0, 0)
endif
set rowRemain = rowRemain - 1
set i = i + 1
endloop
call InitTasButtonListSlider10a(listIndex, cols, rows, colGap, rowGap)
set frame = null
return listIndex
endfunction
function CreateTasButtonList8c takes string buttonName, integer cols, integer rows, framehandle parent, code buttonAction, code rightClickAction, code updateAction, code searchAction, code filterAction, code asyncAction, code asyncRigthAction returns integer
return CreateTasButtonList10(buttonName, cols, rows, parent, buttonAction, rightClickAction, updateAction, searchAction, filterAction, asyncAction, asyncRigthAction, TasButtonListGapCol, TasButtonListGapRow)
endfunction
function CreateTasButtonListEx takes string buttonName, integer cols, integer rows, framehandle parent, code buttonAction, code rightClickAction, code updateAction, code searchAction, code filterAction returns integer
return CreateTasButtonList8c(buttonName, cols, rows, parent, buttonAction, rightClickAction, updateAction, searchAction, filterAction, null, null)
endfunction
function CreateTasButtonList takes integer buttonCount, framehandle parent, code buttonAction, code updateAction, code searchAction, code filterAction returns integer
return CreateTasButtonListEx("TasButton", 1, buttonCount, parent, buttonAction, null, updateAction, searchAction, filterAction)
endfunction
function CreateTasButtonListV2 takes integer rowCount, framehandle parent, code buttonAction, code updateAction, code searchAction, code filterAction returns integer
return CreateTasButtonListEx("TasButtonSmall", 2, rowCount, parent, buttonAction, null, updateAction, searchAction, filterAction)
endfunction
function CreateTasButtonListV3 takes integer rowCount, framehandle parent, code buttonAction, code updateAction, code searchAction, code filterAction returns integer
return CreateTasButtonListEx("TasButtonGrid", 3, rowCount, parent, buttonAction, null, updateAction, searchAction, filterAction)
endfunction
function TasButtonListAddDataEx takes integer listIndex, integer data, integer playerIndex returns nothing
local integer listHandle = GetHandleId(LoadLocationHandle(Hash, GetHandleId(TasButtonListDataList[listIndex]), playerIndex))
local integer index = LoadInteger(Hash, listHandle, 0) + 1
local integer dataFilteredCount
call SaveInteger(Hash, listHandle, 0, index)
call SaveInteger(Hash, listHandle, index, data)
if GetLocalPlayer() == Player(playerIndex) then
// add to current filtered for local player only
set listHandle = GetHandleId(TasButtonListDataListFiltered[listIndex])
set dataFilteredCount = LoadInteger(Hash, listHandle, 0) + 1
call SaveInteger(Hash, listHandle, 0, dataFilteredCount)
call SaveInteger(Hash, listHandle, dataFilteredCount, index)
call BlzFrameSetMinMaxValue(TasButtonListSlider[listIndex], TasButtonListButtonCount[listIndex], dataFilteredCount)
endif
endfunction
function TasButtonListAddData takes integer listIndex, integer data returns nothing
local integer playerIndex = 0
loop
call TasButtonListAddDataEx(listIndex, data, playerIndex)
set playerIndex = playerIndex + 1
exitwhen playerIndex == bj_MAX_PLAYER_SLOTS
endloop
endfunction
function TasButtonListCopyDataEx takes integer writeObject, integer readObject, integer playerIndex returns nothing
local integer i = LoadInteger(Hash, GetHandleId(TasButtonListDataListFiltered[readObject]), 0)
local integer listHandleRead = GetHandleId(LoadLocationHandle(Hash, GetHandleId(TasButtonListDataList[readObject]), playerIndex))
local integer listHandleWrite = GetHandleId(LoadLocationHandle(Hash, GetHandleId(TasButtonListDataList[writeObject]), playerIndex))
call FlushChildHashtable(Hash, listHandleWrite)
call RemoveLocation(TasButtonListDataList[writeObject])
loop
exitwhen i < 0
call SaveInteger(Hash, listHandleWrite, i, LoadInteger(Hash, listHandleRead, i))
set i = i -1
endloop
if GetLocalPlayer() == Player(playerIndex) then
call BlzFrameSetMinMaxValue(TasButtonListSlider[writeObject], TasButtonListButtonCount[writeObject], LoadInteger(Hash, listHandleRead, 0))
call UpdateTasButtonList(writeObject)
endif
endfunction
function TasButtonListCopyData takes integer writeObject, integer readObject returns nothing
local integer playerIndex = 0
loop
call TasButtonListCopyDataEx(writeObject, readObject, playerIndex)
set playerIndex = playerIndex + 1
exitwhen playerIndex == bj_MAX_PLAYER_SLOTS
endloop
endfunction
function TasButtonListRemoveDataEx takes integer listIndex, integer data, integer playerIndex returns nothing
local integer listHandle = GetHandleId(LoadLocationHandle(Hash, GetHandleId(TasButtonListDataList[listIndex]), playerIndex))
local integer i = LoadInteger(Hash, listHandle, 0)
local integer max = LoadInteger(Hash, listHandle, 0)
local integer temp
loop
exitwhen i <= 0
if LoadInteger(Hash, listHandle, 0) == data then
call SaveInteger(Hash, listHandle, i, LoadInteger(Hash, listHandle, max))
call SaveInteger(Hash, listHandle, 0, max - 1)
call RemoveSavedInteger(Hash, listHandle, max)
exitwhen true
endif
set i = i - 1
endloop
if GetLocalPlayer() == Player(playerIndex) then
call BlzFrameSetMinMaxValue(TasButtonListSlider[listIndex], TasButtonListButtonCount[listIndex], LoadInteger(Hash, listHandle, 0))
endif
endfunction
function TasButtonListRemoveData takes integer listIndex, integer data returns nothing
local integer playerIndex = 0
loop
call TasButtonListRemoveDataEx(listIndex, data, playerIndex)
set playerIndex = playerIndex + 1
exitwhen playerIndex == bj_MAX_PLAYER_SLOTS
endloop
endfunction
function TasButtonListClearDataEx takes integer listIndex, integer playerIndex returns nothing
call FlushChildHashtable(Hash, GetHandleId(LoadLocationHandle(Hash, GetHandleId(TasButtonListDataList[listIndex]), playerIndex)))
if GetLocalPlayer() == Player(playerIndex) then
call FlushChildHashtable(Hash, GetHandleId(TasButtonListDataListFiltered[listIndex]))
call BlzFrameSetMinMaxValue(TasButtonListSlider[listIndex], 0, 0)
endif
endfunction
function TasButtonListClearData takes integer listIndex returns nothing
local integer playerIndex = 0
loop
call TasButtonListClearDataEx(listIndex, playerIndex)
set playerIndex = playerIndex + 1
exitwhen playerIndex == bj_MAX_PLAYER_SLOTS
endloop
endfunction
private function SyncRightTriggerAction takes nothing returns nothing
local integer listIndex = LoadInteger(Hash, GetHandleId(BlzGetTriggerFrame()), 0)
local integer dataIndex = R2I(BlzGetTriggerFrameValue() + 0.5)
set TasButtonListData = LoadInteger(Hash, GetHandleId(LoadLocationHandle(Hash, GetHandleId(TasButtonListDataList[listIndex]), GetPlayerId(GetTriggerPlayer()))), dataIndex)
set TasButtonListIndex = listIndex
call TriggerExecute(TasButtonListRightAction[listIndex])
call UpdateTasButtonList(listIndex)
endfunction
private function ButtonRightClickTriggerAction takes nothing returns nothing
local framehandle frame = BlzGetTriggerFrame()
local integer buttonIndex = LoadInteger(Hash, GetHandleId(frame), 1)
local integer listIndex = LoadInteger(Hash, GetHandleId(frame), 0)
local integer dataIndex = LoadInteger(Hash, GetHandleId(TasButtonListDataListFiltered[listIndex]), buttonIndex + TasButtonListViewPoint[listIndex])
local integer data = LoadInteger(Hash, GetHandleId(LoadLocationHandle(Hash, GetHandleId(TasButtonListDataList[listIndex]), GetPlayerId(GetTriggerPlayer()))), dataIndex)
set TasButtonListData = data
set TasButtonListIndex = listIndex
set TasButtonListFrame = frame
if IsRightClick(GetTriggerPlayer()) and GetLocalPlayer() == GetTriggerPlayer() then
call TriggerEvaluate(TasButtonListAsyncRightAction[listIndex])
call StartSound(RightClickSound)
call BlzFrameSetValue(TasButtonListSyncFrameRight[listIndex], dataIndex)
endif
endfunction
private function LoadToc takes nothing returns nothing
// this function should be Repeated when the game is loaded
call BlzLoadTOCFile("war3mapimported\\TasButtonList.toc")
set CreateContextCounter = 0
endfunction
private function Init takes nothing returns nothing
local integer loopA = 0
call LoadToc()
static if LIBRARY_FrameLoader then
call FrameLoaderAdd(function LoadToc)
endif
call TriggerAddAction(SyncTrigger, function TasButtonListTriggerActionSync)
call TriggerAddAction(ButtonTrigger, function TasButtonListTriggerActionButton)
call TriggerAddAction(SearchTrigger, function TasButtonListTriggerActionSearch)
call TriggerAddAction(ButtonScrollTrigger, function TasButtonListTriggerActionButtonScroll)
call TriggerAddAction(SliderTrigger, function TasButtonListTriggerActionSlider)
call TriggerAddAction(SyncRightTrigger, function SyncRightTriggerAction)
call TriggerAddAction(ButtonRightTrigger, function ButtonRightClickTriggerAction)
set RightClickSound = CreateSound("Sound\\Interface\\MouseClick1.wav", false, false, false, 10, 10, "")
call SetSoundParamsFromLabel(RightClickSound, "InterfaceClick")
call SetSoundDuration(RightClickSound, 239)
endfunction
endlibrary
library TasItemShopLite initializer init_function requires TasButtonList, optional FrameLoader
/* TasItemShopLite by Tasyen
An custom ui to buy items from a big pool and with a search bar, selecting a shop shows the ui.
function TasItemShopAddShop takes integer unitCode, integer itemCode returns nothing
adds itemcode for that shop, it should have the ability Asid and select Hero/unit
unitCode is either GetUnitTypeId 'n000' or GetHandleId
easier use wrappers
function TasItemShopAddShopUnit takes unit u, integer itemCode returns nothing
function TasItemShopAddShop5 takes integer unitCode, integer a, integer b, integer c, integer d, integer e returns nothing
function TasItemShopAddShop5Unit takes unit u, integer a, integer b, integer c, integer d, integer e returns nothing
*/
globals
public boolean AutoRun = true //(true) will create Itself at 0s, (false) you need to InitSpellView()
public string TocPath = "war3mapImported\\Templates.toc"
public trigger TriggerSelect
public trigger TriggerESC
public integer buttonListRows = 5
public integer buttonListCols = 3
public real buttonListButtonGapCol = 0.001
public real buttonListButtonGapRow = 0.005
public unit array CurrentShop
public framehandle FrameBox
public framehandle FrameParentSuper
public framehandle FrameTitelText
public framehandle FrameMouseListener
public framehandle FrameParentList
public integer ButtonListIndex // this is the index of the used TasButtonList.
public hashtable Items = null // what can be bought [unit] = {itemCode1, ItemCode2, ...} > [unitCode] = {itemCode1, ItemCode2, ...}
// which button is used inside the ButtonList? Enable one block and disable the other one
//public string buttonListButtonName = "TasButtonSmall"
//public real buttonListButtonSizeX = 0.1
//public real buttonListButtonSizeY = 0.0325
// "TasButtonGrid" are smaller, they don't show the names in the list
public string buttonListButtonName = "TasButtonGrid"
public real buttonListButtonSizeX = 0.064
public real buttonListButtonSizeY = 0.0265
//public string buttonListButtonName = "TasButton"
//public real buttonListButtonSizeX = 0.2
//public real buttonListButtonSizeY = 0.0265
endglobals
public function ParentFunc takes nothing returns framehandle // who is the parent of this UI
return BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0)
endfunction
public function Pos takes framehandle frame returns nothing
// position of the whole Shop UI
call BlzFrameSetAbsPoint(frame, FRAMEPOINT_TOPRIGHT, 0.79, 0.55)
endfunction
public function TooltipPos takes framehandle tooltip, framehandle buttonFrame returns nothing
// position of the tooltips
call BlzFrameClearAllPoints(tooltip)
//call BlzFrameSetPoint(tooltip, FRAMEPOINT_TOPRIGHT, buttonFrame, FRAMEPOINT_BOTTOMRIGHT, 0, -0.052)
call BlzFrameSetPoint(tooltip, FRAMEPOINT_TOPRIGHT, FrameBox, FRAMEPOINT_TOPLEFT, 0, -0.052)
//call BlzFrameSetAbsPoint(tooltip, FRAMEPOINT_TOPRIGHT, 0, -0.052)
endfunction
// config ende
function TasItemShopAddShop takes integer unitCode, integer itemCode returns nothing
local integer newIndex
if itemCode <= 0 then
return
endif
set newIndex = LoadInteger(Items, unitCode, 0) + 1
call SaveInteger(Items, unitCode, newIndex, itemCode)
call SaveInteger(Items, unitCode, 0, newIndex)
call TasItemCaclCost(itemCode)
endfunction
function TasItemShopAddShop5 takes integer unitCode, integer a, integer b, integer c, integer d, integer e returns nothing
call TasItemShopAddShop(unitCode, a)
call TasItemShopAddShop(unitCode, b)
call TasItemShopAddShop(unitCode, c)
call TasItemShopAddShop(unitCode, d)
call TasItemShopAddShop(unitCode, e)
endfunction
function TasItemShopAddShopUnit takes unit u, integer itemCode returns nothing
call TasItemShopAddShop(GetHandleId(u), itemCode)
endfunction
function TasItemShopAddShop5Unit takes unit u, integer a, integer b, integer c, integer d, integer e returns nothing
call TasItemShopAddShop5(GetHandleId(u), a, b, c, d, e)
endfunction
public function updateItemFrame takes integer createContext, integer data returns nothing
local integer lumber = TasItemGetCostLumber(data)
local integer gold = TasItemGetCostGold(data)
local integer playerIndex = GetPlayerId(GetLocalPlayer())
call BlzFrameSetTexture(BlzGetFrameByName("TasButtonIcon", createContext), BlzGetAbilityIcon(data), 0, false)
call BlzFrameSetText(BlzGetFrameByName("TasButtonText", createContext), GetObjectName(data))
call BlzFrameSetTexture(BlzGetFrameByName("TasButtonListTooltipIcon", createContext), BlzGetAbilityIcon(data), 0, false)
call BlzFrameSetText(BlzGetFrameByName("TasButtonListTooltipName", createContext), GetObjectName(data))
call BlzFrameSetText(BlzGetFrameByName("TasButtonListTooltipText", createContext), BlzGetAbilityExtendedTooltip(data, 0))
if GetPlayerState(GetLocalPlayer(), PLAYER_STATE_RESOURCE_GOLD) >= gold then
call BlzFrameSetText(BlzGetFrameByName("TasButtonTextGold", createContext), I2S(gold))
else
call BlzFrameSetText(BlzGetFrameByName("TasButtonTextGold", createContext), "|cffff2010" + I2S(gold))
endif
if GetPlayerState(GetLocalPlayer(), PLAYER_STATE_RESOURCE_LUMBER) >= lumber then
call BlzFrameSetText(BlzGetFrameByName("TasButtonTextLumber", createContext), I2S(lumber))
else
call BlzFrameSetText(BlzGetFrameByName("TasButtonTextLumber", createContext), "|cffff2010" + I2S(lumber))
endif
endfunction
public function updateItemFrameAction takes nothing returns nothing
//TasButtonListFrame
//TasButtonListData
//TasButtonListIndex
local integer buttonIndex = S2I(BlzFrameGetText(TasButtonListFrame))
local integer context = TasButtonListCreateContext[TasButtonListIndex] + buttonIndex
//call BJDebugMsg("updateItemFrameAction" + " context: " + I2S(context) + " buttonIndex: " + I2S(buttonIndex))
call updateItemFrame(context, TasButtonListData)
endfunction
public function Show takes player p, unit shop returns nothing
local integer playerIndex = GetPlayerId(p)
local integer shopHandle = GetHandleId(shop)
local integer shopCode = GetUnitTypeId(shop)
local boolean flag = (shopCode > 0)
local unit oldShop
local boolean isNewShop
local integer i = 1
local integer dataKey = 0
if flag and not HaveSavedInteger(Items, shopCode, 0) and not HaveSavedInteger(Items, shopHandle, 0) then
set flag = false
endif
if p == GetLocalPlayer() then
call BlzFrameSetVisible(FrameParentSuper, flag)
endif
if flag then
set oldShop = CurrentShop[playerIndex]
set isNewShop = oldShop != shop
set CurrentShop[playerIndex] = shop
if isNewShop then
call TasButtonListClearDataEx(ButtonListIndex, playerIndex)
if HaveSavedInteger(Items, shopHandle, 0) then
set dataKey = shopHandle
else
if HaveSavedInteger(Items, shopCode, 0) then
set dataKey = shopCode
endif
endif
if dataKey > 0 then
loop
exitwhen not HaveSavedInteger(Items, dataKey, i)
call TasButtonListAddDataEx(ButtonListIndex, LoadInteger(Items, dataKey, i), playerIndex)
set i = i + 1
endloop
endif
endif
if GetLocalPlayer() == p then
call BlzFrameSetText(FrameTitelText, GetUnitName(shop))
if isNewShop then
call TasButtonListSearch(ButtonListIndex, null)
endif
endif
call UpdateTasButtonList(ButtonListIndex)
else
set CurrentShop[playerIndex] = null
endif
set oldShop = null
endfunction
public function BuyItem takes player p, integer itemCode returns nothing
local integer playerIndex = GetPlayerId(p)
local integer gold = TasItemGetCostGold(itemCode)
local integer lumber = TasItemGetCostLumber(itemCode)
if GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) >= gold then
if GetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER) >= lumber then
call AddItemToStock(CurrentShop[playerIndex], itemCode, 1, 1)
call IssueNeutralImmediateOrderById(p, CurrentShop[playerIndex], itemCode)
call RemoveItemFromStock(CurrentShop[playerIndex], itemCode)
call Show(p, CurrentShop[playerIndex])
elseif not GetSoundIsPlaying(SoundNoLumber[GetHandleId(GetPlayerRace(p))]) then
call StartSoundForPlayerBJ(p, SoundNoLumber[GetHandleId(GetPlayerRace(p))])
endif
elseif not GetSoundIsPlaying(SoundNoGold[GetHandleId(GetPlayerRace(p))]) then
call StartSoundForPlayerBJ(p, SoundNoGold[GetHandleId(GetPlayerRace(p))])
endif
endfunction
private function ButtonListFunction_Search takes nothing returns boolean
//TasButtonListText
//TasButtonListData
//TasButtonListIndex
local string text = StringCase(TasButtonListText, false)
if FindIndex(StringCase(BlzGetAbilityTooltip(TasButtonListData, 0), false), text) >= 0 then
return true
endif
if FindIndex(StringCase(BlzGetAbilityExtendedTooltip(TasButtonListData, 0), false), text) >= 0 then
return true
endif
return FindIndex(StringCase(GetObjectName(TasButtonListData),false), text) >= 0
endfunction
private function ButtonListFunction_LeftClick takes nothing returns nothing
call BuyItem(GetTriggerPlayer(), TasButtonListData)
endfunction
public function InitFrames takes nothing returns nothing
local boolean loaded = BlzLoadTOCFile(TocPath)
local integer loopA
local framehandle parent
local framehandle frame
//local object
set parent = ParentFunc()
// super
set FrameParentSuper = BlzCreateFrameByType("FRAME", "TasItemShopUI", parent, "", 0)
set FrameBox = BlzCreateFrameByType("BACKDROP", "TasItemShopUIBox", FrameParentSuper, "EscMenuControlBackdropTemplate", 0)
set parent = BlzCreateFrameByType("FRAME", "TasItemShopUI", FrameParentSuper, "", 0)
call BlzFrameSetSize(parent, 0.01, 0.01)
call Pos(parent)
set FrameParentList = parent
set FrameMouseListener = BlzCreateFrameByType("SLIDER", "TasItemShopUI", FrameParentList, "", 0)
// ButtonList
set ButtonListIndex = CreateTasButtonList10(buttonListButtonName, buttonListCols, buttonListRows, FrameParentList, function ButtonListFunction_LeftClick, null, function updateItemFrameAction, function ButtonListFunction_Search, null, null, null, buttonListButtonGapCol, buttonListButtonGapRow)
set frame = BlzGetFrameByName(TasButtonListButtonName[ButtonListIndex], TasButtonListCreateContext[ButtonListIndex] + 1)
call BlzFrameClearAllPoints(frame)
//call BlzFrameSetPoint(frame, FRAMEPOINT_TOPRIGHT, FrameCategoryBox, FRAMEPOINT_BOTTOMRIGHT, -0.014, 0)
call BlzFrameSetPoint(frame, FRAMEPOINT_TOPRIGHT, TasButtonListInputFrame[ButtonListIndex], FRAMEPOINT_BOTTOMRIGHT, -0.0045 - (buttonListCols - 1)*(BlzFrameGetWidth(frame) +buttonListButtonGapCol), -0.015)
set loopA = buttonListRows*buttonListCols
loop
exitwhen loopA <= 0
set frame = BlzGetFrameByName("TasButtonListTooltipText", TasButtonListCreateContext[ButtonListIndex] + loopA)
call TooltipPos(BlzGetFrameByName("TasButtonListTooltipText", TasButtonListCreateContext[ButtonListIndex] + loopA), BlzGetFrameByName(TasButtonListButtonName[ButtonListIndex], TasButtonListCreateContext[ButtonListIndex] + loopA))
set loopA = loopA - 1
endloop
set frame = BlzCreateFrame("TasButtonTextTemplate", FrameParentList, 0, 0)
call BlzFrameSetPoint(frame, FRAMEPOINT_TOPRIGHT, TasButtonListInputFrame[ButtonListIndex], FRAMEPOINT_BOTTOMRIGHT, -0.002, 0)
call BlzFrameSetTextAlignment(frame, TEXT_JUSTIFY_CENTER, TEXT_JUSTIFY_MIDDLE)
call BlzFrameSetPoint(frame, FRAMEPOINT_BOTTOMLEFT, BlzGetFrameByName(TasButtonListButtonName[ButtonListIndex], TasButtonListCreateContext[ButtonListIndex] + 1), FRAMEPOINT_TOPLEFT, 0, 0)
call BlzFrameSetText(frame, "Name")
set FrameTitelText = frame
// BlzFrameSetSize(this.ButtonList.Head, BlzFrameGetWidth(this.ButtonList.Head), BlzFrameGetHeight(this.ButtonList.Head) + 0.01)
// call BlzFrameSetPoint(FrameMouseListener, FRAMEPOINT_TOPLEFT, BlzGetFrameByName(TasButtonListButtonName[ButtonListIndex], TasButtonListCreateContext[ButtonListIndex] + 1), FRAMEPOINT_TOPLEFT, 0, 0)
//call BlzFrameSetAllPoints(FrameMouseListener, this.ButtonList.TotalFrame)
//call TasSliderAction(FrameMouseListener, nil, cols, this.ButtonList.Slider)
call BlzFrameSetPoint(FrameBox, FRAMEPOINT_TOPRIGHT, TasButtonListInputFrame[ButtonListIndex], FRAMEPOINT_TOPRIGHT, 0.003, 0.003)
call BlzFrameSetPoint(FrameBox, FRAMEPOINT_BOTTOMLEFT, BlzGetFrameByName(TasButtonListButtonName[ButtonListIndex], TasButtonListCreateContext[ButtonListIndex] + buttonListRows*buttonListCols - (buttonListCols - 1)), FRAMEPOINT_BOTTOMLEFT, -0.003, -0.003)
call BlzFrameSetVisible(FrameParentSuper, false)
endfunction
public function CreateTriggerEx takes code action returns trigger
local trigger t = CreateTrigger()
call TriggerAddAction(t, action)
return t
endfunction
public function TriggerFuctionESC takes nothing returns nothing
call Show(GetTriggerPlayer(), null)
endfunction
public function TriggerFuctionSelect takes nothing returns nothing
call Show(GetTriggerPlayer(), GetTriggerUnit())
endfunction
function Init takes nothing returns nothing
local integer i
if GetExpiredTimer() != null then
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
endif
call InitFrames()
//this.SoundConfig()
static if LIBRARY_FrameLoader then
call FrameLoaderAdd(function InitFrames)
endif
set TriggerSelect = CreateTriggerEx(function TriggerFuctionSelect)
call TriggerRegisterAnyUnitEventBJ(TriggerSelect, EVENT_PLAYER_UNIT_SELECTED)
set TriggerESC = CreateTriggerEx(function TriggerFuctionESC)
set i = bj_MAX_PLAYER_SLOTS - 1
loop
exitwhen i < 0
call TriggerRegisterPlayerEventEndCinematic(TriggerESC, Player(i))
set i = i - 1
endloop
endfunction
public function init_function takes nothing returns nothing
set Items = InitHashtable()
if AutoRun then
call TimerStart(CreateTimer(), 0, false, function Init)
endif
endfunction
endlibrary
function InitShopUserData takes nothing returns nothing
// shops with the unitCode 'n000' sell this items
call TasItemShopAddShop5('n000', 'pdiv','pres','pghe','pgma', 'rej4')
call TasItemShopAddShop5('n000', 'pnvu','rej3','pnvl','pomn','rej2')
call TasItemShopAddShop5('n000', 'rej1','pspd','dust','pinv','phea')
call TasItemShopAddShop5('n000', 'pman','pgin','pclr','plcl', 0)
// shops with the unitCode 'n001' sell this items
call TasItemShopAddShop5('n001', 'ckng','modt','tkno','ratf', 'ofro')
call TasItemShopAddShop5('n001', 'desc','fgdg','infs','shar', 'sand')
call TasItemShopAddShop5('n001', 'wild','srrc','odef','rde4', 'pmna')
call TasItemShopAddShop5('n001', 'rhth','ssil','spsh','sres', 'pdiv')
call TasItemShopAddShop5('n001', 'pres','totw','fgfh','fgrd', 'fgrg')
call TasItemShopAddShop5('n001', 'hcun','hval','mcou','ajen', 'clfm')
call TasItemShopAddShop5('n001', 'ratc','war2','kpin','lgdh', 'ankh')
call TasItemShopAddShop5('n001', 'belv','bgst','ciri','lhst', 'afac')
call TasItemShopAddShop5('n001', 'whwd','fgsk','wcyc','hlst', 'mnst')
call TasItemShopAddShop5('n001', 'sbch','brac','rwiz','pghe', 'pgma')
call TasItemShopAddShop5('n001', 'pnvu','sror','woms','crys', 'evtl')
call TasItemShopAddShop5('n001', 'penr','prvt','rat9','rde3', 'rlif')
call TasItemShopAddShop5('n001', 'bspd','rej3','will','wlsd', 'wswd')
call TasItemShopAddShop5('n001', 'cnob','gcel','rat6','rde2', 0)
// this unit sells other items then his normal type would
call TasItemShopAddShop5Unit(udg_SpecialShop, 'ckng','tkno','rde4','tdx2', 'tin2')
call TasItemShopAddShop5Unit(udg_SpecialShop, 'tpow', 0, 0 , 0, 0)
endfunction