Jump to content

Recommended Posts

player:PushEvent("respawnfromghost", {cause = "testrespawn"}) <-- in another file where its being used

STRINGS.NAMES.TESTRESPAWN = "Test Respawn" <-- In modmain

Anyone know whats wrong, or how to do it? as its still saying "Shenanigans"

Edited by Aquaterion
Link to comment
https://forums.kleientertainment.com/forums/topic/65081-custom-cause-of-respawn/
Share on other sites

Ok so trying that crashed me, but in the background, I could see that it did work

 

[00:02:00]: [string "scripts/prefabs/player_common.lua"]:888: attempt to index field 'components' (a nil value)
LUA ERROR stack traceback:
scripts/prefabs/player_common.lua:888 in (local) fn (Lua) <850-890>
   inst = 108092 - webber (valid:true)
   data = table: 5281C5D0
scripts/entityscript.lua:959 in (method) PushEvent (Lua) <953-976>
   self (valid:true) =
      DynamicShadow = DynamicShadow (32888D28)
      inlimbo = false
      GetMoistureRateScale = function - scripts/prefabs/player_common.lua:86
      SetCameraDistance = function - scripts/prefabs/player_common.lua:1208
      ScreenFlash = function - scripts/prefabs/player_common.lua:1270
      player_classified = 108093 - player_classified (valid:true)
      playercolour = table: 4024EA48
      health_info_max = 175
      IsOverheating = function - scripts/prefabs/player_common.lua:56
      Light = Light (3288CA28)
      _isrezattuned = false
      OnRemoveEntity = function - scripts/prefabs/player_common.lua:568
      health_info_max_exact = 175
      pendingtasks = table: 53CC8080
      ShowHUD = function - scripts/prefabs/player_common.lua:1190
      ShowGiftItemPopUp = function - scripts/prefabs/player_common.lua:1202
      sg = sg="wilsonghost", state="haunt_pre", time=0.50, tags = "doing,busy,"
      IsHUDVisible = function - scripts/prefabs/player_common.lua:1180
      ApplyScale = function - scripts/prefabs/player_common.lua:1285
      SetGhostMode = function - scripts/prefabs/player_common.lua:476
      ShowActions = function - scripts/prefabs/player_common.lua:1184
      HUD = HUD
      OnWakeUp = function - scripts/prefabs/player_common.lua:1122
      Transform = Transform (3288A928)
      actionreplica = table: 53CC7428
      event_listening = table: 53CC8198
      actioncomponents = table: 53CC7270
      lower_components_shadow = table: 53CC71F8
      GetMaxMoisture = function - scripts/prefabs/player_common.lua:76
      net_health_info = net_ushortint (4026A9D0)
      prefab = webber
      updatecomponents = table: 53CCA948
      ShakeCamera = function - scripts/prefabs/player_common.lua:1228
      OnDespawn = function - scripts/prefabs/player_common.lua:1140
      persists = false
      MiniMapEntity = MiniMapEntity (32889988)
      IsFreezing = function - scripts/prefabs/player_common.lua:46
      health_info_exact = 50
      replica = table: 53CC7220
      GetTemperature = function - scripts/prefabs/player_common.lua:36
      GUID = 108092
      ghostenabled = true
      EnableMovementPrediction = function - scripts/prefabs/player_common.lua:437
      worldstatewatching = table: 40289A88
      SetCameraZoomed = function - scripts/prefabs/player_common.lua:1214
      Network = Network (32888388)
      userid = KU_ynbQpeyv
      OnPreLoad = function - scripts/prefabs/player_common.lua:1028
      LightWatcher = LightWatcher (3288ED28)
      inherentactions = table: 4019AE90
      spawntime = 0.033333335071802
      SnapCamera = function - scripts/prefabs/player_common.lua:1220
      rezsource = Test Respawn
      ScreenFade = function - scripts/prefabs/player_common.lua:1261
      bufferedaction = Haunt 108903 - testitem (valid:true)
      entity = Entity (610918A8)
      health_info = 50
      net_health_info_max = net_ushortint (4026AA08)
      AttachClassified = function - scripts/prefabs/player_common.lua:557
      name = Aquaterion
      IsActionsVisible = function - scripts/prefabs/player_common.lua:1174
      OnSleepIn = function - scripts/prefabs/player_common.lua:1094
      OnSave = function - scripts/prefabs/player_common.lua:1002
      SoundEmitter = SoundEmitter (3288ADA8)
      ShowWardrobePopUp = function - scripts/prefabs/player_common.lua:1196
      GetMoisture = function - scripts/prefabs/player_common.lua:66
      AnimState = AnimState (3288DA08)
      OnLoad = function - scripts/prefabs/player_common.lua:1038
      event_listeners = table: 53CC8120
      DetachClassified = function - scripts/prefabs/player_common.lua:563
      talker_path_override = dontstarve_DLC001/characters/
      components = table: 53CC7248
[00:02:00]: [string "scripts/prefabs/player_common.lua"]:888: attempt to index field 'components' (a nil value)
LUA ERROR stack traceback:
    scripts/prefabs/player_common.lua:888 in (local) fn (Lua) <850-890>
    scripts/entityscript.lua:959 in (method) PushEvent (Lua) <953-976>
    ../mods/newmod/scripts/prefabs/modprefab.lua:92 in (upvalue) onuserespawn (Lua) <48-128>
    ../mods/newmod/scripts/prefabs/modprefab.lua:131 in (upvalue) fn (Lua) <130-132>
    scripts/standardcomponents.lua:1017 in (field) onhaunt (Lua) <1009-1029>
    scripts/components/hauntable.lua:101 in (method) DoHaunt (Lua) <99-125>
    scripts/actions.lua:1080 in (field) fn (Lua) <1072-1083>
    scripts/bufferedaction.lua:24 in (method) Do (Lua) <20-34>
    scripts/entityscript.lua:1233 in (method) PerformBufferedAction (Lua) <1225-1243>
    scripts/stategraphs/SGwilsonghost.lua:193 in (field) fn (Lua) <192-194>
    scripts/stategraph.lua:568 in (method) UpdateState (Lua) <536-580>
    scripts/stategraph.lua:607 in (method) Update (Lua) <599-627>
    scripts/stategraph.lua:125 in (method) Update (Lua) <109-148>
    scripts/update.lua:209 in () ? (Lua) <150-223>
   

2 minutes ago, Muche said:

Yeah, source is expected to be an entity, so it's still a hack


player:PushEvent("respawnfromghost", { source = { name = "Test Respawn", components = {} } } )

 

Awesome, thanks man, you're like the only person that ever replies to my posts ^^ How can I easily find where these functions and stuff are being called? I always wanna see what variables things use, but I can rarely actually find them..

I just search all lua files under scripts folder.

For events it's either ListenForEvent("<eventname>" or PushEvent("<eventname>", depending on whether you want to find out what is handling or firing the event, then more searching for declarations of functions and reading how they are handling their parameters. And possibly adding some debug prints that print name of the current function (or other unique identifier) and values of variables of interest.

For general overview, I read

and other guides it refers to.

Edited by Muche
2 minutes ago, Muche said:

I just search all lua files under scripts folder.

For events it's either ListenForEvent("<eventname>" or PushEvent("<eventname>", depending on whether you want to find out what is handling or firing the event, then more searching for declarations of functions and reading how they are handling their parameters. And possibly adding some debug prints that print name of the current function (or other unique identifier) and values of variables of interest.

I'm sure searching each lua file 1 by 1 would take a long time, is there something you use to quickly search all of them?

I use Far manager, I'm sure any other decent file manager would have similar function of searching all files with a specified extension under a folder.

I guess it's possible to setup the search in vanilla Windows as well, I just never bothered to find out how to do it.

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...