代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
1
2二五八.强迫症标尺(按键盘Insert键在地上画坐标,方便建造、种植,再按Insert键消失)
3
4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("playeractionpicker")的下一行插入以下内容:
5
6TheInput:AddKeyUpHandler(KEY_INSERT, function()
7 if not inst:HasTag("ruler") then
8 inst:AddTag("ruler")
9 local pt = inst:GetPosition()
10 for y = 10, 0, -1 do
11 for x = 0, 10 do
12 local coordinate = SpawnPrefab("gridplacer")
13 coordinate.AnimState:SetOrientation( ANIM_ORIENTATION.OnGround )
14 coordinate.AnimState:SetLayer( LAYER_BACKGROUND )
15 coordinate.AnimState:SetSortOrder( 1 )
16 coordinate.Transform:SetRotation( 45 )
17 coordinate.Transform:SetPosition(pt.x-14.1+x*2.82, 0, pt.z-14.1+y*2.82)
18 local light = coordinate.entity:AddLight()
19 light:SetIntensity(.6)
20 light:SetRadius(.5)
21 light:SetFalloff(.6)
22 light:Enable(true)
23 light:SetColour(180/255, 195/255, 225/255)
24 coordinate:AddTag("NOCLICK")
25 coordinate:AddTag("coordinate")
26 end
27 end
28 else
29 inst:RemoveTag("ruler")
30 local pos = Vector3(inst.Transform:GetWorldPosition())
31 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000)
32 for k,v in pairs(ents) do
33 if v:HasTag("coordinate") then
34 v:Remove()
35 end
36 end
37 end
38end )
39
40 即可按键盘Insert键,以主角为中心在地上画出白色坐标,可作为建造或种植的参照线,也可测量你现有的建筑、植物是不是歪了,强迫症必备,还有夜光效果哦,再按一次Insert键坐标消失