Forged Alliance Forever Forged Alliance Forever Forums 2018-04-27T17:57:16+02:00 /feed.php?f=41&t=16069 2018-04-27T17:57:16+02:00 2018-04-27T17:57:16+02:00 /viewtopic.php?t=16069&p=162956#p162956 <![CDATA[Re: IF (a mod is present) THEN]]> Statistics: Posted by DDDX — 27 Apr 2018, 17:57


]]>
2018-04-18T01:19:02+02:00 2018-04-18T01:19:02+02:00 /viewtopic.php?t=16069&p=162692#p162692 <![CDATA[Re: IF (a mod is present) THEN]]>
Domino wrote:
It was but jesus who uses that, think I used it once.. better just to log n repr.... Tbh


I'm on that page too Dom, the debugger always mystified me, but that was actually helpful enough that I will actually try it.

Statistics: Posted by Sprouto — 18 Apr 2018, 01:19


]]>
2018-04-18T00:21:01+02:00 2018-04-18T00:21:01+02:00 /viewtopic.php?t=16069&p=162689#p162689 <![CDATA[Re: IF (a mod is present) THEN]]>
Domino wrote:
Sprouto wrote:Clearest explanation of how to use the debugger - ever. Thanks Speed.


It was but jesus who uses that, think I used it once.. better just to log n repr.... Tbh

Often its enough, but sometimes it was just logging nonsense values so I had to use debugger to go step by step through the code and see whats going on there.

Or for debugging AI, using LOG for eveything would be just a huge mess, so in that the debugger was handy as well.

Statistics: Posted by speed2 — 18 Apr 2018, 00:21


]]>
2018-04-17T23:14:27+02:00 2018-04-17T23:14:27+02:00 /viewtopic.php?t=16069&p=162686#p162686 <![CDATA[Re: IF (a mod is present) THEN]]>
Sprouto wrote:
Clearest explanation of how to use the debugger - ever. Thanks Speed.


It was but jesus who uses that, think I used it once.. better just to log n repr.... Tbh

Statistics: Posted by Domino — 17 Apr 2018, 23:14


]]>
2018-04-17T20:44:59+02:00 2018-04-17T20:44:59+02:00 /viewtopic.php?t=16069&p=162683#p162683 <![CDATA[Re: IF (a mod is present) THEN]]> Statistics: Posted by Sprouto — 17 Apr 2018, 20:44


]]>
2018-04-17T20:19:47+02:00 2018-04-17T20:19:47+02:00 /viewtopic.php?t=16069&p=162682#p162682 <![CDATA[Re: IF (a mod is present) THEN]]> Image
The top left window contains the folder tree, that way you have to click all the way to the maps folder, usually on C drive, in the documents, Mygames folder etc...

you double click the YourMap_script.lua file
that opens it, to the top right window (there you see the whole file as you see it in your text editor)
now if you double click a line there, it will set a break point (the one highlighted on the picture, with the yellot dot next to the line). What that means is when the game reacher that line, it pauses and let you see what's in the variables (you have to run the game in the windowed mode to see the debugger)

Also when you set the break point, the game gets muuuuuuuuuch slower and laggier. So I recomment setting the break points with double clicking all the lines you want before you launch your map. Then you this settings to disable the break points:
Image
And re-enable them just before the game launches.
If you have them enabled all the time, it takes almost forever to load the map.

Once the game reaches the break point it will look like this:
Image
The game window will be just all grey. The debugger will show with the green arrow what line you're at.
The Locals and Globals tabs will show all variables that are set
Image
(you can click though them to see it's content.

Once you have everything checked you can either resume the game OR go step by step through the code ("step into")
Image
Resume execution - will resume the game until the next break point
Step Into - will go line by line through your code and the locals and globals tabs will update their content as the game continues
This way you can see what your code does.

Hope this explains it.

Statistics: Posted by speed2 — 17 Apr 2018, 20:19


]]>
2018-04-17T19:33:22+02:00 2018-04-17T19:33:22+02:00 /viewtopic.php?t=16069&p=162680#p162680 <![CDATA[Re: IF (a mod is present) THEN]]>
As always I lrefer to my old mod DMS I added these functions

I actually tried to push a new table value in the mod_info.lua file
Called mod_identifier so you could use strings instead of the uid to check if a mod was loaded I added quite a few functions to load unload and check mods :)

A working example exists in 4dc and DMS that shows the game SIM speed on the UI ... Think its in score.lua not sure of the file name though from memory :)

Statistics: Posted by Domino — 17 Apr 2018, 19:33


]]>
2018-04-05T12:53:48+02:00 2018-04-05T12:53:48+02:00 /viewtopic.php?t=16069&p=162411#p162411 <![CDATA[Re: IF (a mod is present) THEN]]>
Thanx to both Speed2 and Uveso. Sorry Speed2, I am not knowlegeable enough to fiddle around the debugger in any meaningful way - i figured out how, but by that time Uveso's solution already came. ty for thrying none the less.

Uveso...this freakin WORKS!!! Not as a = false, but that was easily fixable with a if not InstalledMods['Total Mayhem'] == true, so no problems there

thankyou thankyou thankyou thankyou thankyou!!!

Statistics: Posted by DDDX — 05 Apr 2018, 12:53


]]>
2018-04-04T21:13:01+02:00 2018-04-04T21:13:01+02:00 /viewtopic.php?t=16069&p=162401#p162401 <![CDATA[Re: IF (a mod is present) THEN]]>
this is how you can identify a mod inside your Map_script.lua:

Code:
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')

-- create a table for ModNames and UIDs
local InstalledMods = {}

function OnPopulate()
    ScenarioUtils.InitializeArmies()
   
    -- loop over __active_mods table. 
    for index, moddata in __active_mods do
        -- save the modname as index and set it to true.
        InstalledMods[moddata.name] = true
        -- Save also the ModID as index and set it also to true
        InstalledMods[moddata.uid] = true
        -- Debug line for the debuglog [F9]
        LOG('Mapscript: found Mod with name: '..moddata.name..' - UID: '..moddata.uid )
    end
end

function OnStart(self)
    -- identify Total Mayhem by Mod Name:
    if InstalledMods['Total Mayhem'] == true then
        LOG('Mapscript: Yes, Total mayhem is installed. (identified by name)')
    end
    -- identify Total Mayhem by UID (every version has a different UID)
    if InstalledMods['62e2j64a-TOMA-3652-01360-146as555a8u3'] == true then
        LOG('Mapscript: Yes, Total Mayhem Version 1.36 is installed (identified by UID)')
    end
end

Statistics: Posted by Uveso — 04 Apr 2018, 21:13


]]>
2018-04-04T17:37:41+02:00 2018-04-04T17:37:41+02:00 /viewtopic.php?t=16069&p=162396#p162396 <![CDATA[Re: IF (a mod is present) THEN]]> Statistics: Posted by speed2 — 04 Apr 2018, 17:37


]]>
2018-04-04T17:29:09+02:00 2018-04-04T17:29:09+02:00 /viewtopic.php?t=16069&p=162395#p162395 <![CDATA[Re: IF (a mod is present) THEN]]>
Code:
Survival_UpdateWavesB = function(GameTime)

   local OldWaveID = 1;

       for index, mods in __active_mods do                                          -- THIS seems to be the problem
          if mods == "Survival Mayhem&BO balance" then                    --  and this.
             LOG("----- Ballance mod is ON...");
            
            -- check the wave table times vs the wave spawn time to see which waves we spawn
            for x = 1, table.getn(Survival_WaveTablesB) do -- loop through each of the wavetable entries (ground/air/sea...)

         --      OldWaveID = 1;
               OldWaveID = Survival_WaveTablesB[x][1];

               for y = Survival_WaveTablesB[x][1], table.getn(Survival_WaveTablesB[x]) do -- loop through each wave table within the category

                  if (GameTime >= (Survival_WaveTablesB[x][y][1] * 60)) then -- compare spawn time against the first entry spawn time for each wave table
                     if (Survival_WaveTablesB[x][1] < y) then -- should only update a wave once
                     
                        Survival_WaveTablesB[x][1] = y; -- update the wave id for this wave category

                        --if (x == 1) then -- if this is the special category update, immediately call the setup function
                        --   Survival_SpawnSpecialWave(GameTime);
                        --end
                     end
                  else break; end

               end

               if (Survival_WaveTablesB[x][1] != OldWaveID) then -- if we have a new wave ID for this table
                  LOG("----- Survival MOD: Updating wave table from C:" .. x .. " ID:" .. Survival_WaveTablesB[x][1] .. " ( Set:" .. (Survival_WaveTablesB[x][1] - 1) ..") at " .. SecondsToTime(GameTime));      
               end
            end
         else
            LOG("----- Balance mod is not ON...");                     -- I get this in the log
         end
      end
end


the log shows the 'Map Script ... active mods in sim' with all mods listed, so no problem there. The debugger is empty for me - blank (?).

I made logs in the if - then clause that I want to use, and it is there that nothing happens - the log gives me the "----- Balance mod is not ON..."

So everything is loaded as should be, but I am not calling it well with that if-then

Statistics: Posted by DDDX — 04 Apr 2018, 17:29


]]>
2018-04-04T15:57:39+02:00 2018-04-04T15:57:39+02:00 /viewtopic.php?t=16069&p=162391#p162391 <![CDATA[Re: IF (a mod is present) THEN]]>
You can also try debugger Alt-F9 to see whats in those variables

Statistics: Posted by speed2 — 04 Apr 2018, 15:57


]]>
2018-04-04T15:22:21+02:00 2018-04-04T15:22:21+02:00 /viewtopic.php?t=16069&p=162388#p162388 <![CDATA[Re: IF (a mod is present) THEN]]>
Code:
function OnPopulate()
   LOG("----- Survival MOD: OnPopulate()");

   -- start the armies
   ScenarioUtils.InitializeArmies();

   -- prepare all the survival stuff
   Survival_InitGame();

   -- which mods are active?
   local mods = __active_mods
    LOG('Map Script ... active mods in sim: ', repr(__active_mods))

end

-- function OnStart()
-- end

This is my map's OnPopulate function, and this is the OnStart
Code:
function OnStart(self)

   LOG("----- Survival MOD: Initializing game start sequence...");

   -- start the survival tick
   ForkThread(Survival_Tick);

end


And this is what I hope to use to call the mod up, if it is used or not.
Code:
      for index, moddata in __active_mods do
           if moddata == 'Survival Mayhem&BO balance' then


It does nothing, as if the condition is not met. Don't know why.

Statistics: Posted by DDDX — 04 Apr 2018, 15:22


]]>
2018-04-04T14:49:50+02:00 2018-04-04T14:49:50+02:00 /viewtopic.php?t=16069&p=162387#p162387 <![CDATA[Re: IF (a mod is present) THEN]]>
speed2 wrote:
Well you have to edit the map script. The mods are saved in the global variable __active_mods as Uveso posted.

You can access it like this for example (map script):
Code:
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
   
function OnPopulate()
    ScenarioUtils.InitializeArmies()
    local mods = __active_mods
    LOG('Map Script ... active mods in sim: ', repr(__active_mods))
end
   
function OnStart()
end

Statistics: Posted by speed2 — 04 Apr 2018, 14:49


]]>
2018-04-04T11:56:04+02:00 2018-04-04T11:56:04+02:00 /viewtopic.php?t=16069&p=162384#p162384 <![CDATA[Re: IF (a mod is present) THEN]]>
Can't.
Either it needs something more, or I made the if-then segment wrong (look above).

Statistics: Posted by DDDX — 04 Apr 2018, 11:56


]]>