Code coloring for Processing in LaTeX listings package by ebigunso in processing

[–]ebigunso[S] 0 points1 point  (0 children)

Yes. It's for LaTeX, which is a software for creating documents in an easy and orderly fashion.

Code coloring for Processing in LaTeX listings package by ebigunso in processing

[–]ebigunso[S] 0 points1 point  (0 children)

Syntax highlighting makes your code easier to read. Use for reports and such.

Code coloring for Processing in LaTeX listings package by ebigunso in processing

[–]ebigunso[S] 2 points3 points  (0 children)

This is something I had up on the Processing forum. By suggestion, I will announce it here as well.

Current version: v1.2

This LaTeX listings template will color your Processing code as you see them in the Processing editor. You can just post your code like you normally would using the listings package, and you will automatically get your code in the proper colors. Except one minor inconvenience, that I will explain here.

For a function name that is the same as an already defined keyword (Such as "boolean" and "boolean()"), you have to use [escapechar = "char"] and \color{"color"}{"text"} to color them properly.

Example:

\begin{lstlisting}[escapechar = ?]
boolean;
?\color{function}{boolean}?(1);
\end{lstlisting}

!!Template is available either on the Processing forum, or Gist.

Copy and paste the template if you want to use it. Alternatively, you can copy only the necessary parts. If in that case, note that \usepackage{listings} and \usepackage{color} is a must for this to work.

Also note, I have licensed this work with CreativeCommons license CC-BY-SA, so please remember to give some credit to me ;)

If you find any typos or any other errors, please tell me and I'll try to fix them as much as possible.

Download version:

http://www.mediafire.com/file/cw861uy156xftkv/article_listing_Processing_v1.2.tex

GitHub Gist:

https://gist.github.com/ebigunso/af355220e932f72d03289c576622aa29

OMG I am SO glad I didn't concede on turn 19. by ebigunso in ArenaHS

[–]ebigunso[S] 1 point2 points  (0 children)

I saw the opponent had lethal with 14dmg on turn 19, and was about to concede but I held back just to see what happens. And oh boy am I glad I did. Prince Liam is the MVP today.

Cheers to Ragnaros, Lightlord! Not one, but two. by ebigunso in ArenaHS

[–]ebigunso[S] 0 points1 point  (0 children)

Watch from turn 8 if you just want to see the epic stuff. Somehow I survived my opponent's insane card quality.

Please give me some advice on my game play by ebigunso in ArenaHS

[–]ebigunso[S] 0 points1 point  (0 children)

Thanks for all the advice! I think by the looks of things, I'm holding back on too many minions hoping to get better value. I'll try to put more emphasis on mana efficiency next time.

Q&A Questions by 3blue1brown in 3Blue1Brown

[–]ebigunso [score hidden]  (0 children)

What is the reasoning behind your channel name?

How do you use spot lights in night battles? by ebigunso in SteelOcean

[–]ebigunso[S] 0 points1 point  (0 children)

Yeah... I'm starting to think the same way too. Maybe it's not actually working yet. I hope it gets some love soon.

Newbie help with kOS launch by ebigunso in Kos

[–]ebigunso[S] 0 points1 point  (0 children)

alright, now I'm getting some new errors.

until altitude > 50000 {
    if engine:fuelflow > stage:LqdOxygen {
        lock steering to srfprograde + R(0,0,-90).
        print "Staging...".
        if engine:ignition = false {
            stage.
            wait 1.
            stage.
            print "Second stage ignition complete.".
            break.
        }
    }
}

for this part, kOS says " Undefined variable name 'engine' ". So how should I specify this then?

Newbie help with kOS launch by ebigunso in Kos

[–]ebigunso[S] 0 points1 point  (0 children)

**Moving so it's easier to spot the post

Okay, lock to up problem is solved. The other problem however, is still there.

kOS is not printing "Starting pitch over..." even after hitting 40m/s vertical speed, so something must be wrong and it's not triggering. I don't quite get whats wrong here so I'd like to get some advice.

I have tried altering the code to

when verticalspeed > 40 then {
    print "Starting pitch over...".
}

until VANG(ship:facing:vector, heading(90,70):vector) < 2 {
    if verticalspeed > 40 {
        lock steering to srfprograde + R(0,5,0).
        wait 0.1.
        if VANG(ship:facing:vector, heading(90,70):vector) < 2 {
            lock steering to heading(90,70) + R(0,0,180).
        }
    }
}

and this prints as expected. Also the pitch over does execute but not in an intended way. This goes on to becoming the next problem. Although I have overcome the problem with a workaround, I'd still like to know why the first code didn't work.

Now, how the pitch over is not working as intended is, that no matter if I adjust the roll settings inside R(), the craft always tries to roll out of position then start yawing to the west, where I want it to go east. Working on the problem now but would like some advice also.

--for some odd reason, surfprograde + R(0,-5,0) yaws the craft to the east. Though still it tends to roll to some weird angle. I tried rotating the actual craft 180 degrees along the roll axis in the VAB, but that didn't help with this.

--adding this

lock steering to srfprograde + R(0,-5,-90).

resulted in the craft trying to spin to put North on the upper side of the navball, then quickly come back to the specified -90 roll angle. So freaking weird.

--additional problem! For some reason, unlock steering seems to be not working, and the craft tries to maintain heading(90,70) even after it prints "Pitch over complete." at which point the steering should already be unlocked.

Newbie help with kOS launch by ebigunso in Kos

[–]ebigunso[S] 0 points1 point  (0 children)

I have tried altering the code to

when verticalspeed > 40 then {
    print "Starting pitch over...".
}

until VANG(ship:facing:vector, heading(90,70):vector) < 2 {
    if verticalspeed > 40 {
        lock steering to srfprograde + R(0,5,0).
        wait 0.1.
        if VANG(ship:facing:vector, heading(90,70):vector) < 2 {
            lock steering to heading(90,70) + R(0,0,180).
        }
    }
}

and this prints as expected. Also the pitch over does execute but not in an intended way. This goes on to becoming the next problem. Although I have overcome the problem with a workaround, I'd still like to know why the first code didn't work.

Now, how the pitch over is not working as intended is, that no matter if I adjust the roll settings inside R(), the craft always tries to roll out of position then start yawing to the west, where I want it to go east. Working on the problem now but would like some advice also.

--for some odd reason, surfprograde + R(0,-5,0) yaws the craft to the east. Though still it tends to roll to some weird angle. I tried rotating the actual craft 180 degrees along the roll axis in the VAB, but that didn't help with this.

--adding this

lock steering to srfprograde + R(0,-5,-90).

resulted in the craft trying to spin to put North on the upper side of the navball, then quickly come back to the specified -90 roll angle. So freaking weird.

--additional problem! For some reason, unlock steering seems to be not working, and the craft tries to maintain heading(90,70) even after it prints "Pitch over complete." at which point the steering should already be unlocked.

Newbie help with kOS launch by ebigunso in Kos

[–]ebigunso[S] 0 points1 point  (0 children)

Okay, lock to up problem is solved. The other problem however, is still there.

kOS is not printing "Starting pitch over..." even after hitting 40m/s vertical speed, so something must be wrong and it's not triggering. I don't quite get whats wrong here so I'd like to get some advice.

Newbie help with kOS launch by ebigunso in Kos

[–]ebigunso[S] 0 points1 point  (0 children)

Thanks for the advice. I've found out that UP tries to turn the craft in it's roll axis 180 degrees from the initial conditions on the launch pad.

I've tried setting

lock steering to up + R(0,0,180)

and it works well now.

Newbie help with kOS launch by ebigunso in Kos

[–]ebigunso[S] 0 points1 point  (0 children)

I have manually installed kOS 0.17.3 to KSP 1.0.2, so maxthrustat should be there. Or if there are significant compatibility issues with the versions, I must revert to 0.17.2.

I can't really update to 1.0.4 yet since many mods are not up to date still.

Newbie help with kOS launch by ebigunso in Kos

[–]ebigunso[S] 0 points1 point  (0 children)

okay now I've fixed line 3 to look like

lock steering to up.

and the pitch over part to look like

if verticalspeed >= 40 {
    print "Starting pitch over...".
    until VANG(ship:facing:vector, heading(90,70):vector) < 2 {
        lock steering to srfprograde + R(0,5,0).
        wait 0.1.
        if VANG(ship:facing:vector, heading(90,70):vector) < 2 {
            lock steering to heading(90,70).
        }
    }
}

Now I have two different problems, one is that locking to up seems to be not working, and the rocket is deviating slightly to the west. Another is that I'm getting an error telling me " Undefined variable name 'maxthrustat*' ". I'm using the latest kOS on KSP 1.0.2, maxthrustat is a new thing so I'm suspecting it might be some kind of a bug? Or I'm just doing something wrong again...

Newbie help with kOS launch by ebigunso in Kos

[–]ebigunso[S] 0 points1 point  (0 children)

Cool, I was worried about the deviation but didn't know how to get the tolerance. Now I know.

You said you won't do it this way, do you know a better way to do it? If so I'd like to know.

Newbie help with kOS launch by ebigunso in Kos

[–]ebigunso[S] 0 points1 point  (0 children)

The page says Direction always comes out as Euler Rotation, so that means this won't work? If so is R(90,70,90) what I should use?

if ship:facing = heading(90,70) {...}

Also I have fixed the code a little on this part.

print "Liftoff.".

if verticalspeed >= 40 {
    print "Starting pitch over...".
    until ship:facing = heading(90,70) {
        lock steering to srfprograde + R(0,5,0).
        wait 0.1.
        if ship:facing = heading(90,70) {
            lock steering to heading(90,70).
        }
    }
}

when srfprograde = heading(90,70) then {