en:vci:updatelog:1.5.1a

VCI update on Virtual Cast 1.5.1a


Feature to synchronize the state of an item as variables

This version adds vci.state, a feature to synchronize item variables through network, and functions that are necessary to use the feature: updateAll, vci.assets.IsMine and ExportTransform(SubItem).IsMine.

Use examle of updateAll and vci.state

function updateAll() -- This is run by all users regardless of ownership
	if vci.state.Get("TOGGLE") then
		vci.assets.SetMaterialColorFromIndex(0, Color.__new(1, 0, 0, 1)) 
	else
		vci.assets.SetMaterialColorFromIndex(0, Color.__new(1, 1, 1, 1)) 
	end		
end
 
function onUse() -- The grip button
	local toggle = vci.state.Get("TOGGLE")	
	vci.state.Set("TOGGLE", not toggle)	
end	

Before update

An example that does almost the same.

TOGGLE="ITEM_UNIQUE_TOGGLE" -- This won't be unique when more than one of the same item are brought into the studio.
 
vci.studio.shared.Bind(TOGGLE, function(value) -- Bind function is hard to use
	if value then
		vci.assets.SetMaterialColorFromIndex(0, Color.__new(1, 0, 0, 1)) 
	else
		vci.assets.SetMaterialColorFromIndex(0, Color.__new(1, 1, 1, 1)) 
	end		
end)
 
function onUse() -- The grip button
    local value = vci.studio.shared.Get(TOGGLE)
    vci.studio.shared.Set(TOGGLE, not value)
end	

vci.assets.IsMine

function updateAll() -- This is run by all users regardless of ownership
    if vci.assets.IsMine then
        -- The process
    end
end
 
-- The same as above
function update() -- This occurs in the owner of the VCI (The user who spawned the VCI)
    -- The process
end

ExportTransform(SubItem).IsMine

subitem = vci.assets.GetSubItem('item_name')
 
function updateAll() -- This is run by all users regardless of ownership
    if subitem.IsMine then -- This needs to be executed only on the owner of the SubItem
        subitem.SetPosition = Vector3.__new(1, 2, 3)
    end
end
en/vci/updatelog/1.5.1a.txt · Last modified: 2019/10/17 17:31 by h-eguchi

Page Tools