Login

russian armor

[HELP] AI Resource and Camera Zoom Error

4 Sep 2017, 10:53 AM
#1
avatar of TheChosenOne

Posts: 59

My problem is I created a custom Win Condition to edit the AI Resource Bonus and Camera Zoom.

I followed the parameters of a few other posts and I get a Fatal SCAR Error.



I tried the mod as it was created and the game ran fine. Once I put in the code, the game is frozen

at the beginning of a match and I get the message.

The two codes are:


Help is always appreciated.
4 Sep 2017, 17:58 PM
#2
avatar of SneakEye
Senior Modmaker Badge

Posts: 817 | Subs: 5

I don't have experience with Win Conditions and SCAR, but I have experience with many other programming languages so I will try to help you.

It seems that the function which you use requires a 'float' parameter which is a decimal number, like 0,0 instead of just 0. The 'received=nil' means that you gave to few values or a variable without value.

The second code might freeze because there's an 'end' missing. I see 1 function, 1 for-loop and 3 if-blocks, but only 4 end.
4 Sep 2017, 21:09 PM
#3
avatar of TheChosenOne

Posts: 59

Appreciate the help.

My experience is very limited as well. I followed the Tutorials provided by Eliwood on his Youtube Channel. I followed his example, but I get this error. I have looked up the ScarDoc to make sense of it, but Lua is a very new thing to me.
4 Sep 2017, 21:34 PM
#4
avatar of TheChosenOne

Posts: 59

Ok, I got the camera function to work. Now I need to work on the AI Resource code. You stated
I see 1 function, 1 for-loop and 3 if-blocks, but only 4 end.
At where do you think I should put the "end"?

   -- My Stuff: ------------------------------------------------------------------
for p = 1, World_GetPlayerCount() do -- iterate over all the players
local player = World_GetPlayerAt(p) -- get more information about this player
if (AI_IsAIPlayer(player)) then
if (AI_GetDifficulty(player)==AD_Hard) then
Modify_PlayerResourceRate(player,RT_Manpower,0.67,MUT_Multiplication)
Modify_PlayerResourceRate(player,RT_Munition,0.67,MUT_Multiplication)
Modify_PlayerResourceRate(player,RT_Fuel,0.67,MUT_Multiplication)
end
if (AI_GetDifficulty(player)==AD_Hardest) then
Modify_PlayerResourceRate(player,RT_Manpower,0.5,MUT_Multiplication)
Modify_PlayerResourceRate(player,RT_Munition,0.5,MUT_Multiplication)
Modify_PlayerResourceRate(player,RT_Fuel,0.5,MUT_Multiplication)
end
end -- loop over all the players
-- End of My Stuff. ----------------------------------------------------------
4 Sep 2017, 22:04 PM
#5
avatar of TheChosenOne

Posts: 59

Ok, I adjusted a few things. I got the the game to run and looked into the Warnings.log and there were no errors. YAY

Now, I'm not sure if the AI Resource Bonus code I input is working. I watched a replay and it "seems" to work need to look into it further.

If you or someone could look into the code to verify all my ducks are in a row. That would be much appreciated.

local function WinCondition_Init()
for p = 1, World_GetPlayerCount()
do -- iterate over all the players
local player = World_GetPlayerAt(p) -- get more information about this player

if (AI_IsAIPlayer(player)) then
end

if (AI_GetDifficulty(player)==AD_Hard) then
Modify_PlayerResourceRate(player,RT_Manpower,0.67,MUT_Multiplication)
Modify_PlayerResourceRate(player,RT_Munition,0.67,MUT_Multiplication)
Modify_PlayerResourceRate(player,RT_Fuel,0.67,MUT_Multiplication)
end

if (AI_GetDifficulty(player)==AD_Hardest) then
Modify_PlayerResourceRate(player,RT_Manpower,0.5,MUT_Multiplication)
Modify_PlayerResourceRate(player,RT_Munition,0.5,MUT_Multiplication)
Modify_PlayerResourceRate(player,RT_Fuel,0.5,MUT_Multiplication)
end
end -- loop over all the players

local distMin = 3;
local distMax = 75;

Camera_SetTuningValue(TV_DistMin, 3);
Camera_SetTuningValue(TV_DistMax, distMax);
Camera_SetZoomDist(50);

Rule_AddInterval(WinCondition_Check, 3)
end

Scar_AddInit(WinCondition_Init)
1 user is browsing this thread: 1 guest

Livestreams

Germany 19

Ladders Top 10

  • #
    Steam Alias
    W
    L
    %
    Streak
Data provided by Relic Relic Entertainment

Replay highlight

VS
  • U.S. Forces flag cblanco ★
  • The British Forces flag 보드카 중대
  • Oberkommando West flag VonManteuffel
  • Ostheer flag Heartless Jäger
uploaded by XXxxHeartlessxxXX

Board Info

827 users are online: 827 guests
0 post in the last 24h
5 posts in the last week
33 posts in the last month
Registered members: 49139
Welcome our newest member, vibhak
Most online: 2043 users on 29 Oct 2023, 01:04 AM