第328页:地皮改造机
展开二七八.地皮改造机(用排箫种地皮改造机,一次铺70块地皮)
用记事本打开游戏目录\data\scripts\prefabs\panflute.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
local function itemtest(inst, item, slot)
if item.prefab == "turf_road" or item.prefab == "turf_rocky" or item.prefab == "turf_forest" or item.prefab == "turf_marsh" or item.prefab == "turf_grass" or item.prefab == "turf_savanna" or item.prefab == "turf_dirt" or item.prefab == "turf_woodfloor" or item.prefab == "turf_carpetfloor" or item.prefab == "turf_checkerfloor" or item.prefab == "turf_cave" or item.prefab == "turf_fungus" or item.prefab == "turf_fungus_red" or item.prefab == "turf_fungus_green" or item.prefab == "turf_sinkhole" or item.prefab == "turf_underrock" or item.prefab == "turf_mud" then
return true
end
return false
end
local slotpos = { Vector3(0,-75,0)}
local widgetbuttoninfo = {
text = "Do",
position = Vector3(0, -135, 0),
fn = function(inst)
if inst:HasTag("turfmachines") then
if not inst.components.container:IsEmpty() then
for k,v in pairs(inst.components.container.slots) do
if v and v.prefab == "turf_road" then inst.rug = GROUND.ROAD end
if v and v.prefab == "turf_rocky" then inst.rug = GROUND.ROCKY end
if v and v.prefab == "turf_forest" then inst.rug = GROUND.FOREST end
if v and v.prefab == "turf_marsh" then inst.rug = GROUND.MARSH end
if v and v.prefab == "turf_grass" then inst.rug = GROUND.GRASS end
if v and v.prefab == "turf_savanna" then inst.rug = GROUND.SAVANNA end
if v and v.prefab == "turf_dirt" then inst.rug = GROUND.DIRT end
if v and v.prefab == "turf_woodfloor" then inst.rug = GROUND.WOODFLOOR end
if v and v.prefab == "turf_carpetfloor" then inst.rug = GROUND.CARPET end
if v and v.prefab == "turf_checkerfloor" then inst.rug = GROUND.CHECKER end
if v and v.prefab == "turf_cave" then inst.rug = GROUND.CAVE end
if v and v.prefab == "turf_fungus" then inst.rug = GROUND.FUNGUS end
if v and v.prefab == "turf_fungus_red" then inst.rug = GROUND.FUNGUSRED end
if v and v.prefab == "turf_fungus_green" then inst.rug = GROUND.FUNGUSGREEN end
if v and v.prefab == "turf_sinkhole" then inst.rug = GROUND.SINKHOLE end
if v and v.prefab == "turf_underrock" then inst.rug = GROUND.UNDERROCK end
if v and v.prefab == "turf_mud" then inst.rug = GROUND.MUD end
v:Remove()
end
local pt = GetPlayer():GetPosition()
for y = 10, 0, -1 do
for x = 0, 10 do
local tile = GetWorld().Map:GetTileAtPoint(pt.x-2.1*x+2.1*y-10.5+10.5, pt.y, pt.z+2.1*x+2.1*y-10.5-10.5)
if tile ~= GROUND.IMPASSABLE then
local original_tile_type = GetWorld().Map:GetTileAtPoint(pt.x-2.1*x+2.1*y-10.5+10.5, pt.y, pt.z+2.1*x+2.1*y-10.5-10.5)
local x, y = GetWorld().Map:GetTileCoordsAtPoint(pt.x-2.1*x+2.1*y-10.5+10.5, pt.y, pt.z+2.1*x+2.1*y-10.5-10.5)
GetWorld().Map:SetTile(x,y, inst.rug)
GetWorld().Map:RebuildLayer( original_tile_type, x, y )
GetWorld().Map:RebuildLayer( inst.rug, x, y )
local minimap = TheSim:FindFirstEntityWithTag("minimap")
minimap.MiniMap:RebuildLayer( original_tile_type, x, y )
minimap.MiniMap:RebuildLayer( inst.rug, x, y )
end
end
end
end
end
end }
local function OnDeploy (inst, pt)
local turfmachine = SpawnPrefab("panflute")
turfmachine.Transform:SetPosition(pt.x, pt.y, pt.z)
turfmachine.AnimState:SetBank("researchlab3")
turfmachine.AnimState:SetBuild("researchlab3")
turfmachine.AnimState:PlayAnimation("idle")
turfmachine.Transform:SetScale(0.5, 0.5, 0.5)
turfmachine:RemoveComponent("instrument")
turfmachine:RemoveComponent("tool")
if turfmachine.components.finiteuses then turfmachine:RemoveComponent("finiteuses") end
turfmachine:RemoveComponent("deployable")
turfmachine.components.container.canbeopened = true
turfmachine.components.inventoryitem:ChangeImageName("researchlab3")
turfmachine:AddComponent("equippable")
turfmachine.components.equippable.equipslot = EQUIPSLOTS.BODY
turfmachine.components.equippable:SetOnEquip( function(turfmachine)
GetPlayer().components.inventory:SetOverflow(turfmachine)
turfmachine.components.container:Open(GetPlayer())
GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/backpack_open", "open")
end )
turfmachine.components.equippable:SetOnUnequip( function(turfmachine)
turfmachine.components.container:Close(GetPlayer())
GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/backpack_close", "open")
end )
turfmachine:AddTag("turfmachines")
inst:Remove()
end
inst:AddComponent("deployable")
inst.components.deployable.ondeploy = OnDeploy
local function onsave(inst, data)
if inst:HasTag("turfmachines") then
data.turfmachines = true
end
end
local function onload(inst, data)
if data and data.turfmachines then
inst.AnimState:SetBank("researchlab3")
inst.AnimState:SetBuild("researchlab3")
inst.AnimState:PlayAnimation("idle")
inst.Transform:SetScale(0.5, 0.5, 0.5)
inst:RemoveComponent("instrument")
inst:RemoveComponent("tool")
if inst.components.finiteuses then inst:RemoveComponent("finiteuses") end
inst:RemoveComponent("deployable")
inst.components.container.canbeopened = true
inst.components.inventoryitem:ChangeImageName("researchlab3")
inst:AddComponent("equippable")
inst.components.equippable.equipslot = EQUIPSLOTS.BODY
inst.components.equippable:SetOnEquip( function(inst)
GetPlayer().components.inventory:SetOverflow(inst)
inst.components.container:Open(GetPlayer())
GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/backpack_open", "open")
end )
inst.components.equippable:SetOnUnequip( function(inst)
inst.components.container:Close(GetPlayer())
GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/backpack_close", "open")
end )
inst:AddTag("turfmachines")
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(-80,150,0)
inst.components.container.side_widget = true
inst.components.container.itemtestfn = itemtest
inst.components.container.widgetbuttoninfo = widgetbuttoninfo
inst.components.container.acceptsstacks = false
inst.components.container.canbeopened = false
即可用排箫种地皮改造机,装备地皮改造机后,屏幕右侧将出现格子和按钮,在格子中放入1块地皮,按Do按钮,游戏会卡一下(5-10秒),70块地皮就铺好了,方便大面积改造地图。共支持17种地皮,只要可以放入格子的都可以铺。排箫在魔法选项(画着红骷髅)下用5个芦苇、1个曼德拉草、1个绳子制造
更多相关内容请关注:饥荒专区
责任编辑:Shy夏夏