why no score after the game?

Interesting mapping tools and mapping help.

Moderator: Morax

why no score after the game?

Postby Ghoustaq » 25 Dec 2017, 14:19

what's wrong with my new map? it's possible that some bug in the * script.lua file, but I'm not sure. :? Excuse me, I can't post an image here, cause' I'm newcom.
User avatar
Ghoustaq
Avatar-of-War
 
Posts: 65
Joined: 25 Dec 2017, 13:54
Has liked: 10 times
Been liked: 0 time
FAF User Name: Ghoustaq

Re: why no score after the game?

Postby speed2 » 25 Dec 2017, 14:42

Mentioning the name of your map would be a good start, so someone can have a look at it. Or posting the content of the script, since that's just text, or anything that would give any kind of information.
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: why no score after the game?

Postby Ghoustaq » 25 Dec 2017, 15:31

speed2 wrote:Mentioning the name of your map would be a good start, so someone can have a look at it. Or posting the content of the script, since that's just text, or anything that would give any kind of information.


thanks for you suggestions, here's the content of the script:


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


--units to be restricted
local AIRbuildRestriction = categories.AIR + categories.ANTIAIR

local rectSizeX = 5
local rectSizeY = 5

function OnPopulate()
   ScenarioUtils.InitializeArmies()
  local tblArmy = ListArmies()
   for index,army in tblArmy do
      ScenarioFramework.AddRestriction(army, AIRbuildRestriction)
   end

   local self = import('/lua/sim/Entity.lua').Entity()
   for k = 1, 88 do
      local entryName = 'Entry_' .. k
      local exitName = 'Exit_' .. k
      
      local entryPos = ScenarioUtils.MarkerToPosition(entryName)
      local exitPos = ScenarioUtils.MarkerToPosition(exitName)
      ForkThread(TeleportThread, self, entryPos, exitPos)
      CreateTeleportMaintenanceEffects(entryPos, exitPos)
   end
end


   


TeleportThread = function(self, entryPos, exitPos)
   local ex, ey, ez = unpack(entryPos)
   local tx, ty, tz = unpack(exitPos)
   local entryRect = Rect(ex - rectSizeX/2, ez - rectSizeY/2, ex + rectSizeX/2, ez + rectSizeY/2)
   local exitRect = Rect(tx - rectSizeX/2, tz - rectSizeY/2, tx + rectSizeX/2, tz + rectSizeY/2)
   local counter -- wtf value just to havy ANY value at until
   local telUnits
   local killUnits
   while true do
      telUnits = GetUnitsInRect( entryRect)
      killUnits = GetUnitsInRect( exitRect)
      if telUnits ~= nil then
         if table.getn(telUnits) >= 1 then
            for k, v in telUnits do
               if table.find(v:GetBlueprint().Categories,'AIR')  then   
               #v:GetPosition()
               else
                  ForkThread(WarpThread,self, entryPos, exitPos, v)
               end
            end
         end
      end
      if killUnits ~= nil then
         if table.getn(killUnits) >= 1 then
            for k, v in killUnits do
               if table.find(v:GetBlueprint().Categories,'STRUCTURE') then
                  v:Destroy()
               end
            end
         end
      end
      WaitSeconds(3)
   end
end

WarpThread = function(self, entryPos, exitPos, v)
   local ex, ey, ez = unpack(entryPos)
   local tx, ty, tz = unpack(exitPos)



   if table.find(v:GetBlueprint().Categories,'MOBILE') or table.find(v:GetBlueprint().Categories,'PROJECTILE') then

         Warp(v, Vector( tx + Random(-rectSizeX/0.2, rectSizeX/0.2)/10, ty, tz + Random(-rectSizeY/0.2,

rectSizeY/0.2)/10))
         #print('uzoom')

   elseif table.find(v:GetBlueprint().Categories,'STRUCTURE') then
      v:Destroy()
   end
end

function CreateTeleportMaintenanceEffects (entryPos, exitPos)
   #local ex, ey, ez = unpack(entryPos)
   #local tx, ty, tz = unpack(exitPos)


   #CreateUnitHPR('uel0001', 1, ex - rectSizeX/2, ey,ez - rectSizeY/2 , -180, 0, 0)
   #CreateUnitHPR('uel0001', 1, ex + rectSizeX/2, ey,ez - rectSizeY/2 , -180, 0, 0)
   #CreateUnitHPR('uel0001', 1, ex - rectSizeX/2, ey,ez + rectSizeY/2 , -180, 0, 0)
   #CreateUnitHPR('uel0001', 1, ex + rectSizeX/2, ey,ez + rectSizeY/2 , -180, 0, 0)
   
   local entryEnt = import('/lua/sim/Entity.lua').Entity()
   local exitEnt = import('/lua/sim/Entity.lua').Entity()
   Warp(entryEnt, Vector(entryPos[1],entryPos[2] + 0.2,entryPos[3] ))
   Warp( exitEnt, Vector(exitPos[1],exitPos[2] + 0.2,exitPos[3] ))
   
   

   
end
   




function OnStart(self)
end




----------------------------------------
some parts of the script are totally copied from a map named 'Aperture Laboratories' whose author is Col. Jessep, what I do is just modifying some values in the sentenses to make them suitable for my map.
User avatar
Ghoustaq
Avatar-of-War
 
Posts: 65
Joined: 25 Dec 2017, 13:54
Has liked: 10 times
Been liked: 0 time
FAF User Name: Ghoustaq

Re: why no score after the game?

Postby speed2 » 25 Dec 2017, 15:46

what's the name of your map?
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: why no score after the game?

Postby Ghoustaq » 25 Dec 2017, 17:09

speed2 wrote:what's the name of your map?

the name is 13. I haven't rename it yet, because the map is not complished, and I have not uploaded it on the forum or somewhere else. I just test it on my own computer.
User avatar
Ghoustaq
Avatar-of-War
 
Posts: 65
Joined: 25 Dec 2017, 13:54
Has liked: 10 times
Been liked: 0 time
FAF User Name: Ghoustaq

Re: why no score after the game?

Postby speed2 » 25 Dec 2017, 18:52

If there are no errors in the log, it should be fine. Else I'd need to try the map to tell you more.
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: why no score after the game?

Postby Ghoustaq » 25 Dec 2017, 19:39

speed2 wrote:If there are no errors in the log, it should be fine. Else I'd need to try the map to tell you more.

I copied the script to the folder of another map and rename it, then the same problem occured. So I'm sure that there's something wrong with the content of the script.You can try it as I did.
User avatar
Ghoustaq
Avatar-of-War
 
Posts: 65
Joined: 25 Dec 2017, 13:54
Has liked: 10 times
Been liked: 0 time
FAF User Name: Ghoustaq

Re: why no score after the game?

Postby Ghoustaq » 25 Dec 2017, 20:10

speed2 wrote:If there are no errors in the log, it should be fine. Else I'd need to try the map to tell you more.

I think I have found where the bug is. If I delete those sentences below, the score system will work normally. But I can't do that, they are very important for me to complish the map.

local self = import('/lua/sim/Entity.lua').Entity()
for k = 1, 88 do
local entryName = 'Entry_' .. k
local exitName = 'Exit_' .. k

local entryPos = ScenarioUtils.MarkerToPosition(entryName)
local exitPos = ScenarioUtils.MarkerToPosition(exitName)
ForkThread(TeleportThread, self, entryPos, exitPos)
CreateTeleportMaintenanceEffects(entryPos, exitPos)
end
User avatar
Ghoustaq
Avatar-of-War
 
Posts: 65
Joined: 25 Dec 2017, 13:54
Has liked: 10 times
Been liked: 0 time
FAF User Name: Ghoustaq

Re: why no score after the game?

Postby speed2 » 25 Dec 2017, 20:44

do you have markers on your map? specifically markers named
Entry_1, Entry_2, Entry_3, ... Entry_88
and same for
Exit_1 - Exit_88
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: why no score after the game?

Postby Ghoustaq » 26 Dec 2017, 12:22

speed2 wrote:do you have markers on your map? specifically markers named
Entry_1, Entry_2, Entry_3, ... Entry_88
and same for
Exit_1 - Exit_88

Thank you very much! You inspired me a lot. I have found the solution to this problem. :D I should have set the value of 'k' from 1 to 55, 'cause I only have put 55 pairs of entries and exits on the map. The maximum of 'k' must be equal to the totality of the entries or exits on the map.
User avatar
Ghoustaq
Avatar-of-War
 
Posts: 65
Joined: 25 Dec 2017, 13:54
Has liked: 10 times
Been liked: 0 time
FAF User Name: Ghoustaq


Return to Mapping

Who is online

Users browsing this forum: No registered users and 1 guest