Right now for my game, I have switches that open gates and doors you normally wouldn't be able to. How they work right now is, when operated, it searches for gates or doors, that have the same serial as they do, IE spikes 001, anything with the same tag as that, will then operate under that switch.
Is there a better way to go about this, or do I already have the best idea in mind?
ID:265907
Mar 18 2009, 6:23 am
|
|
Mar 18 2009, 7:51 am
|
|
what i would do is just associate a variable to the gate that you want it to open and then use that variable to do what you want. Instead of searching for it each time someone switches it.
|
In response to NightJumper88
|
|
Right now the switches are ambiguous, as are gates and doors. If they are associated with a switch, it will check a var and math it to the other. If they match, then they will operate.
I think that is a little bit better then hard coding, every single switch and gate into the game. This way, I just place down switches, doors and gates, and then edit the var on the map to suit my needs. |
In response to Trosh Kubyo
|
|
Does each switch control only one door/gate?
If so, you could use that variable as an index. So when a switch gets 'switched' it would correspond with door_list[switch_var], where door_list is a list of all your doors. I haven't put enough thought into how to easily make the list of doors correspond, but I'm sure it could be done. That would be a much more efficient way, without loosing the ability to quickly edit switches. The door index would remain static, but the switch key could be quickly edited to match up with whatever. |
In response to Stupot
|
|
You could always use tags to make it easier. You can use locate(tag) to get the door/gate very easily.
|
In response to Kaiochao
|
|
Or do that. I figured there was a better way to it than what I proposed. That's what I get for helping out without really knowing DM.
|
If they only have one action, then a variable, another object with a tag equal to that variable, and locate() should be suitable. As it was mentioned, a list would also work as well, and you could even dictate more complicated actions with a list. Just keep resource usage in mind.
|
In response to Jeff8500
|
|
Tags were mentioned also, by the way. ;)
|
If the target door of a switch isn't changing in any immediate fashion, I'd advise against 'searching' more than is necessary. And all that is necessary is once.
var/Door/Target
var/obj/Door/T And if the target changes, set Target=0. This lets you stick to your simple ID changing setup, and not have to loop through every door in the world every time you use a switch. |
In response to AJX
|
|
locate() and tags would be better here.
|
In response to Jeff8500
|
|
Than a set variable? No.
Than a for loop? Yes. If you felt like being REALLY optimized then you should do the initial search with tags and then any later with a direct variable reference. |
In response to Jeff8500
|
|
Jeff8500 wrote:
locate() and tags would be better here. Unless he needs to activate more than one thing per switch... In which case, something like this could be effective: obj/Switch |
In response to Falacy
|
|
obj/Switch |
In response to T3h P3ngu1n
|
|
T3h P3ngu1n wrote:
> obj/Switch Then he has to manually tag every object numerically & manually add said numerical tags to a list on the switch o.O for(var/v in Tags) Could just do that too <.< |
In response to Falacy
|
|
Tags don't have to be numerical. They can be whatever you want them to be. And he was already tagging them to begin with, and manually adding them on the var. This way just uses the provided tag var and controls it more efficiently.
|
In response to T3h P3ngu1n
|
|
T3h P3ngu1n wrote:
And tags don't have to be numerical. They can be whatever you want them to be. And he was already tagging them to begin with, and manually adding them on the var. This way just uses the provided tag var and controls it more efficiently. Still, he'd have to give every single object a unique tag, then add those unique tags to the list on the switch. If he has 100 spike pits getting activated by a single switch, that'd be a heck of alot of work. I was assuming the switch with ID Spike001 could correspond to 100 spike pits also with the ID Spike001. My way: You ID the switch, ID 1 spike pit, then duplicate that pit 100 times on the map. Your way: Manually re-tag each of those 100 new pits, and then manually add those 100 new tags to the switch's list. |
In response to Falacy
|
|
Yeah it that thing does work. I erased that it didn't shortly after posting it. I'm tired and was typing it wrong.
Now if you want to go for extreme switching like that you could just have a global list then. var/list/TheSwitches=list() |
In response to T3h P3ngu1n
|
|
T3h P3ngu1n wrote:
Now if you want to go for extreme switching like that you could just have a global list then. EXTREME SWITCHING Could make a game out of that. You try to kill other players by activating spike pits while they try to kill you in the same way =P |