Sign in to follow this  
Revanchist

NEED HELP WITH LIGHTNING STRIKE

Recommended Posts

Revanchist    0

Hi, i not really good know english but i try.

I wanna do lightning strike for my character and i wrote this code.

  1. local function ThunderSpell(inst)
  2.     if not (GLOBAL.TheWorld and GLOBAL.TheWorld.ismastersim) then return end
  3.     local player=GLOBAL.ThePlayer
  4.     local cheksan = player.components.sanity:GetPercent()
  5.     if cheksan >= .25 then
  6.     player.components.health.invincible = true
  7.         local pt = GLOBAL.ConsoleWorldPosition()
  8.             GLOBAL.TheWorld:PushEvent("ms_sendlightningstrike", pt)
  9.     player.components.sanity:DoDelta(-50)
  10.     inst.AnimState:PlayAnimation("punch")
  11.     player.components.health.invincible = false
  12.     else 
  13.     player.components.talker:Say("The Force is leaving me...")
  14.     end
  15. end
  16.  
  17. local hk_light = GLOBAL.KEY_C
  18.  
  19. AddModRPCHandler(modname, "ThunderSpell", function(inst)
  20.     ThunderSpell(inst)
  21. end)
  22.  
  23. if hk_light then
  24. GLOBAL.TheInput:AddKeyDownHandler(hk_light, function()
  25.     local player=GLOBAL.ThePlayer
  26.     if player and player.prefab=="revan" and not GLOBAL.IsPaused()
  27.         and not GLOBAL.TheInput:IsKeyDown(GLOBAL.KEY_CTRL) 
  28.         and not GLOBAL.TheInput:IsKeyDown(GLOBAL.KEY_SHIFT)
  29.         and not (player.HUD:IsChatInputScreenOpen() or player.HUD:IsConsoleScreenOpen()) then
  30.             SendModRPCToServer(MOD_RPC[modname]["ThunderSpell"])
  31.      end
  32.     end)
  33. end    

So, its work perfect when i host but when i add cave my server stops after i press button

I will be glad if you can help.

Edited by Revanchist

Share this post


Link to post
Share on other sites
pickleplayer    191

you'll probably need to take a look at the crash log, which is in a different place than the usual crash log if you're hosting a caves server.

You can check under Documents/Klei/DoNotStarveTogether/(bunch of numbers)/Cluster_#/Master/server_log.txt

Share this post


Link to post
Share on other sites
Revanchist    0

It seems he.

[00:03:44]: [string "../mods/build 0.97/modmain.lua"]:172: attempt to index local 'player' (a nil value)
LUA ERROR stack traceback:
../mods/build 0.97/modmain.lua:172 in (upvalue) ThunderSpell (Lua) <169-183>
   inst = 116491 - revan (valid:true)
   player = nil
../mods/build 0.97/modmain.lua:273 in () ? (Lua) <272-274>
   inst = 116491 - revan (valid:true)
   target = nil
=[C]:-1 in (method) CallRPC (C) <-1--1>
scripts/networkclientrpc.lua:1070 in (global) HandleRPCQueue (Lua) <1061-1106>
   i = 1
   fn = function - ../mods/build 0.97/modmain.lua:272
   sender = 116491 - revan (valid:true)
   data = table: 2CA56130
   tick = true
scripts/update.lua:46 in () ? (Lua) <33-134>
   dt = 0.016640100628138

[00:03:44]: [string "../mods/build 0.97/modmain.lua"]:172: attempt to index local 'player' (a nil value)
LUA ERROR stack traceback:
    ../mods/build 0.97/modmain.lua:172 in (upvalue) ThunderSpell (Lua) <169-183>
    ../mods/build 0.97/modmain.lua:273 in () ? (Lua) <272-274>
    =[C]:-1 in (method) CallRPC (C) <-1--1>
    scripts/networkclientrpc.lua:1070 in (global) HandleRPCQueue (Lua) <1061-1106>
    scripts/update.lua:46 in () ? (Lua) <33-134>
    
[00:03:44]: Warning: Widget:SetFocusFromChild is happening on a widget outside of the screen/widget hierachy. This will cause focus moves to fail. Is     ScriptErrorWidget    not a screen?    
[00:03:44]: stack traceback:
    scripts/widgets/widget.lua:604 in (method) SetFocusFromChild (Lua) <601-626>
    scripts/widgets/widget.lua:623 in (method) SetFocusFromChild (Lua) <601-626>
    scripts/widgets/widget.lua:623 in (method) SetFocusFromChild (Lua) <601-626>
    scripts/widgets/widget.lua:648 in (method) SetFocus (Lua) <628-657>
    scripts/widgets/menu.lua:83 in (method) SetFocus (Lua) <74-85>
    scripts/widgets/scripterrorwidget.lua:109 in (method) OnUpdate (Lua) <102-119>
    scripts/update.lua:95 in () ? (Lua) <33-134>    

 

server_log.txt

Share this post


Link to post
Share on other sites
Revanchist    0
On 3/15/2021 at 4:23 AM, pickleplayer said:

you'll probably need to take a look at the crash log, which is in a different place than the usual crash log if you're hosting a caves server.

You can check under Documents/Klei/DoNotStarveTogether/(bunch of numbers)/Cluster_#/Master/server_log.txt

I will also add my modmain.lua, just in case

modmain.lua

Share this post


Link to post
Share on other sites

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
Sign in to follow this