Someone reported a bug in my game that neither they nor I could replicate, and I have no idea how to fix it. It's a first-person puzzle where the player has to assemble 11 inventory items into a circle (a 12th is placed on the screen), and one of them wound up disappearing, rendering the puzzle unsolvable.
The room uses two objects for each part of the circle (one that's loose [oT2, oT3, etc.] and one that's been placed [oP2, oP3, etc.]), and makes an inventory item associated with each part (oTrinket2, iTrinket3, etc.) become active when a loose piece is interacted with. Placing an object in the right hotspot (hH2, hH3, etc.) makes the item's oP (placed) object appear -- otherwise the item's loose (oT) object reappears. However, the third object (represented by oT3, oP3 and iTrinket3) apparently disappeared for this player and never reappeared.
What's wrong with my code? (I tried to remove redundant and unrelated sections to make it shorter.)
function room_Load()
{
aA_Puzzle.Play();
hH2.Enabled=true;
hH3.Enabled=false;
hH4.Enabled=false;
hH5.Enabled=false;
hH6.Enabled=false;
hH7.Enabled=false;
hH8.Enabled=false;
hH9.Enabled=false;
hH10.Enabled=false;
hH11.Enabled=false;
disable_interface();
mouse.EnableMode(eModeInteract);
player.AddInventory(iTrinket2);
player.AddInventory(iTrinket3);
player.AddInventory(iTrinket4);
player.AddInventory(iTrinket5);
player.AddInventory(iTrinket6);
player.AddInventory(iTrinket7);
player.AddInventory(iTrinket8);
player.AddInventory(iTrinket9);
player.AddInventory(iTrinket10);
player.AddInventory(iTrinket11);
player.AddInventory(iTrinket12);
aTrinketsSpill.Play();
}
function replace() {
if (player.ActiveInventory==iTrinket2 && Hotspot.GetAtScreenXY(mouse.x, mouse.y)!=hotspot[2]) {
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT2.Visible=true;
}
if (player.ActiveInventory==iTrinket3 && Hotspot.GetAtScreenXY(mouse.x, mouse.y)!=hotspot[3]) {
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT3.Visible=true;
}
//repeat for rest of items
}
function doesnt_go_there(){
cEThink.Speak("That piece doesn't feel like it belongs there.");
replace();
mouse.Mode=eModeInteract;
}
function puzzle_done() {
//removed irrelevant lines
}
function start_puzzle() {
cEThink.Speak("Hmm...Something makes me think I should start with...");
oT1.Visible=false;
oP1.Visible=true;
aPlacetrinket.Play();
Wait(40);
cEThink.Speak(" This one. ");
}
function room_AfterFadeIn()
{
dark_fadein_blocking();
mouse.Mode=eModeInteract;
btn_walk.Enabled=false;
mouse.DisableMode(eModeWalkto);
btnIconInv.Enabled=false;
start_puzzle();
oT1.Visible=false;
oP1.Visible=true;
}
function on_mouse_click(MouseButton button) {
if (button==eMouseRight && player.ActiveInventory==iTrinket2) {
oT2.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
}
if (button==eMouseRight && player.ActiveInventory==iTrinket3) {
oT3.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
}
//repeat for rest of items
}
function room_Leave()
{
player.ActiveInventory=null;
enable_interface();
aA_Puzzle.Stop();
}
//////////
function hH2_UseInv()
{
if (player.ActiveInventory==iTrinket2) {
aPlacetrinket.Play();
oP2.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT2.Visible=false;
hH2.Enabled=false;
hH3.Enabled=true;
}
else doesnt_go_there();
}
function hH3_UseInv()
{
if (player.ActiveInventory==iTrinket3) {
aPlacetrinket.Play();
oP3.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT3.Visible=false;
hH3.Enabled=false;
hH4.Enabled=true;
if (oP2.Visible==false) hH2.Enabled=true;
}
else doesnt_go_there();
}
///repeat for rest of items
else doesnt_go_there();
}
////////////
function oT2_Interact()
{
mouse.EnableMode(eModeUseinv);
player.ActiveInventory=iTrinket2;
mouse.Mode=eModeUseinv;
oT2.Visible=false;
}
function oT3_Interact()
{
mouse.EnableMode(eModeUseinv);
player.ActiveInventory=iTrinket3;
mouse.Mode=eModeUseinv;
oT3.Visible=false;
}
///repeat for the rest of the items
function room_RepExec()
{
if (mouse.Mode==eModeUseinv) mouse.ChangeModeHotspot(eModeUseinv, 5, 11);
if (oP2.Visible==true && oP3.Visible==true && oP4.Visible==true && oP5.Visible==true && oP6.Visible==true && oP7.Visible==true && oP8.Visible==true && oP9.Visible==true && oP10.Visible==true && oP11.Visible==true && oP12.Visible==true) {
puzzle_done();
}
if (oP2.Visible==true) hH2.Enabled=false;
if (oP3.Visible==true) hH3.Enabled=false;
if (oP4.Visible==true) hH4.Enabled=false;
if (oP5.Visible==true) hH5.Enabled=false;
if (oP6.Visible==true) hH6.Enabled=false;
if (oP7.Visible==true) hH7.Enabled=false;
if (oP8.Visible==true) hH8.Enabled=false;
if (oP9.Visible==true) hH9.Enabled=false;
if (oP10.Visible==true) hH10.Enabled=false;
if (oP11.Visible==true) hH11.Enabled=false;
if (oP12.Visible==true) hH12.Enabled=false;
}
function oSkip_AnyClick(Object *theObject, CursorMode mode)
{
e_solved_trinkets=true;
player.ChangeRoom(144);
}
function hBG_UseInv(Hotspot *theHotspot, CursorMode mode)
{
if (player.ActiveInventory==iTrinket2 && oP2.Visible==false) {
oT2.Visible=true;
}
else if (player.ActiveInventory==iTrinket3 && oP3.Visible==false) {
oT3.Visible=true;
}
///repeat for rest of items
player.ActiveInventory=null;
}
All those repeat for comments, this doesn't look very useful, can you check if they really repeat or paste the full code somewhere?
There's two ways you can fix this:
a) band-aid: after each interaction, make sure each of the 11 pieces exists either as placed object, loose object or active inventory item
b) get rid of all the duplicate code by using loops and the IDs/arrays of the hotspots, objects and inv items.
To complement and elaborate on what Khris said.
Excessive code, especially duplicating code, is often a source of mistakes.
If you are working with numbered sequential objects, usually this may be done using a loop over array.
For example:
hH2.Enabled=true;
for (int i = hH3.ID; i <= hH11.ID; i++)
hotspot[i].Enabled = false;
This will disable all hotspots between H3 and H11 (inclusive).
Another example:
for (int i = iTrinket2.ID; i <= iTrinket12.ID; i++)
player.AddInventory(inventory[i]);
Above will add any inventory item with IDs in range from iTrinket2 to iTrinket12 (inclusive).
Similar solution may be used if you need to set state of some objects depending on other objects. If these objects are arranged in two corresponding sequences (like 10 hotspots and 10 objects, corresponding to each other) - in such case you may use relative index. For example, you have this:
if (oP2.Visible==true) hH2.Enabled=false;
if (oP3.Visible==true) hH3.Enabled=false;
if (oP4.Visible==true) hH4.Enabled=false;
...
This may be redone simply as:
for (int i = 0; i < 10; i++)
{
if (object[oP2.ID + i].Visible==true) hotspot[hH2.ID + i].Enabled=false;
}
Then if you have an identical or almost identical block of commands repeating in a program, then this block may be moved to its own function. The differences can be solved by passing parameter(s) into this function.
For a basic example, you have a similar code repeated multiple times, depending on the clicked object:
function oT2_Interact()
{
mouse.EnableMode(eModeUseinv);
player.ActiveInventory=iTrinket2;
mouse.Mode=eModeUseinv;
oT2.Visible=false;
}
This may be done as a separate function
function InteractWithTrinketObject(Object* obj)
{
int relativeObjID = obj.ID - oT2.ID; // relative index, starting with the oT2
mouse.EnableMode(eModeUseinv);
// it is possible to calculate matching inventory item's ID from object's ID,
// because they have 2 corresponding sequences
player.ActiveInventory=inventory[iTrinket2.ID + relativeObjID];
mouse.Mode=eModeUseinv;
obj.Visible=false;
}
And then called like
function oT2_Interact()
{
InteractWithTrinketObject(oT2);
}
function oT3_Interact()
{
InteractWithTrinketObject(oT3);
}
// and so on
This ensures that each similar operation is performed in a uniform way.
uhm, only because something has a number in the script name doesn't mean it will go in such order. You can instead make your own array. If you want to auto-fill such array based on the script name numbers, then you can use something like string format.
#define MAX_PIECES 12
Object* oT[MAX_PIECES];
Object* oP[MAX_PIECES];
InventoryItem* iTrinket[MAX_PIECES];
function room_AfterFadeIn()
{
for(int i=0; i<MAX_PIECES; i++)
{
oT[i] = Object.GetByName(String.Format("oT%d", i));
oP[i] = Object.GetByName(String.Format("oP%d", i));
iTrinket[i] = InventoryItem.GetByName(String.Format("iTrinket%d", i));
}
}
Quote from: eri0o on Tue 12/11/2024 14:06:46only because something has a number in the script name doesn't mean it will go in such order.
Not necessarily, but a disciplined game maker will usually arrange it so that the indices
are consecutive and in order, since it simplifies coding and speeds up navigation in the room editor.
Your solution is good if they are not, though.
Quote from: eri0o on Tue 12/11/2024 10:01:40All those repeat for comments, this doesn't look very useful, can you check if they really repeat or paste the full code somewhere?
Okay, here's the entire script (minus material such as speech messages and the like). I know this code is pretty bloated and inefficient, but I'm still not familiar with arrays, which is why I didn't attempt to use them. The hotspots are Hotspots 2 through 12, the "loose" trinkets are Objects 1 through 11, and the "placed" trinkets are Objects 12 through 23 (the puzzle starts out with Object 12 already in place).
Spoiler
function room_Load()
{
aA_Puzzle.Play();
hH2.Enabled=true;
hH3.Enabled=false;
hH4.Enabled=false;
hH5.Enabled=false;
hH6.Enabled=false;
hH7.Enabled=false;
hH8.Enabled=false;
hH9.Enabled=false;
hH10.Enabled=false;
hH11.Enabled=false;
disable_interface();
mouse.EnableMode(eModeInteract);
player.AddInventory(iTrinket2);
player.AddInventory(iTrinket3);
player.AddInventory(iTrinket4);
player.AddInventory(iTrinket5);
player.AddInventory(iTrinket6);
player.AddInventory(iTrinket7);
player.AddInventory(iTrinket8);
player.AddInventory(iTrinket9);
player.AddInventory(iTrinket10);
player.AddInventory(iTrinket11);
player.AddInventory(iTrinket12);
aTrinketsSpill.Play();
}
function replace() {
if (player.ActiveInventory==iTrinket2 && Hotspot.GetAtScreenXY(mouse.x, mouse.y)!=hotspot[2]) {
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT2.Visible=true;
}
if (player.ActiveInventory==iTrinket3 && Hotspot.GetAtScreenXY(mouse.x, mouse.y)!=hotspot[3]) {
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT3.Visible=true;
}
if (player.ActiveInventory==iTrinket4 && Hotspot.GetAtScreenXY(mouse.x, mouse.y)!=hotspot[4]) {
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT4.Visible=true;
}
if (player.ActiveInventory==iTrinket5 && Hotspot.GetAtScreenXY(mouse.x, mouse.y)!=hotspot[5]) {
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT5.Visible=true;
}
if (player.ActiveInventory==iTrinket6 && Hotspot.GetAtScreenXY(mouse.x, mouse.y)!=hotspot[6]) {
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT6.Visible=true;
}
if (player.ActiveInventory==iTrinket7 && Hotspot.GetAtScreenXY(mouse.x, mouse.y)!=hotspot[7]) {
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT7.Visible=true;
}
if (player.ActiveInventory==iTrinket8 && Hotspot.GetAtScreenXY(mouse.x, mouse.y)!=hotspot[8]) {
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT8.Visible=true;
}
if (player.ActiveInventory==iTrinket9 && Hotspot.GetAtScreenXY(mouse.x, mouse.y)!=hotspot[9]) {
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT9.Visible=true;
}
if (player.ActiveInventory==iTrinket10 && Hotspot.GetAtScreenXY(mouse.x, mouse.y)!=hotspot[10]) {
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT10.Visible=true;
}
if (player.ActiveInventory==iTrinket11 && Hotspot.GetAtScreenXY(mouse.x, mouse.y)!=hotspot[11]) {
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT11.Visible=true;
}
if (player.ActiveInventory==iTrinket12 && Hotspot.GetAtScreenXY(mouse.x, mouse.y)!=hotspot[12]) {
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT12.Visible=true;
}
}
function doesnt_go_there(){
cEThink.Speak("That piece doesn't feel like it belongs there.");
replace();
mouse.Mode=eModeInteract;
}
function puzzle_done() {
Wait(20);
aPulsarDelay.Play(); //magic activating sound
oP1.Visible=true;
oP2.Visible=true;
oP3.Visible=true;
oP4.Visible=true;
oP5.Visible=true;
oP6.Visible=true;
oP7.Visible=true;
oP8.Visible=true;
oP9.Visible=true;
oP10.Visible=true;
oP11.Visible=true;
oP12.Visible=true;
oGlow1.Transparency=100;
oGlow2.Transparency=100;
oG1.Transparency=100;
oG2.Transparency=100;
oG3.Transparency=100;
oG4.Transparency=100;
oG5.Transparency=100;
oG6.Transparency=100;
oG7.Transparency=100;
oG8.Transparency=100;
oG9.Transparency=100;
oG10.Transparency=100;
oG11.Transparency=100;
oG12.Transparency=100;
oG1.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
oG2.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
oG3.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
oG4.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
oG5.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
oG6.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
oG7.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
oG8.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
oG9.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
oG10.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
oG11.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
oG12.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
Wait(20);
oGlow1.TweenTransparency(0.5, 10, eLinearTween, eNoBlockTween);
oGlow2.TweenTransparency(0.5, 10, eLinearTween, eBlockTween);
Wait(10);
e_solved_trinkets=true;
player.ChangeRoom(144); //window closeup
}
function start_puzzle() {
cEThink.Speak("Hmm...Something makes me think I should start with...");
oT1.Visible=false;
oP1.Visible=true;
aPlacetrinket.Play();
Wait(40);
cEThink.Speak(" This one. ");
}
function room_AfterFadeIn()
{
dark_fadein_blocking();
mouse.Mode=eModeInteract;
btn_walk.Enabled=false;
mouse.DisableMode(eModeWalkto);
btnIconInv.Enabled=false;
start_puzzle();
oT1.Visible=false;
oP1.Visible=true;
}
function on_mouse_click(MouseButton button) {
if (button==eMouseRight && player.ActiveInventory==iTrinket2) {
oT2.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
}
if (button==eMouseRight && player.ActiveInventory==iTrinket3) {
oT3.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
}
if (button==eMouseRight && player.ActiveInventory==iTrinket4) {
oT4.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
}
if (button==eMouseRight && player.ActiveInventory==iTrinket5) {
oT5.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
}
if (button==eMouseRight && player.ActiveInventory==iTrinket6) {
oT6.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
}
if (button==eMouseRight && player.ActiveInventory==iTrinket7) {
oT7.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
}
if (button==eMouseRight && player.ActiveInventory==iTrinket8) {
oT8.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
}
if (button==eMouseRight && player.ActiveInventory==iTrinket9) {
oT9.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
}
if (button==eMouseRight && player.ActiveInventory==iTrinket10) {
oT10.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
}
if (button==eMouseRight && player.ActiveInventory==iTrinket11) {
oT11.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
}
if (button==eMouseRight && player.ActiveInventory==iTrinket12) {
oT12.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
}
}
function room_Leave()
{
player.ActiveInventory=null;
enable_interface();
aA_Puzzle.Stop();
}
function hH2_UseInv()
{
if (player.ActiveInventory==iTrinket2) {
aPlacetrinket.Play();
oP2.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT2.Visible=false;
hH2.Enabled=false;
hH3.Enabled=true;
}
else doesnt_go_there();
}
function hH3_UseInv()
{
if (player.ActiveInventory==iTrinket3) {
aPlacetrinket.Play();
oP3.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT3.Visible=false;
hH3.Enabled=false;
hH4.Enabled=true;
if (oP2.Visible==false) hH2.Enabled=true;
}
else doesnt_go_there();
}
function hH4_UseInv()
{
if (player.ActiveInventory==iTrinket4) {
aPlacetrinket.Play();
oP4.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT4.Visible=false;
hH4.Enabled=false;
hH5.Enabled=true;
if (oP3.Visible==false) hH3.Enabled=true;
}
else doesnt_go_there();
}
function hH5_UseInv()
{
if (player.ActiveInventory==iTrinket5) {
aPlacetrinket.Play();
oP5.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT5.Visible=false;
hH5.Enabled=false;
hH6.Enabled=true;
if (oP4.Visible==false) hH4.Enabled=true;
}
else doesnt_go_there();
}
function hH6_UseInv()
{
if (player.ActiveInventory==iTrinket6) {
aPlacetrinket.Play();
oP6.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT6.Visible=false;
hH6.Enabled=false;
hH7.Enabled=true;
if (oP5.Visible==false) hH5.Enabled=true;
}
else doesnt_go_there();
}
function hH7_UseInv()
{
if (player.ActiveInventory==iTrinket7) {
aPlacetrinket.Play();
oP7.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT7.Visible=false;
hH7.Enabled=false;
hH8.Enabled=true;
if (oP6.Visible==false) hH6.Enabled=true;
}
else doesnt_go_there();
}
function hH8_UseInv()
{
if (player.ActiveInventory==iTrinket8) {
aPlacetrinket.Play();
oP8.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT8.Visible=false;
hH8.Enabled=false;
hH9.Enabled=true;
if (oP7.Visible==false) hH7.Enabled=true;
}
else doesnt_go_there();
}
function hH9_UseInv()
{
if (player.ActiveInventory==iTrinket9) {
aPlacetrinket.Play();
oP9.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT9.Visible=false;
hH9.Enabled=false;
hH10.Enabled=true;
if (oP8.Visible==false) hH8.Enabled=true;
}
else doesnt_go_there();
}
function hH10_UseInv()
{
if (player.ActiveInventory==iTrinket10) {
aPlacetrinket.Play();
oP10.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT10.Visible=false;
hH10.Enabled=false;
hH11.Enabled=true;
if (oP9.Visible==false) hH9.Enabled=true;
}
else doesnt_go_there();
}
function hH11_UseInv()
{
if (player.ActiveInventory==iTrinket11) {
aPlacetrinket.Play();
oP11.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT11.Visible=false;
hH11.Enabled=false;
if (oP10.Visible==false) hH10.Enabled=true;
}
else doesnt_go_there();
}
function hH12_UseInv()
{
if (player.ActiveInventory==iTrinket12) {
aPlacetrinket.Play();
oP12.Visible=true;
player.ActiveInventory=null;
mouse.DisableMode(eModeUseinv);
oT12.Visible=false;
hH12.Enabled=false;
hH11.Enabled=true;
}
else doesnt_go_there();
}
function oT2_Interact()
{
mouse.EnableMode(eModeUseinv);
player.ActiveInventory=iTrinket2;
mouse.Mode=eModeUseinv;
oT2.Visible=false;
}
function oT3_Interact()
{
mouse.EnableMode(eModeUseinv);
player.ActiveInventory=iTrinket3;
mouse.Mode=eModeUseinv;
oT3.Visible=false;
}
function oT4_Interact()
{
mouse.EnableMode(eModeUseinv);
player.ActiveInventory=iTrinket4;
mouse.Mode=eModeUseinv;
oT4.Visible=false;
}
function oT5_Interact()
{
mouse.EnableMode(eModeUseinv);
player.ActiveInventory=iTrinket5;
mouse.Mode=eModeUseinv;
oT5.Visible=false;
}
function oT6_Interact()
{
mouse.EnableMode(eModeUseinv);
player.ActiveInventory=iTrinket6;
mouse.Mode=eModeUseinv;
oT6.Visible=false;
}
function oT7_Interact()
{
mouse.EnableMode(eModeUseinv);
player.ActiveInventory=iTrinket7;
mouse.Mode=eModeUseinv;
oT7.Visible=false;
}
function oT8_Interact()
{
mouse.EnableMode(eModeUseinv);
player.ActiveInventory=iTrinket8;
mouse.Mode=eModeUseinv;
oT8.Visible=false;
}
function oT9_Interact()
{
mouse.EnableMode(eModeUseinv);
player.ActiveInventory=iTrinket9;
mouse.Mode=eModeUseinv;
oT9.Visible=false;
}
function oT10_Interact()
{
mouse.EnableMode(eModeUseinv);
player.ActiveInventory=iTrinket10;
mouse.Mode=eModeUseinv;
oT10.Visible=false;
}
function oT11_Interact()
{
mouse.EnableMode(eModeUseinv);
player.ActiveInventory=iTrinket11;
mouse.Mode=eModeUseinv;
oT11.Visible=false;
}
function oT12_Interact()
{
mouse.EnableMode(eModeUseinv);
player.ActiveInventory=iTrinket12;
mouse.Mode=eModeUseinv;
oT12.Visible=false;
}
function room_RepExec()
{
if (mouse.Mode==eModeUseinv) mouse.ChangeModeHotspot(eModeUseinv, 5, 11);
if (oP2.Visible==true && oP3.Visible==true && oP4.Visible==true && oP5.Visible==true && oP6.Visible==true && oP7.Visible==true && oP8.Visible==true && oP9.Visible==true && oP10.Visible==true && oP11.Visible==true && oP12.Visible==true) {
puzzle_done();
}
if (oP2.Visible==true) hH2.Enabled=false;
if (oP3.Visible==true) hH3.Enabled=false;
if (oP4.Visible==true) hH4.Enabled=false;
if (oP5.Visible==true) hH5.Enabled=false;
if (oP6.Visible==true) hH6.Enabled=false;
if (oP7.Visible==true) hH7.Enabled=false;
if (oP8.Visible==true) hH8.Enabled=false;
if (oP9.Visible==true) hH9.Enabled=false;
if (oP10.Visible==true) hH10.Enabled=false;
if (oP11.Visible==true) hH11.Enabled=false;
if (oP12.Visible==true) hH12.Enabled=false;
}
function oSkip_AnyClick(Object *theObject, CursorMode mode)
{
e_solved_trinkets=true;
player.ChangeRoom(144);
}
function hBG_UseInv(Hotspot *theHotspot, CursorMode mode)
{
if (player.ActiveInventory==iTrinket2 && oP2.Visible==false) {
oT2.Visible=true;
}
else if (player.ActiveInventory==iTrinket3 && oP3.Visible==false) {
oT3.Visible=true;
}
else if (player.ActiveInventory==iTrinket4 && oP4.Visible==false) {
oT4.Visible=true;
}
else if (player.ActiveInventory==iTrinket5 && oP5.Visible==false) {
oT5.Visible=true;
}
else if (player.ActiveInventory==iTrinket6 && oP6.Visible==false) {
oT6.Visible=true;
}
else if (player.ActiveInventory==iTrinket7 && oP7.Visible==false) {
oT7.Visible=true;
}
else if (player.ActiveInventory==iTrinket8 && oP8.Visible==false) {
oT8.Visible=true;
}
else if (player.ActiveInventory==iTrinket9 && oP9.Visible==false) {
oT9.Visible=true;
}
else if (player.ActiveInventory==iTrinket10 && oP10.Visible==false) {
oT10.Visible=true;
}
else if (player.ActiveInventory==iTrinket11 && oP11.Visible==false) {
oT11.Visible=true;
}
else if (player.ActiveInventory==iTrinket12 && oP12.Visible==false) {
oT12.Visible=true;
}
player.ActiveInventory=null;
}
You can hide very long code using the spoiler to make it easier to navigate the forums. I will be able to look into more detail only later. :/
Sorry about that; I was in a hurry when I posted. Fixed.
I guess I'll try Khris's band-aid solution and hope that it fixes the issue. Again, since I've been unable to duplicate the glitch, I'm just crossing my fingers that this works.
Your code of hH11_UseInv is different from the others.
Overall I would try to redo using some way that doesn't require duplicating the code so much - like CW mentioned. You can reuse the handlers so that you can run all in the same handler - in AGS 3.6.1 and later the first parameter of that event is the item (InventoryItem *theItem), but maybe you are using an old version that doesn't support it, or perhaps it's just that this code was written in a previous version and it wasn't updated when you switched versions, then you would need to manually add the parameters (for the UseInv example, you can just create a new item, and copy-paste from it's generated handler into the existing ones).
On the other hand, Khris approach also works, while you still need to retest things, there may be less risk involved if your modification is small and you are just adding stuff, maybe it's better in a late part of making the game. If it works for the player then it should be alright.
All right, thanks for pointing that out. I've done my best to fix things.
Thanks for the input, everyone!