idmillington / undum

A client-side framework for narrative hypertext interactive fiction.
https://idmillington.github.com/undum
MIT License
336 stars 80 forks source link

Error when creating new SimpleSituation with heading property #18

Closed pmmf85 closed 11 years ago

pmmf85 commented 11 years ago

Hello

I think there is no writeHeading method definition in system object when creating new situation.

When I try to create new SimpleSituation object with heading property defined it generates error code in console:

Uncaught TypeError: Object [object Object] has no method 'writeHeading' undum.js:169

idmillington commented 11 years ago

This function is used by various games, so I'm not sure why you're getting the error.

Can you give some minimal example code that makes the error happen (i.e. don't copy and paste your whole game, remove as much as possible while still having the error happen)?

pmmf85 commented 11 years ago

Steps to reproduce:

  1. Download zip from github https://github.com/idmillington/undum
  2. Open file tutorial.game.en.js from games\media\games\tutorial\tutorial.game.en.js
  3. Edit start situation:
    
    undum.game.situations = {
    start: new undum.SimpleSituation(
        "Some content", { heading : "test" }
    )
    }
    
  4. Launch tutorial
  5. Notice error in console

I see in undum.js that this part of code is responsible for it (164 line):

if (this.heading) {
if ($.isFunction(this.heading)) {
system.writeHeading(this.heading());
} else {
system.writeHeading(this.heading);
}
}

But system.writeHeading is not declared anywhere and that is causing an error.

idmillington commented 11 years ago

Brilliant, thanks, that makes it much clearer. I'll have a look.

idmillington commented 11 years ago

Right, that was very odd. Apparently writeHeading didn't exist at all. Which is very odd, because I was sure it was being used in other places.

Anyway, I've added it now, and committed. The steps to reproduce above now work fine for me. Feel free to reopen this if it doesn't work for you.

Sorry about that.