[COMPLETED 075A] RightCopy for strings?

Post your Feature Requests here...
Post Reply
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

[COMPLETED 075A] RightCopy for strings?

Post by Jay » Sat Jul 29, 2006 1:00 pm

I have a request to make. It's something really simpel but it would help me really:

We all know that there is a script command LeftCopy that copys xxx letters from the left side of a string. I would like to have one that copys xxx letters from the right end of the script.

I need it for this script, which is a generic script for chests. It would allow to specify a chest that can be opened with right-clicking on it. The EntityName would then contain all the information about what is in the chest:

Code: Select all

{
    //EntityName of a chest must be: CHESTxxx0000
    //where 0000 is a four letter number defining the amount of xxx thats in the chest
    //xxx does not need having a special amount of letters
    CONSOLE     [true]
    D_DIST_P    [0]
    D_INT       [30]
    D_RENDER    [512]
    CHEST       []
    INCHEST     []
    AMOUNT      []
    
    Setup[ ()
    {
        Console(CONSOLE);
        Gravity(false);
        LowLevel("Init");
    } ]
    Init[ ()
    {
        CHEST = RightCopy(self.EntityName,GetStringLength(self.EntityName)-5);
        INCHEST = LeftCopy(CHEST,GetStringLength(INCHEST)-4);
        AMOUNT = RightCopy(CHEST,4);
        self.think="Idle";
    } ]
    Idle[ () //Normal rendering; check if player gets close or far
    {
        self.ThinkTime=0.5;
        D_DIST_P=DistanceBetweenEntities("Player",self.EntityName,true);
        if(D_DIST_P<D_INT)
        {
            self.think="inters";
            return;
        }
        if(D_DIST_P>D_RENDER)
        {
            PawnRender(false);
            self.think="wI";
            return;
        }
    } ]
    inters[ () //near enough to interact
    {
        self.ThinkTime=0.01;
        if(DistanceBetweenEntities("Player",self.EntityName,true)>D_INT)
        {
            self.think="Idle";
            return;
        }
        if(self.key_pressed=73)
        {
            if(MouseSelect(false,false)=self.EntityName)
            {
                AnimateHold("chest_open");
                self.think="Open";
            }
        }
    } ]
    wI[ () //far away, no need for rendering, wait until player comes nearer
    {
        self.ThinkTime=1.0;
        if(DistanceBetweenEntities("Player",self.EntityName,true)<D_RENDER)
        {
            PawnRender(true);
            self.think="Idle";
            return;
        }
    } ]
    Open[ ()
    {
        ModifyAttribute(INCHEST,AMOUNT,"Player");
        ShowText(0, "Player", "", "I got" # AMOUNT # " " # INCHEST ".", 0, "", 0, -100,"Centre", 255);
        HighLevel("Opened");
    } ]
    Opened[ ()
    {
        FadeOut(2.0,0);
        LowLevel("Opened2");
    } ]
    Opened2[ ()
    {
        RemoveText(0);
        HighLevel("Opened3");
    } ]
    Opened3[ ()
    {
        Remove(true);
    } ]
}
This would be very helpfull if this command could be added.
Thanks in advance
Everyone can see the difficult, but only the wise can see the simple.
-----

User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Post by QuestOfDreams » Mon Jul 31, 2006 7:25 pm

Added in RF 075A

Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Post by Jay » Tue Aug 01, 2006 8:02 pm

Thanks!
Everyone can see the difficult, but only the wise can see the simple.
-----

Post Reply