How to use the Print() command
14 May 2019, 07:14 AM
#1
Posts: 24
I'm currently using Sublime Text to edit my SCAR code, but I am unable to get the Print() function to return the values I am trying to track. Does anyone have any idea on how to get this set up? Would make debugging so much easier.
14 May 2019, 09:08 AM
#2
Posts: 54
I'm currently using Sublime Text to edit my SCAR code, but I am unable to get the Print() function to return the values I am trying to track. Does anyone have any idea on how to get this set up? Would make debugging so much easier.
it's not python
WriteLn('Hello world');
14 May 2019, 14:08 PM
#3
Posts: 756 | Subs: 8
I'm currently using Sublime Text to edit my SCAR code, but I am unable to get the Print() function to return the values I am trying to track. Does anyone have any idea on how to get this set up? Would make debugging so much easier.
For some reason CoH2 does not output calls to print to a scarlog as CoH1 did. This is what I wrote for use in my own mods:
_G.print = {
cache = ''
}
setmetatable(_G.print, {
__call = function(self, ...)
local args = {...}
for index = 1, #args do
self.cache = self.cache..tostring(args[index])..'\t'
end
self.cache = self.cache..'\n'
PersistentMode_SerializeResults('userdata:logs/scarlog.txt', self.cache)
end
})
Feel free to use it.
it's not python
WriteLn('Hello world');
No, it's Lua. This was neither helpful nor correct. The function is print.
14 May 2019, 16:04 PM
#4
Posts: 24
Thank you!
15 May 2019, 02:08 AM
#5
Posts: 24
How do you implement the code you provided? I've placed it in my .scar file but I get the following error:
Also, do I still use print() in order to see the result?
Thanks!
Code
GameObj::OnFatalScarError: [[string "DATA:Scenarios\city_centre_2.scar"]:23: attempt to call global 'PersistentMode_SerializeResults' (a nil value)]
Also, do I still use print() in order to see the result?
Thanks!
15 May 2019, 02:49 AM
#6
Posts: 756 | Subs: 8
That means SCAR has not yet initialized. So, as a general rule of thumb, you want all of your code to start after that has happened.
For example:
This is also mentioned in the SCAR documentation:
http://www.fortresseuropemod.com/scardoc/index.html
And yes, you would just call print, like so: print('hello world') or print('hello', 'world')
It takes n arguments.
For example:
Scar_AddInit(function()
-- put code here
end)
This is also mentioned in the SCAR documentation:
When the game engine reads your *.scar file, anything in the global scope will be immediately called. This may cause problems as some functions are not meant to be used until the game has loaded up all of its components.
The function Scar_AddInit( FunctionName ) can be used to kick off your script. This tells the game engine "When you are ready, call the function FunctionName first."
http://www.fortresseuropemod.com/scardoc/index.html
And yes, you would just call print, like so: print('hello world') or print('hello', 'world')
It takes n arguments.
15 May 2019, 03:21 AM
#7
Posts: 24
Awesome. Got it to work. Thanks again!
15 May 2019, 03:52 AM
#8
Posts: 756 | Subs: 8
No problem!
16 May 2019, 00:56 AM
#9
Posts: 76
Tough to understand lol!
17 May 2019, 15:39 PM
#10
Posts: 756 | Subs: 8
Which part?
PAGES (1)
1 user is browsing this thread:
1 guest
Livestreams
27 | |||||
257 | |||||
97 | |||||
13 | |||||
2 | |||||
2 | |||||
2 |
Ladders Top 10
-
#Steam AliasWL%Streak
- 1.831222.789+37
- 2.34957.860+14
- 3.589215.733+4
- 4.1099614.642-1
- 5.280162.633+8
- 6.305114.728+1
- 7.916405.693-2
- 8.271108.715+22
- 9.721440.621+3
- 10.1041674.607-2
Replay highlight
VS
- cblanco ★
- 보드카 중대
- VonManteuffel
- Heartless Jäger
Einhoven Country
Honor it
9
Download
1231
Board Info
803 users are online:
803 guests
1 post in the last 24h
7 posts in the last week
39 posts in the last month
7 posts in the last week
39 posts in the last month
Registered members: 49062
Welcome our newest member, Mclatc16
Most online: 2043 users on 29 Oct 2023, 01:04 AM
Welcome our newest member, Mclatc16
Most online: 2043 users on 29 Oct 2023, 01:04 AM