Emitter view thingy

Started by milkev, April 03, 2016, 06:46:44 PM

Previous topic - Next topic

milkev

Hello, since im creating my entire map with only use of terrain, digitalis and crpl cores, i was wondeering about soemthing to do with the popup  text.

i have runner nests, and the pop-up works fine, except if i use 3 lines, instead of two.

this is the code i have for two lines.

SetPopUpText("amt: " <-amount <-lineBreak "delay: " <-delay 30 div concat concat concat)

and this is the code i have for three lines:

SetPopUpText("amt: " <-amount <-lineBreak "delay: " <-delay 30 div <-lineBreak "payload: " <-payload concat concat concat)


do i need to remove concats? i tried removing them but it didnt work :( it actually turned the " "amt: " <-amount " to a 6 :(

GoodMorning

Assuming that you began with:


"
" ->lineBreak


The problem seems to be too few concat statements. This means that you aren't joining everything, so only part of the string turns up.

The first bit of code will produce the same as:

<-amount <-lineBreak concat "delay: " concat <-delay 30 div concat SetPopUpText
"amt: "


You probably want:

"amt: " <-amount concat
<-lineBreak concat
"delay: " concat
<-delay 30 div concat
SetPopUpText

and

"amt: " <-amount concat
<-lineBreak concat
"delay: " concat
<-delay 30 div concat
<-lineBreak concat
"payload: " concat
<-payload concat
SetPopUpText


The easiest way to make sure you join everything is to put the concat in immediately after the thing you add.
So "First, " "Second" concat ", Third" concat

Once again, I must stress the usefulness of tracing, specifically, here, TraceStack. This would allow you to notice the additional items on the stack, and save everyone time.
A narrative is a lightly-marked path to another reality.

Vanguard

#2
Excellent reply by Goodmorning. I applaud you, Sir.  :)

@Topic:
Quote from: milkev on April 03, 2016, 06:46:44 PM
SetPopUpText("amt: " <-amount <-lineBreak "delay: " <-delay 30 div concat concat concat)

Simply looking at this statement hard enough and counting the amount of items to join will tell you that you have
1) "amt: "
2) <-amount
3) <-lineBreak
4) "delay: "
5) <-delay 30 div

Elements on the stack. You need thusly to use 4 concats. It´s really simple and a simple to fix mistake.

Always use trace. Always break down your problems into simple problems. Cheers.

GoodMorning

CRPL can be fun to play with, but can also be "difficult" to make.
The most common bugs/errors get picked up by people who have done more, because they made the same errors when they began.

Keep going, and soon you will be able to spend more time helping others then you do asking for help.

Vanguard, thanks, and it made me laugh to see "Sir" in there. Quite apart from anything else, you have been here about half a dozen times as long as I, and so I would think you would be the one who merited an honorific.
A narrative is a lightly-marked path to another reality.

milkev

i dont know how to use trace all that well, so thanks guys :)

GoodMorning

#5
That's fine.

The quick tutorial on Tracing:

1. When debugging, if the code doesn't work perfectly the first time (i.e. always) then you will almost certainly want to use Trace.
2. To see the trace window, run the command ShowTraceLog.

3. Depending on the nature of the bug/s, different tracing functions can help.
3.a. Trace, Trace2, Trace3, and Trace4 will consume that many stack arguments, and trace their values.
A good example of this is the following: "TargetCoords" <-TargetX <-TargetY Trace3
This will leave the stack unchanged, but show you what is going on.

3.b. TraceStack is good when something strange is going on, and things aren't ending up where they should.
TraceStack won't change the stack, only show it. Be warned: this rapidly fills the trace history if you call it often. It can be hard to find something specific, but will give you an overview.

4. If the trace window fills up, and you are looking for something specific, it may be time to use ClearTraceLog, which will clear the trace window. This can be very useful.

5. A command that can be helpful if you have a rare condition that happens quickly, (e.g. the Core finishes charging) you may want to pause, so that you can see the trace from that point.
This can be achieved by: <-SomethingBadlyWrong if
  ShowTracelog
  TraceStack
  PauseGame
  1 Delay
endif


6. If you have managed to fix whatever was wrong, you may want to hide the trace window, instead of the quick-and-dirty make-a-new-Core solution, the you will need HideTraceLog.

7. At some point, you will probably see a message "WARNING: Trying to take item from an empty stack". This is an easy error to make, but one that's infinitely easier to fix with the aid of the trace.

There is little more that can be taught, it's largely a matter of intuition. With practice you can start to guess what is going wrong, or at least where to put the Trace statements. Common places are just before "if"s, at the start, and around function calls.
A narrative is a lightly-marked path to another reality.

milkev

ok! ill definitely try this out next time something goes wrong!

GoodMorning

That's what it's there for. Enjoy.
A narrative is a lightly-marked path to another reality.