Jump to content

Pointers


*i

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...