Skip to main content

News

Topic: Project ZeC (My Zelda-esque Clone) (Read 61496 times) previous topic - next topic

0 Members and 6 Guests are viewing this topic.
Re: Project ZeC (My Zelda-esque Clone)
Reply #60
Hehe, didn't the original LoZ have a glitch just like that in the first dungeon?

Only with the first northern door. You had to leave and reenter level 1 to make the door vanish.

Currently, in ZeC, it's all doors. The same issue occurs if I unlock the Eastern door pictured in the image or other doors in the dungeon. I can't figure out how that is occurring due to the fact that only the current doors variable being is being accessed.
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

  • Rhuan
  • [*][*][*][*]
Re: Project ZeC (My Zelda-esque Clone)
Reply #61
Hehe, didn't the original LoZ have a glitch just like that in the first dungeon?

Only with the first northern door. You had to leave and reenter level 1 to make the door vanish.

Currently, in ZeC, it's all doors. The same issue occurs if I unlock the Eastern door pictured in the image or other doors in the dungeon. I can't figure out how that is occurring due to the fact that only the current doors variable being is being accessed.
There must be something causing the code to hit all the doors, possibilities:
- are you sure they have separate variables?
- do you store multiple properties for each door or only open/closed?
- how do you create the door variables?

  • Rhuan
  • [*][*][*][*]
Re: Project ZeC (My Zelda-esque Clone)
Reply #62
Something you may not know if new to Javascript, if you have an object e.g.:
Code: [Select]
var data = {name:"hi", open:false};
//And then set another variable to equal that object:
var foo = data;
//the object is not copied, rather a reference to it is passed
//so...
foo.open = true;
//will result in
if(data.open===true)
{
  //this code would be executed
}

Re: Project ZeC (My Zelda-esque Clone)
Reply #63
Currently, each dungeon level has its own js file with its own variables. So all of the variables for Kain's Tomb (short handed as KT) are stored in kainstomb.js.

Kain's Tomb is a 21 room dungeon level. The code would be a huge mess if I tried to store everything in 1 file. Not every room has a door that requires a key, so the amount of variables are at a minimum.

I've designed a function called UseKey. It is currently set as UseKey(name, v). Name being the name of the door, v being the variable of the door. The function "unlocks" the door.

When called it:
Determines if it is a normal key or magic key
sets v equal to false
DestroyPerson(name)
Deducts a key from NumKeys if a normal key was used.
  • Last Edit: September 04, 2017, 02:15:52 pm by Miscreant
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

Re: Project ZeC (My Zelda-esque Clone)
Reply #64
Code: [Select]
var foo = data;

funny thing is I have a function called Foo.

Foo(x, y, d, l) I use it to set people or items in the map.
x, y are used always. d and l are optional.
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

  • Rhuan
  • [*][*][*][*]
Re: Project ZeC (My Zelda-esque Clone)
Reply #65
Currently, each dungeon level has its own js file with its own variables. So all of the variables for Kain's Tomb (short handed as KT) are stored in kainstomb.js.

Kain's Tomb is a 21 room dungeon level. The code would be a huge mess if I tried to store everything in 1 file. Not every room has a door that requires a key, so the amount of variables are at a minimum.

I've designed a function called UseKey. It is currently set as UseKey(name, v). Name being the name of the door, v being the variable of the door. The function "unlocks" the door.

When called it:
Determines if it is a normal key or magic key
sets v equal to false
DestroyPerson(name)
Dectucts a key from NumKeys if a normal key was used.
Can you post the JS file containing the variables?

Re: Project ZeC (My Zelda-esque Clone)
Reply #66
I can do that in a few...
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

Re: Project ZeC (My Zelda-esque Clone)
Reply #67
@Rhuan Here it is...
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

  • Rhuan
  • [*][*][*][*]
Re: Project ZeC (My Zelda-esque Clone)
Reply #68
Wow that's a lot of variables.... I'm sure you could do whatever you're doing with a lot less than that.

Looking specifically at the doors though there's nothing obvious please can you post the function you use for opening a door? And an example of how it would be called.

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Project ZeC (My Zelda-esque Clone)
Reply #69
Just to be clear, this doesn't do what you think it does:

Code: [Select]
var x = 812;
function f(v) { v = 1208; }
f(x);
// x is still == 812 here!
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Rhuan
  • [*][*][*][*]
Re: Project ZeC (My Zelda-esque Clone)
Reply #70
Just to be clear, this doesn't do what you think it does:

Code: [Select]
var x = 812;
function f(v) { v = 1208; }
f(x);
// x is still == 812 here!
His issue is too many variables being updated though not too few which is kinda odd.

Re: Project ZeC (My Zelda-esque Clone)
Reply #71
The function & usage
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Project ZeC (My Zelda-esque Clone)
Reply #72
Okay, well like I said above, setting v = false; inside the function won't have any effect.  When you pass a variable to a function you're actually just passing the value, so that just sets your local copy of v.  If you want to modify something you passed into the function, you'd have to pass in an object, e.g.:

Code: (javascript) [Select]
function modify(obj) {
    obj.c = -128;
    // note: this *still* wouldn't work:
    //     obj = somethingElse
}
var obj = { a: 812, b: 1208, c: 0 };
modify(obj);
// obj.c == -128 now

I can't understand why that would cause ALL your doors to get unlocked though.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

Re: Project ZeC (My Zelda-esque Clone)
Reply #73
Okay, well like I said above, setting v = false; inside the function won't have any effect.  When you pass a variable to a function you're actually just passing the value, so that just sets your local copy of v.  If you want to modify something you passed into the function, you'd have to pass in an object, e.g.:

Code: (javascript) [Select]
function modify(obj) {
    obj.c = -128;
    // note: this *still* wouldn't work:
    //     obj = somethingElse
}
var obj = { a: 812, b: 1208, c: 0 };
modify(obj);
// obj.c == -128 now

I can't understand why that would cause ALL your doors to get unlocked though.

Me neither. As you can see only one variable was being passed. So why it was affecting a variable not even entered, I have no idea. Like my pushing block function that I had to take a break from before I actually got it to function properly, this is some thing I may just have to not think about for a lil bit. That's usually when an idea for a solution pops in.
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

Re: Project ZeC (My Zelda-esque Clone)
Reply #74
I stopped trying to pass the variable and just set it directly. Now UseKey functions.

Edit: Gorram it, I just had a thought. The way it is right now, if you touch the door it, whether you have a key or not, it will set the variable to false. Crap, I'll have to change that... again.

That should be a simple enough edit though.

Edit 2 (based on example image):

if (HaveKey > 0)  KTD2 = false;

*Now, UseKey() functions.
  • Last Edit: September 05, 2017, 02:18:54 am by Miscreant
"I am to misbehave." - Malcom Renyolds, Captain of Serenity