Jump to content

Recommended Posts

Hi There!

I'm new at modelling and try to create my character and put an item to it. I followed every steps I found on a forum Here.

 

The Character :

To create my character, I took scripts from other chars to make sure it works cause after hundred crashes I found myself very bad in scripting. The char I used was Wigfrid (Fighting script), Wickerbottom (Picky eater script) and Jack Torrance from the workshop (Insanity script). Then I added a really basic scripts for having Light radius when holding the item, then got to put this on my char instead on the item. Whatever, now game is crashing, referring the error to my character prefabs...

 

Things I want him to do :

Carrying the item

Red light radius (Firefly script)

High damage (Wigfrid script)

High damage when crazy (Jack Torrance script)

Picky eater (Wickerbottom script)

 

The Item :

As mentioned, I created an item using the very simple guide in the link above. It did crash a lot of time, I changed a lot of things and began to think I just can't understand how we make it. Now, I'm asking why it is not working properly? I attach files of my char in a .zip to show the scripts I have and hope someone can help me out.

 

Things I want it does :

Keep on death

Walkspeed +++ (walking cane script?)

Dapperness - Crazyness +++ (amulet script)

 

I used to make it works somehow, but then changed many values here and there to finaly get so many crashes I just can't remember what's really going on...

 

Thanx.

B3tw33_w0rld

 

Maleficum.zip

Anyone please?

Is there a order to follow when you place local fonctions?

Some are local fonction FN, local fonction fn (Sim) 

or (inst) or (inst, data),

comon post_init, master post_init,

what the hell is all that ?!?! Fn (SIM)??

Im deeply lost.

Off course I added "--" before each states where it mentions the items (Philosopher Stone) to disable it when I launch the game, to test my char without the item. Unfortunately, the game crashes anyway! Item or Not!

 

So if you want to test it out with the philosopher stone, get the "--" away so it loads the item and all its assets.

 

Ask if you need more information.

 

@D4rkh0bb1T, could you provide the crash log? After you crash you should find it in Documents/Klei/DoNoNotStarveTogether/log

 

The forum you used to learn scripting is alright but quite outdated (and meant for the singleplayer version).  Instead, I recommend following DragonWolfLeo's tutorial on the Extended Sample Character she made. But chances are, your mod might be set up wrong (and the scripting might be fine). This is why the crash log could come in handy, to see what exactly is crashing the game.

 

 

Is there a order to follow when you place local fonctions?

Not that I know of

 

 

 

Some are local fonction FN, local fonction fn (Sim)  or (inst) or (inst, data),

 I don't know much about that either, sorry, someone else is going to need to answer that.

 

 

 

comon post_init, master post_init,

common_post_init is for things that only the client needs to worry about and master_post_init is for things the server needs to handle (I think) 

Edited by Thibooms

I am very happy you try to help me out!

 

Here are the two crash logs for both the Character and Item.

 

The Char. Log was created in the absence of the item script. "--" on everything in instance with the item.

The Item Log was created with the item assets ON, even if I knew the character still crashing.

 

Hope it helps to discover why it always crashing.

 

Again, thanx dude!

Char Crash.zip

Item Crash.zip

@D4rkh0bb1T, You're welcome, I know how frustrating it is when no one (can) help you.

 

Sorry to say but I can't figure out what's causing the character crash. It says "scripts/prefabs/player_common.lua"]:1441: bad argument #1 to 'ipairs' (table expected, got function)" right? Well I can't find a "player_common.lua" file in the attachment you gave me. I thought it might have been an error in the common_post_init of the character's lua file, but there is nothing wrong with it. Also, you don't even seem to have a lua file that has 1441 lines xD. I'm kind of in the dark on that one. Are you sure you have provided me everything and that that crash was encountered with the current version of the mod files you attached in your first post?

 

Nevertheless, if you are able to find in which file that error is located, you should look for code language mistakes because the log said "bad argument". I think that happens when you don't give a function (or code in general) what is expected.

 

As for the item, I have found the problem. In your philosopherstone's lua file, line 18, you have a "-" in front of the end (that ends your function "onequip". You probably typed that in accidentally when commenting out some things. This breaks everything. You can simply delete that and it should be back up and running ;)

 

Edit: There IS a "player_common.lua" file in the game's data files. At line 1441 I found "        inst.AnimState:Hide("HEAD_HAT")". Which makes no sense as it shouldn't interfeer with your mod. Did you insert a new "player_common.lua" file in your mod? That would explain it, otherwise, I don't know. (or maybe try updating the game?)

Edited by Thibooms

 

 I'm kind of in the dark on that one. Are you sure you have provided me everything and that that crash was encountered with the current version of the mod files you attached in your first post?

 

As for the item, I have found the problem. In your philosopherstone's lua file, line 18, you have a "-" in front of the end (that ends your function "onequip". You probably typed that in accidentally when commenting out some things. This breaks everything. You can simply delete that and it should be back up and running ;)

 

Edit: There IS a "player_common.lua" file in the game's data files. At line 1441 I found "        inst.AnimState:Hide("HEAD_HAT")". Which makes no sense as it shouldn't interfeer with your mod. Did you insert a new "player_common.lua" file in your mod? That would explain it, otherwise, I don't know. (or maybe try updating the game?)

1. Yes, images attached to the .zip files and the log included are from the same mod I posted first, Maleficum.zip. I didnt change anything since then, exept for creating the Item Crash.zip where I had to enable the philosopher stone!

 

2. Oh my, I havent seen that "-" in front of the end fonction... when launched, crash is not refering to the stone anymore, but to the character instead. Now...

 

3. There is no player_common.lua file in my mod and there was never such a file anyway. I found it under the data folder of Dont starve Together, such like you, but the line 1441 express this : 

 

 

1440: if starting_inventory ~= nil then

1441           for i, v in ipairs(starting_inventory) do

                if not prefabs_cache[v] then

                    table.insert(prefabs, v)

                    prefabs_cache[v] = true

                end

            end

        end

 

Plus, I see another line in the crash screen of the game that refers to the mainfunctions.lua, line 98.

 

 

line 90 : function LoadPrefabFile( filename )

    --print("Loading prefab file "..filename)

    local fn, r = loadfile(filename)

    assert(fn, "Could not load file ".. filename)

    if type(fn) == "string" then

        assert(false, "Error loading file "..filename.."\n"..fn)

    end

    assert( type(fn) == "function", "Prefab file doesn't return a callable chunk: "..filename)

line 98 :    local ret = {fn()}

Anyway, how can we both have player_common.lua and not sharing the same lines?!

The game is updated, I got it last week or so...

 

D4rkh0bb1T

I found how to fix the problems. First I had to remove the fn features in the very bottom of the character lua files.

 

turned this :

return MakePlayerCharacter("maleficum", prefabs, assets, fn, common_postinit, master_postinit, start_inv)

to this :

return MakePlayerCharacter("maleficum", prefabs, assets, common_postinit, master_postinit, start_inv)

 

Why? I DONT KNOW! Hahaha... the character crash was now solved.

 

Second, there was a mistake to my dapperness script inside the philosophal stone script.

 

turned this :

ins.components.equippable.dapperness = TUNING.DAPPERNESS_MED

to this :

inst.components.equippable.dapperness = (TUNING.CRAZINESS_MED * 2)

 

inst:AddTag("amulets") to inst:AddTag("gears") (The stone appears on the ground very nicely)

inst.AnimState:SetBank("redamulets") to inst.AnimState:SetBank("gears") (dont know why... to fit better with gears lol)

 

And finally added these lines to the onequip section :

inst.entity:AddLight()
    inst.Light:Enable(true)
    inst.Light:SetRadius(1)
    inst.Light:SetFalloff(.5)
    inst.Light:SetIntensity(.5)
    inst.Light:SetColour(253/255,0/255,0/255)

 

The stone glows red when the character holds it and turns crazy. Every other scripts seem to work fine - The character goes on a killing spree under 45, saying the sentence I command him to say and so on...

 

I think I understand the way it works the more I get crashes. Havent payed attention closely to the log files and such.

Now. quick question : why should we put "return inst" before the "end" of a local function?

 

My character illustration will come in soon, Ill try to publish it somewhere on the workshop if it can useful to someone.

 

D4rkh0bb1T

BUT STILL!!

 

It appears that the game is crashing when I drop the stone. But not MY game, the client game!!! I tried to drop it several times without any crash on the client session. There, I tried to drop it in front of the other player, sharing the same area to say so, then the other player game crashed. On its screen, the crash was refering to the philosopher stone, again, in the inst:AddComponent("inventoryitem").

 

Uhmm... I know a lot of crash can occur on my own session, but didnt expect something would happen to other players playing on my LAN server...

 

D4rkh0bb1T

Now. quick question : why should we put "return inst" before the "end" of a local function?

I never really understood why or when you need to return fuctions, especially local functions as they usually seem to be alright with a "end". Some googling is needed for that one :razz:

 

 

 

It appears that the game is crashing when I drop the stone. But not MY game

 

 

Can you also provide the log for that? Might be a texture issue. I've had a similiar bug in one of my mods because the game couldn't find a ".xml" file for some reason. Make sure the other person on your server has an exact copy of the mod (I'm saying this because sometimes you can make the client download the mod upon joining the server, and I've encountered some issues with this myself).

 

By the way, you can edit your posts instead of making new ones. ;P

 

Edit: Maybe Klei changed some things in the player_common. I had my game updated yesterday, so maybe you do need to try to update :)

Edited by Thibooms

The other person has the exact same folder for my character and we are sharing same mods all the way to be compatible.
The log file is in the attachment, off course, its not from my PC.
 
Why would I edit my post instead of making a new one?
 
Im actually on the very last steam update, none was done yesterday lol
but on the 30th november to be exactly. 158520 - 11/30/2015
I looked up on other PC Datas about player_common.lua.
Everyone has the same line as me.

1440: if starting_inventory ~= nil then1441           for i, v in ipairs(starting_inventory) do

D4rkh0bb1T

log.txt

Why would I edit my post instead of making a new one?

So you don't make 3 posts at once, but it doesn't really matter ;)

 

Im actually on the very last steam update, none was done yesterday lol

Yes, you're right. I can't figure out why our files are different in that case x). The file you looked up IS indeed under scripts/prefabs/player_common.lua right?

 

It appears from the log there's something wrong with the inventory images. Did you think about uncommenting the assets in your philosopherstone's lua (I saw they were commented out)?

 

 

 

 

Hey Thibooms!

 

OK for the Edit thing... anyway the topic is well separated right now, for each post are new steps of comprehension. Anyway... haha!

 

At last, Yeah! Weird thing we do not share the same... "Game"...

I wonder if anyone noticed it so far. Indeed, we both found the scripts/prefabs/player_common.lua,

But lines are different from each others.

 

If you try out the char on your own, drop the item in front of your friend, you might get ANOTHER LINE in the crash log then?

 

I did erase every "--" in the philosopherstone.lua to use it in game, testing it out, and nothing crashed. Everything was fine until I drop it in front of my friend. Now I should put "--" right before : ?

inst:AddComponent("inventoryitem")	inst.components.inventoryitem.atlasname = "images/inventoryimages/philosopherstone.xml"

or putting "--" right before : ?

local assets ={    Asset("ANIM", "anim/philosopherstone.zip"),    Asset("ANIM", "anim/swap_philosopherstone.zip"),		Asset("ATLAS", "images/inventoryimages/philosopherstone.xml")}

Not loading the assets will make the item absent of the game I guess.

What about the swap things? I always wondered what was the main goal of having two images of one item.

Normal and Swap? Animations for the swap are different to the normal one, there in my .zip file, the swap animation is pretty like the cane...

Cane should appear somewhere in the item script then?

 

D4rkh0bb1T

Hey, @D4rkh0bb1T, I would try your mod out with one of my friends but I won't be able to do that for a week and a half, unfortunately.

 

I don't think you should comment out anything. I don't have many more ideas for what might be wrong, maybe someone more experienced should step in at this point ^^'. Does it make any difference if you align the third asset (the last one referring to philosopherstone.xml)?

 

Any equippable item has three images : an inventory image, a ground image and a swap image. The ground image is meant for the texture of the item when on the ground (obviously) and the swap image is meant for when the character holds the item in its hands. This is nice for allowing your item to blend in with the ground (looking like it is actually laying there) while still looking cool when holding it.

 

 Wait a second, is that what's causing the crash? Maybe you just don't have a ground item! :razz: I don't see one in your mod... If that's the problem, then I suggest you simply follow this guide.

 

Edit: if all else fails, try adding this

inst.components.inventoryitem.imagename = "philosopherstone"

Above

inst.components.inventoryitem.atlasname = "images/inventoryimages/philosopherstone.xml"

And this in your assets :

    Asset("IMAGE", "images/inventoryimages/philosopherstone.tex"),
Edited by Thibooms

Hi Thibooms,

 

I did everything in the guide and added the lines. The ground image is different than the inventory image which looks pretty cool.

I believe everything work well so far. But I tried to test it again with a friend, unfortunately, he cannot see my game in his LAN searching list.
Something always come up uh? I'll try to fix this. Thanx for your help, I really appreciate it.

 

D4rkh0bb1T

Hi, @D4rkh0bb1T.

 

The fact that your friend can't find your server is another issue, maybe try clicking on his steam name and select "join game", see what that does.

 

I hope you get to fix this and that the bloody crashing will finally stop :p

You're welcome ;)

Dah! I found how to rebuild the LAN problem. It was easy.

 

Anyway, the stone still crash the other game when I drop it in their face. With all the new things I added, I thought it would be okay... but nope. I did update my friend Mods Folder by putting my new one with new lines and new images. I cannot drop it nor give it.

 

How can other mods from other people do not have this problem? I tried to test any other mods with items and they all have same lines etc. but without crash! I think i've learn many things by sharing with you, and even now, I still feel like a newb hehe.

 

There again, the log crash from the other PC.

 

D4rkh0bb1T

log.txt

At last!

 

This topic is ended and problem solved.

If another PC is crashing cause of your mod, try placing server&client code above the server part. In my case I had to place :

inst.entity:SetPristine()		if not TheWorld.ismastersim then        return inst    end

right after the anim part. This represent the server only part right after this code. so...

 

Since it was before, the anim part was server side, so the client (friend) was not able to see it on the ground! There was no animation base for it to appear! By placing the code after, it makes animations for the client too. Then it reads the script, taking in charge the rest of the code under Mastersim on server side - The client do not need to handle every codes of my stone such as the walkingspeed, craziness, etc...

 

Now it runs on both side very well. The char is playable and published on steam for amusement ;)

 

D4rkh0bb1T

@D4rkh0bb1T, glad you got everything working! 

 

I think i've learn many things by sharing with you, and even now, I still feel like a newb
 

So am I, believe me xD. I just try to help out when I can, allows me to learn as well :)

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