Forged Alliance Forever Forged Alliance Forever Forums 2016-11-06T20:49:40+02:00 /feed.php?f=41&t=13411 2016-11-06T20:49:40+02:00 2016-11-06T20:49:40+02:00 /viewtopic.php?t=13411&p=138467#p138467 <![CDATA[Re: Teleport Help]]> https://test.faforever.com/calendar
19 december is the next game patch according to that calendar.
So then i guess?

Statistics: Posted by KeyBlue — 06 Nov 2016, 20:49


]]>
2016-11-06T17:35:33+02:00 2016-11-06T17:35:33+02:00 /viewtopic.php?t=13411&p=138445#p138445 <![CDATA[Re: Teleport Help]]> Statistics: Posted by Dudekahedron — 06 Nov 2016, 17:35


]]>
2016-11-04T20:05:23+02:00 2016-11-04T20:05:23+02:00 /viewtopic.php?t=13411&p=138316#p138316 <![CDATA[Re: Teleport Help]]>
https://github.com/FAForever/fa/issues/1659

It works in beta. so you can test your mod there.

Statistics: Posted by Androish — 04 Nov 2016, 20:05


]]>
2016-11-04T02:41:39+02:00 2016-11-04T02:41:39+02:00 /viewtopic.php?t=13411&p=138293#p138293 <![CDATA[Re: Teleport Help]]> Although, I am also tired!
This will delay my new unit :/

Statistics: Posted by Dudekahedron — 04 Nov 2016, 02:41


]]>
2016-11-04T02:30:50+02:00 2016-11-04T02:30:50+02:00 /viewtopic.php?t=13411&p=138292#p138292 <![CDATA[Re: Teleport Help]]>
this is kinda a guess though, im a bit tired atm xD

Statistics: Posted by Exotic_Retard — 04 Nov 2016, 02:30


]]>
2016-11-04T01:10:23+02:00 2016-11-04T01:10:23+02:00 /viewtopic.php?t=13411&p=138291#p138291 <![CDATA[Re: Teleport Help]]>
I attempted to simplify the procedure of returning by just calling the warp function on ReturnPos after the TeleportThread ends:
Code:
        self:CleanupTeleportChargeEffects()
        self.TeleportThread = self:ForkThread(self.InitiateTeleportThread, teleporter, location, orientation)
       
        if Return == true then
            Warp(self, ReturnPos, orientation)
        end

Except it would never happen, and no errors were logged.
I noticed though that the teleport order never actually appears to complete. The image below is taken after the ACU teleported to the present location and I'm holding down the shift key:
Image
I'm guessing that the TeleportThread never ends on its own so it doesn't proceed to my if statement?
This behavior happens even without my mod being active!

Statistics: Posted by Dudekahedron — 04 Nov 2016, 01:10


]]>
2016-11-03T23:38:55+02:00 2016-11-03T23:38:55+02:00 /viewtopic.php?t=13411&p=138289#p138289 <![CDATA[Re: Teleport Help]]>
it has to be in a place where its not gonna interfere with any other procedures (in units scripts they are all run at the same tick so you cant possibly wait for them since it would take more than 1 tick to execute), so you need to fork a thread and wait there, then do whatever you want after.

after you fork a thread you can wait freely until the thread is killed and you have code going back across that boundary (like if your thread calls sth like OnKilled)

it should be noted that forking works like the name suggests, the rest of the code can run after the fork is done and you get things running in parallel. so dont expect you to fork a thread wait 5s in it then resume your function. you will get your whole function done without delay and then have this empty useless thread terminate after 5s.

so really you want:

Code:
self.DamnThread = self:ForkThread(self.AmazingThread)

    AmazingThread= function(self)
        --damn im blown away by this code
    end,

so you stick that forkthread line wherever, then perform things in the thread, and it either ends or you can kill it prematurely from some other function via:
Code:
KillThread(self.DamnThread )

note that self.DamnThread is an entry that stores the self.AmazingThread, and you kill DamnThread and not AmazingThread.



you can also do it like this:
Code:
self:ForkThread(    function()
        --damn im blown away by this code
    end)


this is for only one instance of the thread if you want to call it form only one spot, and you cant really interact with it while its running, best for one shot kind of stuff

i haven't looked into your code that far but it seems like you might want to put this return code into the teleport thread since that's there already so you can wait in there and stuff, so you dont fork a thread just to wait, that would be strange. also probably wont work.

hope this helps

Statistics: Posted by Exotic_Retard — 03 Nov 2016, 23:38


]]>
2016-11-03T23:25:27+02:00 2016-11-03T23:25:27+02:00 /viewtopic.php?t=13411&p=138287#p138287 <![CDATA[Re: Teleport Help]]>
Using this, I get a new error:
Code:
WARNING: Error running OnTeleportUnit script in Entity dal401 at 1c5ef808: attempt to yield across metamethod/C-call boundary
         stack traceback:
            [C]: in function `WaitTicks'
            ...ogramdata\faforever\gamedata\lua.nx2\lua\siminit.lua(28): in function `WaitSeconds'
            ...gramdata\faforever\gamedata\lua.nx2\lua\sim\unit.lua(4092): in function <...gramdata\faforever\gamedata\lua.nx2\lua\sim\unit.lua:4066>


Why doesn't the waitseconds work?

Edit: There's a lot more at issue here than just the waitseconds as it turns out.
Simply removing the time delay;
Code:
WARNING: Error running lua script: ...data\faforever\gamedata\lua.nx2\lua\system\utils.lua(44): attempt to loop over local `t' (a number value)

ughhh

Statistics: Posted by Dudekahedron — 03 Nov 2016, 23:25


]]>
2016-11-03T23:10:29+02:00 2016-11-03T23:10:29+02:00 /viewtopic.php?t=13411&p=138285#p138285 <![CDATA[Re: Teleport Help]]>
If you want to add functions to Unit class, you can't simply write another function.
Since the class ends at the end of the original file, this new function is outside of the class.

The error is probably caused by the ',' , since this is an unexpected symbol outside of tables.

Try this :

Code:
local oldUnit = Unit
Unit =  Class(oldUnit) {
    OnTeleportUnit = function(self, teleporter, location, orientation)
        local ReturnTime
        local Return
        local ReturnPos
        local bp = self:GetBlueprint().Economy
        if bp then   
            if bp.TeleportReturn == true then
                ReturnTime = bp.TeleportReturnTime
                Return = true
                ReturnPos = self:GetPositionXYZ()
            else
                ReturnTime = false
                Return = false
            end
        end
        if self.TeleportDrain then
            RemoveEconomyEvent( self, self.TeleportDrain)
            self.TeleportDrain = nil
        end
        if self.TeleportThread then
            KillThread(self.TeleportThread)
            self.TeleportThread = nil
        end
        self:CleanupTeleportChargeEffects()
        self.TeleportThread = self:ForkThread(self.InitiateTeleportThread, teleporter, location, orientation)
        if Return == true then
            WaitSeconds(5)
            self.TeleportThread = self:ForkThread(self.InitiateTeleportThread, teleporter, ReturnPos, orientation)
        end
    end,
}

Statistics: Posted by KeyBlue — 03 Nov 2016, 23:10


]]>
2016-11-03T23:03:49+02:00 2016-11-03T23:03:49+02:00 /viewtopic.php?t=13411&p=138284#p138284 <![CDATA[Re: Teleport Help]]>
So the new problem is it simply doesn't work now

Statistics: Posted by Dudekahedron — 03 Nov 2016, 23:03


]]>
2016-11-03T22:36:22+02:00 2016-11-03T22:36:22+02:00 /viewtopic.php?t=13411&p=138282#p138282 <![CDATA[Teleport Help]]> I've run into issue trying to modify the teleport script. I'm trying to add in a return functionality, and I've got the following so far:

In \mods\MyMod\hook\lua\sim\Units.lua:
Code:
    OnTeleportUnit = function(self, teleporter, location, orientation)
        local ReturnTime
        local Return
        local ReturnPos
        local bp = self:GetBlueprint().Economy
        if bp then   
            if bp.TeleportReturn == true then
                ReturnTime = bp.TeleportReturnTime
                Return = true
                ReturnPos = self:GetPositionXYZ()
            else
                ReturnTime = false
                Return = false
            end
        end
        if self.TeleportDrain then
            RemoveEconomyEvent( self, self.TeleportDrain)
            self.TeleportDrain = nil
        end
        if self.TeleportThread then
            KillThread(self.TeleportThread)
            self.TeleportThread = nil
        end
        self:CleanupTeleportChargeEffects()
        self.TeleportThread = self:ForkThread(self.InitiateTeleportThread, teleporter, location, orientation)
        if Return == true then
            WaitSeconds(5)
            self.TeleportThread = self:ForkThread(self.InitiateTeleportThread, teleporter, ReturnPos, orientation)
        end
    end,

So, in bp.Economy in relevant units I've added TeleportReturn = true and TeleportReturnTime = 'n'

In game, I get the following error:
Code:
WARNING: SCR_LuaDoFileConcat: Loading "c:\programdata\faforever\gamedata\lua.nx2\lua\sim\unit.lua" failed: c:\programdata\faforever\gamedata\lua.nx2\lua\sim\unit.lua(4081): unexpected symbol near `='

There's 4047 lines in the original Unit.lua, so 4081 is line 34, specifically at the end of the OnTeleportUnit function.

Any ideas?

Edit: I should clarify, line 4081 is also the end of file, i had some redundant stuff following

Statistics: Posted by Dudekahedron — 03 Nov 2016, 22:36


]]>