setObjectTextureGlobal: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(size matters)
m (Text replacement - "{{Feature|Informative|" to "{{Feature|informative|")
 
(72 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma3 |= Game name
|game1= arma3
|version1= 1.06


|1.06|= Game version
|arg= global
|eff= global


|arg= global |= Arguments in MP
|gr1= Object Manipulation


|eff= global |= Effects in MP
|descr= Set the texture of the given selection on all computers in a network session.
____________________________________________________________________________________________
{{Feature|informative|
* Not all objects can be textured this way. To find out, run [[getObjectTextures]] command on an object. Empty array <sqf inline>[]</sqf> usually indicates it cannot be textured.
* All textures must have a resolution of 2<sup>a</sup> &times; 2<sup>b</sup> (e.g. 16&times;16, 16&times;32, 64&times;256, 512&times;512, ...). The largest texture size supported by the RV engine is 4096&times;4096.
* Supported formats: .pac, .paa, .jpg, .jpeg, .ogg, .ogv
}}


| Set the texture of the given selection on all computers in a network session. <br><br>'''NOTES''':
|mp= The effect is [[Multiplayer Scripting#Join In Progress|JIP]] compatible.
* Do not put global commands such this one into init field in editor and expect it to work in Multiplayer. See [[Talk:setObjectTextureGlobal]] for the explanation.
* Not all objects could be textured this way. To find out, run [[getObjectTextures]] command on an object. Empty array [] usually indicates it cannot be textured.
* All textures must have resolution 2^x / 2^y (e.g. 16 / 16, 16 / 32, 64 / 256, 512 / 512, etc). The largest texture size commonly supported by graphics cards and RV engine is 4096x4096|= Description
____________________________________________________________________________________________


| obj '''setObjectTextureGlobal''' [selection, texture] |= Syntax
|pr= If executed from an object's init field (which should not be done anyway for {{Icon|globalEffect|32}} commands), execution may happen too early and fail to broadcast over the network and to be [[Multiplayer Scripting#Join In Progress|JIP]] compatible.


|p1= obj: [[Object]] |= PARAMETER1
|s1= object [[setObjectTextureGlobal]] [selection, texture]


|p2= [selection,texture]: [[Array]] |= PARAMETER2
|p1= object: [[Object]]


|p3= selection: [[Number]] |= PARAMETER3
|p2= selection: [[Number]] or {{GVI|arma3|2.10|size= 0.75}} [[String]] - index of the selection. It is defined in the [[CfgVehicles Config Reference#hiddenSelections|hiddenSelections]] array in the vehicle's config (starting with 0). If a string is given, it referes to a hiddenSelection name or clan selection instead of an index.


|p4= texture: [[String]] |= PARAMETER4
|p3= texture: [[String]] - path to texture


| [[Nothing]] |= RETURNVALUE
|r1= [[Nothing]]


|x1= <sqf>player setObjectTextureGlobal [0, "\MyAddon\blue.paa"];</sqf>


|x1= <code>[[player]] [[setObjectTextureGlobal]] [0, "\MyAddon\blue.paa"];</code>|= EXAMPLE1
|x2= <sqf>
|x2= <code>//set up persistent texture keeper
// Set up a persistent texture keeper
[[player]] [[addEventHandler]] ["Take", {
player addEventHandler ["Take", {
([[getObjectTextures]] [[player]] + <nowiki>[</nowiki>[[uniformContainer]] [[player]] [[getVariable]] "texture"])
(getObjectTextures player + [uniformContainer player getVariable "texture"])
[[params]] ["_texUniform", "_texInsignia", "_texCustom"];
params ["_texUniform", "_texInsignia", "_texCustom"];
[[if]] ([[isNil]] "_texCustom") [[exitWith]] {};
if (isNil "_texCustom") exitWith {};
[[if]] (_texUniform == _texCustom) [[exitWith]] {};
if (_texUniform == _texCustom) exitWith {};
[[player]] [[setObjectTextureGlobal]] [0, _texCustom];
player setObjectTextureGlobal [0, _texCustom];
[[false]]
false
}];
}];


// Example: make current uniform persistently blue


//Example: make current uniform persistently blue
private _texture = "#(rgb,8,8,3)color(0,0,1,1)"; // blue texture
player setObjectTextureGlobal [0, _texture]; // set it on player
uniformContainer player setVariable ["texture", _texture, true]; // store it on uniform
</sqf>


_texture = "#(rgb,8,8,3)color(0,0,1,1)"; //blue texture
|seealso= [[setObjectTexture]] [[getObjectTextures]] [[setObjectMaterial]] [[forceFlagTexture]]
[[player]] [[setObjectTextureGlobal]] [0, _texture]; //set it on player
}}
[[uniformContainer]] [[player]] [[setVariable]] ["texture", _texture, [[true]]]; //store it on uniform</code>|= EXAMPLE2
____________________________________________________________________________________________


| [[setObjectTexture]], [[getObjectTextures]], [[setObjectMaterial]], [[forceFlagTexture]] |= SEEALSO
{{Note
 
|user= Killzone_Kid
|  |= MPBEHAVIOUR
|timestamp= 20161024121300
____________________________________________________________________________________________
|text= Sometimes it could be necessary to set default material on an object for the texture to take effect:
<sqf>
private _block = createVehicle ["Land_VR_Block_02_F", player getPos [20, getDir player], [], 0, "CAN_COLLIDE"];
_block setObjectMaterialGlobal [0, "\a3\data_f\default.rvmat"];
_block setObjectTextureGlobal [0, "#(rgb,8,8,3)color(1,0,0,1)"];
</sqf>
Courtesy of '''[[User:Larrow|Larrow]]'''
}}
}}


<h3 style='display:none'>Notes</h3>
{{Note
<dl class='command_description'>
|user= whiztler
<!-- Note Section BEGIN -->
|timestamp= 20220913210401
<!-- Note Section END -->
|text= Following Killzone_Kid's note, a [[sleep]] after the  [[setObjectMaterialGlobal]] and before the setObjectTextureGlobal command is sometimes needed to ensure the texture effect is  carried out correctly.
</dl>
<sqf>private _block = createVehicle ["Land_VR_Block_02_F", player getPos [20, getDir player], [], 0, "CAN_COLLIDE"];
 
_block setObjectMaterialGlobal [0, "\a3\data_f\default.rvmat"];
<h3 style='display:none'>Bottom Section</h3>
sleep 0.01;
[[Category:Arma_3:_New_Scripting_Commands_List|{{uc:{{PAGENAME}}}}]]
_block setObjectTextureGlobal [0, "#(rgb,8,8,3)color(1,0,0,1)"];</sqf>
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
}}Note that you need to run above code in a [[Scheduler|scheduled environment]].
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on March 8, 2015 - 21:15 (UTC)</dd>
<dt class="note">[[User:Sxp2hiiigh|Sxp2hiiigh]]</dt>
<dd class="note">
The effect is persistent and will be synchronized for players who join in progress. (Tested with Arma 3 v1.40)
</dd>
</dl>
<!-- DISCONTINUE Notes -->
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on December 29, 2015 - 18:13 (UTC)</dd>
<dt class="note">[[User:Elch2070|Elch2070]]</dt>
<dd class="note">
In some cases the ".paa" files do not work. Instead you can try ".jpg" files.
</dd>
</dl>
<!-- DISCONTINUE Notes -->
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on October 24, 2016 - 12:13 (UTC)</dd>
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dd class="note">Sometimes it could be necessary to set default material on an object for the texture to take effect:
<code>_block = [[createVehicle]] ["Land_VR_Block_02_F", [[player]] [[getPos]] [20, [[getDir]] [[player]]], [], 0, "CAN_COLLIDE"];
_block [[setObjectMaterialGlobal]] [0, "\a3\data_f\default.rvmat"];
_block [[setObjectTextureGlobal]] [0, "#(rgb,8,8,3)color(1,0,0,1)"];</code>
Courtesy of '''[[User:Larrow|Larrow]]'''
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 01:24, 2 February 2024

Hover & click on the images for description

Description

Description:
Set the texture of the given selection on all computers in a network session.
  • Not all objects can be textured this way. To find out, run getObjectTextures command on an object. Empty array [] usually indicates it cannot be textured.
  • All textures must have a resolution of 2a × 2b (e.g. 16×16, 16×32, 64×256, 512×512, ...). The largest texture size supported by the RV engine is 4096×4096.
  • Supported formats: .pac, .paa, .jpg, .jpeg, .ogg, .ogv
Multiplayer:
The effect is JIP compatible.
Problems:
If executed from an object's init field (which should not be done anyway for GEGlobal commands), execution may happen too early and fail to broadcast over the network and to be JIP compatible.
Groups:
Object Manipulation

Syntax

Syntax:
object setObjectTextureGlobal [selection, texture]
Parameters:
object: Object
selection: Number or Arma 3 logo black.png2.10 String - index of the selection. It is defined in the hiddenSelections array in the vehicle's config (starting with 0). If a string is given, it referes to a hiddenSelection name or clan selection instead of an index.
texture: String - path to texture
Return Value:
Nothing

Examples

Example 1:
player setObjectTextureGlobal [0, "\MyAddon\blue.paa"];
Example 2:
// Set up a persistent texture keeper player addEventHandler ["Take", { (getObjectTextures player + [uniformContainer player getVariable "texture"]) params ["_texUniform", "_texInsignia", "_texCustom"]; if (isNil "_texCustom") exitWith {}; if (_texUniform == _texCustom) exitWith {}; player setObjectTextureGlobal [0, _texCustom]; false }]; // Example: make current uniform persistently blue private _texture = "#(rgb,8,8,3)color(0,0,1,1)"; // blue texture player setObjectTextureGlobal [0, _texture]; // set it on player uniformContainer player setVariable ["texture", _texture, true]; // store it on uniform

Additional Information

See also:
setObjectTexture getObjectTextures setObjectMaterial forceFlagTexture

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Killzone_Kid - c
Posted on Oct 24, 2016 - 12:13 (UTC)
Sometimes it could be necessary to set default material on an object for the texture to take effect:
private _block = createVehicle ["Land_VR_Block_02_F", player getPos [20, getDir player], [], 0, "CAN_COLLIDE"]; _block setObjectMaterialGlobal [0, "\a3\data_f\default.rvmat"]; _block setObjectTextureGlobal [0, "#(rgb,8,8,3)color(1,0,0,1)"];
Courtesy of Larrow
whiztler - c
Posted on Sep 13, 2022 - 21:04 (UTC)
Following Killzone_Kid's note, a sleep after the setObjectMaterialGlobal and before the setObjectTextureGlobal command is sometimes needed to ensure the texture effect is carried out correctly.
private _block = createVehicle ["Land_VR_Block_02_F", player getPos [20, getDir player], [], 0, "CAN_COLLIDE"]; _block setObjectMaterialGlobal [0, "\a3\data_f\default.rvmat"]; sleep 0.01; _block setObjectTextureGlobal [0, "#(rgb,8,8,3)color(1,0,0,1)"];

Note that you need to run above code in a scheduled environment.