OK, well there's a part in my new project that needs a typesof proc. Yeah, thats alright, very easy to do. I need it to be a variable though. I had to look at something, but I knew what to do afterwards. But the problem begins when you define a new type in the code and you don't know how to call it properly.
Its for a card game I said I was making in a deleted "BYOND Central is not Accessible" turned discussion, and the type is /cards, and I have no clue how to do it myself.
ID:165156
![]() Feb 15 2007, 6:01 am
|
|
... Fine. It was just a little background story until the last sentence in the paragraph.
I need to know how to do a typesof proc which uses a variable with a type defined in the code (/cards) |
RedlineM203 wrote:
... Fine. It was just a little background story until the last sentence in the paragraph. Background story is okay, as long as it's coherent, but here it really didn't make any sense; you only confused the issue. I need to know how to do a typesof proc which uses a variable with a type defined in the code (/cards) I'm not sure what you mean about using a variable here. The /cards type is not variable; it's a constant. What would you need a var for? Lummox JR |
var/sometype = text2path("/cards/[stuff]") I'm unsure if you can just put a variable in there, but it should probably work. |
OK, I'll take it down another notch.
mob I want that to work. |
typesof() returns types. ie:
/card/apple /card/banana They aren't actual objs you can do something with. You'd need to actually make new ones. for(var/i in typesof(/card)) |
I found out later that the cards I get in the deck are just clones and do whatever the first one does, if I have them in my hand or not, and the AI's cards might even copy mine.
The solution to that is <s>ofcourse</s> most likely a new proc. The problem is, that the cards don't like to be created again... for(var/i,i<5,i++) <font color = red>runtime error: Cannot create objects of type /cards/monster/guy. proc name: New (/mob/New) source file: Main.dm,34 usr: RedlineM203 (/mob) src: RedlineM203 (/mob) call stack: RedlineM203 (/mob): New()</font color> |
RedlineM203 wrote:
> var/cards/D = pick(dec) Uhh.. So 'D' contains an object reference? If you go and look up 'new' before you use it, it accepts a type path there. You can't use an object. You could look up the 'type' var and use 'new D.type' to create a new object of the same type as D, or if you really want the card to be a duplicate, use a proc to Copy() it. |
What is "it", and why does it need to be a variable?
Uh... what? I don't understand what you're even trying to say in this sentence, or why.
Again I have to ask, what is "it" here? A proc? A verb? If it's not a proc or a verb, did you perhaps mean something other than "call"? What are you trying to accomplish with the new type you've defined?
Huh?
The type of what? What are you trying to do with that type?
Defining the problem clearly is the first step of programming, but also the first step in asking for help. As it stands right now most of what you said came off as gibberish. I'm sure that happened mostly because you're confused, but any time you feel you're getting too vague, just step back and take a breath, and go through the problem in as much detail as you can muster. One thing that will help is a trick I learned from a former supervisor, who said in programming, never say "it"; always use the name of what you're actually working with. The reason is, programming is full of all kinds of things you can call "it", and once several its are interacting, it's impossible to tell which one you're referring to.
Lummox JR