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
|
|
In response to Lummox JR
|
|
... 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) |
In response to RedlineM203
|
|
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 |
In response to RedlineM203
|
|
var/sometype = text2path("/cards/[stuff]") I'm unsure if you can just put a variable in there, but it should probably work. |
In response to Jon88
|
|
I'm unsure on that, I don't think it fits what I mean.
|
In response to Lummox JR
|
|
OK, I'll take it down another notch.
mob I want that to work. |
In response to RedlineM203
|
|
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)) |
In response to Jon88
|
|
With a little mess around as you proberly wanted, it works. Cheers.
|
In response to RedlineM203
|
|
You should take the "as obj" bit out of your for() loop. It has no business there.
Lummox JR |
In response to RedlineM203
|
|
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> |
In response to RedlineM203
|
|
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. |
In response to Kaioken
|
|
Ah, cheers. Don't say I didn't look at New() though.
|
In response to RedlineM203
|
|
Perhaps you have, but you need to look up new(), which is what you're using there and is different (but related to) than New(), and it's entry specifies the first "argument" has to be a type path.
|
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