Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008128opensim[REGION] Script Functionspublic2017-02-08 09:322017-02-11 05:31
ReporterGezebu MindBlue 
Assigned To 
PriorityhighSeveritymajorReproducibilityalways
StatusnewResolutionopen 
PlatformLinuxOSFedora Server 25OS VersionOpenSim 0.9.1.0
Product Version 
Target VersionFixed in Version 
Summary0008128: Conditionals do not work within a for loop
DescriptionThe conditionals do not work properly inside a for loop.

In this example you should get only the names of the prims nameds "glass", but when touching the object, you receive the names of all primitives in the linkset.
Steps To Reproducedefault
{
    state_entry()
    {
        llSay(0, "I'm going crazy?");
    }
    
    touch_start(integer num){
        integer i;
        for(i=0;i<=llGetNumberOfPrims();i++){
            if(llGetLinkPrimitiveParams(i,[PRIM_NAME]) == "glass"){
            //if(osGetLinkPrimitiveParams(i,[PRIM_DESC]) == "glass"){
                llSay(0,(string)osGetLinkPrimitiveParams(i,[PRIM_NAME]));
            }
        }
    }
}
Additional InformationMono JIT compiler version 4.4.2 (Stable 4.4.2.11/f72fe45 Tue Aug 2 08:14:37 UTC 2016)
TagsNo tags attached.
Git Revision or version numberVersion: OpenSim 0.9.1.0 Dev OSgrid 0.9.1.0 (Dev) c673ef7: 2017-01-22 (SIMULATION/0.3 - SIMULATION/0.6)
Run Mode Grid (1 Region per Sim)
Physics EngineBulletSim
Script Engine
EnvironmentMono / Linux64
Mono VersionOther
ViewerFirestorm 5.0.1 (52150)
Attached Files

- Relationships

-  Notes
(0031594)
Lotek (reporter)
2017-02-08 14:09

llGetPrimitiveParams returns a list, while you are comparing it to a string. This may perhaps work in SL but OpenSim is more strict.

Try
 if(llList2String(llGetLinkPrimitiveParams(i,[PRIM_NAME]),0) == "glass"){
(0031595)
Gezebu MindBlue (reporter)
2017-02-08 17:27

Thx for hint Lotek, solve a problem. But anyway here have an issue, because in any case the IF it should not return any output if not find what you check, and it returns one for each primitives in the linkset. Something is not working well.
(0031596)
BillBlight (developer)
2017-02-08 19:19
edited on: 2017-02-08 19:22

Actually the conditions seem to work inside the for statement, just not with that particular statement, if you put it outside the if statement but inside the for it works ...

ie.

default
{
    state_entry()
    {
        llSay(0, "I'm going crazy?");
    }
    
    touch_start(integer num)
    {
        integer i;
        
        for(i=0;i<=llGetNumberOfPrims();i++)
        {
            string primname =(string)llGetLinkPrimitiveParams(i,[PRIM_NAME]);
            if(primname == "glass")
            {
               llOwnerSay(primname);
            }
        }
    }
}

Seems like , like lotek said, it is having an issue validating the string against the list. Maybe it returns everything because it is a list in your script so it is not sure where to stop and start evaluating , but something is screwy for sure.

(0031597)
BillBlight (developer)
2017-02-08 19:26
edited on: 2017-02-08 19:37

BTW it also works like this ..

default
{
    state_entry()
    {
        llSay(0, "I'm going crazy?");
    }
    
    touch_start(integer num)
    {
        integer i;
        
        for(i=0;i<=llGetNumberOfPrims();i++)
        {
            
            if((string)osGetLinkPrimitiveParams(i,[PRIM_NAME]) == "glass")
            {
               llOwnerSay((string)osGetLinkPrimitiveParams(i,[PRIM_NAME]));
            }
        }
    }
}

or with LL functions.

default
{
    state_entry()
    {
        llSay(0, "I'm going crazy?");
    }
    
    touch_start(integer num)
    {
        integer i;
        
        for(i=0;i<=llGetNumberOfPrims();i++)
        {
            
            if((string)llGetLinkPrimitiveParams(i,[PRIM_NAME]) == "glass")
            {
               llOwnerSay((string)llGetLinkPrimitiveParams(i,[PRIM_NAME]));
            }
        }
    }
}

(0031599)
Total Sorbet (reporter)
2017-02-11 05:31

if(llList2String(llGetLinkPrimitiveParams(i,[PRIM_NAME]),0)=="glass"){llOwnerSay("I promise not to attempt typecasting an entire list again (even if it does consist of just 1 element) :p");}

- Issue History
Date Modified Username Field Change
2017-02-08 09:32 Gezebu MindBlue New Issue
2017-02-08 14:09 Lotek Note Added: 0031594
2017-02-08 17:27 Gezebu MindBlue Note Added: 0031595
2017-02-08 19:19 BillBlight Note Added: 0031596
2017-02-08 19:22 BillBlight Note Edited: 0031596 View Revisions
2017-02-08 19:26 BillBlight Note Added: 0031597
2017-02-08 19:29 BillBlight Note Edited: 0031597 View Revisions
2017-02-08 19:37 BillBlight Note Edited: 0031597 View Revisions
2017-02-11 05:31 Total Sorbet Note Added: 0031599


Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker