第343页:网上宠宠店
展开二九三.网上宠宠店(将鸟、兔子、昆虫、鼹鼠放入网店销售箱在线销售)
1.用记事本打开游戏目录\data\DLC0001\scripts\prefabs\rabbit.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
inst:AddComponent("stackable")
inst.components.stackable.maxsize = 999
2.用记事本打开游戏目录\data\DLC0001\scripts\prefabs\birds.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
inst:AddComponent("stackable")
inst.components.stackable.maxsize = 999
3.用记事本打开游戏目录\data\DLC0001\scripts\prefabs\mole.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
inst:AddComponent("stackable")
inst.components.stackable.maxsize = 999
4.用记事本打开游戏目录\data\scripts\prefabs\bugnet.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
local function netsell(inst)
inst.AnimState:SetBloomEffectHandle( "shaders/anim.ksh" )
inst:DoTaskInTime(3, function() inst.AnimState:SetBloomEffectHandle( "" ) end )
if inst.components.container:Has("goldnugget", 10) then
if inst.components.container:Has("bee", 3) then
local sellnum = math.random(1,3)
inst.components.container:ConsumeByName("bee", sellnum)
inst.components.container:ConsumeByName("goldnugget", -sellnum)
end
if inst.components.container:Has("killerbee", 3) then
local sellnum = math.random(1,3)
inst.components.container:ConsumeByName("killerbee", sellnum)
inst.components.container:ConsumeByName("goldnugget", -sellnum*2)
end
if inst.components.container:Has("butterfly", 3) then
local sellnum = math.random(1,3)
inst.components.container:ConsumeByName("butterfly", sellnum)
inst.components.container:ConsumeByName("goldnugget", -sellnum)
end
if inst.components.container:Has("fireflies", 3) then
local sellnum = math.random(1,3)
inst.components.container:ConsumeByName("fireflies", sellnum)
inst.components.container:ConsumeByName("goldnugget", -sellnum*2)
end
if inst.components.container:Has("crow", 3) then
local sellnum = math.random(1,3)
inst.components.container:ConsumeByName("crow", sellnum)
inst.components.container:ConsumeByName("goldnugget", -sellnum*3)
end
if inst.components.container:Has("robin", 3) then
local sellnum = math.random(1,3)
inst.components.container:ConsumeByName("robin", sellnum)
inst.components.container:ConsumeByName("goldnugget", -sellnum*3)
end
if inst.components.container:Has("robin_winter", 3) then
local sellnum = math.random(1,3)
inst.components.container:ConsumeByName("robin_winter", sellnum)
inst.components.container:ConsumeByName("goldnugget", -sellnum*3)
end
if inst.components.container:Has("rabbit", 3) then
local sellnum = math.random(1,3)
inst.components.container:ConsumeByName("rabbit", sellnum)
inst.components.container:ConsumeByName("goldnugget", -sellnum*2)
end
if inst.components.container:Has("mole", 3) then
local sellnum = math.random(1,3)
inst.components.container:ConsumeByName("mole", sellnum)
inst.components.container:ConsumeByName("goldnugget", -sellnum*5)
end
end
end
local function OnDeploy (inst, pt)
if GetPlayer().components.inventory:Has("goldnugget", 200) then
GetPlayer().components.inventory:ConsumeByName("goldnugget", 200)
local sellbox = SpawnPrefab("bugnet")
sellbox.Transform:SetPosition(pt.x, pt.y, pt.z)
sellbox.AnimState:SetBank("bee_box")
sellbox.AnimState:SetBuild("bee_box")
sellbox.AnimState:PlayAnimation("idle")
sellbox.AnimState:SetMultColour(0/255,255/255,0/255,1)
sellbox.Transform:SetScale(1.2, 1.2, 1.2)
sellbox:AddTag("sellbox")
sellbox.components.container.canbeopened = true
sellbox:RemoveComponent("weapon")
sellbox:RemoveComponent("tool")
sellbox:RemoveComponent("finiteuses")
sellbox:RemoveComponent("inventoryitem")
sellbox:RemoveComponent("equippable")
sellbox:AddTag("fridge")
MakeLargeBurnable(sellbox)
inst:Remove()
end
end
inst:AddComponent("deployable")
inst.components.deployable.ondeploy = OnDeploy
local function onsave(inst, data)
if inst:HasTag("sellbox") then
data.sellbox = true
end
end
local function onload(inst, data)
if data and data.sellbox then
inst.AnimState:SetBank("bee_box")
inst.AnimState:SetBuild("bee_box")
inst.AnimState:PlayAnimation("idle")
inst.AnimState:SetMultColour(0/255,255/255,0/255,1)
inst.Transform:SetScale(1.2, 1.2, 1.2)
inst:AddTag("sellbox")
inst.components.container.canbeopened = true
inst:RemoveComponent("weapon")
inst:RemoveComponent("tool")
inst:RemoveComponent("finiteuses")
inst:RemoveComponent("inventoryitem")
inst:RemoveComponent("equippable")
inst:AddTag("fridge")
MakeLargeBurnable(inst)
end
end
local function itemtest(inst, item, slot)
if item.prefab == "goldnugget" or item.prefab == "bee" or item.prefab == "killerbee" or item.prefab == "butterfly" or item.prefab == "fireflies" or item.prefab == "crow" or item.prefab == "robin" or item.prefab == "robin_winter" or item.prefab == "rabbit" or item.prefab == "mole" then
return true
end
return false
end
local slotpos = {Vector3(75,150,0)}
for y = 2, 0, -1 do
for x = 0, 4 do
table.insert(slotpos, Vector3(75*x-75*2+75, 75*y-75*2+75,0))
end
end
inst.OnSave = onsave
inst.OnLoad = onload
inst:AddComponent("container")
inst.components.container:SetNumSlots(#slotpos)
inst.components.container.widgetslotpos = slotpos
inst.components.container.widgetpos = Vector3(-100,200,0)
inst.components.container.side_align_tip = 160
inst.components.container.canbeopened = false
inst.components.container.itemtestfn = itemtest
inst:DoPeriodicTask(30, function() if inst:HasTag("sellbox") then netsell(inst) end end )
即可用捕虫网种网店销售箱,将花费200个黄金,身上黄金数不足时,不给网店销售箱。左键点网店销售箱会打开格子,在箱子最顶上的格子里放入10个黄金的保证金,并放入小宠物后(几个品种都可以,但一个品种至少3只),即可在线销售。网店销售箱亮灯时,是在联网结算,打开箱子可看到商品库存的减少、黄金数量的上升,可以取出黄金用于消费,但最顶上的格子里必须保留至少10个黄金的保证金。鼹鼠定价5个黄金,鸟定价3个黄金,杀人蜂、萤火虫、兔子定价2个黄金,蜜蜂、蝴蝶定价1个黄金,当某种商品库存不足3只时,该品种将无人购买,请及时检查并补货。千万不要将黄金放在下面的商品格中,而将最顶上的保证金格子空着,这代表所有商品定价0个黄金,小心被哄抢哦。从此经营自己的网上宠宠店,捕捉小宠物在线销售吧。不需要网店销售箱时,烧掉即可,记得取出黄金和商品哦
更多相关内容请关注:饥荒专区
责任编辑:Shy夏夏