Forum

> > Stranded II > Scripts > How to get unit's name?
ForenübersichtStranded II-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch How to get unit's name?

3 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Re: How to get unit's name?

Stranded_Guy2910
User Off Offline

Zitieren
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.

alt Re: How to get unit's name?

Hurri04
Super User Off Offline

Zitieren
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."
}
1× editiert, zuletzt 06.03.13 22:13:49
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtStranded II-ÜbersichtForenübersicht