| * To avoid confusing the new zone objects with the zones that can be defined in Magsbot using the various ZONE commands, I will always refer to the AW 4.1 zones as Zone Objects. |
| EXAMPLE: Creating a particle emitter. Here's an example of creating a particle emitter at the bot's location. Note that you don't need to include properties that you want to set to 0 (or blank for a string property). @v=@vlist; STORE_ @v speed_min_z=-0.5; STORE_ @v speed_min_x=-0.5; STORE_ @v speed_min_y=2; STORE_ @v speed_max_z=0.5; STORE_ @v speed_max_x=0.5; STORE_ @v speed_max_y=5; STORE_ @v size_min_z=1; STORE_ @v size_max_z=2; STORE_ @v size_min_x=1; STORE_ @v size_max_x=2; STORE_ @v size_min_y=1; STORE_ @v size_max_y=2; STORE_ @v release_min=10; STORE_ @v release_max=100; STORE_ @v release_size=4; STORE_ @v lifespan=2000; REM the colors of this PE run from hot pink (FF0080) to blue (0080CD), but note that the usual byte order of colors must be reversed when used as an object property! that is, color ABCDEF becomes EFCDAB (the first two digits and the last two digits are swapped). (i have no idea why it was done this way in the SDK!) so in this case ff0080 must be given as 8000ff and 0080cd must be given as cd8000; STORE_ @v color_start=@dec["8000ff"]; STORE_ @v color_end=@dec["cd8000"]; STORE_ @v opacity=0.5; rem render style is 0=normal, 1=bright, 2=glow; STORE_ @v render_style=2; REM actually this PE looks better with flags=0, but i wanted to show an example of using the @particleflags macro; STORE_ @v flags=@particleflags["INTERPOLATE|GRAVITY"]; STORE @v asset_list="c_soft1"; REM note that there is no model, description or action for a PE, so those arguments are left blank. also note that you use @objectaddv not @objectadd; @new_obj=@objectaddv[@ns,@we,@alt,@yaw,0,0,"","","",3,@v]; REM If you plan to create the same special object many times (but in different places), you could save the vlist and just call @objectaddv each time (i.e. you don't have to recreate the vlist each time). Even better, you could covert the vlist to a hex string ($objdata=$objdatafromvlist[@v]) and then call @objectadd[...,$objdata] each time you want to create the object. REM In Magsbot 7.3, you can improve on this even more by using a pointer to object data instead of a hex string, which is faster. In that case, you could fill the vlist, then convert the vlist to object data using @objdata=@objdatafromvlist[@v], then create the object each time using @objectadd[...,@objdata] or @objectaddp[...,@objdata] . REPORT $fmt["new object number=%s",@new_obj]; REM be sure to free the vlist after using it, if you aren't going to be using it again; FREEVLIST @v REM If using @objdata, be sure to free it after using it, if you aren't going to be using it again; FREEOBJDATA @objdata; |