|
|
stranger
|
OP
stranger
Joined: Jul 2014
|
So basically I scripted a simple puzzle to test databases. The basic idea is: if all the right items are inside the trigger, something will start. This is the working script(Which doesen't really use databases as I wanted to). TriggerRegisterForItems(TRIGGER_HIB_ENIGMA02_Optable);
DB_Enigma02_bodyparts(ITEM_HIB_ENIGMA02_BODYPART1);
DB_Enigma02_bodyparts(ITEM_HIB_ENIGMA02_BODYPART2);
DB_Enigma02_bodyparts(ITEM_HIB_ENIGMA02_BODYPART3);
IF
ItemEnteredTrigger(_Item,TRIGGER_HIB_ENIGMA02_Optable,_Player)
AND
DB_Enigma02_bodyparts(_Item)
AND
ItemIsInTrigger(ITEM_HIB_ENIGMA02_BODYPART1,TRIGGER_HIB_ENIGMA02_Optable,1)
AND
ItemIsInTrigger(ITEM_HIB_ENIGMA02_BODYPART2,TRIGGER_HIB_ENIGMA02_Optable,1)
AND
ItemIsInTrigger(ITEM_HIB_ENIGMA02_BODYPART3,TRIGGER_HIB_ENIGMA02_Optable,1)
THEN
CharacterDisplayText(CHARACTER_CHARACTER_Player1, "PENNY_01"); This script as I said works, but if I want to add more items in the puzzle I need to copy/paste the same condition over and over again. So I tried this code TriggerRegisterForItems(TRIGGER_HIB_ENIGMA02_Optable);
DB_Enigma02_bodyparts(ITEM_HIB_ENIGMA02_BODYPART1);
DB_Enigma02_bodyparts(ITEM_HIB_ENIGMA02_BODYPART2);
DB_Enigma02_bodyparts(ITEM_HIB_ENIGMA02_BODYPART3);
IF
ItemEnteredTrigger(_Item,TRIGGER_HIB_ENIGMA02_Optable,_Player)
AND
DB_Enigma02_bodyparts(_Item)
AND
ItemIsInTrigger(_Item,TRIGGER_HIB_ENIGMA02_Optable,1)
THEN
CharacterDisplayText(CHARACTER_CHARACTER_Player1, "PENNY_01"); But the script doesen't work, what it does instead is to trigger the CharacterDisplayText everytime I put even only one item.
|
|
|
|
addict
|
addict
Joined: Jul 2014
|
The reason it's triggering when even one items is present is because 1) ItemEnteredTrigger triggers, and 2) The item is indeed in the database, so 3) The text is displayed on the first item. You might want to check and see if this code works:
TriggerRegisterForItems(TRIGGER_HIB_ENIGMA02_Optable);
DB_Enigma02_bodyparts(ITEM_HIB_ENIGMA02_BODYPART1);
DB_Enigma02_bodyparts(ITEM_HIB_ENIGMA02_BODYPART2);
DB_Enigma02_bodyparts(ITEM_HIB_ENIGMA02_BODYPART3);
IF
ItemEnteredTrigger(_Item,TRIGGER_HIB_ENIGMA02_Optable,_Player)
AND
DB_Enigma02_bodyparts(_Item)
THEN
PopulateTempList();
DisplayWhenAllItemsArePresent();
RemoveTempTrigger();
PROC
PopulateTempList()
AND
DB_Enigma02_bodyparts(_Item)
THEN
NOT DB_Enigma02_bodyparts(_Item);
DB_TempList(_Item);
PopulateTempList();
NOT DB_TempList(_Item);
DB_Enigma02_bodyparts(_Item);
IF
DB_TempList(_Item)
AND
ItemIsInTrigger(_Item, ITEM_HIB_ENIGMA02_Optable, 0)
THEN
DB_NotInTrigger(1);
PROC
DisplayWhenAllItemsArePresent()
AND
NOT DB_NotInTrigger(1)
THEN
CharacterDisplayText(CHARACTER_CHARACTER_Player1, "PENNY_01");
PROC
RemoveTempTrigger()
AND
DB_NotInTrigger(_Num)
THEN
NOT DB_NotInTrigger(_Num);
RemoveTempTrigger();
If I wrote the code correctly (read: I haven't tested this), then it should be making use of Recursive PROCs to iterate through the list of items and checking whether they are in the trigger, and flagging it if they're not. Then it displays the text if it wasn't flagged.
|
|
|
|
stranger
|
stranger
Joined: Sep 2014
|
Here's a slightly more concise version of Rhidian's solution. Tested and confirmed working.
TriggerRegisterForItems(TRIGGER_test);
DB_Enigma02_bodyparts(ITEM_test1);
DB_Enigma02_bodyparts(ITEM_test2);
DB_Enigma02_bodyparts(ITEM_test3);
IF
ItemEnteredTrigger(_Item,TRIGGER_test,_Player)
AND
DB_Enigma02_bodyparts(_Item)
THEN
DB_AllInTrigger(1);
TestAllInTrigger();
DisplayWhenAllItemsArePresent(_Player);
PROC TestAllInTrigger()
AND
DB_Enigma02_bodyparts(_Item)
AND
ItemIsInTrigger(_Item,TRIGGER_test,0)
THEN
NOT DB_AllInTrigger(1);
PROC
DisplayWhenAllItemsArePresent((CHARACTER) _player)
AND
DB_AllInTrigger(1)
THEN
CharacterDisplayText(_player, "PENNY_01");
Note that by passing player to the proc we can ensure that the text will display over the character that moved the object.
|
|
|
|
stranger
|
OP
stranger
Joined: Jul 2014
|
Thanks for the replies! I got the basic idead around databases, I think. Still, I suppose isn't that worthed using them in this particular script.
Just one thing about DB_AllInTrigger(1). Is this 1 a var or a way to add things to the database? In this case the item_bodyparts?
|
|
|
|
addict
|
addict
Joined: Jul 2014
|
When a Database is in a THEN statement, the game creates that database when it is reached. Databases can be created and values added (or removed) mid-game, which is one of the few ways for different functions to communicate with each other.
In svansted's example, DB_AllInTrigger(1) is creating a new database with an Integer entry of 1. The next part of the code then removes this flag if an item is not within the trigger area (by using NOT DB_AllInTrigger(1); in the THEN statement). Finally the last part checks whether the Database still exists, and displays the result if so.
|
|
|
Moderated by Bvs, ForkTong, gbnf, Issh, Kurnster, Larian_QA, LarSeb, Lar_q, Lynn, Monodon, Raze, Stephen_Larian
|
|
|