SenL Posted March 1, 2015 Share Posted March 1, 2015 (edited) I'm making a custom trading guy with "trader" component.However, I can't give him prefabs that I want him to accept (let's say a bee).Can't give here means no option to "give" when I hover the bee over the trader guy.When I hover a meat or flint, cursor changes to "give". How do I change this?I looked at trader.lua and there's nothing about what limiting the trade.I also looked at pigking.lua and it uses goldvalue in the "AcceptTest" function but my "AcceptTest" does not use goldvalue. Edited March 1, 2015 by SenL Link to comment Share on other sites More sharing options...
Jjmarco Posted March 1, 2015 Share Posted March 1, 2015 @SenL, Items to trade must also have the 'tradable' component.It works with meat and flint because they have that component, but bees don't. Link to comment Share on other sites More sharing options...
SenL Posted March 1, 2015 Author Share Posted March 1, 2015 (edited) Argh! Edit: How (or where) is that handled? C++ side? I don't see it in trader.lua (that item must have "tradable" component) Edited March 1, 2015 by SenL Link to comment Share on other sites More sharing options...
Jjmarco Posted March 1, 2015 Share Posted March 1, 2015 (edited) @SenL, It's handled Lua side. The game adds a component action on tradable so any tradable item changes the cursor to "Give" when hovering a trader. Edited March 1, 2015 by Jjmarco Link to comment Share on other sites More sharing options...
SenL Posted March 1, 2015 Author Share Posted March 1, 2015 I see. Whew so complex.So, I added them all "tradable" component but see warnings in log"component tradable already exists! " I could ignore but is it hard to do "add tradable component if it does not yet exist"? Link to comment Share on other sites More sharing options...
Jjmarco Posted March 1, 2015 Share Posted March 1, 2015 @SenL, No, it's not hard. You just have to check if the item has the component, something like this:if not inst.components.tradable then inst:AddComponent("tradable")end Link to comment Share on other sites More sharing options...
SenL Posted March 1, 2015 Author Share Posted March 1, 2015 Wow thanks.It works. 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