Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: How to update the items.items list  (Read 878 times)

0 Members and 1 Guest are viewing this topic.

redfox

  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 122
    • View Profile
How to update the items.items list
« on: September 24, 2016, 02:30:33 AM »

How can I update my Items.Item list for an update, when people already have save games? Other files update but the item list does not?

I tried using Game.LoadItems("items\items.items"); and with merge option too, but it deleted the exiting collected items.
Logged

redfox

  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 122
    • View Profile
Re: How to update the items.items list
« Reply #1 on: September 24, 2016, 09:52:37 AM »

This is my reset function code - this is run for a script thats attached to the game - it resets scripts but dosnt update item list :(

Code: [Select]
method RefreshScript()
{
Game.DetachScript("scripts\game.script");
while(Game.IsScriptAttached("scripts\game.script")) Sleep(1);
Game.DetachScript("items\items.items");
while(Game.IsScriptAttached("items\items.items")) Sleep(1);

Game.ClearScriptCache();
Game.AttachScript("scripts\game.script");
Game.AttachScript("items\items.items");
}
Logged

redfox

  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 122
    • View Profile
Re: How to update the items.items list
« Reply #2 on: September 24, 2016, 10:10:43 AM »

I have tried to put the items.items list in a new package with a higer priority, but this also dosn't work to update the item list.

Any ideas how I can do this? Or how to create a new item list and add code to get the new list to merge even with loading older save games?
Logged

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 184
    • View Profile
Re: How to update the items.items list
« Reply #3 on: September 24, 2016, 11:35:50 PM »

Just to make sure I have understood you correctly  - that what you are trying to do is to add items to a list within a saved game. The only logical reason I can think for doing this is that you are updating the game and want to allow users access to new items - or have I missed something ?

Irrespective of that looking at your code I personally wouldn't recommend the approach of detaching the game scripts, that seems to me to be a tad risky with not obvious benefit.

I don't believe the item file is a script file as such, it's more akin to data, so attaching/detaching it is probably not going to help.


You may have done this already but if I was trying to focus down on the problem I would be tempted to code something like this.



Code: WME Script
  1. on "event" // some trigger event
  2. {
  3.  var ValidInput = false;
  4. ValidInput =LoadItems("items\NewItems.Items",true); // where NewItems.items is your definition file containing the new items you wish to add
  5.  
  6. }
  7.  

When you have initiated the event simply step through the code keeping an eye on the ValidInput var - if it changes to true then your Items file has merged, if not then there is a problem,and I guess then go look at the definition file.

NB I have just tested this in the demo game and it works perfectly well



Logged
 

Page created in 0.277 seconds with 22 queries.