[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:
    530
    Likes Received:
    45
    Best Answers:
    0
    you can't send this message, forbidden characters can someone help me plx
     
  2. putamerda

    putamerda Member

    Joined:
    Jan 2, 2012
    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    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
    Likes Received:
    2
    Best Answers:
    0
    Here it is:


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

    putamerda Member

    Joined:
    Jan 2, 2012
    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    There is LuaSocket for TFS 1.0?
     
  5. boby psaico

    boby psaico Member

    Joined:
    Oct 17, 2009
    Messages:
    76
    Likes Received:
    4
    Best Answers:
    0
    the function
    isMonsterInRange(monsterName, fromPos, toPos)

    doesnt work ;S
     
  6. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,438
    Likes Received:
    1,332
    Best Answers:
    0
    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:
    72
    Likes Received:
    0
    Best Answers:
    0
    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,876
    Likes Received:
    1,479
    Best Answers:
    12
    Code (Text):
    1. Player(cid):save()
     
    putamerda likes this.
  9. putamerda

    putamerda Member

    Joined:
    Jan 2, 2012
    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    Thank you so much! :kiss:
     
  10. boby psaico

    boby psaico Member

    Joined:
    Oct 17, 2009
    Messages:
    76
    Likes Received:
    4
    Best Answers:
    0
    how to do setCreatureMaxHealth in this version?
     
  11. cbrm

    cbrm Just another mod Staff Member Global Moderator

    Joined:
    Jan 6, 2009
    Messages:
    6,523
    Likes Received:
    789
    Best Answers:
    0
    Code (Text):
    1.  
    2. Player(cid):setMaxHealth(maxHealth)
    3.  
    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
    Likes Received:
    4
    Best Answers:
    0
    Thanks dude
     
  13. WibbenZ

    WibbenZ Support Team Support Team Premium User

    Joined:
    Oct 16, 2008
    Messages:
    4,636
    Likes Received:
    685
    Best Answers:
    44
  14. putamerda

    putamerda Member

    Joined:
    Jan 2, 2012
    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    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:
    359
    Likes Received:
    56
    Best Answers:
    0
    Wish doItemSetAttribute() was there! :(
     
  16. Cornex

    Cornex Web Developer Staff Member Global Moderator Premium User

    Joined:
    Jun 15, 2008
    Messages:
    3,426
    Likes Received:
    1,109
    Best Answers:
    5
    Where can i read the db functions?
     
  17. Ninja

    Ninja 「Speedwagon Foundation」 Staff Member Global Moderator

    Joined:
    Apr 6, 2010
    Messages:
    5,876
    Likes Received:
    1,479
    Best Answers:
    12
    luascript.cpp

    Code (Text):
    1. const luaL_Reg LuaScriptInterface::luaDatabaseTable[] = {
    2.     {"query", LuaScriptInterface::luaDatabaseExecute},
    3.     {"storeQuery", LuaScriptInterface::luaDatabaseStoreQuery},
    4.     {"escapeString", LuaScriptInterface::luaDatabaseEscapeString},
    5.     {"escapeBlob", LuaScriptInterface::luaDatabaseEscapeBlob},
    6.     {"lastInsertId", LuaScriptInterface::luaDatabaseLastInsertId},
    7.     {"tableExists", LuaScriptInterface::luaDatabaseTableExists},
    8.     {nullptr, nullptr}
    9. };
    Code (Text):
    1. const luaL_Reg LuaScriptInterface::luaResultTable[] = {
    2.     {"getDataInt", LuaScriptInterface::luaResultGetDataInt},
    3.     {"getDataLong", LuaScriptInterface::luaResultGetDataLong},
    4.     {"getDataString", LuaScriptInterface::luaResultGetDataString},
    5.     {"getDataStream", LuaScriptInterface::luaResultGetDataStream},
    6.     {"next", LuaScriptInterface::luaResultNext},
    7.     {"free", LuaScriptInterface::luaResultFree},
    8.     {nullptr, nullptr}
    9. };
     
  18. Zyntax

    Zyntax *WannaBe Scripter*

    Joined:
    Jan 27, 2010
    Messages:
    533
    Likes Received:
    37
    Best Answers:
    0
    It is there:

    Code (Text):
    1.  
    2. int32_t LuaScriptInterface::luaItemSetAttribute(lua_State* L)
    3. {
    4.    // item:setAttribute(key, value)
    5.    itemAttrTypes attribute;
    6.    if (isNumber(L, 2)) {
    7.      attribute = static_cast<itemAttrTypes>(getNumber<int64_t>(L, 2));
    8.    } else if (isString(L, 2)) {
    9.      attribute = stringToItemAttribute(getString(L, 2));
    10.    } else {
    11.      attribute = ATTR_ITEM_NONE;
    12.    }
    13.    Item* item = getUserdata<Item>(L, 1);
    14.    if (item) {
    15.      if (attribute & 0x7F0013) { // All integer attributes
    16.        item->setIntAttr(attribute, getNumber<int32_t>(L, 3));
    17.        pushBoolean(L, true);
    18.      } else if (attribute & 0x2C) { // All string attributes
    19.        item->setStrAttr(attribute, getString(L, 3));
    20.        pushBoolean(L, true);
    21.      } else {
    22.        pushNil(L);
    23.      }
    24.    } else {
    25.      pushNil(L);
    26.    }
    27.    return 1;
    28. }
    29.  
     
    Last edited: Feb 25, 2014
  19. Zyntax

    Zyntax *WannaBe Scripter*

    Joined:
    Jan 27, 2010
    Messages:
    533
    Likes Received:
    37
    Best Answers:
    0
    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
    Likes Received:
    43
    Best Answers:
    0
    I cant get peoples ips when using /info. I just get a bug about convertstringtoip
     

Share This Page

Loading...