public function help
In one class named "block" I have this script:
PHP Code:
PHP Code:
|
Pretty much. If you want to use a function that's defined in a class, you'll have to join() that class first. The function also doesn't have to be "public". Public functions can be useful in weapons, though. Let's look at an excerpt of some Atlantis weapons.
-Weather: PHP Code:
PHP Code:
|
I figured that was the problem. Thanks!
Unrelated but can you set a gani using a variable as a wildcard? Lets say I have a gani named "walk_true" and another called "walk_false". PHP Code:
|
Well, first off, you should be using setAni() instead. And then, this.foobar is also a boolean in this case. You should evaluate that to something yourself to avoid issues. (this.foobar ? '1' : '0'), for example.
|
What is the difference between using this.ani and setAni()?
Also coming back to the original post, is it possible for two classes to communicate? My example: In the first class I have a switch that the player interacts with by swinging the sword. This class is supposed to tell the second class that it was hit. In the second class I have blocks that raise or lower depending on the status of the switch. I'd rather keep them as separate classes to keep it neat, and I don't want to use triggeraction because I might have a room full of blocks and defining coordinates would be a pain. There must be a clean way to just do something like "triggerclass" or something. |
I've exhausted my theories on how to get this to work outside of using a loop to check for a variable change (but that seems very inefficient and not at all what I want to do). Come one guys, someone must know if what I'm suggesting is possible. I've tried to search this on the forums but there is literally tens of thousands of results for my search terms, and about 99.999% of those results have nothing to do with what I am trying to do.
And if I wasn't clear my goal is for when I hit a switch belonging to Class A I want all the items in Class B to update. |
I went back and tried public function again after reading a post by fp4 and got something that ALMOST works.
CLASS A PHP Code:
PHP Code:
|
Well, you already have the right idea with making object references available through the level object. Instead of just setting one (which will inevitably overwrite things if you have more than one block or whatever), maybe try storing them all in an array? I haven't tried this before. Should work, though.
|
I am not sure how I would do that. I tried something like this.level.foobar.add(this); and this.level.foobar[0] = this; expecting this.level.foobar[0] to return the object but apparently it doesn't work like that. I can only guess you can't store objects in arrays. This is incredibly frustrating. I wish GS2 was better documented.
PS thanks for the input thus far Crow. |
You'll probably want to do something like this:
Class A: PHP Code:
PHP Code:
-------- Alternatively if you want to store the objects and be safe between level updates you could do something like: Class A: PHP Code:
PHP Code:
|
And you just solved in 5 minutes what would have taken me 5 days.
|
I'm pretty desperate for help on this. I'm in over my head.
I'm trying to sync the blocks with everyone in the level. My first guess was to use triggerServer or triggerAction but I can get neither of those to work inside of a class (I've since read that triggerServer doesn't work in local or class NPCs without a hacked workaround). I thought something like this would work, but no dice on this as well. I just can't grasp what I'm doing wrong. PHP Code:
|
Try using setshape() on the serverside as well.
|
That makes perfect sense and worked perfectly. I've successfully synced with players in the level.
(yet another post) What are the limitations of using level variables on a GMAP? I remember reading that the player only loads a 3x3 chunk of the GMAP. Providing that this is true, does the level variable continue to sync past this point? If not then I need a solution for saving my switch variable. My guess is that I would have to use a DB NPC (another thing I have no experience with. Yay). If I save each quest set with a unique prefix is there a simple way to catch the level prefix so I can try to make each set of switches unique? I'm thinking of designing it something like: PHP Code:
PHP Code:
|
All times are GMT +2. The time now is 10:58 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.