Page 1 of 1

how would i script this in SP??

Posted: Fri Dec 05, 2014 3:32 pm
by 8guawong

Code: Select all

   DispatchKeyValue(sprite, "classname", "env_sprite_oriented");
    DispatchKeyValue(sprite, "spawnflags", "1");
    DispatchKeyValue(sprite, "scale", "0.3");
    DispatchKeyValue(sprite, "rendermode", "1");
    DispatchKeyValue(sprite, "rendercolor", "255 255 255");
    DispatchKeyValue(sprite, "model", OVERLAY);
    if(DispatchSpawn(sprite))    return sprite;

GetClientAbsOrigin(client, origin);
        origin[2] = origin[2] + 90.0;
        TeleportEntity(entity, origin, NULL_VECTOR, NULL_VECTOR);

        SetVariantString("!activator");
        AcceptEntityInput(entity, "SetParent", client);

if(IsValidEntity(entity)) {
        AcceptEntityInput(entity, "Kill");
    }


following is what i have come up with but not sure if it'll work

Syntax: Select all

entity = BaseEntity(index)
sprite = BaseEntity(create_entity('env_sprite_oriented'))
sprite.spawnflags = 10
sprite.scale = 1
sprite.rendermode = 1
sprite.rendercolor = 255 255 255
sprite.model = model

PlayerEntity(index).location[1] + 90

Posted: Fri Dec 05, 2014 5:45 pm
by Doldol
If you're not sure then test it!?

But some pointers:

You aren't spawning your entity. (I think this will be changed in an upcoming version of SP)

Syntax: Select all

spawn_entity(sprite.index)


AFAIK you have to use the edict to set key values:

Syntax: Select all

sprite.edict.set_key_value_int("rendermode", 1)


You can set the location of your sprite using:

Syntax: Select all

player = PlayerEntity(index)
sprite.edict.set_key_value_vector("origin", player.location + Vector(0, 90, 0))

Posted: Sat Dec 06, 2014 4:03 am
by satoon101
We have added an 'origin' property for entities in the entities_changes branch. With it, you can use:

Syntax: Select all

sprite.origin = player.origin + Vector(0, 90, 0)


spawn_entity will be located in entities.helpers, and will likely be wrapped by BaseEntity.spawn (except in the case of PlayerEntity). To set the color, you will simply need to use:

Syntax: Select all

BaseEntity.set_color(Color)

# or
BaseEntity.color = Color

Color in the above example is any Color object including any of our built-in colors:
http://wiki.sourcepython.com/pages/colors