-
Notifications
You must be signed in to change notification settings - Fork 8
Inventory Transaction Factory
Hawkmax edited this page Sep 12, 2025
·
1 revision
Factory for creating and managing inventory transactions. Supports chaining and configuration before execution.
Constructor:
InventoryTransactionFactory(_inventory)Factory Methods:
-
create_add(_item, _stack_size): Prepares AddTransaction. -
create_remove(_item, _is_moving_all): Prepares RemoveTransaction. -
create_move(_item, _target, _is_removing_all): Prepares MoveTransaction. -
create_buy(_item, _inventory, _available_money): Prepares BuyTransaction. -
create_split(_item, _stack_size): Prepares SplitTransaction. -
create_join_or_swap(_item1, _item2, _stack_size): Prepares Join or Swap transaction. -
create_join(_item1, _item2, _stack_size): Prepares JoinTransaction. -
create_swap(_item1, _item2): Prepares SwapTransaction. -
create_clean_up(): Prepares CleanUpTransaction.
Execution Methods:
-
execute(): Executes transaction and returns_TransactionData. -
try_execute(): Simulates transaction without modifying inventory. -
repeat_exec(_count, _is_trying): Executes multiple times; stops on failure. -
get_data(): Returns_TransactionDataof last transaction.
Configuration / Chaining:
-
set_inventory(_inventory): Assigns inventory. -
set_owner(_owner): Sets transaction owner. -
set_prop(_name, _value): Sets custom property. -
binder(): Returns binder for stepping back in chain.
The InventoryTransactionFactory allows chaining of transactions, configuration of owners, and simulation of transactions using try_execute().
var fac = new InventoryTransactionFactory(player_inventory);
var inv1 = fac.get_inventory();
var inv2 = another_inventory;
var item = new InventoryItem("Potion", 10);
var trans_data = fac
.create_add(item)
.set_inventory(inv2)
.execute();
dlog(trans_data.success_state);
dlog(trans_data.new_length);
dlog(trans_data.new_count);
dlog(trans_data.new_weight);var trans_data = fac
.create_add(item)
.set_owner(self)
.set_prop("test_prop", "Hello World!")
.execute();
dlog(trans_data.owner);
dlog(trans_data.test_prop);var trans_data = fac
.create_add(item)
.repeat_exec(2)
.parent()
.create_remove(item)
.execute();
dlog(trans_data.new_count);
dlog(trans_data.new_weight);var trans_data = fac
.create_add(item)
.repeat_exec(2)
.parent()
.create_move(new InventoryItem("*"), inv2, true)
.execute();
dlog(trans_data.new_count);
dlog(trans_data.unmoveable_count);var trans_data = fac
.create_add(item)
.repeat_exec(2)
.parent()
.create_buy(new InventoryItem("*"), inv2, 750)
.execute();
dlog(trans_data.new_count);
dlog(trans_data.return_money);var trans_data = fac
.create_add(item)
.execute()
.parent()
.create_split(inv.get_item(0), 5)
.execute();
trans_data = fac
.create_join(inv.get_item(0), inv.get_item(1))
.execute();var trans_data = fac
.create_add(item)
.execute()
.parent()
.create_swap(inv.get_item(0), inv.get_item(9))
.execute();
dlog(trans_data.new_index1);
dlog(trans_data.new_index2);fac.set_inventory(inv3)
.create_add(item)
.repeat_exec(2);
var trans_data = fac
.create_clean_up()
.execute();
dlog(trans_data.new_length);var trans_data = fac
.create_add(item)
.repeat_exec(2, true);
dlog(inv.items_length());Raptor free: Animation ● StateMachine ● Files(Sync) ● Macros ● Logger ● Controllers ● LG Localization ● Particle Effects ● Tools, other Objects and Helpers
Raptor pro: RACE (The Random Content Engine) ● Savegame System ● UI Subsystem ● Shaders ● Files(Async) ● RichJson ● Scriptor
Back to Repo ● Wiki Home ● Copyright © coldrock.games
- Home
- Working with raptor
- Create a Game
- raptor's object model
- Macros
- Logger
- Controllers
- StateMachine
- Animation
- Particle Effects
- LG Localization
- Interfaces
- Tools, other Objects and Helpers
Raptor Pro Modules