Jump to content

Module for Container


charlenni

Recommended Posts

Hello,

 

now I will start with a contribution to the author script library. For a new project I need functions for containers (chest, box, house ...). You could put item(s) or character(s) in this container and remove them. You could lock (automaticaly closed), unlock, open (only if unlocked) and close the container. You could check if an item belongs to the container, if it is visible and how much item(s) belongs to the container. If you move the container, all item(s) will be moved with the container. The item(s) in the container could be visible or not, but if the container is closed, than all item(s) belonging to the container are unvisible. If the container opens than the items will be visible if they was visible before (unvisible items are further unvisible even if the container is open) If there are any changes to the container you can get a messages: OnChanged(What), OnAddItem(Item), OnRemoveItem(Item), OnItemVisible(Item).

 

The code is a module. I have tested it with the emulator (I didn't have my Colorado in the moment).

 

You could save the file "container.lua" to your project-directory and add a 'require "container"' to your author script.

 

To see, how it works, I have made a small Wherigo.

 

It's the first version, so there is not guarantee for perfection.

 

Best regards

Dirk

container.zip

Link to comment

When testing one of my scripts, I decided to try including it with the "require" keyword. While it worked in the emulator, it caused the cartridge to crash in the Garmin (Colorado) Player. I'd warn against using "require" based on that experience.

 

That's right. I have made the same experience. But if you use "require" while creating the cartridge you get fast and clear code. If you are ready, you could copy the code from required files to your cartridge.

Link to comment

That's right. I have made the same experience. But if you use "require" while creating the cartridge you get fast and clear code. If you are ready, you could copy the code from required files to your cartridge.

 

I agree - next time I will go this route for development - less time looking for the typo bugs I just introduced

and then put it all in one big file when ready to publish to public.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...