Forum rules - please read before posting.

The namespace 'AC' already contains a definition for 'SceneInfo' update errors

I'm trying to update from 1.69 to latest and I'm getting a lot of errors like this:
Assets\AdventureCreator\Scripts\Character\PlayerPrefab.cs(25,15): error CS0101: The namespace 'AC' already contains a definition for 'PlayerPrefab'
Assets\AdventureCreator\Scripts\Game engine\SceneInfo.cs(20,15): error CS0101: The namespace 'AC' already contains a definition for 'SceneInfo'
What's causing these errors, and how can I fix them?

«1

Comments

  • It's a Unity error, and one that typically shows if you have two scripts or classes with the same name elsewhere in your project.

    Do you have a pair of scripts named "SceneInfo"?

    Taking a backup first, try deleting AC's Scripts folder before importing the latest.

  • Thanks, I have no idea what happened but I updated and it's not giving those errors (maybe I reimported the same version?)

    I have a few errors now from custom scripts, I believe related to the recent api changes:
    Assets\ScummVerbLine.cs(89,36): error CS7036: There is no argument given that corresponds to the required formal parameter '_language' of 'Button.GetFullLabel(Hotspot, InvInstance, int)'

    Assets\HideGiveTalk.cs(38,42): error CS1061: 'RuntimeInventory' does not contain a definition for 'IsGivingItem' and no accessible extension method 'IsGivingItem' accepting a first argument of type 'RuntimeInventory' could be found (are you missing a using directive or an assembly reference?)

    Assets\Verb1txtVerb2.cs(103,54): error CS1061: 'PlayerInteraction' does not contain a definition for 'GetLabelPrefix' and no accessible extension method 'GetLabelPrefix' accepting a first argument of type 'PlayerInteraction' could be found (are you missing a using directive or an assembly reference?)

    Assets\ScummVerbLine.cs(213,62): error CS1061: 'RuntimeInventory' does not contain a definition for 'Combine' and no accessible extension method 'Combine' accepting a first argument of type 'RuntimeInventory' could be found (are you missing a using directive or an assembly reference?)

    These seem to be related to a similar change, what needs adjusting to make this work with the latest version?

  • edited November 2020

    The Scripting Guide lists all available functions and variables, but I would need proper context to give specific advice.

    What are the functions that contain these errors?

  • edited November 2020

    I believe they are, respectively:
    private void OnHotspotInteract(Hotspot hotspot, AC.Button button) { SetOverrideText(button.GetFullLabel(hotspot, Options.GetLanguage())); }

    private void UpdateHotspot(Hotspot hotspot, int selectedCursor) { if (KickStarter.runtimeInventory.SelectedItem != null && hotspot.GetUseButton(1) == null && KickStarter.runtimeInventory.IsGivingItem()) { hotspot.TurnOff(); } else if (selectedCursor == 1 && hotspot.GetUseButton(1) == null) { hotspot.TurnOff(); } else { hotspot.TurnOn(); } }

    private void MyUse(Hotspot hotspot, AC.Button button) { textOnEvent = true; if (button != null) { int language = Options.GetLanguage(); newLabel = KickStarter.cursorManager.GetLabelFromID(button.iconID, language) + " " + hotspot.GetName(language); } if (hotspot.GetButtonInteractionType(button) == HotspotInteractionType.Inventory) { int language = Options.GetLanguage(); newLabel = KickStarter.playerInteraction.GetLabelPrefix(hotspot, KickStarter.runtimeInventory.SelectedItem, language) + " " + hotspot.GetName(language); } }

    private void OnMenuElementClick(Menu menu, MenuElement element, int slot, int buttonPressed) { MenuInventoryBox inventoryBox = element as MenuInventoryBox; if (inventoryBox != null) { InvItem hoverItem = inventoryBox.GetItem(slot); if (hoverItem != null) { if (buttonPressed == 1) { if (KickStarter.runtimeInventory.SelectedItem == null) { if (KickStarter.playerCursor.GetSelectedCursor() == -1) { hoverItem.RunUseInteraction(useCursorID); } else { hoverItem.RunUseInteraction(KickStarter.playerCursor.GetSelectedCursorID()); } } else { if (KickStarter.runtimeInventory.SelectedItem == hoverItem) { KickStarter.runtimeInventory.SetNull(); } else { KickStarter.runtimeInventory.Combine(KickStarter.runtimeInventory.SelectedItem, hoverItem); } } } else if (buttonPressed == 2) { if (KickStarter.runtimeInventory.SelectedItem != null) { hoverItem.CombineWithItem(KickStarter.runtimeInventory.SelectedItem.id); } } KickStarter.playerInput.ResetClick(); } } }

    Here are the complete scripts:
    ScummVerbLine: https://www.codepile.net/pile/RDMEXXDQ
    Verb1txtVerb2: https://www.codepile.net/pile/J5AXJ47e
    HideGiveTalk: https://www.codepile.net/pile/MyObE3q1

    Btw, is there some other way of sharing code properly on the forum? I always use the code drop-down menu, but it just does single-line style, is it possible to format it block-style?

  • is it possible to format it block-style?

    Yes - just give your code a tab-indent.

    The ScummVerbLine script has been replaced by the ScummInterface script in the Nine Verbs Template package, which has been updated to work with the latest AC release.

    The other amended scripts:

    Verb1txtVerb2:

    using UnityEngine;
    using UnityEngine.UI;
    using AC;
    
    public class Verb1txtVerb2 : MonoBehaviour
    {
    
        public Text textBox1;
        public Text textBox2;
        public GameObject bg;
        private bool textOnce;
        private bool textOnEvent;
        private string newLabel;
        private bool amInteraction;
        private bool amCutscene = true;
        Interaction myInteraction;
        private bool invInteraction;
    
        private Animator _animator;
        public float heightofclick;
    
        private void Start ()
        {
            _animator = GetComponent<Animator> ();
        }
    
        private void OnEnable ()
        {
            EventManager.OnHotspotInteract += MyUse;
            EventManager.OnExitGameState += ExitGameState;
            EventManager.OnEnterGameState += EnterGameState;
            EventManager.OnBeginActionList += OnBeginActionList;
            EventManager.OnEndActionList += OnEndActionList;
            EventManager.OnInventoryInteract += OnInventoryInteract;
        }
    
        private void OnDisable ()
        {
            EventManager.OnHotspotInteract -= MyUse;
            EventManager.OnExitGameState -= ExitGameState;
            EventManager.OnEnterGameState -= EnterGameState;
            EventManager.OnBeginActionList -= OnBeginActionList;
            EventManager.OnEndActionList -= OnEndActionList;
            EventManager.OnInventoryInteract -= OnInventoryInteract;
    
        }
    
        private void OnInventoryInteract (InvItem invItem, int iconID)
        {
            invInteraction = true;
            print ("is inventory");
            int language = Options.GetLanguage ();
            newLabel = KickStarter.cursorManager.GetLabelFromID (iconID, language) + " " + invItem.GetLabel (language);
        }
    
        private void OnEndActionList (ActionList actionList, ActionListAsset actionListAsset, bool isSkipping)
        {
            if (invInteraction == true)
            {
                invInteraction = false;
                print ("inventory actionlist cancel");
    
            }
        }
    
        private void EnterGameState (GameState gamestate)
        {
            if (gamestate == GameState.Cutscene)
            {
                amCutscene = true;
            }
        }
        private void ExitGameState (GameState gamestate)
        {
            if (gamestate == GameState.Cutscene)
            {
                textOnEvent = false;
                amInteraction = false;
                amCutscene = false;
            }
        }
        private void OnBeginActionList (ActionList actionList, ActionListAsset actionListAsset, int startingIndex, bool isSkipping)
        {
            if (actionList is Interaction)
            {
                amInteraction = true;
                myInteraction = actionList as Interaction;
            }
    
        }
        private void MyUse (Hotspot hotspot, AC.Button button)
        {
            textOnEvent = true;
            if (button != null)
            {
                int language = Options.GetLanguage ();
                newLabel = KickStarter.cursorManager.GetLabelFromID (button.iconID, language) + " " + hotspot.GetName (language);
            }
            if (hotspot.GetButtonInteractionType (button) == HotspotInteractionType.Inventory)
            {
                int language = Options.GetLanguage ();
                newLabel = hotspot.GetFullLabel (language);
            }
        }
    
        private void Update ()
        {
            bool doHold = false;
    
            if (KickStarter.playerInteraction.GetHotspotMovingTo () != null)
            {
                if (textOnce == false)
                {
                    textBox2.text = textBox1.text;
                    textBox2.enabled = true;
                    bg.SetActive (true);
                    textOnce = true;
                }
    
            }
            else
            {
                textBox2.text = textBox1.text;
                textBox2.enabled = false;
                bg.SetActive (false);
                textOnce = false;
            }
            if (textOnEvent == true || invInteraction == true)
            {
                textBox1.text = newLabel;
            }
            if (KickStarter.playerInteraction.GetHotspotMovingTo () == null
                && amInteraction == false
                )
            {
                textOnEvent = false;
            }
    
            if (myInteraction != null)
            {
                if (!myInteraction.AreActionsRunning ())
                {
                    //textOnEvent = false;
                    amInteraction = false;
                    // Interaction is set, but no Actions are running
                }
            }
    
            //Highlight Script
    
            if (KickStarter.playerInteraction.GetHotspotMovingTo () != null
                || amInteraction == true
                    //||  textOnEvent == true
                    )
            {
                doHold = true;
            }
            _animator.SetBool ("Hold", doHold);
    
            if (Input.GetMouseButtonDown (0) &&
                KickStarter.playerInteraction.GetActiveHotspot () == null &&
                Camera.main.ScreenToViewportPoint (Input.mousePosition).y >= heightofclick
                && amInteraction == false
                && amCutscene == false
                )
            {
                _animator.SetTrigger ("Flash");
            }
    
        }
    }
    

    HideGiveTalk:

    using UnityEngine;
    using AC;
    
    public class HideGiveTalk : MonoBehaviour
    {
    
        private Hotspot[] allMyHotspots;
    
    
        private void OnEnable ()
        {
            allMyHotspots = FindObjectsOfType (typeof (Hotspot)) as Hotspot[];
            EventManager.OnChangeCursorMode += OnChangeCursorMode;
        }
    
    
        private void OnDisable ()
        {
            EventManager.OnChangeCursorMode -= OnChangeCursorMode;
        }
    
    
        private void OnChangeCursorMode (int selectedCursor)
        {
            foreach (Hotspot hotspot in allMyHotspots)
            {
                UpdateHotspot (hotspot, selectedCursor);
            }
        }
    
    
        private void UpdateHotspot (Hotspot hotspot, int selectedCursor)
        {
            if (InvInstance.IsValid (KickStarter.runtimeInventory.SelectedInstance) &&
                hotspot.GetUseButton (1) == null &&
                KickStarter.runtimeInventory.SelectedInstance.SelectItemMode == SelectItemMode.Give)
            {
                hotspot.TurnOff ();
            }
            else if (selectedCursor == 1 && hotspot.GetUseButton (1) == null)
            {
                hotspot.TurnOff ();
            }
            else
            {
                hotspot.TurnOn ();
            }
        }
    
    }
    
  • Thanks, I’m still working on the same project since 2016, so I’m not sure if I can use the latest scumm template since my interface is heavily modified (but I’ll take a look to see if that script can be replaced.) Which part of ScummVerbLine needs adjusting if I can’t upgrade the 9-verb template?
  • It's not a single part but many throughout. The necessary changes are a result of the overhaul to AC's inventory system, which are covered here.

  • Thanks, I went through and changed it, I was surprised how close both scripts are, really easy to compare!

  • I'm having a little trouble with the money script you helped me with a couple of years ago working with the newest version of AC, it keeps replacing my first inventory item with an item with no icon called "1 coins" every time I run the game. This script has never done this until the latest version, so I assume it's to do with the persistent/instance changes?

            `using UnityEngine;
        using System.Collections;
        using AC;
    
        public class MoneyIcon : MonoBehaviour
        {
    
            public int moneyItemID;
            public Texture[] amountTextures = new Texture[6];
    
    
            private void OnEnable()
            {
                EventManager.OnInventoryAdd += OnInventoryModify;
                EventManager.OnInventoryRemove += OnInventoryModify;
            }
    
    
            private void OnDisable()
            {
                EventManager.OnInventoryAdd -= OnInventoryModify;
                EventManager.OnInventoryRemove -= OnInventoryModify;
            }
    
    
            private void OnInventoryModify(InvItem item, int count)
            {
                if (item.id == moneyItemID && item.count > 0)
                {
                    if (item.count >= 20)
                    {
                        item.tex = amountTextures[5];
                    }
                    else if (item.count >= 8)
                    {
                        item.tex = amountTextures[4];
                    }
                    else if (item.count >= 4)
                    {
                        item.tex = amountTextures[3];
                    }
                    else if (item.count == 3)
                    {
                        item.tex = amountTextures[2];
                    }
                    else if (item.count == 2)
                    {
                        item.tex = amountTextures[1];
                    }
                    else
                    {
                        item.tex = amountTextures[0];
                    }
    
                    PlayerMenus.ResetInventoryBoxes();
                }
    
                if (item.id == moneyItemID && item.count < 2)
                {
                    item.label = item.count.ToString() + " coin";
                }
                else if (item.id == moneyItemID && item.count > 2)
                {
                    item.label = item.count.ToString() + " coins";
                }
            }
    
        }
        `
    
  • Also, the verb highlights when I roll my mouse over hotspots isn't working on the latest update. Which script controls that and would need adjusting?

  • I'm having a little trouble with the money script

    The "count" of an InvItem class now refers to the default amount the Player can carry. For the "live" count value, which is how many the Player is currently carrying, you need to refer to the "Count" of the InvInstance class:

    using UnityEngine;
    using AC;
    
    public class MoneyIcon : MonoBehaviour
    {
    
        public int moneyItemID;
        public Texture[] amountTextures = new Texture[6];
    
        private void OnEnable()
        {
            EventManager.OnInventoryAdd_Alt += OnInventoryModify;
            EventManager.OnInventoryRemove_Alt += OnInventoryModify;
        }
    
        private void OnDisable()
        {
            EventManager.OnInventoryAdd_Alt -= OnInventoryModify;
            EventManager.OnInventoryRemove_Alt -= OnInventoryModify;
        }
    
        private void OnInventoryModify (InvCollection invCollection, InvInstance invInstance, int amount)
        {
            if (invCollection != KickStarter.runtimeInventory.PlayerInvCollection) return;
    
            InvInstance moneyInvInstance = invCollection.GetFirstInstance (moneyItemID);
            if (!InvInstance.IsValid (moneyInvInstance)) return;
    
            if (moneyInvInstance.Count >= 20)
            {
                moneyInvInstance.InvItem.tex = amountTextures[5];
            }
            else if (moneyInvInstance.Count >= 8)
            {
                moneyInvInstance.InvItem.tex = amountTextures[4];
            }
            else if (moneyInvInstance.Count >= 4)
            {
                moneyInvInstance.InvItem.tex = amountTextures[3];
            }
            else if (moneyInvInstance.Count == 3)
            {
                moneyInvInstance.InvItem.tex = amountTextures[2];
            }
            else if (moneyInvInstance.Count == 2)
            {
                moneyInvInstance.InvItem.tex = amountTextures[1];
            }
            else
            {
                moneyInvInstance.InvItem.tex = amountTextures[0];
            }
    
            if (moneyInvInstance.Count >= 2)
            {
                moneyInvInstance.InvItem.label = moneyInvInstance.Count.ToString () + " coins";
            }
            else
            {
                moneyInvInstance.InvItem.label = moneyInvInstance.Count.ToString () + " coin";
            }
    
            PlayerMenus.ResetInventoryBoxes ();
        }
    
    }
    

    Also, the verb highlights when I roll my mouse over hotspots isn't working on the latest update.

    This is incorporated into the ScummInterface script, but the problem is on the AC side. I shall look into it.

  • edited December 2020

    T̶h̶a̶n̶k̶s̶,̶ ̶t̶h̶a̶t̶ ̶w̶o̶r̶k̶s̶ ̶w̶e̶l̶l̶!̶ EDIT: spoke too soon, it's still replacing the first item in my inventory with an item called "1 coins" and replacing the icon with None (it retains the cursor icon though).

    I'm trying to test out everything to make sure nothing has broken in the 2 AC version jumps, here's my ScummVerbLine changes, it seems to work fine so far: https://www.codepile.net/pile/JGyBPgeD

    Glad to know the verb highlights issue isn't this end, let me know what I can do to fix it so I can proceed with testing the rest of the update, thanks!

  • The above script will only modify the appearance of items that match the ID supplied in the Inspector. If it's applying changes to the first item, and removing its texture, I suspect you either have another instance of the script in your scene - or the original's had its values reset.

    The highlight issue has been addressed in the updated template package.

  • edited December 2020

    I compared both 1.71.0 and the recently updated 1.72.4 versions, and 1.71.0 does nothing to my inventory (since I'm not using an item that would be adjusted by the money script) and 1.72.4 definitely changes the first inventory item after running the scene once. Nothing changes on the first play, but on the second play, the scene has hard-changed the item.

    Which changes were made in the ScummInterface (presumably?) so I can update my own 2016-era modified scumm script to work correctly? Here's the script I'm using: https://www.codepile.net/pile/V4KPl0yE

  • I tried this, but it doesn't work, this seems to reflect the only changes in ScummInterface: https://www.codepile.net/pile/MO6DxX4g

  • You haven't shared where/how you're using the money script, but you'd certainly get the behaviour you've described if it's been improperly configured.

    Try placing a Debug.Log statement at the bottom of the OnInventoryModify script:

    Debug.Log ("Updating item " + moneyItemID + ", " + moneyInvInstance.InvItem.label + " from " + this, this);
    

    Clicking the message should then reveal its location in the Hierarchy - does it point to where it's expected to be (and only there)?

    The changes made to ScummInterface were in the Update loop, with the Menu's SetTargetHotspot function being called.

  • In my script, I don't have a menu variable as the script itself is placed on the txtVerbLine object. What should menu.SetHotspot be inheriting from?

  • I've tried modding the script with the menu and it still doesn't seem to get menu highlights showing: https://www.codepile.net/pile/d2lmnaLa

  • See the use of the normalColorBlock, highlightedColorBlock and verbElements variables in the official script - they handle the highlighting.

    I would recommend incorporating the official script and tweaking as necessary.

  • I'd love to, I'm just worried about breaking anything else in this precariously balanced set-up I've worked on since 2017 :( In my script https://www.codepile.net/pile/V4KPl0yE (which I think is based on the original template script unless I'm remembering wrong?) how is the highlighting handled? I did try using the official script, but it didn't seem to work with my original template prefabs.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.