Difference between revisions of "LlRequestUpgrade"
Line 12: | Line 12: | ||
However, there are several things that may happen, depending on how the upgrade was made available. For this, there would be a command like [[llPublishUpgradableObject]] which takes a key and object name as parameter. For example: | However, there are several things that may happen, depending on how the upgrade was made available. For this, there would be a command like [[llPublishUpgradableObject]] which takes a key and object name as parameter. For example: | ||
=== The publishing script === | |||
<pre> | <pre> | ||
key typeid = "18b03c24-809b-2c19-68d9-fac357e98d29"; | key typeid = "18b03c24-809b-2c19-68d9-fac357e98d29"; | ||
Line 41: | Line 42: | ||
</pre> | </pre> | ||
=== The requesting object script (old version of the object) === | |||
<pre> | <pre> | ||
integer version = 1; | integer version = 1; | ||
Line 63: | Line 64: | ||
</pre> | </pre> | ||
=== The upgraded object script === | |||
<pre> | <pre> | ||
integer version = 3; | integer version = 3; |
Revision as of 02:21, 21 April 2007
This article is a feature request, not an actually existing function (yet)
Summary
llRequestUpgrade(key objecttypeid, integer currentversion, list params)
This command sends a request for an upgrade.
Upgrading
Sometimes you don't want to help everyone who has purchased an item you created with an upgrade of that item. In these cases you might want to build in a feature in the object so that it can replace itself for an upgraded version. This is exactly what this command does. It sends a request to the server for an upgraded version of this object and if an upgrade is available, it destroys itself and it is then replaced with an upgraded version.
However, there are several things that may happen, depending on how the upgrade was made available. For this, there would be a command like llPublishUpgradableObject which takes a key and object name as parameter. For example:
The publishing script
key typeid = "18b03c24-809b-2c19-68d9-fac357e98d29"; default { state_entry() { llPublishUpgradableObject(typeid, "some_upgradable_object"); } upgrade_request(key requester, integer currentversion, list params) { if (currentversion < 1) { llUpgradeError(Requester, "Sorry, your current version is too old. Cannot migrate the settings of your current version to the new one"); } else if (currentversion == 1) { llConfirmUpgrade(requester, 100, param); } else { llConfirmUpgrade(requester, 0, param); } } }
The requesting object script (old version of the object)
integer version = 1; key mytypeid = "18b03c24-809b-2c19-68d9-fac357e98d29"; default { state_entry() { llSetText("Version 1...", <1,1,1>, 1); } touch_start(integer num) { list params; params += "some value to pass to new version of object"; params += "another value to pass to new version of object"; llRequestUpgrade(mytypeid, version, params); } }
The upgraded object script
integer version = 3; key mytypeid = "18b03c24-809b-2c19-68d9-fac357e98d29"; default { state_entry() { llSetText("Version 3!", <1,1,1>, 1); } touch_start(integer num) { list params; params += "some value to pass to new version of object"; params += "another value to pass to new version of object"; llRequestUpgrade(mytypeid, version, params); } upgraded(integer oldversion, list params) { if (oldversion == 1) { // Do stuff to migrate settings from version 1... } else { // Do stuff to migrate settings from version 2... } } }
I think the example should make it clear, except perhaps for the second parameter to the llConfirmUpgrade command. Sometimes you might want to support an update for an object, but don't want to do it for nothing. It might have been a difficult job to support the upgrade from that version to the new one. For this, there would be a money parameter. If the value to this parameter is greater than 0, the user will receive a dialog, asking if the user wants to pay the amount of linden dollars passed.
This request might need some tweaking.. I'm interested what you think of it and what your ideas are.