The online racing simulator
LFSLapper New Insimpacket ISP_AXM (Add/Remove multiple objects)
Hi everyone,

I started with adding a another insimpacket into LFSLapper.
With this packet you can add/remove autocross objects, which you also do in the autocross editor.

But now you can control it by insim. LFSLapper in this case.

Ill show you how far i'm with implementing the packet into lapper.

The Functions/Commands you will use is:

addobject($X,$Y,$Z,$TypeOfObject,$HeadingOfObject);
removeobject($X,$Y,$Z,$TypeOfObject,$HeadingOfObject);

You can add/remove up to 30 object at the same time. The functions will look like this.


<?php 
################################
#Adding objects example
################################
$X getcurrentplayervar("X");
$Y getcurrentplayervar("Y");
$Z getcurrentplayervar("Z");
$TypeOfObject 128#type of Object (Long Bump)
$HeadingOfObject 130;

#Up to 30 objects
              
addobject($X,$Y,$Z,$TypeOfObject,$HeadingOfObject,    #object 01
              
$X=$X+2,$Y,$Z,$TypeOfObject,$HeadingOfObject,         #object 02
              
$X=$X+2,$Y,$Z,$TypeOfObject,$HeadingOfObject,         #object 03
              
$X=$X+2,$Y,$Z,$TypeOfObject,$HeadingOfObject,         #object 04 
              
$X=$X+2,$Y,$Z,$TypeOfObject,$HeadingOfObject,         #etc
              
$X=$X+2,$Y,$Z,$TypeOfObject,$HeadingOfObject);

################################
#delete objects example
################################
NOTETo remove an object you must know the location and type of the object.

$X getcurrentplayervar("X");
$Y getcurrentplayervar("Y");
$Z getcurrentplayervar("Z");
$TypeOfObject 128#type of Object (Long Bump)
$HeadingOfObject 130;

#Up to 30 objects
removeobject($X,$Y,$Z,$TypeOfObject,$HeadingOfObject,              #object 01
             
$X=$X+2,$Y,$Z,$TypeOfObject,$HeadingOfObject,         #object 02
             
$X=$X+2,$Y,$Z,$TypeOfObject,$HeadingOfObject,         #object 03
             
$X=$X+2,$Y,$Z,$TypeOfObject,$HeadingOfObject,         #object 04 
             
$X=$X+2,$Y,$Z,$TypeOfObject,$HeadingOfObject,         #etc
             
$X=$X+2,$Y,$Z,$TypeOfObject,$HeadingOfObject);
?>

The list with type of objects can be found in the attachment

I'm also planning to create a new event for getting Information about an object that is being placed or removed. This event can be turned off.
Attached images
i105^cimgpsh_orig.png
Attached files
ObjectsList.txt - 6.8 KB - 391 views
Nice small update: New Event

With this event you can dislay which object you have add or removed.

New Event:

$Action: 1 = Addobject / 2 = remove object
$NumO = Number of objects you have selected
$Index = Index Number ( See first post in attachment)
$Type = Type of Object ( See first post in attachment)


<?php 
$DisplayObjectInfo 
= -1;
Event OnObjectInfo($userName,$NumO,$Action,$X,$Y,$Z,$Type,$InDex,$Heading# Player event
    
privmsg("^7LayoutAction: ^8".$Action);
    
privmsg("^7Number of Objects: ^8".$NumO);
    
privmsg("^7X/Y/Z: ^8".$X."/".$Y."/".$Z);
    
privmsg("^7Index & Type of Object ^8".$InDex."/".$Type);
    
privmsg("^7Heading of Object ^8".$Heading);
CatchEvent
?>


If you do not want the info everytime you add/move/remove an object. Set $DisplayObjectInfo to '-1';
It wont execute the event. To enable it you can set it to '1'

You may also use SetConfigVar("DisplayObjectInfo", 1); or SetConfigVar("DisplayObjectInfo", -1); in your scripts.
Attached images
objectinfo.jpg
I like to share the Test code i'm using to simulate a gate that open and close.
i could it do manually by command or it automaticlly: by driving throught an insimchecker

I have created a new Scriptfile named: TestCode.LPR


<?php 
$DisplayObjectInfo 
1;
CatchEvent OnObjectInfo($userName,$NumO,$Action,$X,$Y,$Z,$Flags,$Type,$InDex,$Heading# Player event
    
privmsg("^7LayoutAction: ^8".$Action);
    
privmsg("^7Number of Objects: ^8".$NumO);
    
privmsg("^7X/Y/Z: ^8".$X."/".$Y."/".$Z);
    
privmsg("^7Index & Type of Object ^8".$InDex."/".$Type);
    
privmsg("^7ObjectFlag ^8".$Flags);
    
privmsg("^7Heading of Object ^8".$Heading);
EndCatchEvent

CatchEvent OnMSO
$userName$text # Player event
 
$idxOfFirtsSpace indexOf$text" ");
 IF( 
$idxOfFirtsSpace == -THEN
   $command 
$text;
   
$argv "";
 ELSE
   
$command subStr$text,0,$idxOfFirtsSpace );
   
$argv trimsubStr$text,$idxOfFirtsSpace ) );
 ENDIF
 
#TEST COMMAND
    
SWITCH( $command )
        CASE 
"!opengate":
            
OpenGate();
        BREAK;
        CASE 
"!closegate":
            
CloseGate$KeyFlags );
        BREAK;            
 ENDSWITCH  
EndCatchEvent

CatchEvent OnCrossingChecker
($userName,$Flags,$Time,$Object,$UserSpeed,$CircleIndex)
        IF ((
$CircleIndex == 25)&&($Flags == 0)) THEN
            OpenGate
();
            
HostDelayedCommand3CloseGate); #Go to Close gate sub
        
ENDIF
EndCatchEvent

Sub OpenGate
()
            
globalmsg("Gate is open");
            
startlightcontrol(5,149,10,8); #Green Startlight
            
$X 19$Y = -654$Z 3$TypeOfObject 175$HeadingOfObject 64$Flag 208#Info about object
            
removeobject(21,-654,3,5,174,195);     #Remove opengate   
            
addobject($X,$Y,$Z,$Flag,$TypeOfObject,$HeadingOfObject); #GateClosed
EndSub

Sub CloseGate
$KeyFlags )
            
globalmsg("Gate is closed");
            
startlightcontrol(5,149,10,1); #Red Startlight
            
$X 21$Y = -654$Z 3$TypeOfObject 174$HeadingOfObject 64$Flag 5#Info about object (Closed gate)vc
            
addobject($X,$Y,$Z,$Flag,$TypeOfObject,$HeadingOfObject); #Add object to simulate a closed gate
            
removeobject(19,-654,3,208,175,64);     #Remove "open gate "object 
EndSub
?>


Good one Danny Big grin
First testvideo about simulating a gate by add/removing objects in LFSLapper

This weekend i will release a testversion.



The code that i used:

EDIT: EDITED CODE to newest version


<?php 
CatchEvent OnLapperStart
()
    
    
#X:Y:Z:Flag:Type:Heading
    
GlobalVar $GateOpen$GateOpen "19:-654:3:208:175:64";
    
GlobalVar $GateClosed$GateClosed "21:-654:3:5:174:64";
    
EndCatchEvent

CatchEvent OnCrossingChecker
($userName,$Flags,$Time,$Object,$UserSpeed,$CircleIndex)
        
#Go to YellowLight sub when driving throught the insimcircle with index=25
        
IF (($CircleIndex == 25)&&($Flags == 0)) THEN
            YellowLight
(); #Goto YellowLight Sub            
        
ENDIF
        
#Go to Closegate sub to close the gate when driving throught the insimcircle with index=26
        
IF (($CircleIndex == 26)&&($Flags == 0)) THEN
            CloseGate
$KeyFlags );            
        ENDIF
EndCatchEvent

Sub YellowLight
()
            
startlightcontrol(5,149,10,2); #Yellow Startlight, Lightindentifier = 10
            
HostDelayedCommand2OpenGate); #Go to Open Gate sub after 2 seconds
EndSub

Sub OpenGate
$KeyFlags )
            
globalmsg("Gate is open");
            
startlightcontrol(5,149,10,8); #Green Startlight,  Lightindentifier = 10
            
removeobject($GateClosed);     #Remove "closed gate" object
            
addobject($GateOpen); #GateClose
EndSub

Sub CloseGate
$KeyFlags )
            
globalmsg("Gate is closed");
            
startlightcontrol(5,149,10,1); #Red Startlight,  Lightindentifier = 10
            
removeobject($GateOpen);#Remove "open gate" object 
            
addobject($GateClosed); #Add object to simulate a closed gate
EndSub
?>


-
(donatas.s) DELETED by donatas.s

FGED GREDG RDFGDR GSFDG