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.
Nothing I do seems to work. What am I doing wrong?
22 Dec 2014, 07:27 AM
#1
Posts: 139
22 Dec 2014, 15:45 PM
#2
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.
Why don't you post your code and maybe we can spot something.
22 Dec 2014, 16:17 PM
#3
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.
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
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.
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
Posts: 139
You have to define player1 before setting the resources. Try something like:
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.
Code
Then you can make the calls to set that player's resources.local player1 = World_GetPlayerAt(1)
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
Posts: 139
You have to define player1 before setting the resources. Try something like:CodeThen you can make the calls to set that player's resources.local player1 = World_GetPlayerAt(1)
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
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.
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.
PAGES (1)
1 user is browsing this thread:
1 guest
Livestreams
10 | |||||
3 | |||||
175 | |||||
24 | |||||
23 | |||||
5 | |||||
5 | |||||
5 | |||||
4 | |||||
3 |
Ladders Top 10
-
#Steam AliasWL%Streak
- 1.831222.789+37
- 2.600215.736+15
- 3.34957.860+14
- 4.1107614.643+8
- 5.305114.728+1
- 6.916405.693-2
- 7.273108.717+24
- 8.722440.621+4
- 9.1041674.607-2
- 10.17146.788+1
Replay highlight
VS
- cblanco ★
- 보드카 중대
- VonManteuffel
- Heartless Jäger
Einhoven Country
Honor it
9
Download
1235
Board Info
812 users are online:
812 guests
0 post in the last 24h
8 posts in the last week
35 posts in the last month
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
Welcome our newest member, zhcnwps
Most online: 2043 users on 29 Oct 2023, 01:04 AM