Any workarounds then? Is there a way to reference the name of a property via a text? If in that table, the second column was a text, could that position be extracted and another function be run against it to refer to the property that had the same string of characters for a name?
I’m kind of at a loss for how to start because I’m not sure what a “property” is, deeper in the code, because I don’t know I6…
The data would already be in the table… now that I think about it, this question isn’t really about tables, but more about properties after all. Nevermind the table.
How can a “function” be written so that it can accept “any” property as a variable, instead of having to code for every one?
So, this uses a table, but the table part isn’t the important part, it’s converting the property to a variable that I’m getting at:
Repeat running through Table of Whatever:
let it be the object entry;
let x be the property entry;
let y be the value entry;
now the x of it is y;
This way, the same little bit of code is scalable to whatever properties you create. It’s useful so that a centralized, global function, possibly in an extension, can be used for different reasons. You don’t have to write all these lines for every property you come up with, but instead can pass the property as a variable x and the value as y… this kind of thing seems basic to how many other programming languages operate, so I’m kind of struggling to get around this not being possible.
I guess properties are nothing like this, but that seems unfortunate to me.
There’s really no way to say, use a text or indexed text with the same string of characters as a property and interpret that as meaning the property? Like, if you have a property called “durability” you couldn’t have a text with the actual string “durability” be read through some logic that then indicates the durability property? I just don’t know where to begin, and it sounds like no one knows what I’m talking about, so maybe there isn’t, but I find it very odd to work in a language that doesn’t have the ability to refer to properties in a more scalable way than having to write a line for each one individually… I would hope there would be a way to loop through them all… it doesn’t seem like you can do a repeat through the properties of a thing either… strange.
Inform is poorly suited to trying to create the most absolutely general tool possible and then deploy it.
If you were writing a game in which you needed to set an object’s size, weight, and color from a table, you’d have written a repeat loop with three explicit declarations (“now the size of T is the size-column entry”, etc) and gotten on with the next task.
Hmm, and that’s what I’m doing now, I’m not writing a game, I’m trying to learn and create a “library” of optimized and scalable implementations in a “framework” that can be reused in practical implementations later. That’s what I always do when I learn a new language… I like having tools, loops, recursive stuff… scalability as far as the language allows is kind of the way I like to operate. Just pushing to the limit I guess, and without I6, and even with, it looks like there are some limits to that in Inform… but there’s so much else that is really good about it I’m still going to stick with it. I guess I should learn I6 after all, I keep saying that but I’m still learning I7! Oh well…
The compiler has information that it doesn’t put into the compiled game file.
Dude, this is the fourth time you’ve asked the same question. The answer hasn’t changed. We’re not holding out on you.
I could tell you that this is handled internally by the I6 function WriteGProperty(). But then you’d go down a long rathole of fighting with the compiler and the type system – I’m not going to explain the details here – and it would end with you saying “I guess this isn’t going to work after all.” So let’s skip straight to “no”.
I’m not really a C# person, but is it really possible in that language to, for example, create a class foo with member variables bar and baz, then write a function to allow SetProperty(“foo”,“bar”,“5”) instead of foo.bar = 5; ?
That’s exactly what I’m doing, and for similar reasons. I had trouble with I7’s relationships and properties, and the extensions looked like Greek, until I figured out how to twist I7 to operate like it would in object orientated PHP. Once I figured that out, it’s been much easier to get it to do the things I want.
If I can guess what you’re trying to do, you’re trying to make a library of objects, characters, and tools (weapons?), that create dynamic text ‘effects’. And then, to pull from those properties so that you don’t have to hard-code and rewrite these dynamic messages 100 times… is this right?
I was trying to ask in different ways, maybe the question I’m asking isn’t really the best way to go about the goal I have… maybe using properties isn’t even the best way to do what I’m doing, I dunno… as extended to the next quote
As Draconis asked, I am also very curious what you mean, because yes, that is exactly what I’m trying to do… create assemblies and “dynamic” functions of loops and variables to create an architecture on which games (not just one game, but any game with similar object types) can be made with minimal code in the game file. It sounds exactly like what you are describing… and without being able to access properties or use some form of variable substitutions for things, I’m not sure how to accomplish it in a way that doesn’t bring the application to it’s knees performance wise.
You say you managed to achieve success with this, I’m sure you can’t explain your whole framework in this post, but can you elaborate on issues related to properties (or your version of doing something similar) in your implementation?
I’m honestly not that good with C#, but given an indefinite length of time I can peck my way through just about any problem as long as I have access to the MSDN documentation. I’m probably not the best person to write hypothetical examples off the top of my head and lead you astray with incorrect information… but there really is hardly anything you CAN’T do with C#… you can access, manipulate, convert, and twist just about anything inside out and backwards if you know what you are doing… it’s not always wise or practical, but it is extremely flexible. However, writing a game like the kind you can with Inform in C# means you have to code your own parser, and that is way outside my capabilities unless I would quit my job and make this my full time endeavor (if even then) so… Inform it is!
I figured things out with trial and error using loops, variables, and functions. I began writing I7 code like I would a PHP program, and assigned variables to different things, such as people, objects, etc., that fit the generic responses I wanted. Then, I use those variables and numbers in functions to determine what my output would be.
One major thing I figured out: if you’re creating dynamic objects, you can’t directly assign properties to them, and then check those properties within a function. A dynamic object doesn’t really ‘exist’ when its created in a function.
My method is a combination of messing around, using the basic I7 objects, and assigning different kinds of numbers and values to them, then creating logic trees that lead to the messages and responses I want. I started by instantiating variables at the top. Then, using loops, I separate the different types of objects as they cycle through each while loop, and decide which one is relevant. Then, I grab the instantiated indexed text for that object, and bring it in.
How detailed and complicated you can make this, depends on how well you can use loops and variables, and throw them at the I7 compiler and see what works and what doesn’t. Eventually, you’ll find a pattern that is close enough to what you know to make I7 do whatever you want. Then it gets fun.