Login

russian armor

How to use the Print() command

14 May 2019, 07:14 AM
#1
avatar of jcbarth

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
avatar of elnur009

Posts: 54

jump backJump back to quoted post14 May 2019, 07:14 AMjcbarth
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
avatar of eliw00d
Honorary Member Badge

Posts: 756 | Subs: 8

jump backJump back to quoted post14 May 2019, 07:14 AMjcbarth
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
avatar of jcbarth

Posts: 24

15 May 2019, 02:08 AM
#5
avatar of jcbarth

Posts: 24

How do you implement the code you provided? I've placed it in my .scar file but I get the following error:

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
avatar of eliw00d
Honorary Member Badge

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:

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
avatar of jcbarth

Posts: 24

Awesome. Got it to work. Thanks again!
15 May 2019, 03:52 AM
#8
avatar of eliw00d
Honorary Member Badge

Posts: 756 | Subs: 8

16 May 2019, 00:56 AM
#9
avatar of TheOldBreed

Posts: 76

Tough to understand lol!
17 May 2019, 15:39 PM
#10
avatar of eliw00d
Honorary Member Badge

Posts: 756 | Subs: 8

1 user is browsing this thread: 1 guest

SHOUT IT OUT!

No ProfanityNumber of ShoutsRefresh Shout Box
Lady Xenarra: @Willy Pete The lack of April Fools this year is odd lol
Last Wednesday, 01:34 AM
Willy Pete: @Rosbone not dead yet. when that happens the font will switch to Papyrus :*(
Last Wednesday, 00:16 AM
dasheepeh: it was an honor guys :guyokay:
01 Apr 2025, 20:34 PM
aerafield: yeah I already prepared my "Can't believe there's comic mode for the 10 daily visitors even on this April 1st" :guyokay:
01 Apr 2025, 20:29 PM
Rosbone: @dasheepeh I guess that means this site is officially dead :guyokay:
01 Apr 2025, 20:19 PM
dasheepeh: no comic sans font for april 1st this year?
01 Apr 2025, 19:56 PM
Willy Pete: @Lady Xenarra this you? https://i.imgflip.com/3e4thi.jpg
01 Apr 2025, 02:53 AM
Lady Xenarra: Does anyone else think that USF needs buffs? It feels like they’re on life support sometimes
01 Apr 2025, 02:36 AM
Willy Pete: @Rosbone Ahh I missed that memo. I still think its a bad decision though. Adds frustration for players and isnt gonna make them that much money
27 Mar 2025, 15:46 PM
Rosbone: It is also good they left it free until after the free to play weekend. Points for that.
27 Mar 2025, 09:34 AM
Rosbone: But I agree, the cost to get a full decent Coh game pushing $115 US is not the best idea. Especially when it needs so much more work for casuals.
27 Mar 2025, 09:32 AM
Rosbone: To be fair, it was a thank you to early fans right? They said it was not free for long and it would become a pay DLC at some point.
27 Mar 2025, 09:30 AM
Willy Pete: Re-releasing free DLC so they can charge new players money for it. Brilliant marketing strategy :clap:
27 Mar 2025, 04:31 AM
Soheil: Coh2 still broken server ?
25 Mar 2025, 18:27 PM
Rosbone: Congrats to Relic. Looks like Coh3 has finally usurped Coh2 s the popular Coh. You smell terrific. :snfQuinn:.
24 Mar 2025, 02:46 AM
Nickbn: and again someone else replies. I mean come on guys. Give @adamírcz a chance
22 Mar 2025, 14:00 PM
Willy Pete: @Nickbn you didn't ask a question, and this is a chat box...
20 Mar 2025, 13:11 PM
Nickbn: @Rosbone it's incredibly rude to speak on someone elses behalf, especially when a question is directly adressed to them. I understand your passion for the subject at hand but I want to hear from him.
20 Mar 2025, 10:16 AM
Rosbone: @Nickbn No, I am just saying people should not be using any Relic owned forum since they have proven they ban anyone who says true things about Coh3.
18 Mar 2025, 19:01 PM

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

447 users are online: 447 guests
0 post in the last 24h
9 posts in the last week
72 posts in the last month
Registered members: 53397
Welcome our newest member, mumbaidarshanbus
Most online: 2043 users on 29 Oct 2023, 01:04 AM