[Lua] Understanding Storages

Discussion in 'Programming & Scripting' started by Evan, May 10, 2013.

  1. Progenosis

    Progenosis Member

    Joined:
    Sep 6, 2011
    Messages:
    129
    Likes Received:
    18
    Best Answers:
    0
    Something like this?
    The creaturescript to create the teleport is this one:

    Code (Text):
    1.  
    2. local tpId = 12509
    3. local tps = {
    4.         ["Grand Ferumbras"] = {pos = {x=870, y=1389, z=12}, toPos = {x=898, y=1366, z=12}, time = 20},
    5. }
    6.  
    7. function removeTp(tp)
    8.         local t = getTileItemById(tp.pos, tpId)
    9.         if t then
    10.                 doRemoveItem(t.uid, 1)
    11.                 doSendMagicEffect(tp.pos, CONST_ME_POFF)
    12.         end
    13. end
    14.  
    15. function onDeath(cid)
    16.         local tp = tps[getCreatureName(cid)]
    17.         if tp then
    18.                 doCreateTeleport(tpId, tp.toPos, tp.pos)
    19.                 doCreatureSay(cid, "El teleport para salir de este lugar desaparecerá en "..tp.time.." segundos.", TALKTYPE_ORANGE_1)
    20.                 addEvent(removeTp, tp.time*1000, tp)
    21.         end
    22.         return TRUE
    23. end
    How can I give an ActionID to the teleport created?

    Then, the onStep function that you are talking about would be this one?
    Code (Text):
    1.  
    2. function onStepIn(cid, item, pos)
    3. if isPlayer(cid) == TRUE then
    4. if (item.actionid == XXXX) then
    5. doPlayerSetStorage(cid,2526,1)
    6. end
    7. end
    ?
     
  2. Zuma Master

    Zuma Master ~Holes Through Happiness~

    Joined:
    Jul 31, 2011
    Messages:
    369
    Likes Received:
    21
    Best Answers:
    0
    The onStepIn() function is correct, please use
    Code (Lua):
    1.  tags to tag your scripts.
    2. As for setting an aID to the teleport, use this type of function:
    3. [code=lua]
    4. doSetItemActionId(doCreateTeleport(tpId, tp.toPos, tp.pos).uid, xxx)
    5.  
    xxx being your aID.
    You should also remove your other doCreateTeleport() line, since this one will do just that.
     
    Last edited: May 25, 2013
  3. Progenosis

    Progenosis Member

    Joined:
    Sep 6, 2011
    Messages:
    129
    Likes Received:
    18
    Best Answers:
    0
    Thanks, I'll try and then comment here how it worked
     
  4. Ahilphino

    Ahilphino Well-Known Member

    Joined:
    Jun 5, 2013
    Messages:
    1,167
    Likes Received:
    346
    Best Answers:
    0
    Nvm, I'm stupid :D
     
  5. Evan

    Evan A splendid one to behold Premium User

    Joined:
    May 6, 2009
    Messages:
    7,011
    Likes Received:
    942
    Best Answers:
    0
    Forgot I had this tutorial. I noticed quite a few mistakes here.
    I should update all of my tutorials sometime soon.
     
  6. clouf

    clouf Member

    Joined:
    Jul 5, 2012
    Messages:
    139
    Likes Received:
    19
    Best Answers:
    0
    Have one question, in what file i can set global storage on server start (like default value)
     
  7. Bogart

    Bogart ...has super panda powers

    Joined:
    Jun 21, 2009
    Messages:
    7,943
    Likes Received:
    526
    Best Answers:
    19
    In globalevents, onStartup()
     

Share This Page

Loading...