[TFS 1.0 / 1.2] LUA Functions

Discussion in 'Programming & Scripting' started by cbrm, Aug 11, 2013.

  1. hellboy

    hellboy Active Member

    Joined:
    Apr 6, 2008
    Messages:
    325
    Global storage is removed from TFS?
    I don't see here any function similar too getGlobalStorageValue or setGlobalStorageValue, what's more I don't see any similar table in mysql schema.
     
  2. Ninja

    Ninja 「Speedwagon Foundation」 Staff Member Global Moderator

    Joined:
    Apr 6, 2010
    Messages:
    5,855
    compat.lua#L747-754
     
    Evil Puncker likes this.
  3. hellboy

    hellboy Active Member

    Joined:
    Apr 6, 2008
    Messages:
    325
    Thanks
     
  4. Saintsbr

    Saintsbr New Member

    Joined:
    Jul 10, 2014
    Messages:
    4
    hello,
    you know how to create " goplayeraddpremiumpoint " ?
     
  5. cbrm

    cbrm Just another mod Staff Member Global Moderator

    Joined:
    Jan 6, 2009
    Messages:
    6,496
  6. Jetro

    Jetro jangeldev

    Joined:
    Aug 1, 2011
    Messages:
    452
    pastebin is not working for me :/
    edit:
    ready, thanks for sharing :)
     
    Last edited: Sep 2, 2014
  7. xenaron

    xenaron New Member

    Joined:
    Oct 6, 2014
    Messages:
    3
    hello a question a little bonus new addon exists for tfs 1.0?
     
  8. Cronox

    Cronox www.Retro-Tibia.com | www.Searz-Online.com

    Joined:
    Jul 5, 2011
    Messages:
    1,807
    fix*
     
    Last edited: Nov 21, 2014
  9. Caio Cesar

    Caio Cesar Member

    Joined:
    Nov 23, 2014
    Messages:
    60
    Is this list updated or outdated?
    Last edited by a moderator: Jul 13, 2014
     
  10. whitevo

    whitevo Feeling good, thats what I do.

    Joined:
    Jan 2, 2015
    Messages:
    3,134
    outdated, but still using this as fast check for new things i want to do
     
  11. Zothion

    Zothion Well-Known Member

    Joined:
    Apr 28, 2014
    Messages:
    1,086
    Code:
    addEvent(callback, delay, ...)
    cleanMap()
    createCombatArea( {area}, <optional> {extArea} )
    debugPrint(text)
    doAddContainerItem(uid, itemid, <optional> count/subtype)
    doAreaCombatCondition(cid, pos, area, condition, effect)
    doAreaCombatDispel(cid, pos, area, type, effect)
    doAreaCombatHealth(cid, type, pos, area, min, max, effect[, origin = ORIGIN_SPELL])
    doAreaCombatMana(cid, pos, area, min, max, effect[, origin = ORIGIN_SPELL])
    doChallengeCreature(cid, target)
    doCreateItem(itemid, <optional> type/count, pos)
        Returns uid of the created item, only works on tiles.  
    doCreateItemEx(itemid, <optional> count/subtype)
    doMoveCreature(cid, direction)
    doPlayerAddItem(cid, itemid, <optional: default: 1> count, <optional: default: 1> canDropOnMap, <optional: default: 1>subtype)
        Returns uid of the created item      
    doSetCreatureLight(cid, lightLevel, lightColor, time)
    doSetCreatureOutfit(cid, outfit, time)
    doSetItemOutfit(cid, item, time)
    doSetMonsterOutfit(cid, name, time)
    doTargetCombatCondition(cid, target, condition, effect)
    doTargetCombatDispel(cid, target, type, effect)
    doTargetCombatHealth(cid, target, type, min, max, effect[, origin = ORIGIN_SPELL])
    doTargetCombatMana(cid, target, min, max, effect[, origin = ORIGIN_SPELL)
    doTileAddItemEx(pos, uid)
    getCreatureCondition(cid, condition[, subId])
    getDepotId(uid)
    getPlayerFlagValue(cid, flag)
    getPlayerInstantSpellCount(cid)
    getPlayerInstantSpellInfo(cid, index)
    getWaypointPosition(name)
    getWorldLight()
    getWorldTime()
    getWorldUpTime()
    isDepot(uid)
    isInArray(array, value)
    isInWar(cid, target)
    isMovable(uid)
    isMoveable(uid)
    isValidUID(uid)
    saveServer()
    sendChannelMessage(channelId, type, message)
    sendGuildChannelMessage(guildId, type, message)
    stopEvent(eventid)
    most relevant luascript.cpp non methamethod functions (i scraped luascript.cpp and then removed things relating to _G, enums etc, all normal functions should be there)

    metamethod functions:
    http://pastebin.com/wrnD8jHH
    Code:
    Game
        Game.createContainer(itemId, size[, position])
        Game.createItem(itemId[, count[, position]])
        Game.createMonster(monsterName, position[, extended = false[, force = false]])
        Game.createNpc(npcName, position[, extended = false[, force = false]])
        Game.createTile(position[, isDynamic = false])
        Game.createTile(x, y, z[, isDynamic = false])
        Game.getExperienceStage(level)
        Game.getGameState()
        Game.getHouses()
        Game.getMonsterCount()
        Game.getNpcCount()
        Game.getPlayerCount()
        Game.getPlayers()
        Game.getReturnMessage(value)
        Game.getSpectators(position[, multifloor = false[, onlyPlayer = false[, minRangeX = 0[, maxRangeX = 0[, minRangeY = 0[, maxRangeY = 0]]]]]])
        Game.getTowns()
        Game.getWorldType()
        Game.loadMap(path)
        Game.setGameState(state)
        Game.setWorldType(type)  
        Game.startRaid(raidName)
    
    Combat
        Combat()  
        combat:execute(creature, variant)
        combat:setArea(area)
        combat:setCallback(key, function)
        combat:setCondition(condition)
        combat:setFormula(type, mina, minb, maxa, maxb)
        combat:setOrigin(origin)
        combat:setParameter(key, value)
      
    Condition
        Condition(conditionType[, conditionId = CONDITIONID_COMBAT])  
        condition:addDamage(rounds, time, value)
        condition:clone()
        condition:delete()
        condition:getEndTime()
        condition:getIcons()
        condition:getId()
        condition:getSubId()
        condition:getTicks()
        condition:getType()
        condition:setFormula(mina, minb, maxa, maxb)
        condition:setOutfit(lookTypeEx, lookType, lookHead, lookBody, lookLegs, lookFeet[, lookAddons[, lookMount]])
        condition:setOutfit(outfit)
        condition:setParameter(key, value)
        condition:setTicks(ticks)
      
    Container
        Container(uid)  
        container:addItem(itemId[, count/subType = 1[, index = INDEX_WHEREEVER[, flags = 0]]])
        container:addItemEx(item[, index = INDEX_WHEREEVER[, flags = 0]])
        container:getCapacity()
        container:getEmptySlots([recursive = false])
        container:getItem(index)
        container:getItemCountById(itemId[, subType = -1])
        container:getItemHoldingCount()
        container:getSize()
        container:hasItem(item)
      
    Creature
        Creature(id or name or userdata)
        creature:addCondition(condition[, force = false])
        creature:addHealth(healthChange)
        creature:addMana(manaChange[, animationOnLoss = false])
        creature:canSee(position)
        creature:canSeeCreature(creature)
        creature:changeSpeed(delta)
        creature:getBaseSpeed()
        creature:getCondition(conditionType[, conditionId = CONDITIONID_COMBAT[, subId = 0]])
        creature:getDamageMap()
        creature:getDescription(distance)
        creature:getDirection()
        creature:getFollowCreature()
        creature:getHealth()
        creature:getId()
        creature:getLight()
        creature:getMana()
        creature:getMaster()
        creature:getMaxHealth()
        creature:getMaxMana()
        creature:getName()
        creature:getOutfit()
        creature:getParent()
        creature:getPathTo(pos[, minTargetDist = 0[, maxTargetDist = 1[, fullPathSearch = true[, clearSight = true[, maxSearchDist = 0]]]]])
        creature:getPosition()
        creature:getSkull()
        creature:getSpeed()
        creature:getSummons()
        creature:getTarget()
        creature:getTile()
        creature:isCreature()
        creature:isHealthHidden()
        creature:isInGhostMode()
        creature:isRemoved()
        creature:registerEvent(name)
        creature:remove()
        creature:removeCondition(conditionType[, conditionId = CONDITIONID_COMBAT[, subId = 0[, force = false]]])
        creature:say(text, type[, ghost = false[, target = nullptr[, position]]])
        creature:setDirection(direction)
        creature:setDropLoot(doDrop)
        creature:setFollowCreature(followedCreature)
        creature:setHiddenHealth(hide)
        creature:setLight(color, level)
        creature:setMaster(master)
        creature:setMaxHealth(maxHealth)
        creature:setOutfit(outfit)
        creature:setSkull(skull)
        creature:setTarget(target)
        creature:teleportTo(position[, pushMovement = false])
        creature:unregisterEvent(name)
      
    Group
        Group(id)  
        group:getAccess()
        group:getFlags()
        group:getId()
        group:getMaxDepotItems()
        group:getMaxVipEntries()
        group:getName()
      
    Guild
        Guild(id)  
        guild:addRank(id, name, level)
        guild:getId()
        guild:getMembersOnline()
        guild:getMotd()
        guild:getName()
        guild:getRankById(id)
        guild:getRankByLevel(level)
        guild:setMotd(motd)
      
    House
        House(id)  
        house:getAccessList(listId)
        house:getBedCount()
        house:getBeds()
        house:getDoorCount()
        house:getDoors()
        house:getExitPosition()
        house:getId()
        house:getName()
        house:getOwnerGuid()
        house:getRent()
        house:getTileCount()
        house:getTiles()
        house:getTown()
        house:setAccessList(listId, list)
        house:setOwnerGuid(guid[, updateDatabase = true])
      
    Item
        Item(uid)  
        item:clone()
        item:decay()
        item:getActionId()
        item:getArticle()
        item:getAttribute(key)
        item:getCharges()
        item:getCount()
        item:getDescription(distance)
        item:getFluidType()
        item:getId()
        item:getName()
        item:getParent()
        item:getPluralName()
        item:getPosition()
        item:getSubType()
        item:getTile()
        item:getTopParent()
        item:getUniqueId()
        item:getWeight()
        item:hasAttribute(key)
        item:hasProperty(property)
        item:moveTo(position or cylinder)
        item:remove([count = -1])
        item:removeAttribute(key)
        item:setActionId(actionId)
        item:setAttribute(key, value)
        item:split([count = 1])
        item:transform(itemId[, count/subType = -1])
      
    ItemType
        ItemType(id or name)  
        itemType:getArmor()
        itemType:getArticle()
        itemType:getAttack()
        itemType:getCapacity()
        itemType:getCharges()
        itemType:getClientId()
        itemType:getDecayId()
        itemType:getDefense()
        itemType:getDescription()
        itemType:getDestroyId()
        itemType:getElementDamage()
        itemType:getElementType()
        itemType:getExtraDefense()
        itemType:getFluidSource()
        itemType:getHitChance()
        itemType:getId()
        itemType:getName()
        itemType:getPluralName()
        itemType:getRequiredLevel()
        itemType:getShootRange()
        itemType:getSlotPosition()
        itemType:getTransformDeEquipId()
        itemType:getTransformEquipId()
        itemType:getType()
        itemType:getWeaponType()
        itemType:getWeight([count = 1])
        itemType:hasSubType()
        itemType:isContainer()
        itemType:isFluidContainer()
        itemType:isMovable()
        itemType:isReadable()
        itemType:isRune()
        itemType:isStackable()
        itemType:isWritable()
      
    ModalWindow
        ModalWindow(id, title, message)  
        modalWindow:addButton(id, text)
        modalWindow:addChoice(id, text)
        modalWindow:getButtonCount()
        modalWindow:getChoiceCount()
        modalWindow:getDefaultEnterButton()
        modalWindow:getDefaultEscapeButton()
        modalWindow:getId()
        modalWindow:getMessage()
        modalWindow:getTitle()
        modalWindow:hasPriority()
        modalWindow:sendToPlayer(player)    item:isItem()
        modalWindow:setDefaultEnterButton(buttonId)
        modalWindow:setDefaultEscapeButton(buttonId)
        modalWindow:setMessage(text)
        modalWindow:setPriority(priority)
        modalWindow:setTitle(text)
      
    Monster
        Monster(id or userdata)  
        monster:addFriend(creature)
        monster:addTarget(creature[, pushFront = false])
        monster:getFriendCount()
        monster:getFriendList()
        monster:getSpawnPosition()
        monster:getTargetCount()
        monster:getTargetList()
        monster:getType()
        monster:isFriend(creature)
        monster:isIdle()
        monster:isInSpawnRange([position])
        monster:isMonster()
        monster:isOpponent(creature)
        monster:isTarget(creature)
        monster:removeFriend(creature)
        monster:removeTarget(creature)
        monster:searchTarget([searchType = TARGETSEARCH_DEFAULT])
        monster:selectTarget(creature)
        monster:setIdle(idle)
        monsterType:canPushCreatures()
        monsterType:canPushItems()
        monsterType:getArmor()
        monsterType:getAttackList()
        monsterType:getBaseSpeed()
        monsterType:getChangeTargetChance()
        monsterType:getChangeTargetSpeed()
        monsterType:getCombatImmunities()
        monsterType:getConditionImmunities()
        monsterType:getCorpseId()
        monsterType:getCreatureEvents()
        monsterType:getDefense()
        monsterType:getDefenseList()
        monsterType:getElementList()
        monsterType:getExperience()
        monsterType:getHealth()
        monsterType:getLight()
        monsterType:getLoot()
        monsterType:getManaCost()
        monsterType:getMaxHealth()
        monsterType:getMaxSummons()
        monsterType:getName()
        monsterType:getNameDescription()
        monsterType:getOutfit()
        monsterType:getRace()
        monsterType:getRunHealth()
        monsterType:getStaticAttackChance()
        monsterType:getSummonList()
        monsterType:getTargetDistance()
        monsterType:getVoices()
        monsterType:getYellChance()
        monsterType:getYellSpeedTicks()
        monsterType:isAttackable()
        monsterType:isConvinceable()
        monsterType:isHealthShown()
        monsterType:isHostile()
        monsterType:isIllusionable()
        monsterType:isPushable()
        monsterType:isSummonable()
      
    NetworkMessage
        NetworkMessage()  
        networkMessage:addByte(number)
        networkMessage:addDouble(number)
        networkMessage:addItem(item)
        networkMessage:addItemId(itemId)
        networkMessage:addPosition(position)
        networkMessage:addString(string)
        networkMessage:addU16(number)
        networkMessage:addU32(number)
        networkMessage:addU64(number)
        networkMessage:getByte()
        networkMessage:getPosition()
        networkMessage:getString()
        networkMessage:getU16()
        networkMessage:getU32()
        networkMessage:getU64()
        networkMessage:reset()
        networkMessage:sendToPlayer(player)
        networkMessage:skipBytes(number)
      
    Npc
        Npc([id or name or userdata])  
        npc:getSpeechBubble()
        npc:isNpc()
        npc:setMasterPos(pos[, radius])
        npc:setSpeechBubble(speechBubble)
      
    Party  
        party:addInvite(player)
        party:addMember(player)
        party:disband()
        party:getInviteeCount()
        party:getInvitees()
        party:getLeader()
        party:getMemberCount()
        party:getMembers()
        party:isSharedExperienceActive()
        party:isSharedExperienceEnabled()
        party:removeInvite(player)
        party:removeMember(player)
        party:setLeader(player)
        party:setSharedExperience(active)
        party:shareExperience(experience)
      
    Player
        Player(id or name or userdata)  
        player:addBlessing(blessing)
        player:addExperience(experience[, sendText = false])
        player:addItem(itemId[, count = 1[, canDropOnMap = true[, subType = 1[, slot = CONST_SLOT_WHEREEVER]]]])
        player:addItemEx(item[, canDropOnMap = false[, index = INDEX_WHEREEVER[, flags = 0]]])
        player:addItemEx(item[, canDropOnMap = true[, slot = CONST_SLOT_WHEREEVER]])
        player:addManaSpent(amount)
        player:addMapMark(position, type, description)
        player:addMoney(money)
        player:addMount(mountId)
        player:addOfflineTrainingTime(time)
        player:addOfflineTrainingTries(skillType, tries)
        player:addOutfit(lookType)
        player:addOutfitAddon(lookType, addon)
        player:addPremiumDays(days)
        player:addSkillTries(skillType, tries)
        player:addSoul(soulChange)
        player:canLearnSpell(spellName)
        player:channelSay(speaker, type, text, channelId)
        player:forgetSpell(spellName)
        player:getAccountId()
        player:getAccountType()
        player:getBankBalance()
        player:getBaseMagicLevel()
        player:getCapacity()
        player:getClient()
        player:getContainerById(id)
        player:getContainerId(container)
        player:getContainerIndex(id)
        player:getDeathPenalty()
        player:getDepotChest(depotId[, autoCreate = false])
        player:getEffectiveSkillLevel(skillType)
        player:getExperience()
        player:getFreeCapacity()
        player:getGroup()
        player:getGuid()
        player:getGuild()
        player:getGuildLevel()
        player:getGuildNick()
        player:getHouse()
        player:getInbox()
        player:getIp()
        player:getItemById(itemId, deepSearch[, subType = -1])
        player:getItemCount(itemId[, subType = -1])
        player:getLastLoginSaved()
        player:getLastLogout()
        player:getLevel()
        player:getMagicLevel()
        player:getManaSpent()
        player:getMaxSoul()
        player:getMoney()
        player:getOfflineTrainingSkill()
        player:getOfflineTrainingTime()
        player:getParty()
        player:getPremiumDays()
        player:getSex()
        player:getSkillLevel(skillType)
        player:getSkillPercent(skillType)
        player:getSkillTries(skillType)
        player:getSkullTime()
        player:getSlotItem(slot)
        player:getSoul()
        player:getStamina()
        player:getStorageValue(key)
        player:getTown()
        player:getVocation()
        player:hasBlessing(blessing)
        player:hasLearnedSpell(spellName)
        player:hasMount(mountId)
        player:hasOutfit(lookType[, addon = 0])
        player:isPlayer()
        player:isPzLocked()
        player:learnSpell(spellName)
        player:openChannel(channelId)
        player:popupFYI(message)
        player:removeBlessing(blessing)
        player:removeExperience(experience[, sendText = false])
        player:removeItem(itemId, count[, subType = -1[, ignoreEquipped = false]])
        player:removeMoney(money)
        player:removeMount(mountId)
        player:removeOfflineTrainingTime(time)
        player:removeOutfit(lookType)
        player:removeOutfitAddon(lookType, addon)
        player:removePremiumDays(days)
        player:save()
        player:sendChannelMessage(author, text, type, channelId)
        player:sendOutfitWindow()
        player:sendPrivateMessage(speaker, text[, type])
        player:sendTextMessage(type, text[, position, primaryValue = 0, primaryColor = TEXTCOLOR_NONE[, secondaryValue = 0, secondaryColor = TEXTCOLOR_NONE]])
        player:sendTutorial(tutorialId)
        player:setAccountType(accountType)
        player:setBankBalance(bankBalance)
        player:setCapacity(capacity)
        player:setGhostMode(enabled)
        player:setGroup(group)
        player:setGuild(guild)
        player:setGuildLevel(level)
        player:setGuildNick(nick)
        player:setMaxMana(maxMana)
        player:setOfflineTrainingSkill(skillId)
        player:setSex(newSex)
        player:setSkullTime(skullTime)
        player:setStamina(stamina)
        player:setStorageValue(key, value)
        player:setTown(town)
        player:setVocation(id or name or userdata)
        player:showTextDialog(itemId[, text[, canWrite[, length]]])
      
    Position
        Position([x = 0[, y = 0[, z = 0[, stackpos = 0]]]])
        Position([position])
        positionValue = position + positionEx
        positionValue = position - positionEx
        position == positionEx  
        position:getDistance(positionEx)
        position:isSightClear(positionEx[, sameFloor = true])
        position:sendDistanceEffect(positionEx, distanceEffect[, player = nullptr])
        position:sendMagicEffect(magicEffect[, player = nullptr])
      
    Teleport
        Teleport(uid)  
        teleport:getDestination()
        teleport:setDestination(position)
      
    Tile
        Tile(x, y, z)
        Tile(position)  
        tile:getBottomCreature()
        tile:getBottomVisibleCreature(creature)
        tile:getCreatureCount()
        tile:getCreatures()
        tile:getDownItemCount()
        tile:getFieldItem()
        tile:getGround()
        tile:getHouse()  
        tile:getItemById(itemId[, subType = -1])
        tile:getItemByTopOrder(topOrder)
        tile:getItemByType(itemType)
        tile:getItemCount()
        tile:getItemCountById(itemId[, subType = -1])
        tile:getItems()
        tile:getPosition()
        tile:getThing(index)
        tile:getThingCount()
        tile:getThingIndex(thing)
        tile:getTopCreature()
        tile:getTopDownItem()
        tile:getTopItemCount()
        tile:getTopTopItem()
        tile:getTopVisibleCreature(creature)
        tile:getTopVisibleThing(creature)
        tile:hasFlag(flag)
        tile:hasProperty(property[, item])
        tile:queryAdd(thing[, flags])
      
    Town
        Town(id or name)  
        town:getId()
        town:getName()
        town:getTemplePosition()
      
    Variant
        Variant(number or string or position or thing)
        Variant:getNumber()
        Variant:getPosition()
        Variant:getString()
      
    Vocation
        Vocation(id or name)  
        vocation:getAttackSpeed()
        vocation:getBaseSpeed()
        vocation:getCapacityGain()
        vocation:getClientId()
        vocation:getDemotion()
        vocation:getDescription()
        vocation:getHealthGain()
        vocation:getHealthGainAmount()
        vocation:getHealthGainTicks()
        vocation:getId()
        vocation:getManaGain()
        vocation:getManaGainAmount()
        vocation:getManaGainTicks()
        vocation:getMaxSoul()
        vocation:getName()
        vocation:getPromotion()
        vocation:getRequiredManaSpent(magicLevel)
        vocation:getRequiredSkillTries(skillType, skillLevel)
        vocation:getSoulGainTicks()
    

    from what i could see everything from first post is in here pretty much, just that most functions are now metamethod functions instead of standalone :)
     
  12. Xeraphus

    Xeraphus the best

    Joined:
    Feb 14, 2015
    Messages:
    1,734
    updated (tfs 1.3)
    http://pastebin.com/3j9nk5gD

    new: (not necessarily new, some just left out)
    Code:
    creature:getEvents()
    creature:isTile()
    player:getLossPercent()
    item:isTile()
    item:isTeleport()
    position:moveUpstairs()
    teleport:isTeleport()
    itemType:isDoor()
    itemtype:usesSlot(slot)
    
     
  13. Verdoom

    Verdoom New Member

    Joined:
    Jul 10, 2016
    Messages:
    6
    thx bro !
     
  14. Firoxis

    Firoxis New Member

    Joined:
    Dec 28, 2016
    Messages:
    3
    what about vocation:getAttackSpeed()? how can i use it?
     
  15. Xeraphus

    Xeraphus the best

    Joined:
    Feb 14, 2015
    Messages:
    1,734
    you use it if you want to get the vocation's attack speed
    ._.
     
  16. Firoxis

    Firoxis New Member

    Joined:
    Dec 28, 2016
    Messages:
    3
    But what if i want to make an item that brings you attack speed?
     
  17. Xeraphus

    Xeraphus the best

    Joined:
    Feb 14, 2015
    Messages:
    1,734
    you cant edit it ingame but you can edit it in items.xml with attribute key "attack speed"
     
  18. Firoxis

    Firoxis New Member

    Joined:
    Dec 28, 2016
    Messages:
    3
    can you help me with the script?
     
  19. Doomdice

    Doomdice Just another day to live.

    Joined:
    Jul 20, 2009
    Messages:
    605
    I cant remember the name of what has all the script lines in it at something with .cpp in sources can someone help me out on what its call?
     
  20. Xeraphus

    Xeraphus the best

    Joined:
    Feb 14, 2015
    Messages:
    1,734
    ??
    luascript.cpp?
     

Share This Page