D4rkh0bb1T Posted December 9, 2015 Share Posted December 9, 2015 Salut! I wanted to mod my own character with his own unique item. At first, there was a couple of crashes. I managed to fix them with a friendly user on this forum, Thibooms. (Thanx again man!) You can see each step I did to ''repair'' all the things here.The character is not crashing and I followed this guide to created my item, just to be sure its okay! It works fine when I play solo. Thats why I created another topic for this problem. I cant play Together because when I drop of give the item to my friend it makes HIS game to crash, reporting there is not enough memory. There I place a log.txt taken from my friend PC.I attach the zipfile of my char if someone need it to spot the problem. Ask what you need,Thanx in advance.D4rkh0bb1T log.txtMaleficum.zip Link to comment https://forums.kleientertainment.com/forums/topic/60514-dropping-my-item-crashes-my-friend-game/ Share on other sites More sharing options...
Lumina Posted December 9, 2015 Share Posted December 9, 2015 I'm not good to search at code, but when a mod work in solo and don't work in multiplayer, it's often because it lack a part like telling "this part is only server-side".Best way to try a mod is to have a dedicated server with the mod enabled. You could test more more easily all the stuff, you can see the crash log and you don't bother your friend with crash. I think that there is an easy way to install dedicated server in local now. Link to comment https://forums.kleientertainment.com/forums/topic/60514-dropping-my-item-crashes-my-friend-game/#findComment-695296 Share on other sites More sharing options...
Lumina Posted December 9, 2015 Share Posted December 9, 2015 (edited) Ok so i tried your mod. I tried this : Instead of : if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() --inst:AddTag("philosopherstone") inst.AnimState:SetBank("philosopherstone") inst.AnimState:SetBuild("philosopherstone") inst.AnimState:PlayAnimation("idle")this : inst.AnimState:SetBank("philosopherstone") inst.AnimState:SetBuild("philosopherstone") inst.AnimState:PlayAnimation("idle") inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end --inst:AddTag("philosopherstone")It seems to work fine on my dedicated server. Could you tell me if it help ? I think that the bank and build part should be not in the server part (after the "if not TheWorld.ismastersim then" part), because the others players on the server should be able to see the image, too, and can't if it's only server side. I'm not sure theinst.entity:SetPristine()should be before if not TheWorld.ismastersim thenreturn instend"But it seems to work better this way. Not sure.. Edited December 9, 2015 by Lumina Link to comment https://forums.kleientertainment.com/forums/topic/60514-dropping-my-item-crashes-my-friend-game/#findComment-695305 Share on other sites More sharing options...
ZupaleX Posted December 9, 2015 Share Posted December 9, 2015 It's also that the AnimState thingy has to be before the "return" in case TheWorld.ismastersim is false. Because it means that there is no AnimState for the client then, and it is an obvious problem Link to comment https://forums.kleientertainment.com/forums/topic/60514-dropping-my-item-crashes-my-friend-game/#findComment-695362 Share on other sites More sharing options...
D4rkh0bb1T Posted December 10, 2015 Author Share Posted December 10, 2015 Hey Lumina! I tried to change what you told me and it seems to work perfectly!!! Thank you for your help, the char is playable now! The rest of the build is about artwork and speeches I did not understand the mastersim thing or why I have to write SetPristine; the only thing I know is that they say to do write it down...Not sure about the AddTag thing either... thats why it is commented out. I tried to search for a list of all AddTags...Local function fn(Sim) is a weird command. I can't understand how it works differently than other local functions. Quick question for another char, and believe the answer lie in the Server/Client part too: I scripted some light aura under Master_Postinit, which works good until the character die. After death, there no more Light Aura. Should the light script be under Common_Postinit instead of Master? Exemple of this :local function master_postinit(inst) --Light Radius inst.Light:Enable(true) inst.Light:SetRadius(1) inst.Light:SetFalloff(.5) inst.Light:SetIntensity(.5) inst.Light:SetColour(255/255,127/255,0/255)Or should I just add inst.entity:AddLight() in the first place and leave it to Master? D4rkh0bb1T Link to comment https://forums.kleientertainment.com/forums/topic/60514-dropping-my-item-crashes-my-friend-game/#findComment-695481 Share on other sites More sharing options...
Lumina Posted December 10, 2015 Share Posted December 10, 2015 Happy to know that it work. Sadly, i'm still a beginner and still not understand some part of the code. If i understand well, mastersim is the server-side part. Some part of the code must be only server-side. if not TheWorld.ismastersim then return inst end I think that this part is telling "if you are client, ignore the following line". So problem here was that the AnimState was after, so client haven't it. @ZupaleX explain it better. I don't know what the pristine part do, but in the other prefab i check, it was before the mastersim part. If i understand well, AddTag will allow to check a tag in another portion of code, like, frog have a inst:AddTag("frog") And there is a line telling : inst.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("frog") and not dude.components.health:IsDead() end, 5) So it will use the tag to tell "if one frog attack one target, the other frog come to help" (If i understand well the line) Having a tag isn't necessary, i think, it's useful only in some case. The gem for example have a tag "molebait", it mean probably that it will attract mole (i don't know if it allow mole to take the item or if it's another part) And sorry i can't help for the light part :/ Link to comment https://forums.kleientertainment.com/forums/topic/60514-dropping-my-item-crashes-my-friend-game/#findComment-695629 Share on other sites More sharing options...
ZupaleX Posted December 10, 2015 Share Posted December 10, 2015 (edited) Hello, TheWorld obviously refers to the world entity Then this entity have several members such as "state", so you can access a lot of useful information with "TheWorld.state", like the current season, if it's raining, stuffs like that... "ismastersim" is a member of TheWorld which return true if you are the Master of the Simulation (how does that sound ? )Basically if you are the one running the server. So it can be true in 2 different cases :You run the server from within the game, like you click Host Server and then launched the game. TheWorld.ismastersim will be true for you, but false for all your friends joining. Then if you're running a dedicated server, TheWorld.ismastersim is true for the dedicated server and false for all the players joining, including you, even if you run the server on your machine. You can see it like, it will be true for the command prompt which pop up when you start the dedicated server, and false for your game which is running. So,if not TheWorld.ismastersim then return instendtells the game that if this part of the code is not executed by the program currently running the simulation, it should stop there. But if you are the "Master Simulation" then you read what's after that part. This is because some stuffs do not have to exists on the client side (some should even never be executed by the client). But the AnimState has to be present for the client because that's what rules what is displayed on the screen.On the other hand you do not need on the client to have all the stuffs which are handling how much damages you deal to an ennemy for example. The client just need to say, "ok i press that button to attack that spider" and that's it. The rest is handled by the "Master Simulation" which has the required informations to calculate how much damages you dealt. The SetPristine thingy, in a nutshell, it's to say that everything before the moment when this SetPristine function is called on the entity exists for both client and server. You will see sometimes exceptions like for the snow, but don't care too much about that. About the light thingy, the issue is not really about the master or the common. The Master postinit is executed only for the server and the Common postinit by server and client as you guessed. But here your issue is different.These functions are called when "constructing" the characters, you can see these as "constructors" for you character entity. These functions are called when joining a game.When you die, the lights turn off. Then if you resurect, you do not "Make" your character again, you just switch his state from ghost to "living beeing". So the function where Light:Enable() is, is not called again. Thus, if you followed me, you understand that you have to call a function containing the Light:Enable() when you resurect your character. Hope this helps. Cheers PS: I forgot to comment about the AddTagBasically AddTag are here just to make your life easier Tags are just strings, which can be whatever you want. The usefulness of it is multiple. Imagine that you want your weapon to deal more damages to shadow creatures? You can put a condition in the function handling the damages thatif enemy:HasTag("shadowcreature") then Do your stuff to multiply the damages by 2 for instanceendOther usefulness is that sometimes you put conditions on something which exists only for the server (TheWorld.mastersim = true). So what happens if you need to execute this function on the client side? It will reach this condition and crash because it will say that it doesn't exists.That's where you use the tags instead, because the tags exists for both the client and the server. Edited December 10, 2015 by ZupaleX Link to comment https://forums.kleientertainment.com/forums/topic/60514-dropping-my-item-crashes-my-friend-game/#findComment-695685 Share on other sites More sharing options...
D4rkh0bb1T Posted December 10, 2015 Author Share Posted December 10, 2015 Wow guys! Thanx to both of you for your great and detailed answers! Imagine a seconde that you find tutorials, people took time to write it down, but they don't even explain what we exaclty do and just add lines here and there. At the end, it begin to be confuse and we can't remember why we put that line here and there. Almost every tutorial I followed to understand each steps didnt even explain what was used to create script parts, we just know that we use it 0_o Now I understand the Hows, Whys and Whens, the most important thing I guess when you have an idea for coding.I bet you managed to understand it by yourself too, reading between lines of some blurry explanations.I tried to google everything to get a better base, hehe. For the Light thing, I'll try to put the code under onbecamehuman function, something like that, it should not be that complicated.For the Tags - We are force to use Tags precreated by Klei in their database or we can create a fictive one? I tried to google the Tags but found only a few. I scrolled a lot of lua files in the data folder but there's too many lol They are interesting I believe. I'm getting addict. D4rkh0bb1T Link to comment https://forums.kleientertainment.com/forums/topic/60514-dropping-my-item-crashes-my-friend-game/#findComment-695773 Share on other sites More sharing options...
ZupaleX Posted December 10, 2015 Share Posted December 10, 2015 As I said, tags are "random" strings. Klei use their own tags (like "shadowcreature" which is an actual tag, or something similar I don't remember exactly how it's called ) but nothing prevent you from adding to an entitymyFancyEntity:AddTag("myExtraFancyTag")This just append a string (the tag) to a list of other tags attached to the entity. I believe there is a limit though, to the number of tags that can be attached to an entity. As Far as I remember it's something like 64 (or maybe 32, I really don't remember). This is due to the fact (again from what I remember I saw when I was digging in the code some time ago) to the fact that for the tags to exists on both server and clients, a net variable is used, and net variables introduce limits due to their type (net_ushortint, net_float, ...) Link to comment https://forums.kleientertainment.com/forums/topic/60514-dropping-my-item-crashes-my-friend-game/#findComment-695783 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now