Larian Studios

Osiris Scripting - Modifying Databases

Posted By: crispyduck

Osiris Scripting - Modifying Databases - 11/06/19 08:10 PM

Hi folks,

Will do my best to be clear.
I'm working with Osiris DB for the first time and it's very different from what I'm used to.

I'm not quite sure how to modify an element in a database except for removing it and replacing it and I'm not sure how to store variables.

So for example, I expected this line to give _Sum the value of 3 but it tells me it's an unbound variable.

IntegerSum(1,2,_Sum);

I'm not looking for code or anything, I just want to understand the rules for declaring variables and modifying databases .

If anyone can help I would really appreciate it.

Thanks.
Posted By: Windemere

Re: Osiris Scripting - Modifying Databases - 11/06/19 11:56 PM

You have the right idea with database entries - you would need to add/delete to modify a database with the same key signature.

For your IntegerSum call, you probably did not call it as a query in your IF/AND block but rather tried to execute it in your THEN block. Anything with an output variable needs to be part of the IF/AND block.

Here is a little example code that actually exemplifies both of your questions. In this frame when a certain flag is set, the player is given 250 gold but the amount of gold given to any player is capped at 5000


Code
IF
ObjectFlagSet("HEA_DBG_GiveGold", _Player, _ID)
AND
DB_HEA_DBG_GoldGiven(_Player, _Count)
AND
_Count < 5000
AND
IntegerSum(_Count, 250, _Sum)
THEN
CharacterAddGold((CHARACTERGUID)_Player, 250);
ObjectClearFlag(_Player, "HEA_DBG_GiveGold", _ID);
NOT DB_HEA_DBG_GoldGiven(_Player, _Count);
DB_HEA_DBG_GoldGiven(_Player, _Sum);


Posted By: crispyduck

Re: Osiris Scripting - Modifying Databases - 16/06/19 01:32 PM

Hi there,

Sorry for the later reply. This worked perfectly, I didn't know you had to do that in the IF/AND blocks, getting the hang of it now.
I think I've seen some of your video's too, all very helpful stuff. Thanks so much.
© 2019 Larian Studios forums