Forum

> > Stranded II > Scripts > How to get unit's name?
Forums overviewStranded II overview Scripts overviewLog in to reply

English How to get unit's name?

3 replies
To the start Previous 1 Next To the start

old Re: How to get unit's name?

Stranded_Guy2910
User Off Offline

Quote
Simple:
1
2
3
4
5
6
7
8
on:event {
	      $id="command to get the unit id (will depend on the event)";
	      if ($id==x) {
			      "event you want with the unit name";
	      }elseif ($id==y) {
			             "event for the other unit";
				    }
}

If you want to receive a message with the unit name when using it, for example, it would be like this:
1
2
3
4
5
6
7
8
on:use {
	   $id=currentid;
	   id ($id==9) {
			    msg "name of the unit with the id=9 (I don't remember which is)";
			}elseif ($id==10) {
				msg "name of the unit with the id=10";
			}
}
Of course this script is uselles since you would have to place it in the unit, but it's just an example and you should also use commands to verify if the object is an unit.

old Re: How to get unit's name?

Hurri04
Super User Off Offline

Quote
do you want something like this?
1
2
3
4
5
6
7
on:use {
	$id=currentid();
	$type=type("unit", $id);
	$name=name("unit", $type);
	
	msg "This is a $name.";		//e.g. "This is a lion."
}
edited 1×, last 06.03.13 10:13:49 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview