Error running script: No parameters passed to AddToInventory function - expected 1 parameters

Hi I'm in the middle of making a game and when I try to play it it keeps showing: Error running script: No parameters passed to AddToInventory function - expected 1 parameters, how do I solve this? Thx!


if you're unable to load/open your game in the GUI/Editor, unable to play your game, get bugs/errors (or something/whatever doesn't/isn't working as it's suppose to) during game play, and/or if your game crashes during game play, all of this stuff just means that you've got errors/mistakes in your game's code, which just needs to be fixed up... (easier said than done/found, lol. But generally it's easy to fix up bad code, just once you find the bad code parts, lol).


you've got a simple coding mistake (very common to mess up code), one of your 'AddToInventory' Functions doesn't have an input (an Object, as the 'AddToInventory' Function moves an Object into the 'pov: currently controlled', which is generally the default 'player' Player Object) to use for its scripting.

if you're using the web/online version, you've got to download your 'xxx.quest' published/uploaded game onto your computer, unzip it (to get at the actual 'xxx.aslx' quest files), and then right click on your 'xxx.aslx' game file and open it up via a text editor software (notepad, wordpad, notepad++, apple: text editor, etc), then you've got to find an 'AddToInventory' Function in your entire game code that is missing its input:

AddToInventory ()

and you need to change it to having some input (an Object), for an example (pretending you've created/added/have this 'book_1_object' Object in your game already):

AddToInventory (book_1_object)

then save your game file of course.

as to getting your game back online/web, I've never published, so not sure if you can replace your old game or if you just have to publish your fixed game again, having now two published games, your old unfixed game and your new fixed game.


if you're using the desktop/offline quest, then it's the same as the above, but you've already got your 'xxx.aslx' quest files on your computer. So, just open up your game file, as explained already above.


an example for you, using the default/new game code, with the added stuff for the example:

from:

<asl version="560">

  <include ref="English.aslx" />
  <include ref="Core.aslx" />

  <game name="xxx">

    <gameid>xxx</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>

    <attr name="start" type="script">

      AddToInventory () // <-------------- missing its need/required 'Object' input/argument: it needs to know what Object to move into the 'player' Player Object (aka, into the "inventory")

    </attr>

  </game>

  <object name="room">

    <inherit name="editor_room" />

    <object name="player">

      <inherit name="editor_object" />
      <inherit name="editor_player" />

    </object>

  </object>

  <object name="book">

    <inherit name="editor_object" />

  </object>

</asl>

to:

<asl version="560">

  <include ref="English.aslx" />
  <include ref="Core.aslx" />

  <game name="xxx">

    <gameid>xxx</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>

    <attr name="start" type="script">

      AddToInventory (book)

    </attr>

  </game>

  <object name="room">

    <inherit name="editor_room" />

    <object name="player">

      <inherit name="editor_object" />
      <inherit name="editor_player" />

    </object>

  </object>

  <object name="book">

    <inherit name="editor_object" />

  </object>

</asl>

Thanks so much for the detailed reply!! But the thing is I'm working on a Mac computer and I can't open the zip files for some reason...


You need to find where you use the AddToInventory function. In the GUI, it looks kind of like this (using v as a triangle):

Add to inventory [Object    v ] [          v ]

If you can find where you put that in, you need to click the second triange and select an object to add - it is currently blank. If you think about what you were doing when you got the error message, that should help you work out where that is.


I don't know apple/mac computers very well, does your computer already unzip them? If the computer is already unzipping them, you should have a folder being made available of them, with 'xxx.aslx' files in it, and those 'xxx.aslx' files should be able to be opened in a text editor software (apple: texteditor, you can use the magnifying glass in the upper right corner, to search/open-up for your 'texteditor' program, which I believe is somewhat-hidden as it's in the 'utilities' folder, I think).

Otherwise, your computer isn't automatically unzip'ing your files. I would think/hope that there's some kind of software for apple/macs that you can get that would unzip 'zip' files for it...


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums