AGS Pointers for Dummies: Difference between revisions

Added note about AGS 3.0 extender methods..
*>Monkey 05 06
mNo edit summary
*>Monkey 05 06
(Added note about AGS 3.0 extender methods..)
Line 3: Line 3:
<center>'''<font size="4">AGS Pointers for Dummies</font>'''</center>
<center>'''<font size="4">AGS Pointers for Dummies</font>'''</center>


<center>'''''<font size="3">A reference for the rest of us!</font>'''''</center>
<center>'''''<font size="3">A Reference for the Rest of Us!</font>'''''</center>


If you're reading this, then you've come looking for answers. ''What are pointers? How do I use them? What makes them better than just using integers?'' These questions, amongst others shall be answered. You're not alone in the confusion caused by pointers. Many people who are new to scripting, or haven't ever used a language that supported pointers don't understand them right away. That's why I'm here to help.
If you're reading this, then you've come looking for answers. ''What are pointers? How do I use them? What makes them better than just using integers?'' These questions, amongst others shall be answered. You're not alone in the confusion caused by pointers. Many people who are new to scripting, or haven't ever used a language that supported pointers don't understand them right away. That's why I'm here to help.
Line 137: Line 137:
This also provides advantages when working with the player's active inventory item.
This also provides advantages when working with the player's active inventory item.


===Player.ActiveInventory===
====Player.ActiveInventory====


In an integral system to access the player character's active inventory, you would have to do something like this:
In an integral system to access the player character's active inventory, you would have to do something like this:
Line 247: Line 247:


You can extend any of the managed types that you can create pointers to in this manner.
You can extend any of the managed types that you can create pointers to in this manner.
====Extending the Character Type for AGS 3.0+====
The above example was originally written and designed around the 2.7x branch of AGS. As of AGS 3.0 however, we have the ability to use extender methods. For this particular example, I would recommend adding global extenders such as Character.GetHealth and Character.SetHealth instead of using a separate structure globally. You could still use the structure inside of your script (perhaps in a different script, where the extenders would actually be defined), but it would make it simpler to integrate your extensions into existing scripts by using extenders instead. Check them out if you're using a 3.x version of AGS!


=Closing=
=Closing=
Anonymous user