Jump to content

Can Some Explain About the Zeroes


Prokofy Neva
 Share

You are about to reply to a thread that has been inactive for 2786 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

//Rental Script v1.5.3
//by Hank Ramos
//08/18/2015, Rex Cronon(added 1h,6h...48h intervals)
// 08/27/2015, Rex Cronon(no more duplicate reminders?)
//08/29/2015, Rex Cronon(timestamp)

//Options
vector  rentalOffset   = <0,0,10>;
float   updateInterval = 60.0; //seconds
string  infoNotecard   = "Rent This Space Info";

//Variables
string  tierName;
float   rentalCost;
float discountTime;
integer primCount;
integer rentalVolume;
float   refundFee;
key     renterID;
string  renterName;
float   rentalTime;
integer listenQueryID;
vector  initPos;
vector  initScale;
integer count;
integer lineCount;
key     readKey;
string  rentalGrade;
integer primAllotment;

//Constants
float ONE_WEEK = 604800.0;
float _48_HOURS  = 172800.0;//2*24*3600
float _36_HOURS=129600.0;//36*3600
float _24_HOURS  = 86400.0;//24*3600
float _12_HOURS=43200.0;//12*3600
float _6_HOURS=21600.0;//6*3600
float _1_HOUR = 3600.0;//60*60
float DISCOUNT_PERCENT = 10.0;

dispString(string value)
{
    llSetText(value, <1,1,1>, 1);
}
sendReminder(string message)
{ 
    llInstantMessage(renterID, "Current date and time: "+llGetTimestamp()+"\n"+"Your lease located in " + llGetRegionName() + " (" + (string)initPos.x + "," + (string)initPos.y + "," + (string)initPos.z + ") will expire " + message); 
}
saveData()
{
    list saveData;
    vector storageVector;
    
    saveData += renterID;
    saveData += renterName;
    saveData += llRound(rentalTime);
    storageVector = initPos * 1000;
    saveData += "<" + (string)llRound(storageVector.x) + "," + (string)llRound(storageVector.y) + "," + (string)llRound(storageVector.z) + ">";
    storageVector = initScale * 1000;
    saveData += "<" + (string)llRound(storageVector.x) + "," + (string)llRound(storageVector.y) + "," + (string)llRound(storageVector.z) + ">";
    saveData += llRound(discountTime);
    
    llSetObjectDesc(llDumpList2String(saveData, "|"));
}
string getTimeString(integer time)
{
    integer days;
    integer hours;
    integer minutes; 
    integer seconds;
    
    days = llRound(time / 86400);
    time = time % 86400;
    
    hours = (time / 3600);
    time  = time % 3600;

    minutes = time / 60;
    time    = time % 60;

    seconds = time;
    
    return (string)days + " days, " + (string)hours + " hours, " + (string)minutes + " minutes"; // + ":" + (string)seconds; 
}

integer setupDialogListen()
{
    integer chatChannel = (integer)llFrand(2000000);
    llListenRemove(listenQueryID);
    listenQueryID = llListen(chatChannel, "", NULL_KEY, "");
    return chatChannel;
}

updateTimeDisp()
{ 
    dispString("Leased by: " + renterName + "\nTime Remaining: " + getTimeString(llRound(rentalTime)));   
}

dispData()
{
    llSay(0, "========================");
    llSay(0, "Rental Space Information");
    llSay(0, "========================");
    llSay(0, "This space is currently leased by " + renterName);
    llSay(0, "The current rental price is L$" + (string)((integer)rentalCost) + " per week.");
    llSay(0, "This space will be open for lease in " + getTimeString(llRound(rentalTime)) + "."); 
    llSay(0, "Memory Free: " + (string)llGetFreeMemory());
}
default
{
    state_entry()
    {
        state initialize;
    }
}

state initialize
{
    state_entry()
    {
        llSetTimerEvent(300);
        llOwnerSay("Waiting to obtain Debit Permissions.");
        llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
    }
    run_time_permissions(integer permissions)
    {
        //Only wait for payment if the owner agreed to pay out money
        if (permissions & PERMISSION_DEBIT)
        {
            state loadSettings;
        }
    }    
    on_rez(integer start_param)
    {
        llResetScript();
    } 
    timer()
    {
        llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
    }
    touch_start(integer total_number)
    {
        integer x;
        for (x = 0; x < total_number; x += 1)
        {
            if (llDetectedKey(x) == llGetOwner())
            {
                llResetScript();
            }
        }
        llSay(0, "Waiting to obtain Debit Permissions from Owner.");
    }
    state_exit()
    {
        llSetTimerEvent(0);
        llSay(0, "Initialized.");
    }
}

state loadSettings
{
    state_entry()
    {
        integer found = FALSE;
        integer x;
        
        count = 0;
        lineCount = 0;
        
        list savedList = llCSV2List(llGetObjectDesc());
        
        if (llGetListLength(savedList) == 4)
        {
            rentalGrade = llList2String(savedList, 0);
        }
        else
        {
            rentalGrade = llGetObjectDesc();
        }
        for (x = 0; x < llGetInventoryNumber(INVENTORY_NOTECARD); x += 1)
        {
            if (llGetInventoryName(INVENTORY_NOTECARD, x) == "Settings")
            {
                found = TRUE; 
            }
        }
        if (found)
        {
            llOwnerSay("Reading Settings Notecard...");
            readKey = llGetNotecardLine("Settings", lineCount); 
        }
        else
        {
            llOwnerSay("Settings Notecard Not Found.");
            llResetScript();
        }
    }
    dataserver(key requested, string data)
    {
        integer integerData;
        float   floatData;
        
        if (requested == readKey) 
        { 
            if (data != EOF)
            {
                if ((llSubStringIndex(data, "#") != 0) && (data != "") && (data != " "))
                {
                    integerData = (integer)data;
                    floatData   = (float)data;
                    
                    if (count == 0)
                    {
                        tierName = data;
                    }
                    else if (count == 1)
                    {
                        if (integerData >= 0)
                        {
                            rentalCost = integerData;
                        }
                        else
                        {
                            rentalCost = 0;
                        }
                    }
                    else if (count == 2)
                    {
                        if (integerData >= 1)
                        {
                            primCount = integerData;
                        }
                        else
                        {
                            primCount = 1;
                        }
                    }
                    else if (count == 3)
                    {
                        if (integerData >= 16)
                        {
                            rentalVolume = integerData;
                        }
                        else
                        {
                            rentalVolume = 16;
                        }
                    }
                    else if (count == 4)
                    {
                        if (integerData >= 0)
                        {
                            refundFee = integerData;
                        }
                        else
                        {
                            refundFee = 0;
                        }
                    }
                    else if (count == 5)
                    {
                        rentalOffset = (vector)data;
                    }
                    else if (count == 6)
                    {
                        infoNotecard = data;
                    }
                    count += 1;
                }
                lineCount += 1;
                readKey = llGetNotecardLine("Settings", lineCount);
            }
            else
            {
                llOwnerSay("===============");
                llOwnerSay("Settings Loaded");
                llOwnerSay("===============");
                llOwnerSay("Space Name: " + tierName);
                llOwnerSay("Rental Cost: L$" + (string)llRound(rentalCost));
                llOwnerSay("Prim Count: " + (string)primCount);
                llOwnerSay("Space Volume: " + (string)rentalVolume + " sqm");
                llOwnerSay("Refund Fee: L$" + (string)refundFee);
                llOwnerSay("===============");
                llOwnerSay("Ready for Service!");

                list savedList = llParseString2List(llGetObjectDesc(), ["|"], []);

                if (llGetListLength(savedList) == 6)
                {
                    renterID    = llList2Key(savedList, 01);
                    renterName  = llList2String(savedList, 1);
                    rentalTime  = llList2Integer(savedList, 2);
                    initPos     = (vector)llList2String(savedList, 3) / 1000;
                    initScale   = (vector)llList2String(savedList, 4) / 1000;
                    discountTime = llList2Integer(savedList, 5);
                    state rented;
                }
                else
                {
                    renterID   = NULL_KEY;
                    renterName = "Nobody";
                    rentalTime = 0;
                    initPos    = llGetPos();
                    initScale  = llGetScale();
                    discountTime = 0;
                    state idle;
                }
            }
        }
    }
}
state idle
{
    state_entry()
    {        
        llSetObjectDesc("");
        llSetTexture("rentthisspace", ALL_SIDES);
        llSetScale(initScale);
        llSetPos(initPos);
        integer fourweekdiscount = (integer)(((float)rentalCost * 4.0) * (DISCOUNT_PERCENT / 100.0));
        integer fourweekrentalprice = (integer)(((float)rentalCost * 4.0) - fourweekdiscount);
        llSetPayPrice((integer)rentalCost, [ (integer)(rentalCost * 1.0), (integer)(rentalCost * 2.0), (integer)(rentalCost * 3.0), (integer)fourweekrentalprice]);
        llSetTimerEvent(updateInterval);

        dispString(tierName + "\nLease this space for L$" + (string)llRound(rentalCost) + " per week.\n" + (string)rentalVolume + " sq meters\n" + (string)primCount + " prims\nPay this Sign to begin your lease.");
    }
    moving_end()
    {
        initPos = llGetPos();
    }
    changed(integer change)
    {
        if (change & CHANGED_SCALE)
        {
            initScale = llGetScale();
        }
    }
    touch_start(integer num_detected)
    {
        integer x;
        integer chatChannel;
        
        for (x = 0; x < num_detected; x += 1)
        {
            if (llDetectedKey(x) == llGetOwner())
            {
                llDialog(llGetOwner(), "Owner Options.  Select one of the options below...", ["Info", "Reset"], setupDialogListen());
                return;
            } 
        }
               
        llSay(0, "Lease this space for L$" + (string)llRound(rentalCost) + " per week. " + (string)rentalVolume + " sq meters. " + (string)primCount + " prims. Pay this Sign to begin your lease.");
        
        for (x = 0; x < num_detected; x += 1)
        {
            llGiveInventory(llDetectedKey(x), infoNotecard);
        } 
    }
    listen(integer channel, string name, key id, string message)
    {
        if (message == "Reset")
        {
            llResetScript();
        }
        else if (message == "Info")
        {
            llListenRemove(listenQueryID);
            dispData();
            llSay(0, "Lease this space for L$" + (string)llRound(rentalCost) + " per week. " + (string)rentalVolume + " sq meters. " + (string)primCount + " prims. Pay this Sign to begin your lease.");
            llGiveInventory(id, infoNotecard);
        }
    }    
    money(key id, integer amount)
    {
        if (amount >= rentalCost)
        {
            renterID   = id;
            renterName = llKey2Name(renterID);
            integer fourweekdiscount = (integer)(((float)rentalCost * 4.0) * (DISCOUNT_PERCENT / 100.0));
            integer fourweekrentalprice = (integer)(((float)rentalCost * 4.0) - fourweekdiscount);
            if (fourweekrentalprice == amount)
            {
                rentalTime = ONE_WEEK * (rentalCost * 4) / rentalCost;
                discountTime = rentalTime;
            }
            else
            {
                rentalTime = ONE_WEEK * amount / rentalCost;
                discountTime = 0;
            }

            saveData();
            
            llSay(0, "Thank you " + renterName + " for leasing!  Your lease will expire in " + getTimeString((integer)rentalTime) + ".");
            
            state rented;
        }
        else
        {
            llSay(0, "This space costs L$" + (string)rentalCost + " to rent. Refunding paid balance.");
            llGiveMoney(id, amount);
        }
    }
}

state rented
{
    state_entry()
    {
        llSetTexture("infosign", ALL_SIDES);
        llSetScale(<0.5, 0.5, 0.5>);
        llSetPos(initPos + rentalOffset);
        
        updateTimeDisp();
        llResetTime();
        llSetTimerEvent(updateInterval);
    }
    touch_start(integer num_detected)
    {
        integer x;
        key     detectedKey;
        
        for (x = 0; x < num_detected; x += 1)
        {
            detectedKey = llDetectedKey(x);
            if (detectedKey == llGetOwner())
            {
                llDialog(detectedKey, "Lease Options. Select one of the options below...", ["Refund Time", "Info", "Release", "Reset"], setupDialogListen());
            }
            else if (detectedKey == renterID)
            {
                llDialog(detectedKey, "Lease Options. Select one of the options below...", ["Refund Time", "Info"], setupDialogListen());
            }
            else
            {
                dispData();
                llGiveInventory(detectedKey, infoNotecard);
            }
        }
    }
    money(key id, integer amount)
    {
        if ((id == renterID)||(id == llGetOwner()))
        {
            float addTime;
            
            integer fourweekdiscount = (integer)(((float)rentalCost * 4.0) * (DISCOUNT_PERCENT / 100.0));
            integer fourweekrentalprice = (integer)(((float)rentalCost * 4.0) - fourweekdiscount);
            if (fourweekrentalprice == amount)
            {
                addTime = ONE_WEEK * (rentalCost * 4) / rentalCost;
                discountTime += addTime;
            }
            else
                addTime = ONE_WEEK * amount / rentalCost;

            rentalTime += addTime;
            
            llInstantMessage(id, "Adding " + getTimeString(llRound(addTime)) + " to your lease. Lease Time is Now: " + getTimeString(llRound(rentalTime)) + ".");
            saveData();
            updateTimeDisp();
        }
        else
        {
            llInstantMessage(id, "Refunding Money...");
            llGiveMoney(id, amount);
            llInstantMessage(id, "This space is currently leased by " + renterName + ". This space will be open for lease in " + getTimeString(llRound(rentalTime)) + "."); 
        }
    }
    listen(integer channel, string name, key id, string message)
    {
        integer refundAmount;
        
        llListenRemove(listenQueryID);

        if (message == "Info")
        {
            dispData();
            llGiveInventory(id, infoNotecard);
        }
        else if (message == "Refund Time")
        {
            llDialog(id, "Are you sure you want to TERMINATE your lease and refund your money, minus a L$" + (string)refundFee + " fee?", ["YES", "NO"], setupDialogListen());
        }
        else if (message == "YES")
        {
            float discount = (float)rentalCost * (DISCOUNT_PERCENT / 100.0);
            integer discountCost = (integer)((float)rentalCost - discount);
            refundAmount = llRound((((rentalTime - discountTime)/ ONE_WEEK) * rentalCost) + ((discountTime / ONE_WEEK) * discountCost) - refundFee);
            llInstantMessage(renterID, "Refunding L$" + (string)refundAmount + ", which includes a L$" + (string)refundFee + " termination fee.");
            llGiveMoney(renterID, refundAmount);
            llInstantMessage(llGetOwner(), "LEASE REFUNDED: leased by " + renterName + " located in " + llGetRegionName() + " (" + (string)initPos.x + "," + (string)initPos.y + "," + (string)initPos.z + ") has ended. Refunded L$" + (string)refundAmount + ".");
            state idle;
        }
        else if (message == "Release")
        {
            llDialog(id, "Are you sure you want to TERMINATE this lease with NO REFUND?", ["Yes", "No"], setupDialogListen());
        }
        else if (message == "Yes")
        {
            llInstantMessage(llGetOwner(), "LEASE TERMINATED: leased by " + renterName + " located in " + llGetRegionName() + " (" + (string)initPos.x + "," + (string)initPos.y + "," + (string)initPos.z + ") has ended. Refunded L$0.");
            state idle;            
        }
        else if (message == "Reset")
        {
            llResetScript();
        }
    }
    timer()
    {
        float timeElapsed = llGetAndResetTime();
        if (timeElapsed > (updateInterval * 4))
        {
            timeElapsed = updateInterval;
        }
        rentalTime -= timeElapsed;
        
        saveData();
 
        updateTimeDisp(); 
        
        //Process Reminders
        if (rentalTime <= 0)
        {
            llInstantMessage(llGetOwner(), "LEASE EXPIRED: leased by " + renterName + " located in " + llGetRegionName() + " (" + (string)initPos.x + "," + (string)initPos.y + "," + (string)initPos.z + ") has expired.");

            state idle;
        }
        
        //if((rentalTime<(_48_HOURS+updateInterval))&&(rentalTime>(_48_HOURS-updateInterval))) 
        if((rentalTime <= _48_HOURS)&&(rentalTime >= _48_HOURS - (updateInterval*2)))
        {
            sendReminder("in two days.");
        }              
        //else if ((rentalTime<(_36_HOURS+updateInterval))&&(rentalTime>(_36_HOURS-updateInterval)))
        else if((rentalTime <= _36_HOURS)&&(rentalTime >= _36_HOURS - (updateInterval*2)))
        {
            sendReminder("in one day and a half.");
        }
        //else if((rentalTime<(_24_HOURS+updateInterval))&&(rentalTime>(_24_HOURS-updateInterval)))
        else if ((rentalTime <= _24_HOURS)&&(rentalTime >= _24_HOURS - (updateInterval*2)))
        {
            sendReminder("in one day.");
        }
        //else if ((rentalTime<(_12_HOURS+updateInterval))&&(rentalTime>(_12_HOURS-updateInterval)))
        else if((rentalTime <= _12_HOURS)&&(rentalTime >= _12_HOURS - (updateInterval*2)))
        {
            sendReminder("in 12 hours.");
        }
        //else if ((rentalTime<(_6_HOURS+updateInterval))&&(rentalTime>(_6_HOURS-updateInterval)))
        else if((rentalTime <= _6_HOURS)&&(rentalTime >= _6_HOURS - (updateInterval*2)))
        {
            sendReminder("in 6 hours.");
        }
       // else if ((rentalTime<(_1_HOUR+updateInterval))&&(rentalTime>(_1_HOUR-updateInterval)))
        else if((rentalTime <= _1_HOUR)&&(rentalTime >= _1_HOUR - (updateInterval*2)))
        {
            sendReminder("in one hour.");
        }        
    }
}

One of the annoyances of this open-source rental script is that when it comes to the refunds, it gives this message:

 

"Are you sure you would like to refund for a $25.000000 fee?

I'm not aware of any human language that has that convention of taking a figure out to 6 places.

What happens is that people don't see the decimal point, or fear they haven't understood the decimal point.

In Russia, for example, people write numbers with commas instead of periods or decimal points, for example.

25,37 could mean 25 rubles, 37 kopecks.

I look at the script, and I can't see where I can take this out or reduce it -- it just doesn't seem to be there.

And that suggests that this is some built-in thing with LSL that it always renders numbers this way in case it needs the spaces.

But given that Linden prices simply cannot be with decimal points and "cents" -- they are rounded off as a hard stop -- I  don't know why LSL is doing this.

You would be surprised at the number of people who actually think I've written in "US $25,000,000 as a deterrent to them refunding.

 

Link to comment
Share on other sites

That's very strange.  The script that you posted never says that. The closest that it gets is

"Are you sure you want to TERMINATE your lease and refund your money, minus a L$" + (string)refundFee + " fee?"

If you're really hearing "Are you sure you would like to refund for a $25.000000 fee?", it's coming from some other script. That's nitpicky, though.  I see what you mean, and where it's coming from.  The refund fee is read from a notecard, where you typed it in, quite correctly, as an integer.  The scripter was clumsy, though.  As soon as the script read that value from the notecard, it converted the integer to a float.  So 25 became 25.000000.  There was no need to do that, because the refund fee is never treated as a float later.  As you discovered, it also makes life confusing when the script converts the float to a string and prints it out in full.

This is not LSL's fault.  The language doesn't know what dollars and cents are.  It just knows that when you use a float, it will have a bunch of zeroes hanging out there.  If a scripter only wants to show some of the zeroes, he has to trim the rest off deliberately.  (Coincidentally, a scripter asked about that exact process in this forum today >>> https://community.secondlife.com/t5/LSL-Scripting/Float-cut-Zeroes/td-p/3064953 ).  In your case, you don't want ANY zeroes, so the refund fee should never have been a float in the first place.  The easiest way to cure it now is to change that line in the script very slightly so that it says

llDialog(id, "Are you sure you want to TERMINATE your lease and refund your money, minus a L$" + (string)((integer)refundFee) + " fee?", ["YES", "NO"], setupDialogListen());

If there's a lesson in this, it's that you get what you pay for.  If you pick up freebie scripts, you can expect that they are free for a reason -- not very well tested or up to date. 

Link to comment
Share on other sites

No, it's not coming from some other script. There is only one script in the rental box.

Yes, I realize you can't see those words on this script. That's why I'm asking this question.

I will send you the all perms set of materials including this script that enables you to test it as a rental box. Then you will see this behavior.

And no, the rest of the stuff has no scripts in it.

Your notion that I have "picked up freebie scripts" is just based on ignorance.

This is a perfectly good script that was originally created as a proprietary script by Hank Ramos, then opened when he went out of business.

Since then, about 4 or 5 scripters have methodically worked on improving and updating it. I've even paid some of them. I'm no fan of open source scripting and the open source culture at all, but there are good reasons to stay away from the huge monopolists in the rental scripting business in SL.

This script has been upgraded and corrected numerous times which is why it is on 1.7 and not 1.0.

It's great that it's "not LSL's fault" but the reality is, these components have to work together and your fellow scripters simply overlooked this problem because they are not grounded in USE.

So the lessons is don't make assumptions and don't think scripts are perfect entities because they are in the hands of coders; only use by normal people can make them function in the real world.

You've given me what I need here which is NOT A CHANGE TO THE CARD which didn't work. But a CHANGE TO THE SCRIPT!

Imagine!

Link to comment
Share on other sites

Sorry.  The words "Are you sure you would like to refund for a $25.000000 fee?" do not appear anywhere in this script.  The script cannot make them up by itself.  If those are the exact words you are seeing, then they cannot come from this script.  That's really just a side issue, though.  I didn't mean to get drawn into a discussion of what words the script says.  Your basic question was about the number.

I told you specifically how to change the script to make the numerical output have the correct format.  It's hard to find any script that can't use further improvement, whether it's on its version 1.0 or 1.7 or 1.369.  This one just needs that little repair.

Link to comment
Share on other sites

Yeah, I got it. You don't have to be a scripter to get it. Derp. That's why I asked the forums here since the words do not appear in the script, derp.

Now, if they are a function of the config card, that is part of the script's functioning. You can't have a script like this without a notecard. So to act as if the notecard is from some other realm instead of something working in tandem with the script just seems strange.

No, my basic question was "what needs to be changed in this script to make it get rid of this number problem"?

You jammed on the literalism and lesser point that "the words aren't in the script". You then insisted that "the problem" was the notecard.

You then gave a solution which involved...changing the script. LOL. So the script was at issue, in any normal and non-literalist /particularist sense.

It's like the old joke:

P: I’m heading to the store. Any requests?

S: Pick up a loaf a bread. If they have eggs, get a dozen.

P: OK.

An hour later, Programmer returns home with a dozen loaves of bread.

S: Why’d you buy a dozen loaves of bread?

P: They had eggs!

 

Nobody cares about loaves of bread as a condition of the presence of eggs. They just want a dozen eggs, is all.

 

Link to comment
Share on other sites

No, I didn't.  Please read my original response again.  The only reason I even mentioned the notecard is that the script was written to read the notecard in an odd way.  Then I told you how to fix the script in the simplest way possible.  I said:

The easiest way to cure it now is to change that line in the script very slightly so that it says

llDialog(id, "Are you sure you want to TERMINATE your lease and refund your money, minus a L$" + (string)((integer)refundFee) + " fee?", ["YES", "NO"], setupDialogListen());

I just highlighted the small part that you need to change in red , just in case.

Link to comment
Share on other sites

In doesn't matter if the script "was written to read the notecard in an odd way". 

The solution still involved fixing THE SCRIPT, not the notecard, imagine!

So quick question: do I now call this amended script "Version 1.8" even though the change was tiny? I assume so.

And for extra credit: at what point can a script be numbered "2.0"?

 

PS It works fine. I will add you to the credits.

Anyone who wants this all perms script in a box with the rest of its ingredients for $1, go here to Ross.

 

 

Link to comment
Share on other sites

I'm glad that it works.  As for what you call it, that's entirely up to you.  There is no standard.  Every scripter has her own way of keeping track of which updated version is which.  People have asked periodically for a standardized versioning capability for inventory items, but I doubt that it will ever happen. So .... 1.8?  2.0?  1.7.1?  It's whatever you want it to be.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2786 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...