Login

russian armor

Nothing I do seems to work. What am I doing wrong?

22 Dec 2014, 07:27 AM
#1
avatar of Vangruffe

Posts: 139

Just pulling my hair out, SCAR is really frustrating to even learn. Everything I do either ends up with a fatal scar, a non-running script, even if I enter a simple piece of line - Player_AddResource (player1, RT_Manpower, 1000) into the console in -dev mode in-game, I always get a nil value error. I don't even know why everything I do with this language ends with an error. Somebody please tell me and teach me what I'm doing wrong. I don't think I even understand how to use this scripting language.

Edit: I really want to make mods for this game, but if the difficulty level for SCAR is this high, then this is definitely a steep barrier for me. That or I'm just screwing up everywhere.
22 Dec 2014, 15:45 PM
#2
avatar of trigg

Posts: 139

There's a steep learning curve, but it gets better (eventually).

Why don't you post your code and maybe we can spot something.
22 Dec 2014, 16:17 PM
#3
avatar of Paid_Player

Posts: 60 | Subs: 1

Hi!
Scar has deep learning barrier because there isn't enough documentation. The language itself is pretty easy. It is running over Lua script.

Best way to code scar is by making simple mod which imports your test file. Import("test.lua") loads file from the main folder of the game (steam folder). Start a custom game with the loader mod. Then you can write code and test the result by just pressing esc and then restart.

Good way to avoid structure errors is using codepad website.
23 Dec 2014, 21:27 PM
#4
avatar of Vangruffe

Posts: 139

jump backJump back to quoted post22 Dec 2014, 15:45 PMtrigg
There's a steep learning curve, but it gets better (eventually).

Why don't you post your code and maybe we can spot something.


Code

import("ScarUtil.scar")

function onInit()

Player_SetResource(player1, RT_Manpower, 100)
Player_SetResource(player1, RT_Munition, 0)
Player_SetResource(player1, RT_Fuel, 0)
Player_SetResource(player1, RT_Command, 1)


Setup_SetPlayerRace(World_GetPlayerAt(1), 3)
Setup_SetPlayerRace(World_GetPlayerAt(2), 3)
Setup_SetPlayerRace(World_GetPlayerAt(3), 3)
Setup_SetPlayerRace(World_GetPlayerAt(4), 3)
Setup_SetPlayerRace(World_GetPlayerAt(5), 3)
Setup_SetPlayerRace(World_GetPlayerAt(6), 3)
Setup_SetPlayerRace(World_GetPlayerAt(7), 3)
Setup_SetPlayerRace(World_GetPlayerAt(8), 3)

end

Scar_AddInit(onInit)


23 Dec 2014, 23:58 PM
#5
avatar of trigg

Posts: 139

You have to define player1 before setting the resources. Try something like:
Code
local player1 = World_GetPlayerAt(1)
Then you can make the calls to set that player's resources.

I'm not sure, but setting the player race may not be supported. After you fix the player1 problem, start a game, immediately hit pause, and see if the console has any error messages regarding setting the race.

25 Dec 2014, 11:39 AM
#6
avatar of Vangruffe

Posts: 139

jump backJump back to quoted post23 Dec 2014, 23:58 PMtrigg
You have to define player1 before setting the resources. Try something like:
Code
local player1 = World_GetPlayerAt(1)
Then you can make the calls to set that player's resources.

I'm not sure, but setting the player race may not be supported. After you fix the player1 problem, start a game, immediately hit pause, and see if the console has any error messages regarding setting the race.



When I tried this I got a Fatal Scar Error but when I press the ESC key (in-game menu) and went back to the game the scar error disappears and everything goes back to normal. Bad thing or no?
25 Dec 2014, 19:40 PM
#7
avatar of trigg

Posts: 139

No, that means something blew up and the script didn't finish executing.

When that happens, open the console and scroll until you find the error message. It will give a line number and a message that may or may not be helpful understanding what it didn't like. (It may also give line numbers in the function you called, or another internal function that was called indirectly, but the line number in your own file is the best clue.)

It helps to use an editor that shows line numbers, or will let you jump to a specific line number.

Note that when you got the message it was just paused, and pressing pause again will let the game contine, though the script didn't finish executing. I often pause a game as soon as it starts so I can look at my map, and thus inadvertantly un-pause a script error when I press the key. So I usually put something visible at the very end of the script, such as changing the population cap or creating a unit, and then I have direct visible evidence as to whether the script finished.
1 user is browsing this thread: 1 guest

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

877 users are online: 877 guests
0 post in the last 24h
8 posts in the last week
35 posts in the last month
Registered members: 49104
Welcome our newest member, zhcnwps
Most online: 2043 users on 29 Oct 2023, 01:04 AM