How to catch build event

Everything about mods can be found here.

Moderator: Morax

Re: How to catch build event

Postby Phelom » 12 Jun 2015, 18:17

Thanks a lot... i'll try it

I copied the broadcast function from survival map...
User avatar
Phelom
Avatar-of-War
 
Posts: 195
Joined: 08 Apr 2015, 15:04
Location: Tizi Ouzou
Has liked: 104 times
Been liked: 25 times
FAF User Name: Phelom/Gurzil

Re: How to catch build event

Postby quark036 » 12 Jun 2015, 18:24

The broadcast function might be defined somewhere else in that survival map, its not necessarily a universal function.
quark036
Avatar-of-War
 
Posts: 165
Joined: 11 Mar 2015, 03:17
Has liked: 10 times
Been liked: 26 times
FAF User Name: Quark036

Re: How to catch build event

Postby speed2 » 12 Jun 2015, 18:35

For example, defined at the beginning
Code: Select all
BroadcastMSG = function(MSG, Fade, TextColor)
   PrintText(MSG, 20, TextColor, Fade, 'center') ;   
end

then used later in some function
Code: Select all
BroadcastMSG("Well done, but can you do better?", 30);
User avatar
speed2
Contributor
 
Posts: 3189
Joined: 05 Jan 2013, 15:11
Has liked: 636 times
Been liked: 1119 times
FAF User Name: speed2

Re: How to catch build event

Postby Phelom » 12 Jun 2015, 19:40

Yes i know that, i copied it.. so if i've no msg it means that the callback function is not catched
User avatar
Phelom
Avatar-of-War
 
Posts: 195
Joined: 08 Apr 2015, 15:04
Location: Tizi Ouzou
Has liked: 104 times
Been liked: 25 times
FAF User Name: Phelom/Gurzil

Re: How to catch build event

Postby Phelom » 12 Jun 2015, 19:52

Nothing happends :(

Even if i call BroadcastMSG in OnStart function

Code: Select all
function OnStart(self)
   
   ScenarioFramework.CreateUnitBuiltTrigger( myCB, unit, categories.FACTORY * categoriesTECH1 )
end

function myCB()
   
   BroadcastMSG("Well done !", 8);
   
end


User avatar
Phelom
Avatar-of-War
 
Posts: 195
Joined: 08 Apr 2015, 15:04
Location: Tizi Ouzou
Has liked: 104 times
Been liked: 25 times
FAF User Name: Phelom/Gurzil

Re: How to catch build event

Postby speed2 » 12 Jun 2015, 20:05

you need have BroadcastMSG defined at the beginning, after you import other files and then you also need to define unit somewhere
User avatar
speed2
Contributor
 
Posts: 3189
Joined: 05 Jan 2013, 15:11
Has liked: 636 times
Been liked: 1119 times
FAF User Name: speed2

Re: How to catch build event

Postby Phelom » 12 Jun 2015, 20:06

BroadcastMSG functon is defined

How do i define units ?
User avatar
Phelom
Avatar-of-War
 
Posts: 195
Joined: 08 Apr 2015, 15:04
Location: Tizi Ouzou
Has liked: 104 times
Been liked: 25 times
FAF User Name: Phelom/Gurzil

Re: How to catch build event

Postby Phelom » 12 Jun 2015, 21:01

Can u please help me to find a working example ?
User avatar
Phelom
Avatar-of-War
 
Posts: 195
Joined: 08 Apr 2015, 15:04
Location: Tizi Ouzou
Has liked: 104 times
Been liked: 25 times
FAF User Name: Phelom/Gurzil

Re: How to catch build event

Postby Phelom » 12 Jun 2015, 22:48

in debug i got this :

Code: Select all
WARNING: BeginSession() failed: ...d alliance\gamedata\lua.scd\lua\scenariotriggers.lua(366): attempt to call method `AddOnUnitBuiltCallback' (a nil value)
         stack traceback:
            ...d alliance\gamedata\lua.scd\lua\scenariotriggers.lua(366): in function `CreateUnitBuiltTrigger'
            ...ce\maps\survival contest\survival contest_script.lua(67): in function `OnStart'
            ...ogramdata\faforever\gamedata\lua.nx2\lua\siminit.lua(147): in function <...ogramdata\faforever\gamedata\lua.nx2\lua\siminit.lua:138>
            ...ogramdata\faforever\gamedata\lua.nx2\lua\siminit.lua(291): in function `BeginSession'
User avatar
Phelom
Avatar-of-War
 
Posts: 195
Joined: 08 Apr 2015, 15:04
Location: Tizi Ouzou
Has liked: 104 times
Been liked: 25 times
FAF User Name: Phelom/Gurzil

Re: How to catch build event

Postby Myxir » 13 Jun 2015, 00:02

this looks like you have a typo (callbackfunction parameter to actual function name) but it was supposed to be called
Unhappy with balance http://i.imgur.com/q5G2BlM.png
User avatar
Myxir
Evaluator
 
Posts: 791
Joined: 09 Apr 2012, 14:01
Has liked: 94 times
Been liked: 306 times
FAF User Name: Washy (irc)

PreviousNext

Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest