Jump to content

Recommended Posts

Hello! I want to add the ability to trigger the telelocator staff on diffrents structures. If i add this code: 

AddPrefabPostInit("statueglommer", function(inst)
	inst:AddComponent("locomotor")
	inst.components.locomotor.walkspeed = 0
	inst.components.locomotor.runspeed = 0
end)

in my modmain.lua, this work, and work with "pond", "statueglommer", "sanityrock", "pigking", "gravestone", "pigtorch" and etc. But when i try add "tallbirdnest" or "mound" and maybee something else, server don't start whith this problem:

Spoiler

[00:03:09]: [string "scripts/components/locomotor.lua"]:293: attempt to index field 'Physics' (a nil value)
LUA ERROR stack traceback:
scripts/components/locomotor.lua:293 in (method) StopMoving (Lua) <291-294>
   self =
      slowmultiplier = 0.6
      IsFasterOnGroundTile = function - scripts/components/locomotor.lua:170
      faster_on_tiles = table: 3732EE28
      RunSpeed = function - scripts/components/locomotor.lua:63
      wantstorun = false
      wantstomoveforward = false
      hop_distance = 6
      _externalspeedmultipliers = table: 3732EFB8
      throttle = 1
      inst = 112578 - tallbirdnest (valid:true)
      isrunning = false
      fastmultiplier = 1.3
      time_before_next_hop_is_allowed = 0
      wasoncreep = false
      ExternalSpeedMultiplier = function - scripts/components/locomotor.lua:120
      triggerscreep = true
      hopping = false
      groundspeedmultiplier = 1
      is_prediction_enabled = false
      arrive_step_dist = 0.15
      arrive_dist = 0.15
      enablegroundspeedmultiplier = true
      ismastersim = true
      GetSpeedMultiplier = function - scripts/components/locomotor.lua:128
      FasterOnCreep = function - scripts/components/locomotor.lua:101
      FasterOnRoad = function - scripts/components/locomotor.lua:82
      lastpos = table: 3732EB58
      _ = table: 3732E9A0
      walkspeed = 0
scripts/components/locomotor.lua:759 in (method) Stop (Lua) <742-764>
   self =
      slowmultiplier = 0.6
      IsFasterOnGroundTile = function - scripts/components/locomotor.lua:170
      faster_on_tiles = table: 3732EE28
      RunSpeed = function - scripts/components/locomotor.lua:63
      wantstorun = false
      wantstomoveforward = false
      hop_distance = 6
      _externalspeedmultipliers = table: 3732EFB8
      throttle = 1
      inst = 112578 - tallbirdnest (valid:true)
      isrunning = false
      fastmultiplier = 1.3
      time_before_next_hop_is_allowed = 0
      wasoncreep = false
      ExternalSpeedMultiplier = function - scripts/components/locomotor.lua:120
      triggerscreep = true
      hopping = false
      groundspeedmultiplier = 1
      is_prediction_enabled = false
      arrive_step_dist = 0.15
      arrive_dist = 0.15
      enablegroundspeedmultiplier = true
      ismastersim = true
      GetSpeedMultiplier = function - scripts/components/locomotor.lua:128
      FasterOnCreep = function - scripts/components/locomotor.lua:101
      FasterOnRoad = function - scripts/components/locomotor.lua:82
      lastpos = table: 3732EB58
      _ = table: 3732E9A0
      walkspeed = 0
   sgparams = nil
scripts/components/locomotor.lua:272 in (method) OnEntitySleep (Lua) <271-273>
   self =
      slowmultiplier = 0.6
      IsFasterOnGroundTile = function - scripts/components/locomotor.lua:170
      faster_on_tiles = table: 3732EE28
      RunSpeed = function - scripts/components/locomotor.lua:63
      wantstorun = false
      wantstomoveforward = false
      hop_distance = 6
      _externalspeedmultipliers = table: 3732EFB8
      throttle = 1
      inst = 112578 - tallbirdnest (valid:true)
      isrunning = false
      fastmultiplier = 1.3
      time_before_next_hop_is_allowed = 0
      wasoncreep = false
      ExternalSpeedMultiplier = function - scripts/components/locomotor.lua:120
      triggerscreep = true
      hopping = false
      groundspeedmultiplier = 1
      is_prediction_enabled = false
      arrive_step_dist = 0.15
      arrive_dist = 0.15
      enablegroundspeedmultiplier = true
      ismastersim = true
      GetSpeedMultiplier = function - scripts/components/locomotor.lua:128
      FasterOnCreep = function - scripts/components/locomotor.lua:101
      FasterOnRoad = function - scripts/components/locomotor.lua:82
      lastpos = table: 3732EB58
      _ = table: 3732E9A0
      walkspeed = 0
scripts/mainfunctions.lua:582 in () ? (Lua) <561-587>
   guid = 112578
   inst = 112578 - tallbirdnest (valid:true)
   k = locomotor
   v = table: 3732E978
=[C]:-1 in (method) SetPosition (C) <-1--1>
scripts/mainfunctions.lua:372 in (global) SpawnSaveRecord (Lua) <363-405>
   saved = tab
[00:03:09]: [string "scripts/components/locomotor.lua"]:293: attempt to index field 'Physics' (a nil value)
LUA ERROR stack traceback:
    scripts/components/locomotor.lua:293 in (method) StopMoving (Lua) <291-294>
    scripts/components/locomotor.lua:759 in (method) Stop (Lua) <742-764>
    scripts/components/locomotor.lua:272 in (method) OnEntitySleep (Lua) <271-273>
    scripts/mainfunctions.lua:582 in () ? (Lua) <561-587>
    =[C]:-1 in (method) SetPosition (C) <-1--1>
    scripts/mainfunctions.lua:372 in (global) SpawnSaveRecord (Lua) <363-405>
    scripts/gamelogic.lua:586 in (upvalue) PopulateWorld (Lua) <349-620>
    scripts/gamelogic.lua:844 in (upvalue) DoInitGame (Lua) <719-923>
    scripts/gamelogic.lua:957 in (local) cb (Lua) <951-958>
    scripts/shardindex.lua:209 in (upvalue) OnLoadSaveDataFile (Lua) <191-210>
    scripts/shardindex.lua:214 in () ? (Lua) <213-215>
    =[C]:-1 in (method) GetPersistentString (C) <-1--1>
    
[00:03:24]: Reconstructing topology    
[00:03:24]:     ...Sorting points    
[00:03:24]:     ...Sorting edges    
[00:03:24]:     ...Connecting nodes    
[00:03:24]:     ...Validating connections    
[00:03:24]:     ...Housekeeping    
[00:03:24]:     ...Done!    
[00:03:24]: 1 uploads added to server. From server_temp
[00:03:24]: About to start a shard with these settings:
[00:03:24]:   ShardName: [SHDMASTER]
[00:03:24]:   ShardID: 1
[00:03:24]:   ShardRole: MASTER
[00:03:24]:   MasterHost: (null)
[00:03:24]:   MasterBind: 127.0.0.1
[00:03:24]:   MasterPort: 10888
[00:03:24]: [Shard] Starting master server
[00:03:24]: [Warning] Could not confirm port 10888 is open in the firewall. 
[00:03:24]: [Shard] Shard server started on port: 10888
[00:03:24]: [IPC] Signal 'DST_Master_Ready' opened  #00000698
[00:03:24]: [IPC] Sending signal... #00000698
[00:03:24]: Telling Client our new session identifier: 33FE62C6B9D1F712
[00:03:24]: Check for write access: TRUE
[00:03:24]: Check for read access: TRUE
[00:03:24]: Available disk space for save files: 72263 MB
[00:03:24]: ModIndex: Load sequence finished successfully.    
[00:04:32]: Reset() returning
[00:04:32]: Registering master server in EU lobby
[00:04:33]: [Shard] Secondary shar Caves(1613285401) connected: [LAN] 127.0.0.1

Please help me with this problem, i am new in modding and don't understand much.

The error code already tells you what the problem is, tallbirdnest and mound have no Physics.

If you have a look at the prefabs, you can see that the prefabs that work all have this function called:

--From pigking.lua
MakeObstaclePhysics(inst, 2, .5)

If you look for this function, you an find it in standardcomponents.lua:

function MakeObstaclePhysics(inst, rad, height)
    inst:AddTag("blocker")
    local phys = inst.entity:AddPhysics()
    phys:SetMass(0) --Bullet wants 0 mass for static objects
    phys:SetCollisionGroup(COLLISION.OBSTACLES)
    phys:ClearCollisionMask()
    phys:CollidesWith(COLLISION.ITEMS)
    phys:CollidesWith(COLLISION.CHARACTERS)
    phys:CollidesWith(COLLISION.GIANTS)
    phys:SetCapsule(rad, height or 2)
    return phys
end

This means, you will need to add physics to these prefabs. I don't know if just adding inst.entity:AddPhysics() to the AddPrefabPostInit will be enough so that these prefabs still have no collision, you will need to test that out ;)

 

  • Like 2

@Monti18

Thanks a lot! I add only one string in code:

AddPrefabPostInit("tallbirdnest", function(inst)
	inst.entity:AddPhysics()
	inst:AddComponent("locomotor")
	inst.components.locomotor.walkspeed = 0
	inst.components.locomotor.runspeed = 0
end)

and it all worked! :-)

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...