Ghostrick
Cannot be Normal Summoned, unless you control a "Ghostrick" monster. Once per turn: You can change this card to face-down Defense Position. When a Level 4 or higher monster(s) is Normal or Special Summoned: Change that monster(s) to face-down Defense Position. There must be another "Ghostrick" monster on the field to activate and to resolve this effect.
local SETCARD_ID_0 = 0x8d --Ghostrick

local SETCARD_ID_0 = 0x8d --Ghostrick
local s, id, o = GetID()
function s.initial_effect(c)
	--summon limit
	local e1 = Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_SINGLE)
	e1:SetCode(EFFECT_CANNOT_SUMMON)
	e1:SetCondition(s.sumcon)
	c:RegisterEffect(e1)
	--turn set
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 0))
	e2:SetCategory(CATEGORY_POSITION)
	e2:SetType(EFFECT_TYPE_IGNITION)
	e2:SetRange(LOCATION_MZONE)
	e2:SetTarget(s.postg)
	e2:SetOperation(s.posop)
	c:RegisterEffect(e2)
	--change pos
	local e3 = Effect.CreateEffect(c)
	e3:SetDescription(aux.Stringid(id, 1))
	e3:SetCategory(CATEGORY_POSITION)
	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
	e3:SetRange(LOCATION_MZONE)
	e3:SetCondition(s.condition)
	e3:SetTarget(s.target)
	e3:SetOperation(s.operation)
	c:RegisterEffect(e3)
	local e4 = e3:Clone()
	e4:SetCode(EVENT_SUMMON_SUCCESS)
	c:RegisterEffect(e4)
end
function s.sfilter(c)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
end
function s.sumcon(e)
	return not Duel.IsExistingMatchingCard(s.sfilter, e:GetHandlerPlayer(), LOCATION_MZONE, 0, 1, nil)
end
function s.postg(e, tp, eg, ep, ev, re, r, rp, chk)
	local c = e:GetHandler()
	if chk == 0 then
		return c:IsCanTurnSet() and c:GetFlagEffect(id) == 0
	end
	c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD - RESET_TURN_SET + RESET_PHASE + PHASE_END, 0, 1)
	Duel.SetOperationInfo(0, CATEGORY_POSITION, c, 1, 0, 0)
end
function s.posop(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	if c:IsRelateToEffect(e) and c:IsFaceup() then
		Duel.ChangePosition(c, POS_FACEDOWN_DEFENSE)
	end
end
function s.condition(e, tp, eg, ep, ev, re, r, rp)
	return Duel.IsExistingMatchingCard(s.sfilter, tp, LOCATION_MZONE, 0, 1, e:GetHandler())
end
function s.filter(c, e)
	return c:IsFaceup() and c:IsLevelAbove(4) and c:IsCanTurnSet() and (not e or c:IsRelateToEffect(e))
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return eg:IsExists(s.filter, 1, nil)
	end
	Duel.SetTargetCard(eg)
	local g = eg:Filter(s.filter, nil)
	Duel.SetOperationInfo(0, CATEGORY_POSITION, g, g:GetCount(), 0, 0)
end
function s.operation(e, tp, eg, ep, ev, re, r, rp)
	if not Duel.IsExistingMatchingCard(s.sfilter, tp, LOCATION_MZONE, 0, 1, e:GetHandler()) then
		return
	end
	local g = eg:Filter(s.filter, nil, e)
	Duel.ChangePosition(g, POS_FACEDOWN_DEFENSE)
end


Ghostrick
Cannot be Normal Summoned, unless you control a "Ghostrick" monster. Once per turn: You can change this card to face-down Defense Position. When a Level 4 or higher monster(s) is Normal or Special Summoned: Change that monster(s) to face-down Defense Position. There must be another "Ghostrick" monster on the field to activate and to resolve this effect.
-- Ghostrick
local SETCARD_ID_0 = 0x8d --Ghostrick
local s, id, o = GetID()
function s.initial_effect(c)
	--summon limit
	local e1 = Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_SINGLE)
	e1:SetCode(EFFECT_CANNOT_SUMMON)
	e1:SetCondition(s.sumcon)
	c:RegisterEffect(e1)
	--turn set
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 0))
	e2:SetCategory(CATEGORY_POSITION)
	e2:SetType(EFFECT_TYPE_IGNITION)
	e2:SetRange(LOCATION_MZONE)
	e2:SetTarget(s.postg)
	e2:SetOperation(s.posop)
	c:RegisterEffect(e2)
	--change pos
	local e3 = Effect.CreateEffect(c)
	e3:SetDescription(aux.Stringid(id, 1))
	e3:SetCategory(CATEGORY_POSITION)
	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
	e3:SetRange(LOCATION_MZONE)
	e3:SetCondition(s.condition)
	e3:SetTarget(s.target)
	e3:SetOperation(s.operation)
	c:RegisterEffect(e3)
	local e4 = e3:Clone()
	e4:SetCode(EVENT_SUMMON_SUCCESS)
	c:RegisterEffect(e4)
end
function s.sfilter(c)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
end
function s.sumcon(e)
	return not Duel.IsExistingMatchingCard(s.sfilter, e:GetHandlerPlayer(), LOCATION_MZONE, 0, 1, nil)
end
function s.postg(e, tp, eg, ep, ev, re, r, rp, chk)
	local c = e:GetHandler()
	if chk == 0 then
		return c:IsCanTurnSet() and c:GetFlagEffect(id) == 0
	end
	c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD - RESET_TURN_SET + RESET_PHASE + PHASE_END, 0, 1)
	Duel.SetOperationInfo(0, CATEGORY_POSITION, c, 1, 0, 0)
end
function s.posop(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	if c:IsRelateToEffect(e) and c:IsFaceup() then
		Duel.ChangePosition(c, POS_FACEDOWN_DEFENSE)
	end
end
function s.condition(e, tp, eg, ep, ev, re, r, rp)
	return Duel.IsExistingMatchingCard(s.sfilter, tp, LOCATION_MZONE, 0, 1, e:GetHandler())
end
function s.filter(c, e)
	return c:IsFaceup() and c:IsLevelAbove(4) and c:IsCanTurnSet() and (not e or c:IsRelateToEffect(e))
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return eg:IsExists(s.filter, 1, nil)
	end
	Duel.SetTargetCard(eg)
	local g = eg:Filter(s.filter, nil)
	Duel.SetOperationInfo(0, CATEGORY_POSITION, g, g:GetCount(), 0, 0)
end
function s.operation(e, tp, eg, ep, ev, re, r, rp)
	if not Duel.IsExistingMatchingCard(s.sfilter, tp, LOCATION_MZONE, 0, 1, e:GetHandler()) then
		return
	end
	local g = eg:Filter(s.filter, nil, e)
	Duel.ChangePosition(g, POS_FACEDOWN_DEFENSE)
end

