JacobJ 10 Posted April 15, 2011 Hey all I have a script that returs a number and that number is put to a variable called mst. mst = 10; How would I get that number into a task? This doesnt seem to work: tskMST = player createSimpleTask ["Step"]; tskMST setSimpleTaskDescription ["Step: mst", "Step: mst", "Step: mst"]; /Jacob Share this post Link to post Share on other sites
celery 8 Posted April 15, 2011 [format ["Step: %1","Step: %1","Step: %1",mst]]; Share this post Link to post Share on other sites
JacobJ 10 Posted April 15, 2011 I get and error: Error 1 elements provided, 1 expected. What does this mean? Share this post Link to post Share on other sites
shuko 59 Posted April 15, 2011 Probably wrong use of format. _str = format ["Step: %1",mst]; ..settaskdesc [_str,_str,_str]; Share this post Link to post Share on other sites
celery 8 Posted April 15, 2011 Sorry, the quotes confused my simple mind. [format ["Step: %1",mst],format ["Step: %1",mst],format ["Step: %1",mst]]; Share this post Link to post Share on other sites
JacobJ 10 Posted April 15, 2011 Okay the two different type result in this: Shuko's version doesnt give the number, but "scalar" and Celery, yours give "any" instead of the number. How can this be? Share this post Link to post Share on other sites
celery 8 Posted April 15, 2011 (edited) mst = 10; tskMST = player createSimpleTask ["Step"]; tskMST setSimpleTaskDescription [format ["Step: %1",mst],format ["Step: %1",mst],""]; Edited April 15, 2011 by Celery Share this post Link to post Share on other sites
JacobJ 10 Posted April 15, 2011 Yes but mst isnt defined. It was just an example. Through the mission numbers gets added to mst, so I want to display the current number mst represents. The mst variable is comming from another script. It doesnt seem to work to put this to publicVariable. Still I get the scalar output and not the number that mst represents. Share this post Link to post Share on other sites
celery 8 Posted April 15, 2011 If a variable isn't defined before it's used somewhere, naturally it doesn't work. If you want the task to update its description, you have to loop tskMST setSimpleTaskDescription [format ["Step: %1",mst],format ["Step: %1",mst],""]; throughout the mission. Share this post Link to post Share on other sites
JacobJ 10 Posted April 15, 2011 Okay after searching around here on the forum I found out that it could be a timing problem. I tried to wait a few seconds to execute the tskdes script and now it did display the number very nicely. It is an interesting thought, to have a loop to update this number. A simple while {true} do {sleep 5; bla blab bla would be fine right? I have a few loops in my mission, how many loops can be allowed, before the server begins to lag? Is that even an issue? Share this post Link to post Share on other sites
celery 8 Posted April 15, 2011 A loop like that should work. There is no limit to loops and scripts unless they're scripted in a way that puts stress on the cpu (loops without sleep or the sleep is needlessly fast). Share this post Link to post Share on other sites