Great job, Hope this gets SVN'd cus I can understand how useful this could be.
I'm currently trying to make a drone/bot thing out of the little colored GLaDOS sphere with handles. I wanted it to change eye colors with different modes, so I whipped up a setSkin() function. Then, I added getSkin() and skinCount() to make it even more useful.
Basically, you know how there's like a million different doors in the Useful Construction spawnmenu? They're actually the same model, with alternate built-in textures. This lets you switch those textures after you spawn the model. There's a LOT of props with multiple skins, most notably oilbarrels, cargo containers, almost all of SBMP, and many others. You can spot them by looking for what appears to be several copies of the same model, but with different textures. Props other than the default skin will have a "(skin#)" at the end of their name in the spawnlist.
For the purposes of using setSkin to get that version, make sure you subtract 1 from the skin number in the spawnmenu.
I recorded a video, but it won't re-encode into something I can upload....
USAGE:
E:setSkin() -0 is default skin, any numbers above that will change the prop's skin, IF it has more than one, and IF the number you entered is valid.
E:getSkin() -Returns the current skin.
E:skinCount() -Returns the total number of skins INCLUDING THE DEFAULT OF 0! Be sure to subtract 1 from it to get the highest skin number you can set.
Example E2:
This will take the prop you spawn it on, and cycle through it's available skins.
It'll go up, then down. This was originally intended for making the non-handled Portal ball "flash". To make it do so convincingly, you'll need an interval of 100, and make it stop reversing on 1 instead of 0.
Code:@name SkinTest @persist Num Rev Ent=entity():isConstrainedTo() Count=Ent:skinCount() if (Count>1) { interval(500) if (Num==Count-1){Rev=1} if (Num==0){Rev=0} if (Rev){Num--} else{Num++} Ent:setSkin(Num) hint(toString(Ent:getSkin()),2) }
LUA:
Drop the LUA into your addons\wire\lua\entities\gmod_wire_expression2\cor e\custom.lua file.Code:registerFunction("setSkin", "e:n", "", function(self, args) local op1, op2 = args[2], args[3] local rv1, rv2 = op1[1](self, op1), op2[1](self, op2) if(!validEntity(rv1) || !rv1:IsValid()) then return end if(!isOwner(self, rv1)) then return end local skins = rv1:SkinCount()-1 if rv2<=skins and rv2>=0 then rv1:SetSkin(rv2) end end) registerFunction("getSkin", "e:", "n", function(self, args) local op1 = args[2] local rv1= op1[1](self, op1) if(!validEntity(rv1) || !rv1:IsValid()) then return 0 end local skin = rv1:GetSkin() return skin end) registerFunction("skinCount", "e:", "n", function(self, args) local op1 = args[2] local rv1 = op1[1](self, op1) if(!validEntity(rv1) || !rv1:IsValid()) then return 0 end local count = rv1:SkinCount() return count end)
Also, if someone wants to stick this in the SVN, go for it. *hint nudge*
Great job, Hope this gets SVN'd cus I can understand how useful this could be.
I just was gonna to ask for it lol very very good idea anyway =D
As nice as it is, this has come up before and it's not really SVN material. There's not much merit to making it an E2 function. It sounds like what you really want is a skin stool.
A quick search turned up something, maybe this is what you're looking for:
skinswitcher 0.1.zip Download!
Where has this come up before? I did a quick search too, before I started writing these, to avoid wasting my own time.
SVN-able-ness aside, I have that STool. In fact I looked at it as a reference to help ensure I was doing mine properly
I need things to change skins according to my E2 code.
If all I needed was a stool, I wouldn't have bothered. This is why I wanted the video, to demonstrate how this works.
For example, my little GLaDOS drone:
The eye is purple when it's off
Blue when it's in Manual Override mode
It'll be red when in Auto-Sentry mode, and yellow when in "curious" mode (neither of which I've tryed to implement yet)
I can't just use a simple setcolor(), either, because that changes the color of the whole prop, and doesn't seem to affect the eye of it at all for some reason. Changing skins, however, does exactly what I need/want. But it needs to happen when I switch modes. Kinda defeats the purpose if I have to shut the drone off and shoot it with a STool.
And why would you go "Maybe this is what you need:" when I POSTED what I MADE to suit my needs? I mean, thanks for your concern, but I'm not an idiot.
Well you also can change skins by E:setMaterial(S)...
I did that for a stargate screen worked fine.
But the e2 skin switcher is also a very good idea.
Ah, but to use setMaterial, I'd have to spend half an hour or more digging through the GCFs to find the materials for the skins. It took less time to write these than it would take for me to locate the materials.
Unless you're saying I can put "Skin0" or somesuch in the material function and directly access the prop's skins that way..... In which case yeah, nevermind.
Oh my bad, it was a discussion on a server, not on the forums. Also remember that when suggesting additions, it's important to mention what you actually want them for. Otherwise it makes it difficult to tell what the advantages of adding them really are.
setMaterial already does the job, is that right?
Point of note is that we have no getMaterial
Theoretically, setMaterial can do the same thing, but this is easier to use and requires 100% less digging through the resource browser for hours. You can just look at your spawnmenu and know what you need to enter.
Also, I've not tested using setMaterial for this like I have my own functions, because I'd rather code behavior than go digging for the mats right now. So it might NOT work, but I see no reason why it shouldn't. So, I suppose that makes this similar the the writeString function for wirelinked console screens. They're helpers, to make this particular task more expeditious.
As far as why I'm suggesting this addition, there's the whole "No easy way of doing this yet so people may find it handy" standard stuff, but really, it's so I can take my awesomesauce drone on the internet and impress people with it.
Although, honestly, besides my drone, making that other portal ball pulse it's glowing eye, or altering the colorscheme of your entire SBMP-based ship at once, I guess I don't know what it'd be useful for.
But I could say the same for half the currently existing functions.
Bookmarks