im having trouble with frikfile and saving/loading my bot waypoints
Saving seems to work, but it seems not to load and spawn on the map..
Anybody can help me?
heres the frikfile code:
Code: Select all
void(vector here, float which) create_waypoint;
void() write_waypoints =
{
local float file;
string h;
h = strcat(mappath, ".way");
file = fopen (h, FILE_WRITE);
local entity botwp;
botwp = find(world, classname, "waypoint");
while (botwp)
{
dprint ("Saving waypoints\n");
fputs(file,"create_waypoint(");
fputs(file,vtos(botwp.origin));
fputs(file,")\n");
botwp = find(botwp, classname, "waypoint");
if (botwp)
fputs(file,"\n");
}
fclose(file);
};
void() Load_Waypoints =
{
float file, which;
string h;
local vector here;
dprint("loading waypoints.. \n");
h = strcat(mappath, ".way");
file = fopen (h, FILE_READ);
if (file == -1)
{
dprint("Error: file not found \n");
return;
}
while (1)
{
bprint("Loading waypoint\n");
// the first line is just a comment, ignore it
h = fgets(file);
if (h != "waypoint")
{
bprint("Last waypoint\n");
fclose(file);
return;
}
h = (fgets(file));
here = stov(h);
h = (fgets(file));
which = stof(h);
create_waypoint(here, which);
}
};
Code: Select all
void(vector here, float which) create_waypoint =
{
local entity ent;
ent = spawn();
ent.solid = #SOLID_TRIGGER;
ent.movetype = #MOVETYPE_NONE;
setorigin(ent, here);
ent.model = "progs/s_bubble.spr";
ent.touch = way_touch;
ent.flags = FL_ITEM;
ent.classname = "waypoint";
ent.waypoint = which;
total_ways = total_ways + 1;
};