[TFS 1.0 / 1.2] LUA Functions

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

  1. carre

    carre Active Member

    Joined:
    Apr 23, 2013
    Messages:
    512
    you can't send this message, forbidden characters can someone help me plx
     
  2. putamerda

    putamerda Member

    Joined:
    Jan 2, 2012
    Messages:
    73
    I dont need? can you explain me? Because im working on a system that insert a row on guild_wars table, but i used to use this functions on TFS 0.4 to start a war Ingame
     
  3. amoeba13

    amoeba13 New Member

    Joined:
    Jan 7, 2011
    Messages:
    10
    Here it is:


    Code:
    local cd = 30 -- How long after the broadcast will the map be cleaned? in seconds
    function onTime(interval)
        broadcastMessage("Game map will be cleaned in ".. cd .." seconds. Mind it may freeze.")
        addEvent(cleanMap, cd*1000)
        addEvent(broadcastMessage, cd+1*1000, "Game map cleaned.")
        return true
    end
     
    putamerda likes this.
  4. putamerda

    putamerda Member

    Joined:
    Jan 2, 2012
    Messages:
    73
    There is LuaSocket for TFS 1.0?
     
  5. boby psaico

    boby psaico Member

    Joined:
    Oct 17, 2009
    Messages:
    76
    the function
    isMonsterInRange(monsterName, fromPos, toPos)

    doesnt work ;S
     
  6. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,427
    use isInRange(getThingPos(uid),fromPos,toPos)
    where uid is what you have to read from creature
     
  7. putamerda

    putamerda Member

    Joined:
    Jan 2, 2012
    Messages:
    73
    Im building an system to save only 1 player theres a function like: doPlayerSave(cid)
     
  8. Ninja

    Ninja 「Speedwagon Foundation」 Staff Member Global Moderator

    Joined:
    Apr 6, 2010
    Messages:
    5,855
    Code:
    Player(cid):save()
     
    putamerda likes this.
  9. putamerda

    putamerda Member

    Joined:
    Jan 2, 2012
    Messages:
    73
    Thank you so much! :kiss:
     
  10. boby psaico

    boby psaico Member

    Joined:
    Oct 17, 2009
    Messages:
    76
    how to do setCreatureMaxHealth in this version?
     
  11. cbrm

    cbrm Just another mod Staff Member Global Moderator

    Joined:
    Jan 6, 2009
    Messages:
    6,496
    Code:
    Player(cid):setMaxHealth(maxHealth)
    
    I updated the main post with all source and lua-made functions, including metamethods.
     
    boby psaico likes this.
  12. boby psaico

    boby psaico Member

    Joined:
    Oct 17, 2009
    Messages:
    76
    Thanks dude
     
  13. WibbenZ

    WibbenZ Well-Known Member

    Joined:
    Oct 16, 2008
    Messages:
    4,208
  14. putamerda

    putamerda Member

    Joined:
    Jan 2, 2012
    Messages:
    73
    setCombatFormula with only 6 params?
    What about the real tibia formulas?

    setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -2, -80, -1, -90, 6, 4, 6, 5) --Sudden Death?


    NVM got it...
     
    Last edited: Jan 20, 2014
  15. trollebror

    trollebror Developer

    Joined:
    Aug 8, 2009
    Messages:
    358
    Wish doItemSetAttribute() was there! :(
     
  16. Cornex

    Cornex Web Developer Staff Member Global Moderator

    Joined:
    Jun 15, 2008
    Messages:
    3,407
    Where can i read the db functions?
     
  17. Ninja

    Ninja 「Speedwagon Foundation」 Staff Member Global Moderator

    Joined:
    Apr 6, 2010
    Messages:
    5,855
    luascript.cpp

    Code:
    const luaL_Reg LuaScriptInterface::luaDatabaseTable[] = {
        {"query", LuaScriptInterface::luaDatabaseExecute},
        {"storeQuery", LuaScriptInterface::luaDatabaseStoreQuery},
        {"escapeString", LuaScriptInterface::luaDatabaseEscapeString},
        {"escapeBlob", LuaScriptInterface::luaDatabaseEscapeBlob},
        {"lastInsertId", LuaScriptInterface::luaDatabaseLastInsertId},
        {"tableExists", LuaScriptInterface::luaDatabaseTableExists},
        {nullptr, nullptr}
    };
    Code:
    const luaL_Reg LuaScriptInterface::luaResultTable[] = {
        {"getDataInt", LuaScriptInterface::luaResultGetDataInt},
        {"getDataLong", LuaScriptInterface::luaResultGetDataLong},
        {"getDataString", LuaScriptInterface::luaResultGetDataString},
        {"getDataStream", LuaScriptInterface::luaResultGetDataStream},
        {"next", LuaScriptInterface::luaResultNext},
        {"free", LuaScriptInterface::luaResultFree},
        {nullptr, nullptr}
    };
     
  18. Zyntax

    Zyntax *WannaBe Scripter*

    Joined:
    Jan 27, 2010
    Messages:
    533
    It is there:

    Code:
    int32_t LuaScriptInterface::luaItemSetAttribute(lua_State* L)
    {
       // item:setAttribute(key, value)
       itemAttrTypes attribute;
       if (isNumber(L, 2)) {
         attribute = static_cast<itemAttrTypes>(getNumber<int64_t>(L, 2));
       } else if (isString(L, 2)) {
         attribute = stringToItemAttribute(getString(L, 2));
       } else {
         attribute = ATTR_ITEM_NONE;
       }
       Item* item = getUserdata<Item>(L, 1);
       if (item) {
         if (attribute & 0x7F0013) { // All integer attributes
           item->setIntAttr(attribute, getNumber<int32_t>(L, 3));
           pushBoolean(L, true);
         } else if (attribute & 0x2C) { // All string attributes
           item->setStrAttr(attribute, getString(L, 3));
           pushBoolean(L, true);
         } else {
           pushNil(L);
         }
       } else {
         pushNil(L);
       }
       return 1;
    }
    
     
    Last edited: Feb 25, 2014
  19. Zyntax

    Zyntax *WannaBe Scripter*

    Joined:
    Jan 27, 2010
    Messages:
    533
    Quick question;
    How exactly do you use the method monster:addFriend(creature)?
    I tried several ways now of defining "creature" with UID,CID,Name, .. nothing worked so far.
     
  20. vingo

    vingo Active Member

    Joined:
    Oct 27, 2012
    Messages:
    466
    I cant get peoples ips when using /info. I just get a bug about convertstringtoip
     

Share This Page