R
rawket
Guest
So I've got an object which runs the create event when I hit "E" near it, and then on a one step alarm, runs a dialogue object using variables in the creation code. I'm now trying to use ds maps to change it's state actively in the creation code and thus use different dialogue options.
Instances creation code--------------------------------------------------------------------------------------------
Objects step event--------------------------------------------------------------------------------------------
Objects User Event 0--------------------------------------------------------------------------------------------
So that's the whole thing. If you need any of the custom scripts posted as well I can do that. The issue is that this setup works for pretty much every other thing. I'm trying to get it to change its state after running through the first three lines once so that the next time I interact with it, it runs through the next set of lines. The thing is, it should be working as far as I can tell because, it's successfully changing the variable I need it to change it just doesn't seem to notice UNLESS I leave the room and re-enter, then it goes to the next set of lines. But if I don't leave the room it keeps going through the first set, repeating itself, and allowing me to farm gold unfairly.
Instances creation code--------------------------------------------------------------------------------------------
Code:
key = scr_save_data_get_key();
var _save_data = ds_map_find_value(save_game_data, key);
if (is_undefined(_save_data))
ds_map_replace(save_game_data, key, "first");
state = ds_map_find_value(save_game_data, key);
if state == "first"
{
lines = 3;
scr_resetDialogue();
i = 0;
line[i] = "There's a couple books on these shelves.";
scrpt[i] = [scr_addCoins, 5];
i++
line[i] = "One of them has some coins in it!";
scrpt[i] = [ds_map_replace_intext, save_game_data, key, "looted"];
i++
line[i] = "You got 5 coins!";
scrpt[i] = [scr_change_variable, "state", "looted"];
}
else if state == "looted"
{
lines = 3;
scr_resetDialogue();
i = 0;
line[i] = "There's a couple books on these shelves.";
i++
line[i] = "They appear to be written about the islands history and culture.";
i++
line[i] = "Read one?";
}
Code:
if (!instance_exists(obj_text))
{
current_line = 0;
}
if (keyboard_check_pressed(ord("E"))) && (distance_to_object(obj_player) <= 4) && (((bbox_left <= obj_player.x) && (obj_player.x <= bbox_right) && (((obj_player.y <= y) && (obj_player.idleDir = 4)) || ((obj_player.y >= y) && (obj_player.idleDir = 2)))) || ((bbox_top <= obj_player.y) && (obj_player.y <= bbox_bottom) && (((obj_player.x <= x) && (obj_player.idleDir = 1)) || ((obj_player.x >= x) && (obj_player.idleDir = 3)))))
{
event_user(0);
alarm[0] = 1;
}
if (instance_exists(obj_text)) with obj_player
{
hsp = 0;
vsp = 0;
state = states.handsOff;
}
Code:
event_perform(ev_create, 0);