Multiple instances of same object

LinkVanyali

I have two rooms and a candle in each room, called Candle and Candle1
There is a candle Snuffer that will call the function 'snuff candle' which checks to see if the Candle is lit before snuffing it
The Snuffer acts on the Candle by un-setting a 'lit' flag
But using the Snuffer (calling the function) unsets the lit flag on ALL candles - how can I restrict it only to the candle in question?


Silver

you're duplicating something - either the flag, the function or both so that when the flag changes on one it also does on the other. You would need to set up independent flag/function scripts for both objects I think - setting the verbs independently for each object and them having their own individually named flag to check should work.


LinkVanyali

Thanks for the reply. I think I am being overly ambitions , and the terminology is confusing me; I keep confusing commands, verbs and functions.

At the moment under Snuffer I am using the 'use this on (other object)' set to handle objects individually, to call the 'snuff candle' script, but this needs a new entry for every candle named uniquely for each room, which is a pain.


XanMag

Seems the game is small right now. Mind pasting the code?


hegemonkhan

'commands' is a general term that can mean nearly anything (scripting, input, Functions, Commands, Verbs, etc) in code

The 'Command' Element ( http://docs.textadventures.co.uk/quest/elements/command.html ) is general scripting that uses input from from person playing the game in its scripting

The 'Verb' Element ( http://docs.textadventures.co.uk/quest/elements/verb.html ) is a special 'sub-Command' Element which is specifically for an individual Object only, it's actually just a Script Attribute of an Object (with some additional code for handling it as a 'Verb'), but which also creates the 'buttons' and 'hyperlinks' during game play in the panes on the right side and the text pane on the left side.

Verbs and Commands are connected, as for Verbs (since it is actually a sub-Command), you can instead of using the hyperlink or button, type in your use of it (for example: open door_1) as you would for a Command.

The 'Function' Element ( http://docs.textadventures.co.uk/quest/elements/function.html ) is just that, a Function (just like in math, except its a Function for coding/scripting, of course and not a math input-output formula-function).


this is for programming terminology:

an 'instance (instantiation)' of an OBJECT is conceptually giving a CLASS "physical form". A CLASS is like the properties, and then you create an OBJECT which 'instantiates' that CLASS' properties, as the OBJECT contains those properties (an OBJECT is the 'instantiation' of a CLASS), and you can act upon that OBJECT.


handling multiple Objects is a bit complex... as the ID in quest is the 'name' String Attribute (the 'name' of the Object), and an Object's 'name' must be unique.

Object's (1) Name: HK
Object's (2) Name: HK // ERROR! can't have two of the same Object!
Object's (3) Name: hk // NO error, as quest is upper/loser case sensitive
Object's (4) Name: LinkVanyali
Object's (5) Name: HK_2

so, you need some indicator/flag (an Attribute) to identify/separate it from your other 'candle' Objects, and check (the 'if' Script) for that.

the strange thing is that you're already acting upon all candles, as usually the issue is that quest asks which candle you want to act upon, for people new to coding... so it seems like you already now some coding, to have whatever you do, that all candles are being used.

could we see your entire game code, to see what you're doing, or at least your relevant code (Function, or whatever), if you can. so we know what we're working with, in order to help you do what you want to do?


Log in to post a reply.

Support

Forums