Jump to content

Recommended Posts

Hello, I have a question :)! If somebody could help me I would be very grateful :D!

So, my question is... Would it be possible to mod the limit of tags a character can have to be more than 31? Because there are many things I want to give to my character which is not possible without tags... For example,

"beaver", " brushable",  "cooker", "heater", "insomniac",

"UPGRADETYPES.SPIDER.."_upgradeuser" ", "valkyrie", "mime", "woodcutter", "monster" 

these are all tags which is impossible to replicate for me code wise... And they would work if only I could add them to my character but the 31 tag limit crashes the game, & that sucks a lot for me because it puts a huge restriction on my creativity for no reason :?!

So, would anyone know how I can up the tag limit from 31 to 100 :D? Because I never want to have to see this dumb crash again 

[00:00:22]: Error serializing tags for entity adam[107984] - 32 tags; exceeds maximum size of 31
[00:00:22]: Net partial byte (32) out of range [0, 31]

 

I really hope this would be possible but if it's impossible please tell me, i'll just have to go cry in a corner that's all :?... And thank you so much for taking the time to read my question, have a wonderful, amazing day/night :D!!!

Edited by SuperDavid

My character has ability to swap between many different forms which all give different tags.

Like Valkyrie mode, Mime mode, Wickerbottom mode, Fire mode, Frozen mode, Insane mode, Electric mode & like 6 other modes... All these modes give extra tags to my character plus I want all the modes to be able to stack on each other meaning all the tags will be active at the same time (I even made unique textures for the modes when they stack) but the game crashes :wilson_enraged:!!!

Right now my character only has these tags & to me it's not even over 31?! But the game crashes when I try to add more than 5 tags to my character...!!

So, I really need to increase the tag limit or all that texture work was pointless :wilson_cry:...

inst:AddTag("brushable") -- Has these tags by default, if gets more than 2 tags extra tags then game crashes. R.I.P Wickerbottom mode :(
inst:AddTag("doppelganger")
inst:AddTag(UPGRADETYPES.SPIDER.."_upgradeuser")

inst:AddTag("beaver") -- When goes insane mode.
inst:AddTag("monster") -- When goes insane mode.

inst:AddTag("fridge") -- When goes frozen mode.

inst:AddTag("bookbuilder") -- When goes wickerbottom mode.
inst:AddTag("insomniac") -- When goes wickerbottom mode.
inst:AddTag("reader") -- When goes wickerbottom mode.

inst:AddTag("valkyrie") -- When goes valkyrie mode.

inst:AddTag("mime") -- When goes mime mode.

inst:AddTag("heater") -- When goes fire mode.
inst:AddTag("cooker") -- When goes fire mode.

inst:AddTag("electricdamageimmune") -- When goes electric mode.

 

 

 

Edited by SuperDavid

Something to try is to split your character into multiple player prefabs and have each transformation change the player's entity into a new instance, storing all of its stats/inventory for the new one and duplicate those.

 

The tags are hardcoded in the C-side to be this partial byte which is of course not easily editable (read: client and server memory alterations/hooking not in LUA-space), so you'll definitely need to think outside of the box or find ways to reduce the number of tags.

 

Another possibility is to hook into the [Add/Remove/Has]Tag functions to add in a custom LUA table of yours that it checks against to extend functionality.

You will need to make sure that each tag you add on the server is also added on the client and removed on the client at the same time to remove client/server desync with their usages.

32 minutes ago, Maris said:

It's better not to use tags.

What can I use instead though? Like for example I have tag "doppelganger" which is basically my character's unique tag which I use for all it's custom crafting recipes, calling upon in states & calling upon in actions, events..

And from the looks of adding crafting recipes, to make the recipe specific it seems you can only do it with a tag or could I use a component or something, I have no idea... I wish stuff like "inst.doppelganger == true" worked for everything...

AddRecipe("kunai",
{
Ingredient("flint", 2),
Ingredient("cutgrass", 1)
},
RECIPETABS.TOOLS, TECH.NONE, nil, nil, nil, nil, "ninja", "images/inventoryimages/kunai.xml")

 

 

@Lumina 

4 hours ago, Lumina said:

merge some tags or something

You gave me great idea! Maybe I can reuse my 1 unique tag & replace it with something else when I need another tag, like my unique tag is called "doppelganger" but I can do something like "doppelganger_valkyrie" & so on! That would make it that I only need 1 tag! The only problem is i'd have to edit a bunch of DST's coding to check for those tags too...but it shouldn't be a problem, I think :)?  

4 hours ago, Lumina said:

And maybe you should focus on something more simple. I'm not sure people will like having thousand of state to manage

You don't have to worry because all the different state can only be activated if you want them activated, if you don't want them then don't use them (except insane mode, you're kinda forced into that one) :)...

 

Edited by SuperDavid

but "inst.doppelganger" is not saved and also not propagated to clients automatically. So you have to set this for client and server,and at every gamestart (this should be no problem if you want your char to have this mode forever, but might be tricky if you want to add and remove it).

about your tags used for recipes:
In another thread I modded the builder component, to add a custom test-function. Maybe you can mod that component, so that you don't need the tags... so you have to mod the "CanLearn" function... I'm not sure if also modding the "KnowsRecipe" function is neccessary ... lets make first only canLearn, and if it does not work, then we mod also the other :D
http://forums.kleientertainment.com/topic/70550-solved-recipes-availability-while-running-game/#comment-820391

Put this code into modmain. this way you should be able to use inst.valkyrie to be able to craft recipes.
But keep the things I mentioned above in mind. That everytime you add or remove this, you have to do it for server and client and that it is not saved.
So if your transformation is only done server side (wich is likely) you have to find a better way. Maybe using and checking for components instead ;)

AddClassPostConstruct("components/builder_replica",  function(self) -- for client
    local _CanLearn = self.CanLearn
    self.CanLearn = function(self, recname)
        local recipe = GLOBAL.GetValidRecipe(recname)
        if recipe~=nil and recipe.builder_tag~=nil and self.inst[recipe.builder_tag] then -- instead of the Tag "xyz", we now ask for inst.xyz (=inst["xyz"])
            return true
        else
            return _CanLearn(self, recname) -- if it does not have inst.xyz , check the normal function
        end
    end
end)


AddComponentPostInit("builder", function(self) -- for server
    if not GLOBAL.TheNet:GetIsServer() then
        return
    end
    local _CanLearn = self.CanLearn
    self.CanLearn = function(self, recname)
        local recipe = GLOBAL.GetValidRecipe(recname)
        if recipe~=nil and recipe.builder_tag~=nil and self.inst[recipe.builder_tag] then -- make sure to test your mod also with caves enabled, to see if you assigned the inst.xyz to server and client correctly
            return true
        else
            return _CanLearn(self, recname)
        end
    end
end)

 

Edited by Serpens

@Serpens I probably did something really stupid but I put this code like you said & edited to give me battle_spear recipe but nothing happened?

AddClassPostConstruct("components/builder_replica",  function(self) -- for client
    local _CanLearn = self.CanLearn
    self.CanLearn = function(self, spear_wathgrithr)
        local recipe = GLOBAL.GetValidRecipe(spear_wathgrithr)
        if recipe~=nil and self.inst[recipe.builder_tag] and inst.wathgrithr_mode == true then -- instead of the Tag "xyz", we now ask for inst.xyz (=inst["xyz"])
            return true
        else
            return _CanLearn(self, spear_wathgrithr) -- if it does not have inst.xyz , check the normal function
        end
    end
end)


AddComponentPostInit("builder", function(self) -- for server
    if not GLOBAL.TheNet:GetIsServer() then
        return
    end
    local _CanLearn = self.CanLearn
    self.CanLearn = function(self, spear_wathgrithr)
        local recipe = GLOBAL.GetValidRecipe(spear_wathgrithr)
        if recipe~=nil and self.inst[recipe.builder_tag] and inst.wathgrithr_mode == true then -- make sure to test your mod also with caves enabled, to see if you assigned the inst.xyz to server and client correctly
            return true
        else
            return _CanLearn(self, spear_wathgrithr)
        end
    end
end)

 

1 hour ago, SuperDavid said:

@Serpens I probably did something really stupid but I put this code like you said & edited to give me battle_spear recipe but nothing happened?

Just take a look at the code ;)
Now there is written:

if recipe~=nil and recipe.builder_tag~=nil and self.inst[recipe.builder_tag] and inst.wathgrithr_mode == true then
    return true

so go through it step by step:
recipe ~= nil -> will be okay.
self.inst[recipe.builder_tag] -> does your character has the tagname in inst ? for battle spear and such stuff you HAVE to give your char inst.valkyrie cause these 3 conditions are linked with "and" ;) So all three of them need to be true.

But the better way is to not add other conditions. if you dont want to add inst.valkyrie to your char, you can change it to inst.valkyrie_mode by adding the "_mode" to the code:
 

if recipe~=nil and recipe.builder_tag~=nil and self.inst[recipe.builder_tag.."_mode"] then

 

Edited by Serpens

@Serpens Okay, so I don't really know what i'm doing wrong?

In modmain.lua I put

AddClassPostConstruct("components/builder_replica",  function(self) -- for client
    local _CanLearn = self.CanLearn
    self.CanLearn = function(self, spear_wathgrithr)
        local recipe = GLOBAL.GetValidRecipe(spear_wathgrithr)
        if recipe~=nil and self.inst[recipe.builder_tag] then
            return true
        else
            return _CanLearn(self, spear_wathgrithr)
        end
    end
end)


AddComponentPostInit("builder", function(self)
    if not GLOBAL.TheNet:GetIsServer() then
        return
    end
    local _CanLearn = self.CanLearn
    self.CanLearn = function(self, spear_wathgrithr)
        local recipe = GLOBAL.GetValidRecipe(spear_wathgrithr)
        if recipe~=nil and self.inst[recipe.builder_tag] then
            return true
        else
            return _CanLearn(self, spear_wathgrithr)
        end
    end
end)

and in mycharacter.lua in master_postinit I put

inst.valkyrie = true

but still nothing happens?

Edited by SuperDavid
25 minutes ago, SuperDavid said:

@Serpens Okay, so I don't really know what i'm doing wrong?

In modmain.lua I put


AddClassPostConstruct("components/builder_replica",  function(self) -- for client
    local _CanLearn = self.CanLearn
    self.CanLearn = function(self, spear_wathgrithr)
        local recipe = GLOBAL.GetValidRecipe(spear_wathgrithr)
        if recipe~=nil and self.inst[recipe.builder_tag] then
            return true
        else
            return _CanLearn(self, spear_wathgrithr)
        end
    end
end)


AddComponentPostInit("builder", function(self)
    if not GLOBAL.TheNet:GetIsServer() then
        return
    end
    local _CanLearn = self.CanLearn
    self.CanLearn = function(self, spear_wathgrithr)
        local recipe = GLOBAL.GetValidRecipe(spear_wathgrithr)
        if recipe~=nil and self.inst[recipe.builder_tag] then
            return true
        else
            return _CanLearn(self, spear_wathgrithr)
        end
    end
end)

and in mycharacter.lua in master_postinit I put


inst.valkyrie = true

but still nothing happens?

what the hell are you doing to my nice code ?! :D:D

okay, I will explain it in detail to you :)
1) Don't change my code. It already works for everything. Use the one I initially posted and only change the "_mode" thing if you want to.
2) The code does mod the builder component. So "recipe" will be every existing recipe. You don't have to assign a specific one. Every single recipe and builder==self.inst (the char who is trying to build) will be checked with this "CanLearn" function.
3) The "self.inst[recipe.builder_tag]" is the "inst.valkyrie" check. "recipe.builder_tag" can be every tag that was used anywere in any recipe. Instad of checking inst:HasTag(recipe.builder_tag) we are now checking "self.inst[recipe.builder_tag]". Additional info for you: inst.valkyrie is the same like inst["valkyrie"],
4) You code in master_postinit is okay. If you added the "_mode" thing, it has to be inst.valkyrie_mode of course.

@Serpens Okay, so I got it to work thanks to you :) but when I tried changing the 

24 minutes ago, Serpens said:

if recipe~=nil and self.inst[recipe.builder_tag] then

To

1 hour ago, Serpens said:

if recipe~=nil and self.inst[recipe.builder_tag.."_mode"] then

I get this crash

crash.jpg

 

Also, it seems having inst.valkyrie = true in master_postinit does nothing & it only works if it's in common_postinit but that means I can't set it to nil or true when going between different modes :?.. Do you know a way I can make it work with master_postinit? Thanks a lot for your help Serpens & explaining in detail for me :D!!

 

@Serpens 

So if your transformation is only done server side (wich is likely) you have to find a better way. Maybe using and checking for components instead ;)

If I want to replace inst.valkyrie_mode with a component then it works like a tag or whatever can you tell me how to do that if you can :)?

Edited by SuperDavid

about the crash:
Ah yes, it can bei nil, I forgot. So the line should be instead (I will add this to my post above too):

if recipe~=nil and recipe.builder_tag~=nil  and self.inst[recipe.builder_tag] then

I have to think a bit about the component solution... of course it is easy to replace that line with a component check. But the problem is, that the "builder_recplica" component does not have access to components.... hmmm...

 

 

 

Soooooooo....

I think I have the ultimate code for you now and I did test it first, so it should work ;)

You put this into modmain:

Spoiler

-- ########## Serpens:  A mod to change a mode of a character that way, that he is able to craft character specific items. The transformermode component is needed in addition to the following code:

-- we have to define all possible modes here. Cause clients will only have a number. And with that number they need to find out, which mode this is.
GLOBAL.TUNING.TRANSFORMERMODES = {valkyrie_mode={"valkyrie"}} -- a list with modenames and the builder_tags the mode should have, any number of builder_tags is possible
GLOBAL.TUNING.TRANSFORMERMODENAMES = {"valkyrie_mode"} -- order must be the same in both! Up to 63 diffrent modes are possible

AddPlayerPostInit(function(inst)
    if inst.prefab == "mycharacter" then -- replace "mycharacter" with the prefab of the character you want to have this ability (or comment line out if everyone should have this)
        -- defined in netvars.lua
        -- GUID of entity, unique name identifier (among entity netvars), dirty event name
        inst.mynetvarTransformermode = GLOBAL.net_smallbyte(inst.GUID, "TransformermodeNetStuff", "DirtyEventTransformermode") -- numbers 0 - 63
        -- set a default value
        inst.mynetvarTransformermode:set(0) -- 0 will be -> no mode active
        inst:DoTaskInTime(0, RegisterListenersTransformermode)
        if not GLOBAL.TheNet:GetIsServer() then
            return
        end
        inst:AddComponent("transformermode")
            if inst.components.transformermode then -- now ask for the actual mode and transalte it into numbers
            -- inst.components.transformermode:ChangeToMode("valkyrie_mode")
            inst.mynetvarTransformermode:set(inst.components.transformermode:GetModeNumber(inst.components.transformermode:GetModeName()))
        end
    end
end)

AddClassPostConstruct("components/builder_replica",  function(self) -- for client
    local _CanLearn = self.CanLearn
    self.CanLearn = function(self, recname)
        local recipe = GLOBAL.GetValidRecipe(recname)
        if recipe~=nil and recipe.builder_tag~=nil and self.inst.mynetvarTransformermode and table.contains(GLOBAL.TUNING.TRANSFORMERMODES[GLOBAL.TUNING.TRANSFORMERMODENAMES[self.inst.mynetvarTransformermode:value()] or ""] or {},recipe.builder_tag) then
            return true
        else
            return _CanLearn(self, recname) -- if it does not have inst.xyz , check the normal function
        end
    end
end)

AddComponentPostInit("builder", function(self) -- for server
    if not GLOBAL.TheNet:GetIsServer() then
        return
    end
    local _CanLearn = self.CanLearn
    self.CanLearn = function(self, recname)
        local recipe = GLOBAL.GetValidRecipe(recname)
        if recipe~=nil and recipe.builder_tag~=nil and self.inst.components and self.inst.components.transformermode and type(self.inst.components.transformermode.builder_tags)=="table" and table.contains(self.inst.components.transformermode.builder_tags,recipe.builder_tag) then
            return true
        else
            return _CanLearn(self, recname)
        end
    end
end)

 


And then you create a new .lua file with the name "transformermode.lua" and put it into the directory "yourmodname/scripts/components" of your mod (create folders if they do not exist).
In this lua file you put the following code:

Spoiler

-- ### component by Serpens:
-- help function: return the first integer index holding the value
local function AnIndexOf(t,val)
    for k,v in ipairs(t) do
        if v == val then return k end
    end
    return 0 -- 0, if it was not found
end

local TransformerMode = Class(function(self, inst)
    self.inst = inst
    self.modename = nil
    self.builder_tags = {} -- the builder_tags your char should get this way, which will be check with the modded CanLearn function from modmain
end)

function TransformerMode:ChangeToMode(newmode) -- eg. "valkyrie_mode". If no mode should be active, just use empty ""
    if not newmode then newmode = "" end
    self.modename = newmode
    self.builder_tags = TUNING.TRANSFORMERMODES[newmode] or {}
    if self.inst.mynetvarTransformermode then -- this variable is defined in modmain. Without it wont work for clients
        self.inst.mynetvarTransformermode:set(self.inst.components.transformermode:GetModeNumber(newmode))
    end
end

function TransformerMode:GetModeNumber(modename)
    if modename and modename~="" and TUNING.TRANSFORMERMODENAMES then
        return AnIndexOf(TUNING.TRANSFORMERMODENAMES,modename)
    else
        return 0
    end
end

function TransformerMode:GetModeName()
    return self.modename
end

function TransformerMode:GetModeBuilderTags()
    return self.builder_tags
end

function TransformerMode:OnSave()
    return {
    modename = self.modename,
    builder_tags = self.builder_tags,
    }
end

function TransformerMode:OnLoad(data)
    self.modename = data and data.modename or nil
    self.builder_tags = data and data.builder_tags or {}
end

return TransformerMode

 


Leave all the code as it is. You can change the following:

1) In modmain code add all your modes and the builder_tags they should provide into:
GLOBAL.TUNING.TRANSFORMERMODES and GLOBAL.TUNING.TRANSFORMERMODENAMES the same way like I already did it.
So if your second mode is "doppelganger_mode" with the builder_tag "doppelganger" (you can name the mode now like whatever you want)
the result would look like this:

GLOBAL.TUNING.TRANSFORMERMODES = {valkyrie_mode={"valkyrie"},doppelganger_mode={"doppelganger"}} -- a list with modenames and the builder_tags the mode should have
GLOBAL.TUNING.TRANSFORMERMODENAMES = {"valkyrie_mode","doppelganger_mode"} -- order must be the same in both! Up to 63 diffrent modes are possible


You can also write more than just one builder_tag in the brackets, so with one mode you can craft things of multiple other characters.

2) In modmain code, replace the "mycharacter" in AddPlayerPostInit with your character prefab.


Do not add anything in your character lua files. The code I gave you already does everything.

How to use:
1) To change the mode of your char you just call inst.components.transformermode:ChangeToMode("doppelganger_mode") or any other mode. If you don't want any mode to be active, just use empty "" or any name you did not add to the Tuning list.
2) You can also use this component for all your other mode stuff.
So instead of making inst.xyz_mode = true, like you did before, you just add your mode to that Tuning list.
If you don't want your mode to have builder_tags, just leave that bracket empty.
And to check if your char is in a e.g doppelgange_mode, you can just check:
if inst.components.transformermode:GetModeName()=="doppelgange_mode" then

Edited by Serpens

@Serpens Wow, like thanks so much man that insane you did so much for me :D! And it works fine I can get the valkyrie items & not get them super amazing & it's all thanks to you, & this seems like a much more proper way for mode swapping thanks a so much!!

If I can just ask some questions cause just to make sure I got everything correctly :)!

1) So, I use code like this to see if my character's in a certain mode for example In mycharacter.lua

if inst.wendy_mode == true then

end

 

If I want to convert it to your mode thing I would do something like this?

In modmain.lua

GLOBAL.TUNING.TRANSFORMERMODES = { valkyrie_mode={"valkyrie"}, wendy_mode={"ghostlyfriend"} }

GLOBAL.TUNING.TRANSFORMERMODENAMES = {"valkyrie_mode", "wendy_mode"} -- order must be the same in both! Up to 63 diffrent modes are possible

In mycharacter.lua     that's how it would be to add a new mode, right?

if inst.components.transformermode:GetModeName() == "wendy_mode" then

end

 

My next question is if wendy mode & valkyrie I want them to stack would I add another mode & do something like...

In modmain.lua

GLOBAL.TUNING.TRANSFORMERMODES = { valkyrie_mode={"valkyrie"}, wendy_mode={"ghostlyfriend"}, valkyrie_wendy_mode={"valkyrie", "ghostlyfriend"} }

GLOBAL.TUNING.TRANSFORMERMODENAMES = {"valkyrie_mode", "wendy_mode", "valkyrie_wendy_mode"}

In mycharacter.lua     that's how it would be to add a new mode, right?

if inst.components.transformermode:GetModeName() == "valkyrie_wendy_mode" then

end

 

 

 

2) Now if I wanted to add a mode that doesn't have a tag would I just put the name in "GLOBAL.TUNING.TRANSFORMERMODENAMES"

or would it be something else? Again, thank you so much for this Serpens, it helps my mode stuff a lot :D!

 

@Serpens I have one more question! The modes in these things if you connect the mode to a tag does it only make you unlock crafting recipes that need that tag or does it actually make it that you gain all of the attributes the tag provides?! If that's how it is then that means you can have 94 tags :D!!? 63 tags from modes here & 31 from the game!!

...But that's probably not how it works, right? '-'

GLOBAL.TUNING.TRANSFORMERMODES = { valkyrie_mode={"valkyrie"}, wendy_mode={"ghostlyfriend"}, valkyrie_wendy_mode={"valkyrie", "ghostlyfriend"} }

GLOBAL.TUNING.TRANSFORMERMODENAMES = {"valkyrie_mode", "wendy_mode", "valkyrie_wendy_mode"}

Thanks again! Serpens!

Edited by SuperDavid
46 minutes ago, SuperDavid said:

1) So, I use code like this to see if my character's in a certain mode for example In mycharacter.lua


if inst.wendy_mode == true then

end

If I want to convert it to your mode thing I would do something like this?

In modmain.lua


GLOBAL.TUNING.TRANSFORMERMODES = { valkyrie_mode={"valkyrie"}, wendy_mode={"ghostlyfriend"} }

GLOBAL.TUNING.TRANSFORMERMODENAMES = {"valkyrie_mode", "wendy_mode"} -- order must be the same in both! Up to 63 diffrent modes are possible

In mycharacter.lua     that's how it would be to add a new mode, right?


if inst.components.transformermode:GetModeName() == "wendy_mode" then

end

 

Yes, you replace if inst.wendy_mode == true then with if inst.components.transformermode:GetModeName() == "wendy_mode" then.
And yes, if ghostlyfriend is the builder_tag you want your wendy_mode to use, the Tuning stuff is right ;)

46 minutes ago, SuperDavid said:

My next question is if wendy mode & valkyrie I want them to stack would I add another mode & do something like...

In modmain.lua


GLOBAL.TUNING.TRANSFORMERMODES = { valkyrie_mode={"valkyrie"}, wendy_mode={"ghostlyfriend"}, valkyrie_wendy_mode={"valkyrie", "ghostlyfriend"} }

GLOBAL.TUNING.TRANSFORMERMODENAMES = {"valkyrie_mode", "wendy_mode", "valkyrie_wendy_mode"}

In mycharacter.lua     that's how it would be to add a new mode, right?


if inst.components.transformermode:GetModeName() == "valkyrie_wendy_mode" then

end

 

yes exaclty :)

 

 

46 minutes ago, SuperDavid said:

2) Now if I wanted to add a mode that doesn't have a tag would I just put the name in "GLOBAL.TUNING.TRANSFORMERMODENAMES"

or would it be something else?

 

You always have to put every new mode in both Tuning lists. If you don't want a builder_tag, just leave the bracket empty so:
 

GLOBAL.TUNING.TRANSFORMERMODES = { valkyrie_mode={"valkyrie"}, wendy_mode={"ghostlyfriend"}, valkyrie_wendy_mode={"valkyrie", "ghostlyfriend"}, other_mode={} }

GLOBAL.TUNING.TRANSFORMERMODENAMES = {"valkyrie_mode", "wendy_mode", "valkyrie_wendy_mode", "other_mode"}

We need both lists, because clients only have this lists and a number. They don't get the name or builder_tags directly. So if they have the number "1" then they look in the names list, what the name at position 1 is. And then they use this name to get the builder_tags from the other list.  That is also the reason why the order of modes have to be identical in both lists.

 

46 minutes ago, SuperDavid said:

 I have one more question! The modes in these things if you connect the mode to a tag does it only make you unlock recipes that need that tag or does it actually make it that you gain all of the tag's attributes?! If that's how it is then that means you can have 63 tags :D!!?

...But that's probably not how it works, right?

Thanks again! Serpens!

It only unlocks recipes, cause I only modded the "builder" component to not only look for tags, but also look for this component.
If you want other things too, you have to find out which component is responsible for it, find out where it checks the tag and then mod this function that way, that it also checks the component.

Edit:
Of course you also can add other stuff to this transformermode component. Everything that should be saved. At the moment it only saves the modename and the builder_tags.

Edited by Serpens

@Serpens I'm so sorry to bother you.. but if I may ask. Is it possible to further increase the amount of modes transformermode can have from 63 to a much higher number? Because my character has so many modes & all the different combinations of those modes seem to pass 63 :shock:!!

It's probably not possible to increase how many modes it can have, right :wilson_horror:...?

Edited by SuperDavid
31 minutes ago, SuperDavid said:

@Serpens I'm so sorry to bother you.. but if I may ask. Is it possible to further increase the amount of modes transformermode can have from 63 to a much higher number? Because my character has so many modes & all the different combinations of those modes seem to pass 63 :shock:!!

It's probably not possible to increase how many modes it can have, right :wilson_horror:...?

it is possible ;)  63 is the limit of the netvar "net_smallbyte" I use to send information from host to client.
We can also use a bigger netvar, eg change "net_smallbyte" in my code to "net_byte" then you can have up to 255.
If even this is too less, you can change it to "net_ushortint", to have 65535 possibilties ;)

But are these really more than 63 different modes? Or is the number just that high, because you want to combine different modes, so instead of having only "abc" or "def" mode, you want a "abcdef" mode ? With some changes, I could allow combination of modes, so intead of checking only the mode name, you would check a list of mode names and your character can have several modes in that list..... but it would be difficult for clients, cause they only have a number to find out the mode... so I would need to use a calculation to combine all modes. And that would mean that we still need to increase the netvar to higher numbers.
The only advantage then would be, that it would be much easier for you to combine any modes ;)

Another thing:
Looking at the code again, I'm not 100% sure, that the mode is also saved and loaded for clients. Clients only have this "net" variable to get the mode. And I doubt this is saved... only the component and the stuff in save/load is saved. So you should test with caves enabled, if the mode you last had, is saved when loading the game.
If it is not saved, then you have to save the netvar too in save/load. I will write you the code for it, but first test it ;)

edit:
if you already read this, before this "edit" appeard, please load and read again ;)

Edited by Serpens

@Serpens I've already test your amazing component with caves server on & caves server off & both times it saves the mode I was last in :)! (By clients to you mean people that join my server? If that's what you mean I'll have to test that, tell me if that's what you mean then I test with somebody :))

1 hour ago, Serpens said:

But are these really more than 63 different modes? Or is the number just that high, because you want to combine different modes, so instead of having only "abc" or "def" mode, you want a "abcdef" mode ?

Yes, exactly! There aren't over 63 different unique modes (yet)! But so far I have 10 different modes I want and I want them to all be able to be completely compatible with eachother, so that would make the possibilities of different modes be like... I dunno...? 100 xD? And I might always want to add a new mode in the future...

So, I would if you could change it to  "net_ushortint" then I never have to worry about a limit (i'm sure no matter how many modes/mode combinations I make I will ever reach  65535 possibilties!)

1 hour ago, Serpens said:

I could allow combination of modes, so intead of checking only the mode name, you would check a list of mode names and your character can have several modes in that list.....

I think it would be easier for you & me if I just merge modes like, that's how i've been doing it until now & I think that's the simplest way (for me since i'm not super adept at coding)!

inst.components.transformermode:GetModeName() == "gelid_mode"
and
inst.components.transformermode:GetModeName() == "flawless_mode"
=
inst.components.transformermode:GetModeName() == "flawless_gelid_mode"

Edit: Thanks so much for your help Serpens this component really made everything so much easier for me :D!!!

Edited by SuperDavid
10 minutes ago, SuperDavid said:

@Serpens I've already test your amazing component with caves server on & caves server off & both times it saves the mode I was last in :)! (By clients to you mean people that join my server? If that's what you mean I'll have to test that, tell me if that's what you mean then I test with somebody :))

If you have caves enabled, you act like a "pseudo client". It should be good enough. To be 100% sure, you can also test it with somebody else, or with a dedicated server.
But the code I was referring to, might only be a problem if you execute code from clients perspective...hmmm.......
Yes, test it with somebody and give him a mode where he should be able to build something special. Then close and load the game again, and see, if he is still able to build this thing.
If yes, everything is fine. If not, I have to adjust the code a bit ;)

Quote

Yes, exactly! There aren't over 63 different unique modes (yet)! But so far I have 10 different modes I want and I want them to all be able to be completely compatible with eachother, so that would make the possibilities of different modes be like... I dunno...? 100 xD? And I might always want to add a new mode in the future...

So, I would if you could change it to  "net_ushortint" then I never have to worry about a limit (i'm sure no matter how many modes/mode combinations I make I will ever reach  65535 possibilties!)

ok ;) just search the modmain code I gave you, and replace "net_smallbyte" with "net_ushortint". That should be all you need to change ;)

Quote

I think it would be easier for you & me if I just merge modes like, that's how i've been doing it until now & I think that's the simplest way (for me since i'm not super adept at coding)!

If I got you right, you don't need that "lists of modes" thing I suggested, right? Ok, good, cause it could be some hours of work for me to make it working :D
 

Edited by Serpens
16 minutes ago, Serpens said:

If you have caves enabled, you act like a "pseudo client". It should be good enough. To be 100% sure, you can also test it with somebody else, or with a dedicated server.
But the code I was referring to, might only be a problem if you execute code from clients perspective...hmmm.......
Yes, test it with somebody and give him a mode where he should be able to build something special. Then close and load the game again, and see, if he is still able to build this thing.
If yes, everything is fine. If not, I have to adjust the code a bit ;)

Okay, so I just tested with someone else & the modes get saved but if either one of us log out or go in a cave we lose the unique crafting recipes the modes should give. So, if you could adjust that, that would be super awesome of you :D!

 

18 minutes ago, Serpens said:

ok ;) just search the modmain code I gave you, and replace "net_smallbyte" with "net_ushortint". That should be all you need to change ;)

So, instead of

inst.mynetvarTransformermode = GLOBAL.net_smallbyte(inst.GUID, "TransformermodeNetStuff", "DirtyEventTransformermode") -- Numbers 0 - 63!

I replace it with?

inst.mynetvarTransformermode = GLOBAL.net_ushortint(inst.GUID, "TransformermodeNetStuff", "DirtyEventTransformermode") -- Numbers 0 - 63!

 

20 minutes ago, Serpens said:

If I got you right, you don't need that "lists of modes" thing I suggested, right? Ok, good, cause it could be some hours of work for me to make it working :D

Yes, I don't think I need it...but if I ever change my mind i'll be back ;)lol!

 

Also, thanks so, so, so much for your great help Serpens :D!!!

13 minutes ago, SuperDavid said:

Okay, so I just tested with someone else & the modes get saved but if either one of us log out or go in a cave we lose the unique crafting recipes the modes should give. So, if you could adjust that, that would be super awesome of you :D!

 

So, instead of


inst.mynetvarTransformermode = GLOBAL.net_smallbyte(inst.GUID, "TransformermodeNetStuff", "DirtyEventTransformermode") -- Numbers 0 - 63!

I replace it with?


inst.mynetvarTransformermode = GLOBAL.net_ushortint(inst.GUID, "TransformermodeNetStuff", "DirtyEventTransformermode") -- Numbers 0 - 63!

 

Yes, I don't think I need it...but if I ever change my mind i'll be back ;)lol!

 

Also, thanks so, so, so much for your great help Serpens :D!!!

Go to the component script and replace the OnLoad function with this one (in case you already changed the function yourself, then only add the 3 lines I added):

function TransformerMode:OnLoad(data)
    self.modename = data and data.modename or nil
    self.builder_tags = data and data.builder_tags or {}
    if self.inst.mynetvarTransformermode and self.modename and self.modename~="" then
        self.inst.mynetvarTransformermode:set(self.inst.components.transformermode:GetModeNumber(self.modename))  -- also load the mode for clients
    end
end

now try it again ;)

About netvar:
yes this looks right ;) If you want you can remove the 63 in the comment ^^
Also test, if it works.

Thank you very, very much Serpens, this seems to have worked perfectly :D!!

If I have any other thingies with this component I dunno how to do in the future i'll be coming back to ask for your help, sorry :D!

And again thank you so much Serpens for making such a great component for my character :D!!

Edited by SuperDavid

@Hello, I encountered a serialization issue, seemingly caused by having too many tags. I have researched a lot and found that you have some expertise in this area. Is there any suitable mod now available to solve this problem? When my game crashes, it shows " Error serializing tags for entity engineer[125645] - 64 tags; exceeds maximum size of 63" now.

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