weird: Red vid doesn't take into account line break in box if it has background color - red

1°) align: 'left doesn't work (is my syntax right ?)
2°) ^/ sometimes not taken into account:
view layout [
box 400x400
font [align: 'left size: 40 color: red] "line1^/line2"
]
but if I just add white to box:
view layout [
box white 400x400
font [align: 'left size: 40 color: red] "line1^/line2"
]

StackOverflow is not the place where bugs or issues for Red language should be reported. We have specific channels for that. Please report the issue on Red's issue tracker.

Related

An autoclicker I wrote to claim twitch channel points isn't working properly, I'd like to understand why

I've used AutoHotKey to write out a program that in theory, should claim the little channel point chests on twitch automatically. However, in practice it just does nothing. I'm a bit of a coding noob so cut me some slack. Below is the code:
o:: ; this is a killswitch in case anything goes wrong
{
exitapp
}
p::
while (true)
{
PixelGetColor, color, 1680, 1060 ; finds the color of a pixel that the chest appears on
if (color = 8FFFD2) ; if the color of that pixel is the color of the chest when it is highlighted
{
Click, 1700, 1060 ; click on where the chest appears
}
}
I tried running this while a chest was there and the code did nothing, I made sure that my mouse was highlighting it too. I also understand that BTTV can claim chests automatically, this is just a little project I'm doing for fun.
All you need to do is have a line of code to move the mouse to the co-ordinates, and then another line to click.
Try this, it should work:
o:: ; this is a killswitch in case anything goes wrong
{
exitapp
}
p::
while (true)
{
PixelGetColor, color, 1680, 1060 ; finds the color of a pixel that the chest appears on
if (color = 8FFFD2) ; if the color of that pixel is the color of the chest when it is highlighted
{
Mousemove, 1700, 1060
click ; click on where the chest appears
}
}

NetLogo chain of turtles breaks up when linking

I'm doing a model of some chains of cells (as part of a larger DNA string model). They wiggle around on screen, and when they wiggle so much, that they come close to a cell of the same type in the same string, they must create a link with that cell.
Code below.
It kinda works.... But after I introduced the linking behavior described above, the string breaks into pieces after a short while. I can't figure out why :-) Any ideas?
Thanks,
Palle
breed [cells cell]
cells-own [paired?]
globals [chains]
to setup
clear-all
set chains []
addchain
reset-ticks
end
to go
foreach chains [c -> movechain c]
ask cells [if any? other cells-here with [label = [label] of myself and paired? = false] [
let makker one-of other cells-here with [label = [label] of myself and paired? = false]
create-link-with makker [tie]
set color red
set paired? true
ask makker [set color red set paired? true]
print word label " was found!"
]]
tick
end
to addchain
set chains lput makechain chains
end
to movechain [mylist]
let antalfollowers length mylist - 1
let i antalfollowers
repeat antalfollowers [
ask item i mylist [
move-to (item (i - 1) mylist)
]
set i i - 1
]
ask first mylist [
right random-float wigglefactor
left random-float wigglefactor
fd 1
]
end
to-report makechain
let mylist []
let text "MGIVEQCCTSICSRYQ"
let startx random-xcor / -3
let starty random-ycor / -3
let i 0
repeat length text [
create-cells 1 [
set color green
set shape "circle"
set label item i text
set paired? false
set mylist lput self mylist
setxy startx + i * .75 starty + i * .75
]
set i i + 1
]
report mylist
end
OK - I finally figured out what's going on. This was hard to see. The tricks I used
in order to see it are listed at the bottom of this post.
In the case of a single strand of synthetic DNA floating around,
when two cells of the same type hit and stick, at that point there will
be a loop of all the cells that were between the moving cell and the
cell that got run into in the list of the sequence of cells.
What you need to do is to:
(a) take the cell that just got run into and link it and tie it to the moving
cell, making the moving cell the MASTER of the link [tie]. You do that
already.
(b) remove the cell you just made a SLAVE from the list of cells your code
has to move, because it will now be moved automatically when the master cell
moves.
AND ... importantly ...
(c) repeat steps (a) and (b) for EVERY cell on the list in positions between
the two cells that just collided and stuck.**
That will effectively freeze the configuration of the entire loop and make it
into a single large unit that will move as one unit when the master cell is
moved by your code.
The User Manual states in the subsection on TIE in the section on LINKS:
When the root turtle turns right or left, the leaf turtle rotates
around the root turtle the same amount as if a stiff were attaching
the turtles. When tie-mode is set to “fixed” the heading of the leaf
turtle changes by the same amount.
I think that you do want to set tie-mode to FIXED so the whole cluster will rotate when the master cell rotates.
I think, but have not looked at it, that this algorithm will work even if the linked cell is the very first or very last one on the chain. Better check it though. Maybe the cell that should be the MASTER is the one that got hit, not the one doing the moving.
In the case of two different strands of DNA intersecting,
basically forming an X, or more complicated cases ... I leave it up to you to figure out what you want the larger connected structure to do, and how hit should move. Do BOTH of the leading cells of each strand tug on it at once? Do you need to shut off one of them so there is only one cell moving the crowd? Will you need to change your code that moves the chain to insert one of the chains entirely into the middle of the other chain on the list that moves them in sequence? I don't know!
By the way, to figure this out, I had to:
slow down the motion and
set the color of the cells to [0 255 0 125] which is a half-transparent green
so I could see through them and see through them overlap, and
use the "watch" feature of the Inspector to follow one of the cells I knew
was going to get linked up, and
use the slider in the inspector to zoom up as far as it would go, and
put a 500 millisecond "wait" in side the innermost loop of the motion.
I'm working on your question and have made some progress -- at least I have a revision of your code with some troubleshooting additions to it, and a revision of the Interface. I can't figure out how to attach a model here, or an image of the view you will see when you run it, so I posted the full model and a PNG file in the netlogo-users Google Group.
The revisions do not fully answer your question about how to solve the breaking up of the chain, but they provide a reproducible version of the model that you can be sure will break at step 746 and that you can turn on dense printing and slow action and watch what is going on with attempted moves after that.
Maybe if we both look at that it will be obvious why this is breaking.
One thing I think may be happening is that, once two cells link and tie, your move algorithm no longer is the correct logic for how the knotted chain should move.
Here's the changes that I made:
I added a random-seed command in setup so that the model can be repeatedly run with exactly the same choices in random variables, so we can both look at the results.
I added a "verbose?" switch on the Interface to turn on or off detailed printing of what's going on.
I added a "clear-stop" button that will allow the "stop" commands I put in the model to stop the running using a stop-requested? flag, which the code sets and this button resets so that "go" and "one step" work again after a stop and the ticks counter keeps on incrementing.
I added a msec-per-tick slider to put a fixed number of milliseconds at the end of the go step so the model will run at a speed that is usable for debugging. I don't know how other people can do it -- when I try to use the built-in slider at the top of the interface to control speed, either it's way too slow, or it's way too fast, and I can't seem to be able to tweak it to just right. So I added this kludge.
I guessed what limits you had on your wigglefactor slider on your interface and made one that goes from 0 to 90 (degrees). It works ok and reproduces your bug.
I added some additional tests to prevent the two C-cells that are adjacent in your choice of cells from linking to each other when they discover, as they do sometimes, that they are on the same patch. With a random seed of 23456 your original code ties its own CC adjacent pair together in tick 2 for instance.
(
Here's the revised code, and comments as to how to use it are in the posted model (in netlogo-users) and below after the code as well.
breed [cells cell]
cells-own [paired?]
globals [
chains
stop-requested? ;;//////////////////////////////////////////////////
]
to setup
clear-all
;; random-seed 12345 ;; /////////////// breaks at either step 35 or 45 ////
;; random-seed 23456 ;; ////////////////// ties its own CC in tick 2 ///
random-seed 34567 ;; /////////////////// ties own cc in tick 84 , ties C at 746 and breaks in 6 steps
;;// wow -- it SNIPS TSIC out of the middle of the chain!! snips out CTIS, turtles 7 8 9 and 10
;; cell 6 C is directly followed by cell 11 -- also C
set chains []
addchain
set stop-requested? FALSE ;; ////////////////////////////////////////
reset-ticks
end
to go
if stop-requested? [ stop ] ;;////////////////////////////////////////////
foreach chains [c -> movechain c]
ask cells [if any? other cells-here with [label = [label] of myself and paired? = false
and who != [who] of myself + 1
and who != [who] of myself - 1
] [
let makker one-of other cells-here with [label = [label] of myself and paired? = false]
create-link-with makker [tie]
set color red
set paired? true
ask makker [set color red set paired? true]
print ( word label " was found at tick " ticks)
set stop-requested? TRUE ;;/////////////////////////////////////////////
]]
wait ( msec-per-tick / 1000 ) ;;////////////////////////////////////////
tick
end
to addchain
set chains lput makechain chains
end
to movechain [mylist]
if verbose? [print ( word "\n\nin code at tick " ticks " starting movechain") ];;//////////////
;;if verbose? [ show mylist ]
let antalfollowers length mylist - 1
let i antalfollowers
repeat antalfollowers [
ask item i mylist [
if verbose? [
;;print (word " asking item " i " on mylist to move to item " (i - 1) )
let mover [label] of item i mylist
let moveto [label] of item (i - 1) mylist
let mover-color [color] of item i mylist
let moveto-color [color] of item (i - 1) mylist
;; BLUE one moves TO the YELLOW ONE at the end of this second
print (word " move " mover " to " moveto )
ask item i mylist [set color blue set shape "square" set size 2]
ask item (i - 1) mylist [set color yellow set shape "square" set size 2]
display
wait 4
ask item i mylist [set color mover-color set shape "circle" set size 1]
ask item (i - 1) mylist [set color moveto-color set shape "circle" set size 1]
display
]
move-to (item (i - 1) mylist)
;;print word "just moved follower " i ;;//////////////////////////
;; wait 0.1 ;;////////////////////////////////////////////////////
]
set i i - 1
]
ask first mylist [
right random-float wigglefactor
left random-float wigglefactor
fd 1
]
end
to-report makechain
let mylist []
let text "MGIVEQCCTSICSRYQ" ;; NOTE - this has a repeat of CC in it which SOMETIMES gets tied (23456 tick 2)
let startx random-xcor / -3
let starty random-ycor / -3
let i 0
repeat length text [
create-cells 1 [
set color green
set shape "circle"
set label item i text
set paired? false
set mylist lput self mylist
setxy startx + i * .75 starty + i * .75
]
set i i + 1
]
report mylist
end
to clear-stop ;;////////////////////////////////
set stop-requested? FALSE ;;////////////////////////////////
end ;;////////////////////////////////
Anyway, here's how to run it to reproduce the problem and examine it
in fine detail very closely.
WHAT IS IT?
model of DNA in motion modified for troubleshooting. When a "C" cell
touches another "C" cell in step 746, and sets a link between the two
C cells and ties them to move as one, the algorithm for motion
breaks somehow. This may help figure out why,
HOW IT WORKS
This has added to it a msec-per-tick slider, default 50, to set the
display speed about right if you leave the usual speed slider at the
very top in the middle (normal).
I also added a button ("clear stop") and a switch ( verbose?)
normally off. With verbose? ON, the model runs very very slowly and
color codes which cell is about to move to which cell ( blue is moving
to yellow ) and they both temporarily change to squares.
HOW TO USE IT
1) set msecs-per-tick to 50 2) shut off verbose?, click SETUP, click
GO. The model will run 746 ticks. ( thats with the random-seed set to
a value of 34567 in globals. )
3) After it stops at tick 746. click clear-stop.
NOTICE the CTI group at the upper right. This is logically BETWEEN the
two C-cells which have linked up. This group will be snipped-out of
the moving DNA It has who numbers 7, 8, 9 and 10 as you can see by
inspecting it.
4) click one-step 6 times to advance to where you can see more clearly
that the two groups have become separate. Then turn on verbose? and
click one-step once to watch the gory details with a 4 second pause
between cell-moves and the running commentary in the Command Center
telling which cells are about to move.

How the legends on Google charts can be wrapped

I need the legends of Google chart to get wrapped (comes in new line) automatically if it exceeds container area.
I don't want scroll button as it is not enough convenient.
With available customization options, seems it cannot be done.
Any other way?
Use the maxLines property for the legend.
i.e.:
options.legend = {position: 'top', maxLines: 5};
Note that this undocumented property only works if the legend is positioned at the top and there is enough vertical space to render both the chart and multi-line legend.
with the maxLines property for the legends, chartArea with specific set of values can help in rendering the display.
legend: { position: "top", alignment: "start", maxLines: 2 },
chartArea: {top:50,bottom:30,right:0,left:50, 'width': '100%' }
I did a lot of testing of this and it seems that you need to have chartArea width and height set to 'auto'. Still not perfect but sort of OK.

Setting Table Border in Mircrosoft Word using AppleScript

When I try to set the line thickness of a table border, the result changes the line type to something undesired. Why is the line width parameter affecting the line style parameter? See the examples below and try them for yourself. I am using MS Office 2011 Word v14.2.3.
tell application "Microsoft Word"
set line style of (get border selection which border border bottom) to line width225 point
get line width of (get border selection which border border bottom)--test:results in line width150. Why? I just set it to line width225!
--width25 = fine dots
--width225 = cornered sine wave
--width50 = dashed line
--width75 = dash + 3 dots + dash
--width100 = 3 lines
--width150 = 2 lines
--width300 = single
--width450 = does not work
--width600 = does not work
end tell
If I run this on a table which has the settings that I want, in order to see what they are:
tell application "Microsoft Word"
get properties of (get border selection which border border bottom)
end tell
I get:
{class:border, visible:true, color index:no highlight, inside:false, line style:line style single, line width:line width225 point, art style:missing value, art width:missing value, color:{0, 0, 0}, color theme index:no theme color}
Which is correct. I should be able to copy those parameters to make my script work, but something happens when I try to set the line width (border thickness).
If you want to change the line thickness, use line width instead of line style, otherwise it's normal that it doesn't do what you expect.
set line width of (get border selection which border border bottom) to line width225 point
If you want to change the line style, you should use a value from this list : (
line style none, line style single, line style dot, line style dash small gap, and many more ...)

NetLogo - How to set turtle color from array

How can I set a turtle's color from an array?
Here's my code but it doesn't work:
let colors array:from-list ["red" "yellow" "blue" "pink"]
set index random 3
let c array:item colors index
set color array:item colors index
Which leads to this error:
can't set flower variable COLOR to non-number blue error while flower 101 running SET
In NetLogo color, the names of the 14 main colors, plus black and white are defined as constants, so no quotes are required. Also, since they are constants, they are treated like literal values, so you can use them in the bracketed list notation, otherwise, you'd need to use the (list . . . ) reporter to create that list.
Also, your use of an array may be more complicated than needed.
You can write:
let colors [ red green blue yellow ]
set index random 3
let c item colors index
set color c
As an extra bonus, you can use the one-of primitive to do all the above:
set color one-of [ red green blue yellow ]
The accepted answer is the correct one, but as an aside, note that the read-from-string function will interpret a basic NetLogo color name as a color value:
observer> show read-from-string "red"
observer: 15
Also useful to know about is the base-colors built-in function that reports an array of the 14 basic NetLogo colors as numeric values, allowing you to do things such as:
ask turtles [ set color one-of base-colors ]
try setting your color names to number values, according to this site