Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

How do I test if an object is in another room?

A topic by Garry Francis created Sep 13, 2019 Views: 102 Replies: 3
Viewing posts 1 to 5
Submitted

I need to test whether an object is in a certain room - not the current room. Something like:

: if (is_object_at object = "object" room = "room") {
   // Do something
}

How do I do that?

Host (3 edits)

I've added this section to the document.

(NOTE: I removed a comment by auraes as they were referencing a version of the document that I accidentally uploaded and contained a bad function name - sorry auraes, you definitely were advising correctly from the 10 minute window where that bad document was online).

https://adventuron.io/docs/tut/#FindingAnObject

start_at = village
locations {
   village  : location "You are in the village.";
}
objects {
   sword : object "a sword"  ;
   lamp  : object "a lamp"  start_at = "inventory" ;
   spoon : object "a spoon" start_at = "village"  ;
   fork  : object "a fork"  start_at = "bag";
   bag   : object "a bag"   start_at = "inventory" container_type="bag";
}
on_tick {
   : if (parent_of "lamp" == "inventory") {
      : print "The lamp is in your inventory." ;
   }
   : if (parent_of "spoon" == current_location()) {
      : print "The spoon is in the same location as you." ;
   }
   : print {( "Location of Lamp  : " + parent_of "lamp" )}
   : print {( "Location of Sword : " + parent_of "sword" )}
   : print {( "Location of Spoon : " + parent_of "spoon" )}
   : print {( "Location of Bag   : " + parent_of "bag" )}
   : print {( "Location of Fork  : " + parent_of "fork" )}
}
Submitted

Can I do:

: if (parent_of "spoon" == "room01")

or something like that?

Submitted

Aha. I just read the document and it looks like I can do it. It's 3:00 a.m. now, so I'll try it tomorrow.