GameMaker: Studio
Gamemaker error code that I dont get, can anybody help me please?
Whenever I try to rn my game an error code that says:

FATAL ERROR in
action number 1
of Step Event0
for object obj_honey:

Push :: Execution Error - Variable Get 12.switches(100002, -1)
at gml_Object_obj_honey_StepNormalEvent_1 (line 1) - if(GameState.switches[? "quest_honeypot_started"] == true){
############################################################################################


its wierd because it used to work perfectly at first but now i just dont know what to do anymore?
< >
กำลังแสดง 16-30 จาก 42 ความเห็น
ok guys, its still not working, so I'm not sure you guys are willing to do thism but can you tell me each code and wherer I must put it. I'm not going to use coal anymore, im using syrup now and i have an item parent (basically each item object has it as a parent). Please tell me how and where to form the code. it all comes down to this. I still can't believe something like this is so hard to understand when it shouldn't be. Or maybe i'm just stupid. Just understand, that I am doing programming on my spare ti,me. I'm not even learining it in school yet. IU just really want to start programming as I took a deep interest to it. Thank you guys for your help (and previous help) in advance :)
Make a room called "rm_loading" or something similar. You'll need to go to this room before entering the main game. That way we can create some global variables before the proper game starts.

In the loading room creation code:
for (n = 0; n <= 20; n += 1) // change 20 to whatever number of items you want to track { global.item_collected[n] = false; // this will populate the array and make everything false }

Now right click on each item object that you place in the room and go to "Creation Code" and add:
item_id = 0; // change the 0 to whatever number you want (must be unique for each)

Wherever you have the code for the item being "picked up" (probably the item's step event) you need to add:
// within the if statement for the item pick up global.item_collected[item_id] = true;

And finally (also in the item's step event, but outside of the "pick up" check):
if (global.item_collected[item_id] == true) { instance_destroy(); }

There are other ways to do this, but this is the simplest way I could think of.

Note that the game will crash if you forget to give an object an id number or if the object's id number exceeds the length of the array in the creation code (the 20 from earlier).
แก้ไขล่าสุดโดย Thew; 25 ก.ค. 2014 @ 9: 30am
Note that the game will crash if you forget to give an object an id number or if the object's id number exceeds the length of the array in the creation code (the 20 from earlier).

There's an easy enough fix for that first one, I'd wager; you should be able to declare item_id in the object's create event and give it a default value (probably zero), and then have the instance creation code overwrite that and set the value to something else. Any item you neglect to tag will be marked the same and all go at once, but it'll prevent a game crash well enough.
โพสต์ดั้งเดิมโดย Zaron X:
There's an easy enough fix for that first one, I'd wager; you should be able to declare item_id in the object's create event and give it a default value (probably zero), and then have the instance creation code overwrite that and set the value to something else. Any item you neglect to tag will be marked the same and all go at once, but it'll prevent a game crash well enough.

Ah, I wasn't sure whether the creation code or the create event would be parsed first. If that's the case, then yeah -- easy fix!
I think older versions were a bit iffy on that matter but I believe Studio finally straightened that crap out. I could be wrong! I imagine that'll be apparent pretty quick if so. XD
ok maybe its a different problem See I think I found a different problem. When I leave the room_1 to room_2 and then go back to room_1, i think game maker is reloading everything in room_1 when I go to room_2 (same scenario when I go to room_1, everything in room_2 (all objects, characters, etc.) is reloaded). Is there a way to change that?
You can get around this by checking the "persistent" checkbox inside the objects (which you probably should do for your player object, at least), but the code I gave you above is designed to get around this problem. Each time you enter the room, it reloads the items, but if the global variables are set to "true" then those items are instantly destroyed.

The global variables are not reset when you leave the room. They remain persistent throughout your project (they also stay in memory all the time, so you should only use them when you have to).
when you wrote

global.item_collected[n] = false;

do I actually type in 'n'
i think i did something wrong. When I take 1 of the 3 syrup jars and leave the room_1 and go to room_2 and then when I go back to room_1, the other 2 syrup jars are gone
Never mind, I GOT IT TO WORK :D! But, but, but ,but. What do I do when this happens:


############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object obj_item_parent:

Push :: Execution Error - Variable Get -1.item_id(100044, -1)
at gml_Object_obj_item_parent_StepNormalEvent_1 (line 1) - if (global.item_collected[item_id] == true)
############################################################################################
basically when I want to put the object somewhere out of the inventory slot, something cancels it out
That error is warning you that the item_id variable doesn't exist. I believe this code should go in the child objects, not the parent. But if you do have something referencing it in the parent step event, make sure you make the variable in the create event first.

item_id = 0;

And above, you asked if you actually need to put the 'n' as the array index -- yes! The value of 'n' will change each time the loop iterates. In my example the loop runs 21 times. 'n' starts at 0, and will eventually have a value of 20.

EDIT: And it might help if you post some of your actual code, so we can see specifically what you're trying to do.
แก้ไขล่าสุดโดย Thew; 25 ก.ค. 2014 @ 11: 24am
Ok, but im not sure youll like this coding:

in item parent;

left pressed event

///Pick up selected item

///Make sure you have NO item
if(global.item == -1){
global.item = object_index;
global.item_collected[item_id] = true;
}


in step event;

if (global.item_collected[item_id] == true)
{
instance_destroy();
}

In obj_syrup right pressed event

action 1;

if(mouse_check_button(mouse_button) == true){
show_debug_message("healed player with syrup")
instance_destroy ();
}

mouse_button = vk_right

(irrelevant)

I know it looks messy but it does work
If I had to guess, I'd wager you didn't assign the item_id to one of the objects in the room, and if you're not decalring the variable anywhere else it has nothing to default to.

My general rule with parent objects is to declare defaults for every child object; if every single item uses item_id, then in the parent's create event, declare item_id. If your child objects don't need to change that information, you don't need to declare or alter it so long as the parent has it and it's not overriden (if a parent and child share an event, ie. a Step event, the child event takes priority, but you can call the parent's event from the child with a certain d&d action or line of code). This is actually a pretty serious time saver, so long as you're using your parenting properly.

I'd also argue against the use of persistent objects generally, and rooms... ever. There is very little reason to ever need a persistent room; it causes more problems than it solves, proper use of globals can work around almost any reasonable use, and it bloats GM's default save method's files like nobody's business (one old GM RPG famously wound up with 400+ meg save files due to every room being persistent, making the file larger and larger as you progressed through the game and causing some pretty serious hang time whenever you saved). Object persistance does have some use, but you need to handle it carefully.

And this ties into what the rooms are doing; GM isn't "reloading" the previous room when you leave it, it's dumping it all together. Persistent rooms would stay in memory, but that accumulates over time and ends up taking a lot of space simply to avoid having to code in a simple flag system, which is what we're trying to do here with the item_id business. For now, though, the items come back because GM is reloading that entire room from its default state; if item_id is implemented properly, the items will then be removed immediately, and barring any room transistion animations the player shouldn't even see that happen. As far as you can see while playing, it'll be as if the item was never there in the first place. How fancy.
Don't worry, I'm not here to judge you. It's just easier to see where you're going with something when I can look at the code.

Watch that mouse button click near the bottom though. You're assigning it's key variable below the check for the click, and also you're assigning it to check for a keyboard key. You're also missing the "pressed" so it's going to fire off every frame that you hold the mouse button in (30-60 times every second; that's a LOT of syrup).

You should write it like this:

// This will return true or false (0 or 1) mouse_button = mouse_check_button_pressed(mb_right); // But you also need to make sure the mouse is over the object when clicked if (mouse_button == true && position_meeting(x, y, self)) { show_debug_message("healed player with syrup") instance_destroy (); }
guys I still have the problem where i try to set the object down again. it just isnt wanting to fix itself.
< >
กำลังแสดง 16-30 จาก 42 ความเห็น
ต่อหน้า: 1530 50

วันที่โพสต์: 14 ก.ค. 2014 @ 6: 20am
โพสต์: 42