Fangames > Programming Questions

Spike Trigger Error in KS Engine

(1/2) > >>

RandomFangamer:
Hey Guys  :atkHappy:
So I  was using the KS Engine and I was trying to make a spike trigger when I got this strange error:

--- Code: ---FATAL ERROR in
action number 1
of  Step Event0
for object spikeUp:

Push :: Execution Error - Variable Get 100109.trg(100061, -2147483648)
 at gml_Object_spikeUp_StepNormalEvent_1 (line 2) - if (trg!=0) {

--- End code ---
The step event in said spike:
(click to show/hide)//if this object has a trigger
if (trg!=0) {
    //if it hasn't been triggered yet and the trigger is set
    if (!triggered && global.trigger[trg]) {
        //start moving
        vspeed=vs;
        hspeed=hs;
        triggered=true;
   }
}
For some reason gamemaker is having trouble with
if (trg! = 0)

Spikes Creation Code:

--- Code: ---trg = 2
vs = -5
hs = 0

--- End code ---
Does anyone know what the problem here is?

klazen108:
You mention you set the trigger value in "Creation Code" - is this Instance Creation Code or in the Create Event? It shouldn't matter, but it would be good to confirm.

I just checked the engine myself, and it seems to work fine; can you confirm your code looks like the following?

Spike Instance Creation Code
(click to show/hide)
Trigger Instance Creation Code
(click to show/hide)
spikeUp Create Event & spikeUp Step Event
(click to show/hide)
Your step event looks correct, so we just need to find where the problem is. Which kind of spike are you using for this trigger? is it a spikeUp, or a different kind of spike? Is it a custom spike object? If so, show me the Create Event for it, I want to make sure trg is being initialized.

RandomFangamer:
For some reason my create  event looks like this: (Don't know why I did that :atkWut:)
After correcting it, I get this error:
(click to show/hide)___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Other Event: Room Start
for object objTrigger:
Push :: Execution Error - Variable Get 100449.trg(100061, -2147483648)
 at gml_Object_objTrigger_StartRoomEvent_1 (line 1) - if (!persist) global.trigger[trg]=0;
############################################################################################


Spike Creation Code:

Trigger: (click to show/hide)Trigger Creation Code:
Collision with Player Event: global.trigger[trg]=1;
Room Start: if (!persist) global.trigger[trg]=0;
Also, I am using the creation code when you right click an object
Also Also, I am using the SpikeUp object, but plan on using custom spikes in the future

Anon70000:

--- Quote from: RandomFangamer on September 07, 2015, 11:31:13 AM ---FATAL ERROR in
action number 1
of Other Event: Room Start
for object objTrigger:
Push :: Execution Error - Variable Get 100449.trg(100061, -2147483648)
 at gml_Object_objTrigger_StartRoomEvent_1 (line 1) - if (!persist) global.trigger[trg]=0;

--- End quote ---
Simplified: you need to initialize variables before using it, old GM had "treat uninitialized variables as 0", GM:S doesn't have that.
Problem is in objTrigger, check create event (not creation code) and type "trg=0;", it'll probably work

RandomFangamer:
Old Message
(click to show/hide)Thanks- this is a very weird issue and I have no idea why it hates me
Alright, so i added trg = 0 in the trigger
Now I have this issue and adding trg = 0 to SpikeUp doesn't fix it
FATAL ERROR in
action number 1
of  Step Event0
for object spikeUp:

Push :: Execution Error - Variable Get 100109.trg(100061, -2147483648)
 at gml_Object_spikeUp_StepNormalEvent_1 (line 2) - if (trg!=0) {

Step event in question:

--- Code: ---//if this object has a trigger
if (trg!=0) {
    //if it hasn't been triggered yet and the trigger is set
    if (!triggered && global.trigger[trg]) {
        //start moving
        vspeed=vs;
        hspeed=hs;
        triggered=true;
   }
}

--- End code ---


EDIT:
Alright, so I used a fresh version of the 0.8 KS Engine  and copied the spikeUp and Trigger object code into the old version, and now its giving me this error:


--- Code: ---FATAL ERROR in
action number 1
of Other Event: Room Start
for object objTrigger:

Push :: Execution Error - Variable Get 100448.trg(100061, -2147483648)
 at gml_Object_objTrigger_StartRoomEvent_1 (line 1) - if (!persist) global.trigger[trg]=0;

--- End code ---

EDIT EDIT:
YES, IT WORKS  :atkHappy:  :IceFairy: :paraKid: :tenKapple: :denMiku_v2:
Adding trg = 0 to Trigger + Copying the triggers + SpikeUp some how fixed it
To help anyone else tat is having this issue, ill describe it
(click to show/hide)I had custom spikes, parented to SpikeUp
The Custom Spikes had Create and Step Events identical to SpikeUp's
This somehow messed up the SpikeUp
Yeah idk

Navigation

[0] Message Index

[#] Next page

Go to full version