Jump to content

Recommended Posts

Hello,

i want to create a mod to ass the masked pig bandit in shipwrecked (when towns are presents).

It's my first mod :/

Error in client log file :

 

...common/dont_starve/data/../mods/anchocho/modmain.lua:79: attempt to index global 'inst' (a nil value)
LUA ERROR stack traceback:
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/../mods/anchocho/modmain.lua(79,1) in main chunk
        =[C] in function 'xpcall'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/util.lua(552,1) in function 'RunInEnvironment'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/mods.lua(217,1) in function 'InitializeModMain'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/mods.lua(198,1) in function 'LoadMods'
        scripts/main.lua(273,1) in function 'ModSafeStartup'
        scripts/main.lua(320,1)
        =[C] in function 'SetPersistentString'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/mainfunctions.lua(26,1) in function 'SavePersistentString'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/modindex.lua(68,1)
        =[C] in function 'GetPersistentString'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/modindex.lua(55,1) in function 'BeginStartupSequence'
        scripts/main.lua(319,1) in function 'callback'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/modindex.lua(338,1)
        =[C] in function 'GetPersistentString'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/modindex.lua(318,1) in function 'Load'
        scripts/main.lua(318,1) in main chunk
	
[00:00:38]: scripts/mods.lua(206,1) Mod: workshop-712470670 ( [DS]Aerial view)	Loading modworldgenmain.lua	
[00:00:38]: scripts/mods.lua(214,1) Mod: workshop-712470670 ( [DS]Aerial view)	  Mod had no modworldgenmain.lua. Skipping.	
[00:00:38]: scripts/mods.lua(206,1) Mod: workshop-712470670 ( [DS]Aerial view)	Loading modmain.lua	

 

i suppose it's this line who create the error in modmain.lua :

inst:AddComponent("banditmanager")

( my mod is attached.)

thanks

 

 

 

anchocho.zip

You can't just call a function on something that doesn't exist. inst is nowhere in your code here, except in your commented lines above it where you tried to spawn the world for some reason.

Try this:

GLOBAL.GetWorld():AddComponent("banditmanager")

That should work. I haven't looked at the actual banditmanager script, though.

Thanks Ultroman for your help.

I have used

Quote

GLOBAL.GetWorld():AddComponent("banditmanager")

--> and the log file say :

Quote

...common/dont_starve/data/../mods/anchocho/modmain.lua:103: attempt to index a nil value
LUA ERROR stack traceback:
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/../mods/anchocho/modmain.lua(103,1) in main chunk
        =[C] in function 'xpcall'

 

And when i use :

Quote

local inst = GLOBAL.GetWorld()
AddComponentPostInit("world", function(inst)
  inst:AddComponent("banditmanager")
end)

--> the game crash only if i use the command line : c_spawn("pigbandit")

Log :

Quote

[00:01:24]: .../data/../mods/anchocho/scripts/prefabs/pigbandit.lua:216: attempt to index field 'banditmanager' (a nil value)
LUA ERROR stack traceback:
C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/../mods/anchocho/scripts/prefabs/pigbandit.lua:216 in (field) fn (Lua) <214-218>

Have you an idea ?

 

 

anchocho.zip

World isn't a component, it's a prefab. AddComponentPostInit is for altering components. Try AddPrefabPostInit instead. And you don't need the preceding line:

local inst = GLOBAL.GetWorld()

I don't understand why GLOBAL.GetWorld() is nil in your modmain, though.

Edited by Ultroman

Thanks a lot for your help :)

i have used AddPrefabPostInit like this :

Quote

AddPrefabPostInit("world", function(inst)
  inst:AddComponent("banditmanager")
end)

But i obtain the same message when the game crash :

Quote

[00:01:27]: .../data/../mods/anchocho/scripts/prefabs/pigbandit.lua:216: attempt to index field 'banditmanager' (a nil value)
LUA ERROR stack traceback:
C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/../mods/anchocho/scripts/prefabs/pigbandit.lua:216 in (field) fn (Lua) <214-218>

I hope Klei will add the masked pig in shipwrecked and RoG in the futur...

Well, now I spent a stupid amount of time looking at this, in order to successfully procrastinate from the much more important and pertinent things I have to do, and I have to say that it would (probably?) be a mountain of work to get the bandit into Shipwrecked. After adding the bandit hat properly and actually getting the bandit to spawn in the game, it crashed because it requires changes to the locomotor component, and probably has a bunch of other functionality from Hamlet that it needs in order to...live. So I dropped it.

Porting mods is probably a bit too tall an order for your first mod.

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