[Mod] Random Item Stats

Discussion in 'Mods & Lua Functions' started by Cykotitan, Jun 1, 2011.

  1. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,425
    The console says why. Post your error, we're scripters, not faires.
    Edit: My bad, xml debugger is shit. Rewrite that mod to creaturescript.
     
  2. heba

    heba Well-Known Member

    Joined:
    Aug 5, 2011
    Messages:
    1,144
    i fix it but idk its now work fine but don't loot any random items but other loot work fine now
     
  3. 7804364

    7804364 Member

    Joined:
    Mar 6, 2010
    Messages:
    472
    you wont get help, use 0.3.6 by cykotitan
     
  4. heba

    heba Well-Known Member

    Joined:
    Aug 5, 2011
    Messages:
    1,144
    i don't have 0.3.6 tfs i have 0.4
     
  5. 7804364

    7804364 Member

    Joined:
    Mar 6, 2010
    Messages:
    472
    better start using 0.3.6
     
  6. heba

    heba Well-Known Member

    Joined:
    Aug 5, 2011
    Messages:
    1,144
    noway 0.4 better i will try again to fix this
     
  7. heba

    heba Well-Known Member

    Joined:
    Aug 5, 2011
    Messages:
    1,144
    now its work no bugs but never loot random items D:"
     
  8. imback1

    imback1 Unknown member

    Joined:
    Jul 11, 2013
    Messages:
    763
    Hmm I'm using 0.3.6 and i found this error when i tried to kill some monsters
    Code:
    [25/04/2015 16:15:09] [Error - CreatureScript Interface]
    [25/04/2015 16:15:09] In a timer event called from:
    [25/04/2015 16:15:09] buffer:onKill
    [25/04/2015 16:15:09] Description:
    [25/04/2015 16:15:09] [string "loadBuffer"]:53: attempt to compare number with nil
    [25/04/2015 16:15:09] stack traceback:
    [25/04/2015 16:15:09]     [string "loadBuffer"]:53: in function 'createLoot'
    [25/04/2015 16:15:10]     [string "loadBuffer"]:225: in function <[string "loadBuffer"]:212>
     
  9. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,425
  10. durassek

    durassek New Member

    Joined:
    Dec 2, 2008
    Messages:
    12
    id this would be working on tfs 1.1?
     
  11. Lifer420

    Lifer420 Well-Known Member

    Joined:
    Jul 27, 2009
    Messages:
    1,492
    if( getConfigInfo('monsterLootMessage') ~= 0 )then
    print('[Notice] Set monsterLootMessage = 0 to prevent duplicate loot messages')
    end
    ]]></config>

    ^ is that the end of the first script, then make a 2nd one for the one blow this? or is it all one? Confusing when it's not in lua/a php box

    <event type="kill" name="itemstats" event="script"><![CDATA[
    domodlib('itemstats_conf')
     
  12. Lifer420

    Lifer420 Well-Known Member

    Joined:
    Jul 27, 2009
    Messages:
    1,492
    @imkingran when I add that to mods, I login to my OT and I test it (with minotaurs atm) but whatever I kill, itll say "Loot of a XX - " then all the items, but there's NOTHING in the body at all.

    Edit : The log itself is a huge ass error lol
     
  13. imkingran

    imkingran Learning everyday. Premium User

    Joined:
    Jan 15, 2014
    Messages:
    1,151
  14. Lifer420

    Lifer420 Well-Known Member

    Joined:
    Jul 27, 2009
    Messages:
    1,492
  15. Lifer420

    Lifer420 Well-Known Member

    Joined:
    Jul 27, 2009
    Messages:
    1,492
    @imkingran got this - but monsters drop loot again

    [​IMG]
    That's from killing 1 mino that dropped 18:27 Loot of a minotaur: a bag, a sword, leather legs, a plate shield, a chain armor.

    Edit : I got it working, but it didn't say the "RARE" above the body. I want it to say "RARE" or w/e type it is for 5s, once per second :X
     
    Last edited: Apr 23, 2015
  16. Lifer420

    Lifer420 Well-Known Member

    Joined:
    Jul 27, 2009
    Messages:
    1,492
    Can anyone help me? The rare/legendary items drop, but it doesn't do any effect. How can I make it say "RARE" with a green sparkle under it once every second, for 5 seconds, above the body that dropped it?
     
  17. imkingran

    imkingran Learning everyday. Premium User

    Joined:
    Jan 15, 2014
    Messages:
    1,151
    Use addEvent() to send delayed messages.

    addEvent(callback, delay, ...)

    Here is a full list of functions you may find helpful: TFS 0.4 Functions
     
  18. Lifer420

    Lifer420 Well-Known Member

    Joined:
    Jul 27, 2009
    Messages:
    1,492
    I added
    Code:
                 if( ret )then
                   doSendMagicEffect(pos, CONST_ME_MAGIC_GREEN)
                  doSendAnimatedText(pos, ret:upper(), tiers[ret].color)
                  addEvent(callback, delay, 1000)
                 end
    and I get an error "Callback parameter should be a function"
     
  19. imkingran

    imkingran Learning everyday. Premium User

    Joined:
    Jan 15, 2014
    Messages:
    1,151
    addEvent(callback, delay, parameters)

    "Callback should be a function" - this means exactly that. In your situation what are the functions that you are trying to add a delay on?
    - doSendAnimatedText
    - doSendMagicEffect
    Those functions should replace the word callback.

    Next is delay, you should replace here the time in miliseconds for which you would like to delay the event.
    - 1000
    This number should replace the word delay.

    Last but not least is the parameters. These parameters should match the parameters of the function you are trying to callback. Let's take a look at doSendAnimatedText for example:

    doSendAnimatedText(pos, text, color) -- The words in green are the parameters of the function. These are the values that should be added to the end of the addEvent.

    addEvent(doSendAnimatedText, 1000, pos, text, color)
    addEvent(callback, delay, parameters)
     
  20. Lifer420

    Lifer420 Well-Known Member

    Joined:
    Jul 27, 2009
    Messages:
    1,492
    Hmm that really helped alot. But can you show me where to put it and all? Just so you know, before I blindly ask questions, im trying to configure it myself personally, but I just can't get it :X

    I was trying " addEvent(doSendAnimatedText, 1000, pos, RARE, color)" and after RARE pops up, 1000MS later a black 0 pops up, or a 9, or something (cant really tell) Here's the script from where it says CONST_ME_MAGIC_GREEN the first time, down to the second time. I guess after this experience, I should prolly learn to script, like, actually script. I've just been editing ones and I learn little things here and there about what makes WHICH thing work. So i'm getting some knowledge, but obviously not enough lmfao

    Code:
    if( ret )then
               doSendMagicEffect(pos, CONST_ME_MAGIC_GREEN)
              doSendAnimatedText(pos, ret:upper(), tiers[ret].color)
              addEvent(doSendAnimatedText, 1000, pos, RARE, color)
             end
             doAddContainerItemEx(parent, tmp)
             size = size + 1
           end
         end
       end
       return size > 0
    end
    local function dropLoot(pos, v, ext, master, cid, target)
       local corpse
       if( not master or master == target )then -- 0.3/4
         corpse = getTileItemById(pos, v.lookCorpse).uid
         if( isContainer(corpse) )then
           for i = 1, getContainerSize(corpse) do
             doRemoveItem(getContainerItem(corpse, 0).uid)
           end
           local size, cap = 0, getContainerCap(corpse)
           for i = 1, #v.loot do
             if( size == cap )then
               break
             end
             local tmp, ret = createLoot(v.loot[i], ext)
             if( tmp )then
               if( isContainer(tmp) )then
                 if( createChildLoot(tmp, v.loot[i].child, ext, pos) )then
                   doAddContainerItemEx(corpse, tmp)
                   size = size + 1
                 else
                   doRemoveItem(tmp)
                 end
               else
                 if( ret )then
                   doSendMagicEffect(pos, CONST_ME_MAGIC_GREEN)
                  doSendAnimatedText(pos, ret:upper(), tiers[ret].color)
                  addEvent(doSendAnimatedText, 1000, pos, RARE, color)
                 end
     

Share This Page