Converting object class types


#1

Continuing the discussion from Getting the components of a Blueprint:

To convert an object you use the conversion operator >> so

method_with_name_arg("Lawl">>Name)

The conversion will only be called if it is necessary, so "AString">>String would do nothing.

SkookumSript tries to reduce typing when what you would type seems obvious and conversion calls can implicitly supply the class type if the parser can figure out the class that is desired.

method_with_name_arg("Lawl">>)

Since it is obvious to the parser that a Name class is desired, specifying that you want to convert it with >> is sufficient enough - you don’t actually have to write out the class since the parser already knows what you want.

Conversion calls rely on the presence of conversion methods - a method with the same name as the class type to convert to.

You can also call the conversion method directly - in this example it is the String@Name() method:

method_with_name_arg("Lawl".Name)

Calling the conversion method directly ensures that it is always called, so "AString".String will call String() even though "AString" is already a String object.

Sometimes classes will have constructor methods that essentially take the type that you want to convert as an argument though they are a bit longer to type - like the constructor that you started with.

method_with_name_arg(Name!("Lawl"))


Great curated posts to learn about SkookumScript
Variable declaration and assignment as I understand it at the moment
#2

Hey, thanks for the clarification on conversions. Could I also get an answer to the question of how to access actor components by tag and by class with code examples? If these examples already exist a link would suffice as an answer.