Jump to content

Help, Item That Changes Stats


Recommended Posts

Question related to this. How are you guys going about dealing with the current stat vs max stat issue?

I tried to mimic this, and found simply changing the max changes the current hp as well to match the max stat is there a way to maintain the old hp? For example the base character max hp was 20 and then they equip the item it becomes 120. But it also heals them to 120 which means they can always just swap it on and off to recover to full.

local function onequip(inst, owner)owner.components.health.maxhealth = 120    owner.components.health:DoDelta(0)end
local function onunequip(inst, owner) owner.components.health.maxhealth = 20    owner.components.health:DoDelta(0)end
 

 

 

 

Edited by Hyaciao
Link to comment
Share on other sites

@Fredson, currently you either have:

1) Servers hosted by person

2) Servers hosted by computer

 

If server is hosted by person, if the host has nightvision, it will protect everyone near him.

The light the host gets is the light used by the game to calculate sanity penalty and the grue attacks.

 

If the server is hosted by the computer, that does't happen, since the lights in all the client worlds are fake.

This gets achieved by doing something like this: http://forums.kleientertainment.com/topic/49419-dedicated-server-working-nightvision-component/

 

There's a reason moggles aren't here.

Link to comment
Share on other sites

@Fredson,

You can make alternative recipes for the same item, as shown here:

http://forums.kleientertainment.com/topic/54230-helpcould-i-make-some-different-items-to-create-the-a-same-new-item/

You can use tags (like sociopath) to limit them to somebody in particular.

 

To make somebody craft something at low cost, look at how the green amulet works:

local function onequip_green(inst, owner)    owner.AnimState:OverrideSymbol("swap_body", "torso_amulets", "greenamulet")    owner.components.builder.ingredientmod = TUNING.GREENAMULET_INGREDIENTMOD    inst.onitembuild = function()        inst.components.finiteuses:Use(1)    end    inst:ListenForEvent("consumeingredients", inst.onitembuild, owner)endlocal function onunequip_green(inst, owner)    owner.AnimState:ClearOverrideSymbol("swap_body")    owner.components.builder.ingredientmod = 1    inst:RemoveEventCallback("consumeingredients", inst.onitembuild, owner)end

It modifies the ingredientmod of the builder component.

Link to comment
Share on other sites

Placer is the glowy figure you see when trying to place something.

In this example, I make what I did in other thread to make alternative board recipes.

But with the labs.

 

I also override the function of the builder replica in order to edit the CanLearn function and remove the older recipes from the bar.

example.zip

Link to comment
Share on other sites

it worked, but after modifying the recipe it gives me this:
 

 

CURL ERROR: Failed to connect to lobby.c.kleientertainment.com port 443: Timed out

[00:03:33]: Failed to send server broadcast message
[00:05:26]: WARNING! Could not find region 'OUTOFSPACE' from atlas 'images/inventoryimages.xml'. Is the region specified in the atlas?
[00:05:26]: Looking for default texture '(null)' from atlas 'images/inventoryimages.xml'.
[00:05:26]: images/inventoryimages.xml
LUA ERROR stack traceback:
        scripts/widgets/image.lua(30,1) in function 'SetTexture'
        scripts/widgets/image.lua(11,1) in function '_ctor'
        scripts/class.lua(181,1) in function 'Image'
        scripts/widgets/ingredientui.lua(28,1) in function 'constructor'
        scripts/modutil.lua(72,1) in function '_ctor'
        scripts/modutil.lua(80,1) in function 'IngredientUI'
        scripts/widgets/recipepopup.lua(280,1) in function 'Refresh'
        scripts/widgets/recipepopup.lua(290,1) in function 'SetRecipe'
        scripts/widgets/craftslot.lua(160,1) in function 'Refresh'
        scripts/widgets/craftslot.lua(169,1) in function 'SetRecipe'
...
        scripts/widgets/crafttabs.lua(238,1) in function 'OnControl'
        scripts/widgets/widget.lua(115,1) in function 'OnControl'
        scripts/widgets/widget.lua(115,1) in function 'OnControl'
        scripts/widgets/widget.lua(115,1) in function 'OnControl'
        scripts/widgets/widget.lua(115,1) in function 'OnControl'
        scripts/widgets/widget.lua(115,1) in function 'OnControl'
        scripts/screens/playerhud.lua(353,1) in function 'OnControl'
        scripts/frontend.lua(270,1) in function 'OnControl'
        scripts/input.lua(163,1) in function 'OnControl'
        scripts/input.lua(362,1)
[00:05:26]: images/inventoryimages.xml
LUA ERROR stack traceback:
        scripts/widgets/image.lua(30,1) in function 'SetTexture'
        scripts/widgets/image.lua(11,1) in function '_ctor'
        scripts/class.lua(181,1) in function 'Image'
        scripts/widgets/ingredientui.lua(28,1) in function 'constructor'
        scripts/modutil.lua(72,1) in function '_ctor'
        scripts/modutil.lua(80,1) in function 'IngredientUI'
        scripts/widgets/recipepopup.lua(280,1) in function 'Refresh'
        scripts/widgets/recipepopup.lua(290,1) in function 'SetRecipe'
        scripts/widgets/craftslot.lua(160,1) in function 'Refresh'
        scripts/widgets/craftslot.lua(169,1) in function 'SetRecipe'
...
        scripts/widgets/crafttabs.lua(238,1) in function 'OnControl'
        scripts/widgets/widget.lua(115,1) in function 'OnControl'
        scripts/widgets/widget.lua(115,1) in function 'OnControl'
        scripts/widgets/widget.lua(115,1) in function 'OnControl'
        scripts/widgets/widget.lua(115,1) in function 'OnControl'
        scripts/widgets/widget.lua(115,1) in function 'OnControl'
        scripts/screens/playerhud.lua(353,1) in function 'OnControl'
        scripts/frontend.lua(270,1) in function 'OnControl'
        scripts/input.lua(163,1) in function 'OnControl'
        scripts/input.lua(362,1)

 

Link to comment
Share on other sites

Just the recipe ingredients 

local cheap_one = AddRecipe("researchlab3_dummy",{Ingredient("log", 8), Ingredient("flint", 3)}, RECIPETABS.MAGIC, TECH.NONE, "researchlab3_placer",nil, nil, nil,"cheapmagic", "images/inventoryimages.xml", "researchlab3.tex")cheap_one.sortkey = 2local cheap_two = AddRecipe("researchlab4_dummy",{Ingredient("flower", 4), Ingredient("log", 2)}, RECIPETABS.MAGIC, TECH.NONE, "researchlab4_placer", nil, nil, nil, "cheapmagic", "images/inventoryimages.xml", "researchlab4.tex")cheap_two.sortkey = 1STRINGS.NAMES.RESEARCHLAB3_DUMMY = "Shadow Manipulator"STRINGS.NAMES.RESEARCHLAB4_DUMMY = "Prestihatitator"STRINGS.RECIPE_DESC.RESEARCHLAB3_DUMMY = "Shadows come cheap."STRINGS.RECIPE_DESC.RESEARCHLAB4_DUMMY = "Wood To Magic!"local mycharacter = "yin"AddPrefabPostInit(mycharacter, function(inst)	inst:DoTaskInTime(0, function()		local old = inst.replica.builder.CanLearn		inst.replica.builder.CanLearn = function(self, recipename)			if recipename == "researchlab3" or recipename == "researchlab4" then				return false			end			return old(self, recipename)		end	end)	inst:AddTag("cheapmagic")end)
Link to comment
Share on other sites

@Fredson, there is no such thing as a flower ingredient.

You are thinking of petals, probably.

 

If you have a mod flower prefab though, that can be used, you will need to specify the atlas.

Like

Ingredient("myprefab", 2, "images/inventoryimages/myprefab.xml")
Link to comment
Share on other sites

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
 Share

×
  • Create New...