• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Condition is not randomizing outfits TFS[1.2]

Moj mistrz

Monster Creator
Joined
Feb 1, 2008
Messages
932
Solutions
10
Reaction score
295
Location
Poland
Hello, as the title says. Condition is not randomizing outfits, only when I reload actions it does change outfit, but anyways, that's not the solution.
Piece of code:
Code:
local condition1Outfits = {47, 89, 91, 120, 232, 246, 305, 311, 320}
local condition1 = Condition(CONDITION_OUTFIT)
condition1:setTicks(60 * 60 * 1000)
condition1:setOutfit({lookType = condition1Outfits[math.random(#condition1Outfits)]})

Any help is appreciated. :)
 
Hello, as the title says. Condition is not randomizing outfits, only when I reload actions it does change outfit, but anyways, that's not the solution.
Piece of code:
Code:
local condition1Outfits = {47, 89, 91, 120, 232, 246, 305, 311, 320}
local condition1 = Condition(CONDITION_OUTFIT)
condition1:setTicks(60 * 60 * 1000)
condition1:setOutfit({lookType = condition1Outfits[math.random(#condition1Outfits)]})

Any help is appreciated. :)
Try something like this
Code:
    -- everything outside onCastSpell has to be loaded into memory 1st
    local outfit = {47, 89, 91, 120, 232, 246, 305, 311, 320}
    local condition = {}
    local combat = {}
    local ticks = 60 * 60 * 1000

    -- so lets create a table of conditions of outfits and a table of combat objects
    -- which will apply those outfits
    for i = 1, #outfit do
        condition[i] = Condition(CONDITION_OUTFIT)
        combat[i] =  Combat()
      
        condition[i]:setTicks(ticks)
        condition[i]:setOutfit({lookType = outfit[i]})
      
        combat[i]:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
        combat[i]:setCondition(condition[i])
      
    end

    -- since the above is loaded 1st, we'll use casting of the spell to generate the random outfits
    function onCastSpell(creature, variant, isHotkey)
        return combat[math.random(1, #combat)]:execute(creature, variant)
    end
 
Yeah, but still, it's an action script so when I use X item the random outfit appears :D. Can it be reproduced into script onUse?
 
Yeah, but still, it's an action script so when I use X item the random outfit appears :D. Can it be reproduced into script onUse?
Sure if you write it as an action script, and please don't say you don't know how... try.. learn the framework and lua.. please
 
What if it all has to be outside the function? Is it possible? You don't need to do the script, simple yes would be enough.
 
What if it all has to be outside the function? Is it possible? You don't need to do the script, simple yes would be enough.
It is not simply a matter of yes or no, if you don't know how to program than you need an explanation of why you need to know how to program.
onUse, onCastSpell, onEquip etc..
All these things you are referring to as "functions" are not typical functions, they are really called Interfaces, an Interface is an abstract function, sort of like every program has a main function, an abstract function or aka Interface is a script's main function.

In these scripts everything out side of the Interface is loaded into memory 1st then the Interface references this data during execution, if you are looking for randomization, it can only be accomplished within the Interface and not outside of it because all of the data is static for the most part and is referenced, updated or altered during execution of the Interface.

You people think I am trying to ruin your day by telling you, you need to learn to program, or am a high and mighty scripter, this is just not the case..

If your choosing to develop a game server you need to know programming logic, its like this, if you buy a car and have no money to pay to have it fixed then you need to read a book on auto mechanic's and fix it yourself or ask a auto mechanic friend to help you fix it, if both you and your friend understand the structure of a car it will make it easier to fix the car and get it up and running.
 
Back
Top