Page 1 of 2

counter print question

Posted: Sat Jun 14, 2003 10:31 pm
by 7th Es Cyborg
ok I'm using a local.counter and need to print out the value ingame

how would that script be done with iprintlnbold "You died ( counter here ) times."

this is not the actual useage, but you can see what i need.

Posted: Sat Jun 14, 2003 10:34 pm
by Alcoholic
i think u need to use some sort of convert string thing. like how the singleplayer maps tell you what key to press to go forward. (m1l1)

Posted: Sat Jun 14, 2003 10:45 pm
by nuggets
quotes in " and then what ever you like, repeat as necessary

e.g.

iprintlnbold_noloc "This counter is on " level.counter " so hurry your ass up " level.something_else

or

if ( level.die_counter == 1 )
{iprintlnbold_noloc "You died for the 1st time"}
if ( level.die_counter == 2 )
{iprintlnbold_noloc "You died for the 2nd time keep trying though"}
if ( level.die_counter == 3 )
{iprintlnbold_noloc "3rd time now, do you think your a target ???"}
if ( level.die_counter >> 3 )
{iprintlnbold_noloc "For the " level.die_counter "th time, will you STOP DYING!!!"}




for counters use level. rather than local.

Posted: Sun Jun 15, 2003 12:16 am
by Bjarne BZR
Or just:

Code: Select all

iprintlnbold "You died " + local.counter + " times."

Posted: Sun Jun 15, 2003 12:19 am
by nuggets
some people take all the fun out of scripting :P

Posted: Sun Jun 15, 2003 3:40 am
by 7th Es Cyborg
danka

script

Posted: Sun Jun 15, 2003 6:22 am
by tltrude
Some people over script a simple line too.


If you don't want all that clicking with "iprintlnbold_noloc", you can use just "iprintln". That makes it show up on the leftside of the screen in yellow and with no clicking sound.

Posted: Sun Jun 15, 2003 6:38 am
by jv_map
Bjarne BZR wrote:Or just:
iprintlnbold "You died " + local.counter + " times."
Sorry but that won't work :P

Try this:
iprintlnbold ("You died " + local.counter + " times.")

The other one is not allowed since the syntaxis of the iprintln command is the following:
iprintlnbold [string1] [string2] [string3].....

Thus you can type
iprintlnbold "hello " "world"

but not
iprintlnbold "hello " + "world"

If you put it between parens however, it's automatically casted to a string and supplied as the first argument only, instead of multiple.
iprintlnbold ("hello " + "world")

Posted: Sun Jun 15, 2003 10:57 am
by Bjarne BZR
Trust jv to slap you on the fingers as soon as you post anything remotely similar to a script :wink:
Thanx jv :oops:

Posted: Sun Jun 15, 2003 11:06 am
by Bjarne BZR
Actually I like nuggets version better, except this is a classical time to use the switch statement:

Code: Select all

switch (level.die_counter)
{
  case 1: {
    iprintlnbold_noloc "You died for the 1st time"
    break
  }
  case 2: {
    iprintlnbold_noloc "You died for the 2nd time keep trying though"
    break
  }
  case 3: {
    iprintlnbold_noloc "3rd time now, do you think your a target ???"
    break
  }
  default: {
    iprintlnbold_noloc "For the " level.die_counter "th time, will you STOP DYING!!!"
  }
}
Jv? :wink:

Posted: Sun Jun 15, 2003 12:08 pm
by nuggets
although we love the switch statement, i though i'd just try to show an easy introduction to the language of scripting

i could of taken it a step further and used something even more complicateder but me no good at complicated schtuff :P

Posted: Sun Jun 15, 2003 1:16 pm
by jv_map
The compiler might not like the curlies around each case. :?

Posted: Sun Jun 15, 2003 5:50 pm
by nuggets
they'll be happy, with the use of ; in there (line seperator)

Posted: Sun Jun 15, 2003 8:29 pm
by 7th Es Cyborg
thanks JV that fixed it up, what I'm doing in converting the mohaa maps into CTF maps using a script that tstrait72 and scorpio made with some modifications. Since the original is first capture wins the round, I changed it to you need 3 captures to win and when one team gets a cap. it shows the current score to the left.

Posted: Mon Jun 16, 2003 5:19 pm
by nuggets
thanks JV??? i mean thanks where thanks is due... but come on!!!