Paulenaz690
Member
with (pNPC)
{
var map = ds_map_create();
ds_list_add(rootList, map);
ds_list_mark_as_map(rootList, ds_list_size(rootList)-1);
if instance_exists(object_index)
{
var objName = object_get_name(object_index);
ds_map_add(map, "ObjectName", objName);
ds_map_add(map, "NPC", object_index);
ds_map_add(map, "X", x);
ds_map_add(map, "Y", y);
ds_map_add(map, "Name", name);
ds_map_add(map, "Bothered", bothered);
ds_map_add(map, "QuestsDone", questsDone);
}
}
Whats the best approach for saving NPCs, who might come and leave the map? Added if to save only NPCs on the map, but I dont know if that is needed or there is better approach.
pNPC is core NPC, or in other words parent NPC, which is parent of all objects and I dont know what game is doing, does it take all objects inside the parent, or just active ones
and how do I load NPCs?
var buffer = buffer_load("Save.txt");
var stringToLoad = buffer_read(buffer, buffer_string);
buffer_delete(buffer);
var wrapper = json_decode(stringToLoad);
var list = wrapper[? "ROOT"];
for (var i = 0; i < ds_list_size(list); i++)
{
var map = list[| i];
var npc = map[? "ObjectName"]; //
var obj = map[? "ObjectID"];
if object_exists(obj)
{
with (npc)
{
x = map[? "X"];
y = map[? "Y"];
name = map[? "Name"];
bothered = map[? "Bothered"];
questsDone = map[? "QuestsDone"];
}
}
This method gives only exception
{
var map = ds_map_create();
ds_list_add(rootList, map);
ds_list_mark_as_map(rootList, ds_list_size(rootList)-1);
if instance_exists(object_index)
{
var objName = object_get_name(object_index);
ds_map_add(map, "ObjectName", objName);
ds_map_add(map, "NPC", object_index);
ds_map_add(map, "X", x);
ds_map_add(map, "Y", y);
ds_map_add(map, "Name", name);
ds_map_add(map, "Bothered", bothered);
ds_map_add(map, "QuestsDone", questsDone);
}
}
Whats the best approach for saving NPCs, who might come and leave the map? Added if to save only NPCs on the map, but I dont know if that is needed or there is better approach.
pNPC is core NPC, or in other words parent NPC, which is parent of all objects and I dont know what game is doing, does it take all objects inside the parent, or just active ones
and how do I load NPCs?
var buffer = buffer_load("Save.txt");
var stringToLoad = buffer_read(buffer, buffer_string);
buffer_delete(buffer);
var wrapper = json_decode(stringToLoad);
var list = wrapper[? "ROOT"];
for (var i = 0; i < ds_list_size(list); i++)
{
var map = list[| i];
var npc = map[? "ObjectName"]; //
var obj = map[? "ObjectID"];
if object_exists(obj)
{
with (npc)
{
x = map[? "X"];
y = map[? "Y"];
name = map[? "Name"];
bothered = map[? "Bothered"];
questsDone = map[? "QuestsDone"];
}
}
This method gives only exception
Last edited: