Luis95R Posted September 7, 2016 Share Posted September 7, 2016 (edited) EDIT: I've decided to scrap my original post as it was confusing, so I deleted my original message. Here's my new issue: I now want to know if it's possible to make a player turn transparent when wearing 3 items each containing a special tag. So lets say If I wore a cane, tam'o shanter, and thulecite suit my character then become transparent like night armor. I've already added the special tags to the items I want to use, now I just need help making it work (if it's possible) It would probably start out something like this maybe: ---------------------------------------------------------------------------------------------------------------------------------------- if what I'm currently wearing has this tag(example1) and this tag (example2) and this tag (example3) then My character becomes transparent. ---------------------------------------------------------------------------------------------------------------------------------------- Basically I just want a character to become transparent when wearing 3 different items all containing different tags. I have only found another thread so far mentioning turning a character transparent: Edited September 7, 2016 by Luis95R Link to comment Share on other sites More sharing options...
. . . Posted September 7, 2016 Share Posted September 7, 2016 I think this work AddSimPostInit (function(inst) inst:DoPeriodicTask(0.01, function() if inst:HasTag("NightmareOne") and inst:HasTag("NightmareTwo") and inst:HasTag("NightmareThree") and not inst:HasTag("mastema") then inst.AnimState:SetMultColour(0.05, 0.05, 0.05, 0.5) end) if not (inst:HasTag("fakeinsane")) then inst:AddTag("fakeinsane") end else inst.AnimState:SetMultColour(1, 1, 1, 1) if (inst:HasTag("fakeinsane")) then inst:RemoveTag("fakeinsane") end end end) Link to comment Share on other sites More sharing options...
Luis95R Posted September 7, 2016 Author Share Posted September 7, 2016 19 minutes ago, SuperDavid said: I think this work AddSimPostInit (function(inst) inst:DoPeriodicTask(0.01, function() if inst:HasTag("NightmareOne") and inst:HasTag("NightmareTwo") and inst:HasTag("NightmareThree") and not inst:HasTag("mastema") then inst.AnimState:SetMultColour(0.05, 0.05, 0.05, 0.5) end) if not (inst:HasTag("fakeinsane")) then inst:AddTag("fakeinsane") end else inst.AnimState:SetMultColour(1, 1, 1, 1) if (inst:HasTag("fakeinsane")) then inst:RemoveTag("fakeinsane") end end end) I ended up getting this error unfortunately: https://gyazo.com/da2422f50782fa2e187db5bf6d7c92e8 this is what my modmain.lua looks like: https://gyazo.com/9886d830925815d6fba76f2f22387363 Link to comment Share on other sites More sharing options...
. . . Posted September 7, 2016 Share Posted September 7, 2016 How about this one? AddSimPostInit (function(inst) inst:DoPeriodicTask(0.01, function() if inst:HasTag("NightmareOne") and inst:HasTag("NightmareTwo") and inst:HasTag("NightmareThree") and not inst:HasTag("mastema") then inst.AnimState:SetMultColour(0.05, 0.05, 0.05, 0.5) end end) inst:DoPeriodicTask(0.02, function() if not (inst:HasTag("fakeinsane")) then inst:AddTag("fakeinsane") else inst.AnimState:SetMultColour(1, 1, 1, 1) end end) inst:DoPeriodicTask(0.03, function() if (inst:HasTag("fakeinsane")) then inst:RemoveTag("fakeinsane") end end) end) Link to comment Share on other sites More sharing options...
Luis95R Posted September 7, 2016 Author Share Posted September 7, 2016 14 minutes ago, SuperDavid said: How about this one? AddSimPostInit (function(inst) inst:DoPeriodicTask(0.01, function() if inst:HasTag("NightmareOne") and inst:HasTag("NightmareTwo") and inst:HasTag("NightmareThree") and not inst:HasTag("mastema") then inst.AnimState:SetMultColour(0.05, 0.05, 0.05, 0.5) end end) inst:DoPeriodicTask(0.02, function() if not (inst:HasTag("fakeinsane")) then inst:AddTag("fakeinsane") else inst.AnimState:SetMultColour(1, 1, 1, 1) end end) inst:DoPeriodicTask(0.03, function() if (inst:HasTag("fakeinsane")) then inst:RemoveTag("fakeinsane") end end) end) With that I get attempt to index local 'inst' (a nil value) https://gyazo.com/d97ff71252d9426257961997715ae200 This error and the one before are the common ones I get when trying to fix this, I feel as if I'm probably not setting the AddSimPostInit correctly. Link to comment Share on other sites More sharing options...
. . . Posted September 7, 2016 Share Posted September 7, 2016 Can you maybe tell me what SimPostInit does then I can understand a better way to help xD? Link to comment Share on other sites More sharing options...
Serpens Posted September 7, 2016 Share Posted September 7, 2016 there is areason why the code has indentations If you make it right, you can see instantly wich functions or if statement ends where. So it will help alot if you two try also to add those indentations. That's just a coding advise for you Assuming that the code from the first function only does not work because of wrong "if else", this should fix it: AddSimPostInit (function(inst) inst:DoPeriodicTask(0.01, function(inst) if inst:HasTag("NightmareOne") and inst:HasTag("NightmareTwo") and inst:HasTag("NightmareThree") and not inst:HasTag("mastema") then inst.AnimState:SetMultColour(0.05, 0.05, 0.05, 0.5) if not (inst:HasTag("fakeinsane")) then inst:AddTag("fakeinsane") else inst.AnimState:SetMultColour(1, 1, 1, 1) end if (inst:HasTag("fakeinsane")) then inst:RemoveTag("fakeinsane") end end end) end) But this code does not make much sense, since this add the Tag "fakeinsane" and then removes it again... So the best thing would be if you could explain when exactly what sould be done, so when do the color thing? and when to add tag and when to remove it? Explain as detailed as possible what your goal is Link to comment Share on other sites More sharing options...
Luis95R Posted September 7, 2016 Author Share Posted September 7, 2016 58 minutes ago, Serpens said: there is areason why the code has indentations If you make it right, you can see instantly wich functions or if statement ends where. So it will help alot if you two try also to add those indentations. That's just a coding advise for you Assuming that the code from the first function only does not work because of wrong "if else", this should fix it: AddSimPostInit (function(inst) inst:DoPeriodicTask(0.01, function(inst) if inst:HasTag("NightmareOne") and inst:HasTag("NightmareTwo") and inst:HasTag("NightmareThree") and not inst:HasTag("mastema") then inst.AnimState:SetMultColour(0.05, 0.05, 0.05, 0.5) if not (inst:HasTag("fakeinsane")) then inst:AddTag("fakeinsane") else inst.AnimState:SetMultColour(1, 1, 1, 1) end if (inst:HasTag("fakeinsane")) then inst:RemoveTag("fakeinsane") end end end) end) But this code does not make much sense, since this add the Tag "fakeinsane" and then removes it again... So the best thing would be if you could explain when exactly what sould be done, so when do the color thing? and when to add tag and when to remove it? Explain as detailed as possible what your goal is I tried that and it said " attempt to index local 'inst' (a nil value)" again. I've just decided to scrap the thing altogether. Instead is there a possible way to make my character see-through/transparent, like the shadow items (night armor, dark sword)? It would turn my character transparent if I wore the night armor, a dark sword, and a custom made night helmet item. I've already added the tags: NightmareOne to the Night Armor / NightmareTwo to the Dark Sword / and NightmareThree to the Night Helmet. I could possibly use this line if inst:HasTag("NightmareOne") and inst:HasTag("NightmareTwo") and inst:HasTag("NightmareThree") then to check make it check that all 3 shadow items are being worn. The thing is I have no idea how I would make my character transparent or which script to edit. Link to comment Share on other sites More sharing options...
Luis95R Posted September 7, 2016 Author Share Posted September 7, 2016 I managed to find only this post which even mentions about turning a character transparent. Link to comment Share on other sites More sharing options...
Aquaterion Posted September 7, 2016 Share Posted September 7, 2016 what exactly are you trying to do here? make a set of prefabs change their multcolour? if so i would do something like this local nightmareprefabs = {"prefab1", "prefab2", "prefab3"} --replace the prefabs with the actual prefab names for k,v in pairs(nightmareprefabs) do AddPrefabPostInit(v, function(inst) inst:DoPeriodicTask(0.01, function(inst) if inst:HasTag("NightmareOne") and inst:HasTag("NightmareTwo") and inst:HasTag("NightmareThree") and not inst:HasTag("mastema") then inst.AnimState:SetMultColour(0.05, 0.05, 0.05, 0.5) if not (inst:HasTag("fakeinsane")) then inst:AddTag("fakeinsane") else inst.AnimState:SetMultColour(1, 1, 1, 1) end if (inst:HasTag("fakeinsane")) then inst:RemoveTag("fakeinsane") end end end) end) end Link to comment Share on other sites More sharing options...
Luis95R Posted September 7, 2016 Author Share Posted September 7, 2016 (edited) 2 hours ago, Aquaterion said: what exactly are you trying to do here? make a set of prefabs change their multcolour? if so i would do something like this local nightmareprefabs = {"prefab1", "prefab2", "prefab3"} --replace the prefabs with the actual prefab names for k,v in pairs(nightmareprefabs) do AddPrefabPostInit(v, function(inst) inst:DoPeriodicTask(0.01, function(inst) if inst:HasTag("NightmareOne") and inst:HasTag("NightmareTwo") and inst:HasTag("NightmareThree") and not inst:HasTag("mastema") then inst.AnimState:SetMultColour(0.05, 0.05, 0.05, 0.5) if not (inst:HasTag("fakeinsane")) then inst:AddTag("fakeinsane") else inst.AnimState:SetMultColour(1, 1, 1, 1) end if (inst:HasTag("fakeinsane")) then inst:RemoveTag("fakeinsane") end end end) end) end I scrapped that idea Aquaterion. Please ignore my original post. What I'm trying to do now is make my character transparent like the night armor and dark sword when he wears 3 items containing the tags NightmareOne, NightmareTwo and NightmareThree. The way it would work for example is like this: IF what I'm currently wearing has this tag("NightmareOne) AND this tag(NightmareTwo) AND this tag(NightmareThree) THEN My character becomes transparent. -------------------------------------------------------------- Is this possible at all in Multiplayer? To wear 3 items with certain tags causing the player to become transparent light nightmare items? I've only found this post mentioning turning a character transparent: Edited September 7, 2016 by Luis95R Link to comment Share on other sites More sharing options...
Serpens Posted September 7, 2016 Share Posted September 7, 2016 (edited) One big question is also, were you put the code. I'm not familiar with character-making. But I would know a way to add this ability to every character with putting the code in modmain.lua. if not (GLOBAL.TheNet:GetIsServer() or GLOBAL.TheNet:IsDedicated()) then -- only make this at server return end local function OnEquip(inst) if inst and inst.components and inst.components.inventory then -- make sure we have a server character ... if you only want YOUR character to be able to get transparent, add to this line a check for a Tag that only your character has: and inst:HasTag("ismycharacter") local HandItem = inst.components.inventory:GetEquippedItem(GLOBAL.EQUIPSLOTS.HANDS) -- if we are in modmain, we have to use "GOBAL." , if we are not in modmain, we dont use it. local HeadItem = inst.components.inventory:GetEquippedItem(GLOBAL.EQUIPSLOTS.HEAD) local BodyItem = inst.components.inventory:GetEquippedItem(GLOBAL.EQUIPSLOTS.BODY) if HandItem and HeadItem and BodyItem and HandItem:HasTag("example1") and BodyItem:HasTag("example2") and HeadItem:HasTag("example3") then -- check if items are equipped and if they have the tags if not inst:HasTag("istransparent") then -- if character is not already transparent inst.AnimState:SetMultColour(1, 1, 1, 0.1) -- make transparent. The lower the fourth number is, the more transparent he will get inst:AddTag("istransparent") -- add this tag to the character end elseif inst:HasTag("istransparent") then -- if he does not have the needed items, but the tag, remove transparent inst.AnimState:SetMultColour(1, 1, 1, 1) inst:RemoveTag("istransparent") -- remove tag end end end AddPlayerPostInit(function(inst) inst:ListenForEvent("equip", OnEquip) -- call the function everytime someone is equipped inst:ListenForEvent("unequip", OnEquip) -- also call it, if sth is unequipped end) In the first line of the OnEquip function I wrote a comment (comment is everything after "--" ), that if you only want your character to get transparent, you can add an additional check: and inst:HasTag("ismycharacter") Also I have no clue what the difference between: SetMultColour and OverrideMultColour is... I think if you use "Set" it can be changed by any game/mod command that also uses Set. And if you use Override, the only way to revert it back, is again the Override command... So maybe you really should use Override ... but try out what you find better Edited September 7, 2016 by Serpens Link to comment Share on other sites More sharing options...
Luis95R Posted September 7, 2016 Author Share Posted September 7, 2016 if not (GLOBAL.TheNet:GetIsServer() or GLOBAL.TheNet:IsDedicated()) then -- only make this at server return end Do I put this in the modmain.lua? Also yes I want it to work for every character not just only 1 character. Link to comment Share on other sites More sharing options...
Luis95R Posted September 7, 2016 Author Share Posted September 7, 2016 (edited) Also thank you it works! I ended up putting what I mentioned on my previous post in my modmain.lua now I just gotta find the correct multicolor to make my character look black-transparent like the night armor and dark sword. I appreciate the help. Edited September 7, 2016 by Luis95R Link to comment Share on other sites More sharing options...
Serpens Posted September 7, 2016 Share Posted September 7, 2016 the first three numbers are standing for "RGB" -> Red Green Blue. If the value is 1, it is a RGB value of 255. Try eg. here what RGB value you need, and divide it with 255. For total black a value of 0 for each of those three should work:http://www.rapidtables.com/web/color/RGB_Color.htm Link to comment Share on other sites More sharing options...
Luis95R Posted September 7, 2016 Author Share Posted September 7, 2016 (edited) Awesome I seem to have got now. Thanks again! Going to put [SOLVED] into my post title. https://gyazo.com/d34b0524dd02d1aa088b89657e748c06 Edited September 7, 2016 by Luis95R 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