Help me with .lua script

  • Hello.


    Let me apologize first that I start this topic in English language, but my German knowledge is a bit rusty.


    I have made an adjustable animated bale forks for my private use, but my knowledge of .lua is not so good.
    I wanna modify the AnimationHandler.lua and the objectAttacherMBH.lua @author Geri-G (edited by PeterJ FS-UK modteam), found can be in this package: http://fs-uk.com/forum/index.php?topic=130148.0.


    The problem with the script is that I do not know how to detach the bale as soon as the animation of the forks is started ... so to be more precise ... if the bale is locked on to forks and the animation is set still then the bale stays locked ... as soon the forks are started to move apart or towards each other the bale must be unlocked.
    I am pretty sure that it must be done in objectAttacherMBH.lua in this part here:


    [lua]if self:getIsActive() and self.isServer then
    if self.animationParts[1].currentPosition > 1001 then
    if self.isBaleAttach == true then
    self:setIsBaleAttached(not self.isBaleAttach);
    end;
    end;
    if self.animationParts[1].currentPosition < 1001 then
    if self.isBaleAttach == false then
    self:setIsBaleAttached(not self.isBaleAttach);
    end;
    end;
    end;[/lua]


    but like I have said Im not much of a scripter. Would appreciate if anyone could help me with this script.


    This will be for my personal use only.

  • I think you could have done it with a global variable, that is set true, when the animation is played.
    this has to be in the move.lua
    in the attacher.lua I'd do it like that:
    [lua]
    if self:getIsActive() and self.isServer and self.yourvariable then
    if self.animationParts[1].currentPosition > 1001 then
    if self.isBaleAttach == true then
    self:setIsBaleAttached(not self.isBaleAttach);
    end;
    end;
    if self.animationParts[1].currentPosition < 1001 then
    if self.isBaleAttach == false then
    self:setIsBaleAttached(not self.isBaleAttach);
    end;
    end;
    end; [/lua]

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!