Help acessing values from OGMO


(Oli) #1

I feel bad always depending on the generosity of the people on this forum but getting help elsewhere on the internet is very difficult.

anyway I have a rly quick question to ask here

i am trying to access this value “num” i have linked to an entity in ogmo this is the way i did it

however when the player collide the door entity i get an error due to the node var and my game crash

plz feel no obligation to answer this if you dont have time


(Mike Evmm) #2

Can you please post the code on the .OEL?
(also, and I hope I’m speaking for the forum, there’s no need to apologize, people are here to help and be helped)


(Oli) #3

there is more to it however thats the relevant part


(Mike Evmm) #4

Did you set node? I can’t see any reference to it besides its declaration. You’ll probably also want node.Entities.DoorPos.@num instead of simply node.@num, though I’m not sure on this one, as XML is far from my comfort zone.


(Oli) #5

well i have declared the var node:XML; but i have not set node in the ogmo file


(Oli) #6

im not even sure what node means i just know i have used it previously in my world class

my //TEST works in this class


(Mike Evmm) #7

Hmm, I think you’re missing something here. As I said, I’m no expert in XML, far from it, so I may be fooling you, but I know for sure that you need to “fetch” the XML file (which in this case, is your OGMO (or .oel) file). Flashpunk makes this easy, as it does it for you. All you need to do is call FP.getXML like so:

var node:XML = FP.getXML(YOUR_EMBEDDED_XML_FILE);

Anyway, @zachwlewis has a really nice tutorial on OGMO, XML and Flashpunk, it’s pretty much the only approach to XML I’ve had. Try watching it, I believe it’ll help.

If it didn’t, and I’m being obnoxiously condescending, then please tell me, I may have misunderstood.


(Oli) #8

I know ive seen this one so many times…lol


(Mike Evmm) #9

Obnoxiously condescending it is then.
I believe I’ve found the problem though: there should be no handling of XML inside of door; node is null. If you pass an int at Door's construction, then XML handling should be done outside. Basically, you’re declaring an “empty” XML at interaction() an trying to access a property (num), which doesn’t exist.
Notice how you’re already handling XML at the Player's construction. Plus, surely mapXML is assigned somewhere above what you’ve shown.

Or, again, I’m completely off.


(Martí Angelats i Ribera) #10

In this line of the constructor,

num = door_number;

Shoudn’t it be like this?

door_number = num;

(Jacob Albano) #11

Good catch. I hate those bugs…they’re innocuous enough that you can totally gloss over them when you’re looking for the problem.


(Zachary Lewis) #12

It would be more helpful to share your source code as text than as images.

You can add code blocks like this:

```
public function foo(bar:String):void
{
  trace(bar);
}
```

And it’ll return code formatted like this:

public function foo(bar:String):void
{
  trace(bar);
}

If you want to specify the language (it’s ActionScript by default), you can add a language specifier after ```.

```ruby
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
```
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html