Lokoluna Posted March 22, 2019 Share Posted March 22, 2019 (edited) Soo.. recently I added Wendy's Abigail code to my own character, and since then my game stutters, and I'm unsure why, Even with only that mod on, it still happens, and I need advice, does anyone else have this issue? I really like Abigail, Are there any other options I could do besides adding her code, and tags? Really makes the game unenjoyable. The lag limit is above 60.. and I have 10, including the ghostfriend tag, Could the number of tags I have be causing the stutter? Edited March 22, 2019 by Lokoluna Link to comment Share on other sites More sharing options...
Ultroman Posted March 22, 2019 Share Posted March 22, 2019 No. If you were hitting the limit, the game would crash and tell you. What exactly do you mean by "I added Wendy's Abigail code to my own character"? Can you post a zip of the mod so we can see what you've done? You can try turning off certain parts of the Abigail code, to see which parts make it stutter. Look for things like DoPeriodicTask, ListenForEvent and WatchWorldState calls, which might be "fighting" each other. Link to comment Share on other sites More sharing options...
Lokoluna Posted March 22, 2019 Author Share Posted March 22, 2019 Well, what i mean is the part of Wendy's code that makes Abigail.. work. Here's the Zip. hehexd.rar Link to comment Share on other sites More sharing options...
Ultroman Posted March 23, 2019 Share Posted March 23, 2019 I don't know if it has anything to do with it, but kutsil.lua has an "onpoad" function right beneath its "onload" function...it doesn't look like it's being used, but it seems to do things with Abigail code. Why do you add the abigail.lua in your mod? Isn't it already part of the game? You actually also have two "onload" functions, so there's 3 in total, and one is misnamed. Link to comment Share on other sites More sharing options...
Lokoluna Posted March 23, 2019 Author Share Posted March 23, 2019 (edited) 59 minutes ago, Ultroman said: I don't know if it has anything to do with it, but kutsil.lua has an "onpoad" function right beneath its "onload" function...it doesn't look like it's being used, but it seems to do things with Abigail code. Why do you add the abigail.lua in your mod? Isn't it already part of the game? You actually also have two "onload" functions, so there's 3 in total, and one is misnamed. I forgot to add the onpoad function to the lua itself, I have multiple on load functiosn which all are called in that similar instance, I have abigail's lua there because I modified her damage, and I don't know how to do prefab postinit's, I did onpoad because onload was already being used, and I think i tried adding it to the onload function but.. it broke. Edited March 23, 2019 by Lokoluna Link to comment Share on other sites More sharing options...
Ultroman Posted March 23, 2019 Share Posted March 23, 2019 (edited) Doing AddPrefabPostInit is incredibly simple. AddPrefabPostInit("abigail", function(inst) -- Make your change. inst is an instance of the Abigail prefab. end) This, however, changes Abigail for players using Wendy, as well, which your solution also does since it's overwriting the original game files (which makes it incompatible with any mod that makes changes to Abigail). If you do not want that, you should change the name of your Abigail prefab (it's the first parameter in the Prefab() call at the bottom of her LUA file). Not sure if any other changes would be required, though. Just make sure that anywhere you use her old prefab name in quotes (e.g. when you spawn her), to change it to use the new prefab name instead of the original one. Concerning the onload functions, I don't think that's how LUA works. I'm pretty sure that if you declare something multiple times, like you're declaring your onload function multiple times, every declaration overwrites the previous one. Effectively, only the lowest placed onload function is being called right now, and "onpoad" is never called. I can't see anything that would specifically cause a stutter, but I might be blind. Edited March 23, 2019 by Ultroman Link to comment Share on other sites More sharing options...
Lokoluna Posted March 23, 2019 Author Share Posted March 23, 2019 Well they seem to coexist and work just fine, the prefab i sent you hasn't implemented the onpload yet, I totally forgot about it, Yeah im aware it overwrite Wendy's Abigail and such, but this character is strictly for playing alone, and is only ever active on single worlds, On the terms of AddPrefabPostInit, how would one say, change the drop rate of something? Link to comment Share on other sites More sharing options...
Ultroman Posted March 23, 2019 Share Posted March 23, 2019 Drop rates are kind of a special thing, and they're specific to the individual prefabs which drop them e.g. a tree knows it's drop rates for the items it can drop, so you have to change the drop rate on every specific prefab you want to change. As an example, take a look at the marsh_tree prefab. It does this: SetSharedLootTable( 'marsh_tree', { {'twigs', 1.0}, {'log', 0.2}, }) and then in it's master_postinit does this: inst:AddComponent("lootdropper") inst.components.lootdropper:SetChanceLootTable('marsh_tree') SetSharedLootTable is a function which adds an entry to the shared loot table (one big table used for all prefabs in the game which use this mode of loot distribution), which links an identifier, 'marsh_tree', to a table of dropable loot and their chances of dropping. The lootdropper component is added to the prefab, and its SetChanceLootTable function is called upon to make it use the loot table with the given identifier. There are other ways of adding loot, which do not rely on a table e.g. static loot drops which always drop the same loot, is chance loot or a sort of open-ended way where you add loot with weights attached to each item, so you can freely add/remove loot dynamically, and it'll automatically figure out the chance of which loot should drop. The way I've shown above is probably the easiest to work with. Make a table of loot and chances, and tell the lootdropper to use it. You can change the loot table by just calling GLOBAL.SetSharedLootTable. Here's an example: AddPrefabPostInit("krampus", function(inst) SetSharedLootTable( 'krampus', { {'monstermeat', 1.0}, {'charcoal', 1.0}, {'charcoal', 1.0}, {'krampus_sack', 0.2}, }) -- Make sure the lootdropper component is on the prefab. if(inst.components.lootdropper == nil) then inst:AddComponent("lootdropper") end -- Set the loot table. inst.components.lootdropper:SetChanceLootTable('krampus') end) 11 hours ago, Lokoluna said: Well they seem to coexist and work just fine Have you tested this? Try putting a print-statement in both onload functions saying "onload 1" and "onload 2", and see if both are being called. I will eat...this...cake(?)...if that's the case. Link to comment 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