| 09-03-2008, 11:36 AM | #1 |
1) Is it possible to do something like local MyStruct data = SomeInt? (yes, I know structs are integers, but I've never actually set it to a specific integer before )2) If the second one of the above is possible, is there anything specific that needs to be done before I can do it, or can I directly set the struct variable to SomeInt? I'm making a lightning system and I want some fairly easy way to allow users to change some of the lightning's properties (such as the source, the target, the RGB values) after the lightning has been created |
| 09-03-2008, 11:55 AM | #2 |
to 1): yes, that is possible. to 2): depends. normal structs only use integers values that are are >0 and <8190(or 8191, not 100% sure), due to the fact that they're actually used as indexes for global arrays that store the variables of each struct instance. However, if you look at vex' ARGB, you will see that you can do all kinds of fancy stuff with them, aslong as you know what you're doing. Try to figure out how ARGB works, that will help you alot. now the question is, WHY you do not want to use methods or custom operators to let the user change you lightning's properties? |
| 09-03-2008, 12:11 PM | #3 | |
1) Fair enough 2) Thanks for the tip on ARGB Quote:
Anyway, until I find something wrong with how I'm doing things so far, it's going to stay that way |
| 09-03-2008, 03:58 PM | #4 |
You always has to expose the way the user can intereact with the struct behaviour. You just need to tell then what functions are available to them, by setting the public and documenting them. The innards (to be precisoe, how your struct does what it was meant to do) should be kept private, though. |
| 09-03-2008, 05:01 PM | #5 |
Meh, I've got everything coded now (and I don't plan on changing it) - having normal functions acting as a go-between for end-user and struct works just fine Anyway, if I allowed access to the struct, someone will, inevitably, be stupid enough to call DestroyLightning (data.tl) and come complaining to me when the game crashes as a result of their stupidity >.> |
| 09-03-2008, 06:36 PM | #6 |
well, you can't be 100% foolproof. if they are stupid to do that, they shouldn't be using your scripts to begin with. |
| 09-03-2008, 07:24 PM | #7 |
Well, if they start messing with the system code itself, they get what they deserve ![]() |
