Jump to content

Character Perk Creation, Assistance appreciated


Recommended Posts

 

 

After testing it, I realized I made a slight mistake in the parameters of OnUnequip and OnEquip functions. The first param should be "self", and second is the "data". Sorry about that.
 
Tested working code using the procedure I mentioned previously:
local armor_off = function(armor)	print(armor.prefab, "unequipped")	armor.components.armor:SetPercent(0.5)endlocal function isArmor(data)	return (data.eslot == EQUIPSLOTS.BODY) and (data.item.components.armor)endlocal OnUnequip = function(self, data)	if isArmor(data) then		armor_off(data.item)	endendAddSimPostInit(function(inst)	inst:ListenForEvent("unequip", OnUnequip)end)
 

 

Tutorial to character/item mods

Sample mods (see the prefab mod within, you can use it as a base)

 

Ahh okay, I'll see if I can get that working and adjust accordingly.  My method works pretty good too, but I could probably save some space with yours better.  Also yours is probably cleaner for performance.

 

also, appreciate the links.

Link to comment
Share on other sites

Okay, I've got the item created for the most part, but a couple things I'm struggling with figuring out.

 

I want the item to have the ability "Predict" as the option for right clicking it.  

 

I have the function ready to fire as soon as the item is used, but I can't get the option to use it to show up.

 

Whenever I put my mouse over the item to use it, it only comes up with "Examine"

 

I've tried reading the lua's of the other items in the prefab folder to figure out how this is changed, but I can't seem to find what does it.

 

I'm not sure which example I should reference to get what I need.  But as soon as I figure that out, the item will be finished.

 

edit:

I used maxwell's "Codex Umbra" as a base for making my item, but I replaced the component for "Book" with a component I made of my own "Predict" which is basically just a copied "Book" component

    inst:AddComponent("predict")    inst.components.predict.onpredict = onpredict
local Predict = Class(function(self, inst)    self.inst = instend)function Predict:OnPredict(predictor)    if self.onpredict then        return self.onpredict(self.inst, predictor)    end    return trueendreturn Predict

For my character, I gave him another component I made called "Predictor" which is essentially "Reader" just renamed.

local Predictor = Class(function(self, inst)    self.inst = inst    inst:AddTag("predictor")end)function Predictor:OnRemoveFromEntity()    self.inst:RemoveTag("predictor")endfunction Predictor:Predict(predict)	if predict.components.predict then		if predict.components.predict:OnPredict(self.inst) then			if predict.components.finiteuses then				predict.components.finiteuses:Use(1)			end			return true		end			endendreturn Predictor

I thought that the method "Predict" is what replaces the "Examine" on the item, but it didn't so I guess I must be missing something else.  I don't exactly know where to look.

 

Edit: Okay I just found out I need to create an ACTION for it, gotta figure out how to do that.

 

Edit 2: Okay so I decided to switch the item into a book and made my character a reader to test it, everything works perfectly.  3rd perk complete!

 

But I still wanna create my own action for this item if possible.  But when I tried making an action it still didn't show up properly.  What exactly do I need to do for creating an action?

 

 

Link to comment
Share on other sites

Okay, I've got the item created for the most part, but a couple things I'm struggling with figuring out.

 

I want the item to have the ability "Predict" as the option for right clicking it.  

 

I have the function ready to fire as soon as the item is used, but I can't get the option to use it to show up.

 

Whenever I put my mouse over the item to use it, it only comes up with "Examine"

 

I've tried reading the lua's of the other items in the prefab folder to figure out how this is changed, but I can't seem to find what does it.

 

I'm not sure which example I should reference to get what I need.  But as soon as I figure that out, the item will be finished.

 

edit:

I used maxwell's "Codex Umbra" as a base for making my item, but I replaced the component for "Book" with a component I made of my own "Predict" which is basically just a copied "Book" component

For my character, I gave him another component I made called "Predictor" which is essentially "Reader" just renamed.

I thought that the method "Predict" is what replaces the "Examine" on the item, but it didn't so I guess I must be missing something else.  I don't exactly know where to look.

 

Edit: Okay I just found out I need to create an ACTION for it, gotta figure out how to do that.

 

Edit 2: Okay so I decided to switch the item into a book and made my character a reader to test it, everything works perfectly.  3rd perk complete!

 

But I still wanna create my own action for this item if possible.  But when I tried making an action it still didn't show up properly.  What exactly do I need to do for creating an action?

 

Did you try to use the useableitem component as I suggested? Out of interest

 

Link to comment
Share on other sites

Did you try to use the useableitem component as I suggested? Out of interest

 

 

Yes, but it's a little more complicated than book was, but it's definately on my consideration.  If making an action proves to be not worth it I'll just use useableitem instead

Link to comment
Share on other sites

Okay still having issues with my custom action, so I wanna see if anyone notices what I'm missing.

 

local Action = GLOBAL.Actionlocal ActionHandler = GLOBAL.ActionHandlerlocal PREDICT = Action() --(3) --I don't know if it does anythingPREDICT.str = "Predict"PREDICT.id = "PREDICT"PREDICT.fn = function(act) local targ = act.target or act.invobject --This sounds right-- if targ and targ.components.predict and act.doer and act.doer.components.predictor then  --Commented out for testingif act.targ.components.predict then  --Does the item have the "predict" component?return act.doer.components.predictor:Predict(targ) --Make the player do the predict action?endendAddAction(PREDICT)AddStategraphActionHandler("wilson", ActionHandler(PREDICT, "book"))

I have this in my modmain, which is what I've gathered from the beefalo milker mod as a base.

 

For my other stuff

--My Characters LUA has this	inst:AddComponent("predictor")--My Characters Item has    inst:AddComponent("predict")    inst.components.predict.onpredict = onpredict--The predict components codelocal Predict = Class(function(self, inst)    self.inst = instend)function Predict:OnPredict(predictor)    if self.onpredict then        return self.onpredict(self.inst, predictor)    end    return trueendreturn Predict--And heres the Predictor codelocal Predictor = Class(function(self, inst)    self.inst = inst    inst:AddTag("predictor")end)function Predictor:OnRemoveFromEntity()    self.inst:RemoveTag("predictor")endfunction Predictor:Predict(watch)	if watch.components.predict then		if watch.components.predict:OnPredict(self.inst) then			if watch.components.finiteuses then				watch.components.finiteuses:Use(1)			end			return true		end			endendreturn Predictor

This is what I have, but it's not working because the "predict" action doesn't show up over the item, it only shows "Examine"

 

When I change the components of "predictor" to "reader" and "predict" to "book" it works great so the only real problem has to be something I'm doing with creating the action.

 

But I don't know which part I'm missing from it.  If anyone can help me point out where the fault is that would be great.

 

I'm considering using the "useableitem" component instead, but I want to have the word "Predict" show up when they try to use the item instead of "Use" so if theres a way to make that happen also that would be good also.

 

Link to comment
Share on other sites

Does anybody have any idea what I'm missing from my custom action?  I'm searching high and low to figure out what I'm missing but I can't seem to find it.

 

Edit: Figured it out in another post.  Thanks for the help everyone, my character is complete.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...