Author Topic: SetChosenActions() targeted item in the container  (Read 2799 times)

SetChosenActions() targeted item in the container
« on: January 13, 2015, 01:42:00 am »
Hello.
I'm trying to apply SetChosenActions() to an item, laying the in container.
The critter has opened the container the typical way, then after he clicks the item, I have the item.Id and should be enough.
The problem is that I swear to God it worked 2 days ago but not anymore. I checked all changes but didn't find any changes which could lead to this.

So I call these to each of the functions:

Code: [Select]
void ChosenScienceItem(uint itemId)
{
uint[] skill = { CHOSEN_USE_SKL_ON_ITEM, 1, SK_SCIENCE, itemId, 0, 0, 0 };
SetChosenActions(skill);
}

void ChosenEngineerItem(uint itemId)
{
uint[] skill = { CHOSEN_USE_SKL_ON_ITEM, 1, SK_ENGINEERING, itemId, 0, 0, 0 };
SetChosenActions(skill);
}

I have correct itemId (at least server log shows itemId the same I've sent to the function). And yes, it works in inventory and pickUp screens if I target item in the critter's inventory.
I know that arguments are suppose to be IsInventory, Skill index (SK_*), Item id. If I change IsInventory to 0, then action doesn't happen even for items in critter inventory.

1. Any idea if it's possible to apply SetChosenActions() to the item in the container or I was on hard drugs while it was working for >3 hours?
2. What is IsInventory exactly?
3. Can you please elaborate parameters for CHOSEN_MOVE_ITEM ( Item id, Item count, To slot, Is barter container, Is second try ) ? What are Is barter container and Is second try?
4. How exactly works SLOT_GROUND? Can I use it for items items in the containers? If not, is there anything like that I can use?
5. Is there a way to update the PickUp screen of the item (e.g. looting the locker), so it won't show items moved out of it ? E.g. if I call MoveItem( item, count, cr ) I will see changes after I call item.Update() in the critter inventory but not in the locker inventory. Surely I can call cr.ShowContainer(null, container, TRANSFER_HEX_CONT_UP) , but then I will lose scrolling position.
« Last Edit: January 13, 2015, 03:10:02 pm by paragonid »

Re: SetChosenActions() targeted item in the container
« Reply #1 on: January 19, 2015, 05:41:24 pm »

Offline Wipe

  • Rotator
  • Random is god
Re: SetChosenActions() targeted item in the container
« Reply #2 on: January 26, 2015, 12:54:45 am »
Glad that this old wrapper helped someone :)

As for updating screen, what you most likely want is RefreshItemCollection() [just look up barter filters for examples], GetScroll() and SetScroll(); these three used in right way should be enough for smooth screen update - at least in default.ini-based interface.
Games are meant to be created, not played...

Re: SetChosenActions() targeted item in the container
« Reply #3 on: January 29, 2015, 06:00:46 am »
Yes, thank you a lot for it.

Couple of mysteries are still there: like why did it work for items in the containers for me

Re: SetChosenActions() targeted item in the container
« Reply #4 on: February 01, 2015, 10:03:19 am »
Back to params:
CHOSEN_MOVE_ITEM's param "Is second try" certainly changes behaviour, in state 1 if queue is used it just makes critter does nothing, while it's ok in state 0. I don't get it ):

Offline Wipe

  • Rotator
  • Random is god
Re: SetChosenActions() targeted item in the container
« Reply #5 on: February 02, 2015, 07:50:04 pm »
SecondTry is used internally when swapping items, don't think it's intended to be used by scripts; more like cvet's notes for future self in case of changes.
Games are meant to be created, not played...