Aller au contenu

Photo

[Help] Resource from object for a summon-able chest


  • Veuillez vous connecter pour répondre
24 réponses à ce sujet

#1
Quildra

Quildra
  • Members
  • 45 messages
Any one have any idea how to get a resource from an object?

Reason being I am trying to make a portable chest. I have the chest spawning from an item use. I have the chest able to store items and remove items. I have the chests inventory stored for when we move areas.

the last bit i need to do it re-add the items to a newly spawned chest in the new area. 
The only problem is that i have only got objects. and all the add item functions take resources.

I have made my current working in progress downloadable on a project which can be found here.
So any help with the last bit needed for this mod would be very welcome. 

Modifié par Quildra, 20 novembre 2009 - 08:56 .


#2
AND04

AND04
  • Members
  • 154 messages
make the file "public" and i'll gladly take a look - should be easy enough imo

#3
Quildra

Quildra
  • Members
  • 45 messages
... what do you mean it was always public .....:whistle: 

#4
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
You can try using MoveItem with an invalid source object...might work:
[dascript]MoveItem( OBJECT_INVALID, oNewChest, oItem );[/dascript]

Modifié par Axe_Murderer, 20 novembre 2009 - 10:17 .


#5
Quildra

Quildra
  • Members
  • 45 messages
Nope didn't work :( Nice idea though.

#6
Quildra

Quildra
  • Members
  • 45 messages
Ok as an update to the global objects it turns out that my object[] is being cleared when I move zones. so I cant even try to do move item :(

#7
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
A topic that might help

I realize you know about the thread already but for others following this...

Modifié par Axe_Murderer, 21 novembre 2009 - 12:28 .


#8
maikanix

maikanix
  • Members
  • 142 messages
He was heavily involved in that topic, you silly billy

edit:nvm

Modifié par maikanix, 21 novembre 2009 - 12:22 .


#9
Nodrak

Nodrak
  • Members
  • 144 messages
It seems as though the scripts we have acess too via the toolset (ie, not the engine), is called 'event script'. It is possible that these scripts are non-persistent in the engine, but that seems oddish, since that would make all the scripts assign and reassign their variables every time they are run, or atleast at whatever rate they are unloaded at.

If we really can't store global vars in a script like the one we were talking about, you might have to 'attach' is to the player somehow, since they would have to be 'persistent'. To me, it is looking like the 2da data structure is what is supposed to these 'global vars', and as such you may have to make a 2da with a defined length to store items in.  (Can we write to a 2da from script?)

I will try working on this topic when I have some time too.  Trying to find an example in the existing script where they declare a variable, but define it in a different loop of logic might reveal any voodoo we overlooked.

Modifié par Nodrak, 21 novembre 2009 - 02:11 .


#10
maikanix

maikanix
  • Members
  • 142 messages
Can the game still access items in the inventory of inactive objects?


#11
kosmonymous

kosmonymous
  • Members
  • 16 messages
You can save a lot of information to 2da and if you put it to player object or (preferably?) to module object you can access it globally.

#12
Quildra

Quildra
  • Members
  • 45 messages
To get slightly back to the original problem.

does any one know a cunning way to get a resource from an object?

I can get the tag but the tag doesn't always mean a resource :(

#13
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
GetResRef will give you the string I think but then you need a way to convert that to a resource.
string sThingy = GetResRef( oThingy );
resource rThingy = R sThingy; // seems to be no way to do this either ?????
Maybe there is a StringToResource or ObjectToResource function? There must be somewhere in the core code where they do something like this.

Modifié par Axe_Murderer, 21 novembre 2009 - 07:42 .


#14
weriKK

weriKK
  • Members
  • 106 messages

Axe_Murderer wrote...
Maybe there is a StringToResource or ObjectToResource function? There must be somewhere in the core code where they do something like this.


I can't see the reason why would they do something like that.
They know beforehand what resources they have and how they want to handle them. I think they simply separate cases with plot flags instead of defining resources dynamically.

About moving chest content:
I'd probably tinker around with moving the item into the player's inventory from the chest, set it's active status to inactive so it does not show up on the client, and create a module variable m2da to store item tracking data.

Something like:
if chest to be dismissed
    for each item in chest inventory
        move item to player inventory
        deactivate item
    store tracking data in module_var
    destroy chest

if chest to be summoned
    create chest
    retrive tracking data from module_var
    for each item in tracking data
        move item from player inventory to chest inventory
        activate item

#15
Quildra

Quildra
  • Members
  • 45 messages
The only problem with that plan is that people will end up using the chest as excess storage when their inventory is full.



I was planning, if it was possible, to get the resource as a string and the item count and use kosmonymous 2da array project to write them out to a 2da, then laod them back in when the chest is summoned.




#16
weriKK

weriKK
  • Members
  • 106 messages
You can add obects to your inventory even if it's full via scripts. Now I am unsure of the consequences of that but I am 100% sure you can go over the artificial inventory limit. I am also fairly sure that you have quite a lot of hidden items in your inventory, like the specialization books.

#17
AND04

AND04
  • Members
  • 154 messages

weriKK wrote...

You can add obects to your inventory even if it's full via scripts. Now I am unsure of the consequences of that but I am 100% sure you can go over the artificial inventory limit. I am also fairly sure that you have quite a lot of hidden items in your inventory, like the specialization books.


true idd - and we wouldn't even need a variable to differentiate the items that belong into the chest - we'd just need to add something to the tag (like_summon_chest) and then remove it again.

#18
Craig Graff

Craig Graff
  • Members
  • 608 messages
I think you'll find you are better off exploring the fact that the char_stage area is always in memory and you can move your chest there with SetLocation, then bring it back in the same way.

(Edit: fixed name of area)

Modifié par Craig Graff, 23 novembre 2009 - 03:55 .


#19
weriKK

weriKK
  • Members
  • 106 messages

Craig Graff wrote...

I think you'll find you are better off exploring the fact that the char_gen area is always in memory and you can move your chest there with SetLocation, then bring it back in the same way.


Awesome :) I wonder how many secrets are hidden in that area!

#20
AND04

AND04
  • Members
  • 154 messages

Craig Graff wrote...

I think you'll find you are better off exploring the fact that the char_gen area is always in memory and you can move your chest there with SetLocation, then bring it back in the same way.


nice - a global area thx a lot :)

edit: hmm i can't seem to access the area - whats the tag for it? "char_gen" doesn't work for me :/

Modifié par AND04, 22 novembre 2009 - 04:10 .


#21
Craig Graff

Craig Graff
  • Members
  • 608 messages
Sorry - my fault for being tired and away from the toolset - I meant char_stage.

#22
Quildra

Quildra
  • Members
  • 45 messages
excellent! I shall give that a try tomorrow. I may even have a working mod by the end of the day :)

#23
AND04

AND04
  • Members
  • 154 messages
great - it works :)
many thx @Craig
@Quildra i got mine running now - summonable chest that keeps its contentss wherever i go :)

if you run into any problems leave me a pm

edit: hmm, the first Draft of Mod is finished - it is a summonable Chest as well - though that is not its Main purpose:

http://social.bioware.com/project/883/

Modifié par AND04, 23 novembre 2009 - 01:26 .


#24
Quildra

Quildra
  • Members
  • 45 messages
Yeah the Release of mien should happen later today, then can start working on the item count restriction as i want to eventually turn mine into a quest, where you complete a series of challenges to unlock more space in the chest.

#25
Quildra

Quildra
  • Members
  • 45 messages
What event did you wire your de-spawn function to?