Pointers

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: Pointers
The Establishment
Member # 6
Profile #0
I've been thinking and I plan on introducing a new concept into OBoE that will drastically expand its programming power. A pointer is a value from -100 to -199 that when inserted into a node field references a value specified in an array of length 100.

Why do we care? Because as of now it is impossible to insert a dynamic value inside a field. Suppose I want to create a node to give all of the level 4 mage spells. Currently I would need to create a unique node for each one. With the pointer, I can put a dummy value (say -110 representing variable index 10) of 0. After I call the add spell node, I can increment the value of the pointer by 1 and recall it until I have given all of the mage spells.

I've done some basic testing and it appears to work. Before implementing this, I need comments. The one cost of this power is that it will break current save files. I may try to fix this, but I don't know how quite yet. Any comments or objections?

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
Babelicious
Member # 39
Profile Homepage #1
So will there be new nodes to populate this array, increment and decrement its values, etc? I mean, I like the idea, but how many nodes will it cost?

In addition, couldn't we find a way to allow the value of SDFs to be used instead? That seems potentially more powerful, and there are already nodes in place to manipulate those. At the very least, I'd want to be able to load the value of an SDF into a pointer slot, and vice versa.

At which point you'd really have more of a really large register system.

--------------------
Pygmalion | Desperance | Djur
Posts: 1074 | Registered: Wednesday, October 3 2001 07:00
The Establishment
Member # 6
Profile #2
Yes, the current nodes for manipulation are: Set Pointer, Pointer to/from Flag, and Pointer Arithmetic. I'm working on comparison ones now.

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
The Establishment
Member # 6
Profile #3
To better answer your question, there are four nodes planned:

Set Pointer: sets a pointer to a specific numerical value (which may be another pointer). ex1a = pointer ID (0-99), ex1b = value to set

Pointer to/from Flag: transfers data from a pointer to a flag and vice versa. sd1,sd2 = flag. ex1a = pointer ID (0-99), ex1b = 0 for send value from pointer to flag, 1 for send value from flag to pointer. Note that set flag can do the send value from pointer to flag.

Pointer arithmetic: does expression a +/- b = c. ex1a: pointer a, ex1b: pointer b, ex2a: pointer c, ex2b: 0 for add, 1 for subtract. Pointer c may be the same as a or b.

Compare pointer?: Does a comparison of a pointer with a value (or another pointer). ex1a: pointer id (0-99), ex1b: value, ex2a: 0 for equal, 1 for greater than, ex2b: special to jump to if condition met.

Total cost is four nodes. But it drastically expands the power. I thought about using flags, but as is we need two values to reference a flag which is difficult to port into one individual field.

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
The Establishment
Member # 6
Profile #4
I've been rethinking (I didn't edit because it is a major shift in thought). That it would be better to just do one node. It sets a pointer to reference to a flag. If you change the value of the flag, the pointer value also adjusts. This way we do not need any comparison or other tests, just one node to reference.

A loop structure would look like this:

1: Set Pointer 10 to reference flag 100,0
2: Set flag 100,0 = 0
3: Give Mage Spell (-110) [reference pointer 10]
4: Increment 100,0 by 1
5: If 100,0 less than 10, goto 3, else goto 6
6: Set Pointer 10 to reference flag -1,-1 (nullify)

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
Babelicious
Member # 39
Profile Homepage #5
Yeah, that saves a few node types, as well as uncountable nodes per chain. Good thinking.

--------------------
Pygmalion | Desperance | Djur
Posts: 1074 | Registered: Wednesday, October 3 2001 07:00
The Establishment
Member # 6
Profile #6
I reworked the pointers as I had stated above. The tests I have run appear to work. I was also able to fix the save file problem. In doing so, I put in a version index at the beginning of every save file to help with future changes.

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00