Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Probs with Goodnight's pushing  (Read 1493 times)

0 Members and 1 Guest are viewing this topic.

Zhello

N.A.D.I.
Probs with Goodnight's pushing
« on: October 20, 2009, 08:42:01 pm »
  • L'homme avec beaucoup de noms.
  • *
  • Reputation: +6/-1
  • Offline Offline
  • Gender: Male
  • Posts: 925
Using: GM7 lite (unreg.)

Yeah I teid testing it with both objDeku Link and objLink, the problem I get is something with "fhold" yet this action is called before the pushing even beings.

I dont see how it is marked as an unknwon var. is it is already called to begin with.

Quote
ERROR in
action number 2
of  Step Event
for object objLink:

Error in code at line 184:
      } else if !(holdl || holdr || fholdl || fholdr || place_free(x,y+ystep)) {

at position 35: Unknown variable fholdl

« Last Edit: October 20, 2009, 10:32:49 pm by Linkwolf48 »
Logged
The IT Guy
Intermediate Coder
Linux is a wonderful thing
~Linkwolf48/Gumstone1080~

The Legend of Zelda - New Beginnings

http://zfgc.com/forum/index.php?topic=34986.0
1.6 Demo -
https://www.dropbox.com/s/56km0iadaras56g/LoZNB%20Game%20Folder.rar?dl=0


Side Projects:

Dragon Diary - Cybernetic Threat
Story: http://wiki.zfgc.com/Cybernetic_Threat

Quote
Aero88
ZFGC is like the Hotel California.  You can come in but you can never leave!

devianart: http://linkwolf48.deviantart.com/
Re: Probs with Goodnight's pushing
« Reply #1 on: October 20, 2009, 09:49:17 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
You'd be able to not run into these errors if you made the attempt to understand what was going on; rather than simply merging engines all wishy-washy. The error you are getting likely refers to the values of fhold not getting initialized to anything before the error message/location you get. You cannot determine whether or not fhold values are true or false since they are not set to anything.

It is somewhat difficult to fully assess your issue because the entirety of the Step Event code is not shown, but even if you have fhold somewhere in your code, to clear up the error you are getting you have to be making sure that the fhold values are getting set. For example, if they only get set in corner-cutting, and you are not corner-cutting, then they are not set.
Logged

Zhello

N.A.D.I.
Re: Probs with Goodnight's pushing
« Reply #2 on: October 20, 2009, 10:07:51 pm »
  • L'homme avec beaucoup de noms.
  • *
  • Reputation: +6/-1
  • Offline Offline
  • Gender: Male
  • Posts: 925
(I'm learning GML as I go lol)

Now then:
This is Goodnight's pushing code which is found in his objLink:
Code: [Select]
 // Wall-pushing detection code.
    // Just to clarify, Link's pushcount activates his pushing animation,
    // while the block's pushcount activates its movement.

    // If you weren't moving diagonally, and weren't able to move, check for a solid for Link to push.
    var pushblock;
    pushblock=0
    // Determine the id of the solid block in front of Link (if there is one).
    if !(holdd || holdu || fholdd || fholdu || place_free(x+xstep,y)) {
        pushblock=collision_point(x+xstep*8+(xstep>0)*16,y+8,parSolid,0,0)
    } else if !(holdl || holdr || fholdl || fholdr || place_free(x,y+ystep)) {
        pushblock=collision_point(x+8,y+ystep*8+(ystep>0)*16,parSolid,0,0)
    }
    // If there is a solid, increase Link's pushcount (to a maximum of 16).
    if pushblock>0 {
        pushcount=min(pushcount+1,16)
        // Set the alarm to reset the pushcount to 0 when Link stops moving.
        alarm[7]=2
        // If the solid is pushable, and Link is fairly in-line with it,
        if object_get_parent(pushblock.object_index)=parPushable && ((ystep=0 && abs(pushblock.y-y)<=4) || (xstep=0 && abs(pushblock.x-x)<=4)) {
            with pushblock {
                // and it's not already moving,
                if !moving {
                    // and it can be pushed in the direction Link is facing,
                    movedir=global.facing
                    if movesa>0 || (movedir="D" && movesd>0) || (movedir="U" && movesu>0) || (movedir="L" && movesl>0) || (movedir="R" && movesr>0) {
                        // then increase its pushcount.
                        pushcount=min(pushcount+1,16)
                        alarm[7]=2
                    }
                }
            }
        }
    }

    // Set the right sprite when you are moving.
    // If Link has been pushing for at least 15 steps, use the pushing animation.
    if pushcount>=15 {
        switch global.facing {
            case "D": sprite_index=sprLinkPushD; break;
            case "U": sprite_index=sprLinkPushU; break;
            case "L": sprite_index=sprLinkPushL; break;
            case "R": sprite_index=sprLinkPushR; break;
        }
        // (Which is slightly slower than the running animation.)
        image_speed=animspeed*0.7
    // Otherwise, use the running animation.
    } else {
        switch global.facing {
            case "D": sprite_index=sprLinkRunD; break;
            case "U": sprite_index=sprLinkRunU; break;
            case "L": sprite_index=sprLinkRunL; break;
            case "R": sprite_index=sprLinkRunR; break;
        }
        image_speed=animspeed
    }
// If Link is not moving this step,
} else {
    // Set the right standing sprite.
    switch global.facing {
        case "D": sprite_index=sprLinkStandD; break;
        case "U": sprite_index=sprLinkStandU; break;
        case "L": sprite_index=sprLinkStandL; break;
        case "R": sprite_index=sprLinkStandR; break;
    }
    movestep=0
}

// Almighty depth leverage technique
depth=-y

This code was placed last on my objLink so it wouldn't get expected and or unexpected errors(which I fixed) .

fhold could be found in my step event which is for movement like this(mainly for Corner-cutting loop if Link is being blocked by solids also the movement keys of Deku and human Link):
Code: [Select]
// Start doing the movement.
    while (movestep>=1) {
        movestep-=1
        fholdd=0; fholdu=0; fholdl=0; fholdr=0;

Yet this code comes before Goodnight's code and the fhold are already called, if not the objDekuLink wont be working.  WE all know the cut conner code and I'm guessing that this is whats causing the error.

I had this called 4 times: 2 in scr and 2 in both objDekuLink and objLink:
Code: [Select]
var cc;
for (cc=6; cc>0; cc-=1) {
    if holdu {
        if !place_free(x,y-1) {
            if place_free(x-cc,y-1) && !(holdr || fholdr) { fholdl=1 }
            else if place_free(x+cc,y-1) && !(holdl || fholdl) { fholdr=1 }
        }
    } else if holdd {
        if !place_free(x,y+1) {
            if place_free(x-cc,y+1) && !(holdr || fholdr) { fholdl=1 }
            else if place_free(x+cc,y+1) && !(holdl || fholdl) { fholdr=1 }
        }
    }
    if holdl {
        if !place_free(x-1,y) {
            if place_free(x-1,y-cc) && !(holdd || fholdd) { fholdu=1 }
            else if place_free(x-1,y+cc) && !(holdu || fholdu) { fholdd=1 }
        }
    } else if holdr {
        if !place_free(x+1,y) {
            if place_free(x+1,y-cc) && !(holdd || fholdd) { fholdu=1 }
            else if place_free(x+1,y+cc) && !(holdu || fholdu) { fholdd=1 }
        }
    }
}


What I'm doing to do now:
I'm going to change the setups of how the fhold functions are into more movement; the after effect was that Link cannot push anything that is parsolid and or grabs or pushables.


A question:  How is the error coming up if the fholds are being called BEFORE the code is taken into action? :huh:

PS: I added extra conner cutting into scr, making the game place more smooth, fholds can be found there as well but the action is preventing the play due to objLink's fatal error.

Quote
You'd be able to not run into these errors if you made the attempt to understand what was going on; rather than simply merging engines all wishy-washy. The error you are getting likely refers to the values of fhold not getting initialized to anything before the error message/location you get. You cannot determine whether or not fhold values are true or false since they are not set to anything.
there not set as true or false values in this situation, aslo I did try some other methods to make the pushing actucally work.
« Last Edit: October 20, 2009, 10:19:03 pm by Linkwolf48 »
Logged
The IT Guy
Intermediate Coder
Linux is a wonderful thing
~Linkwolf48/Gumstone1080~

The Legend of Zelda - New Beginnings

http://zfgc.com/forum/index.php?topic=34986.0
1.6 Demo -
https://www.dropbox.com/s/56km0iadaras56g/LoZNB%20Game%20Folder.rar?dl=0


Side Projects:

Dragon Diary - Cybernetic Threat
Story: http://wiki.zfgc.com/Cybernetic_Threat

Quote
Aero88
ZFGC is like the Hotel California.  You can come in but you can never leave!

devianart: http://linkwolf48.deviantart.com/
Re: Probs with Goodnight's pushing
« Reply #3 on: October 20, 2009, 10:53:51 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
I am going to repeat this, because it is what you are not understanding - if the error result comes back to where it doesn't know what an fhold value is, that means that for that step (each time the Step Event is run, well that's called a step) the fhold value in the error was never set to true or false. And in Game Maker, true and false is the same as 1 and 0.

The push code isn't going to know what the fhold values are if the fhold values are only set in the corner-cutting code; if you don't corner-cut, the values won't be set. The reason you seem to be getting these errors is because of your engine merging; I have seen a Goodnight engine that had pushing in it with no errors. You can't just place code at the end of something and expect it to fully work with what you have.

I am not totally sure what you're code is doing, but I know that if a variable is not getting recognized like that, then it isn't getting set. Further looking into it, fhold is only going to get set when Link is movestep >=1 (possibly). Thus if it gets to the push code, the push code can't do logical comparisons using the fhold values because there is nothing in them then. A way around this could be to also set the fhold values outside of any major loop like say at the beginning of the step event, but I don't know how that will go.
Logged

Mamoruanime

@Mamoruanime
Re: Probs with Goodnight's pushing
« Reply #4 on: October 20, 2009, 11:22:56 pm »
  • ^Not actually me.
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 9786
My biggest fear is that your game is going to be filled with hunrdreds of thousands of inconsistencies. For example, you may have one object that has the variables "varDir" for your direction, and another that uses "linkDirection", and another saying "Direct", so on so forth. Now each of those variables could be accessed differently. One may be using a constant "dirLeft" that equals 0, while another uses strings to determine direction, or even another that uses vague integers.

Because of this you're going to have so many confusing issues while making your game, that you'd be better off just learning from scratch. Learning GML this way is only going to mess up any chance you have from learning how to code properly :x
Logged

Goodnight

Once and future Captain
Re: Probs with Goodnight's pushing
« Reply #5 on: October 25, 2009, 01:15:59 am »
  • With a Capital G
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 706
What Mamo said. You'll either need naming consistency or a huge list of each variable name for each object... I think we know which is better. :P Feel free to change the variable names in my own engines/examples; as long as you change them all, it will work the same.

So I'm guessing that the problem might be that you have those pieces of code in different "execute code" Drag & Drop blocks. If the variables are initialised with the var statement, then they're wiped from memory at the end of the block, even if they're all in the Step event.

If that fails then please post a copy of the .gmk (you can remove all the objects/sprites/sounds except for the ones relevant to this problem, so nobody will steal them) and we can see exactly how your objects are set up. Something must have been moved around because I don't recall seeing any errors like this when I wrote the engine.

Of course there's always the work-around of putting:
Code: [Select]
fholdu=0;
fholdd=0;
fholdl=0;
fholdr=0;
In the Create event, but that doesn't really fix the problem.
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.194 seconds with 46 queries.

anything