Modding Help Complex Vendor Luas?(Chatty and Musical)

Discussion in 'Starbound Modding' started by gMaImNeDs, Jan 11, 2021.

  1. gMaImNeDs

    gMaImNeDs Void-Bound Voyager

    Currently working on a vendor for a clothing mod. Got almost everything done(150 item files+recipe files+blueprint files). Aiming on making the vendor play music, but only when powered by an active wire, and occasionally output a chat message.

    I managed to get the chat blurbs working by just yanking the repairo.lua and modifying the object file to spurt different text. Adding a sound effect file and line in the object file for the music works well too,... but it's on 100% of the time(at least it's not as repetitive as that clubdeck tripe).

    I then tried to slap in the light.lua for toggling the music(broken glass sounds). The repairo.lua blurbs failed to work, music on 100% still, regardless of wiring or the ""defaultlightstate" : false" I borrowed from the jukebox. I then tried the light.lua by itself(squealing tires). Still 100% on, wiring does nothing, but now the menu for the vendor is inaccessible.

    Help appreciated. Will update if solved by myself through repetitious introduction of my forehead to my keyboard or vice versa.
     
  2. gMaImNeDs

    gMaImNeDs Void-Bound Voyager

    Semi-successful. I can get my butchering of the light.lua to work just fine after chopping off anything to do with light or modifying interactability. It spawns off, you hook it to a wire, it's still off, you power it, blam, tunes. The tunes remain after removal of power source, which works good for aesthetic purposes, then stop the moment an unpowered wire's hooked, and regardless of wire or power status, the vending menu is still accessible. It also took unhitching repairo in the scripts section of the .object file, since they just don't seem to like each other. I want both, so, I'll see if there's any components/elements/blurbs shared between them outside of the ifs thens and elses.

    Anyhow, in case anybody else could get some use out of it, here's the frankenstein of a light lua I managed to zap back to life:
    "
    function init()
    if storage.state == nil then storage.state = config.getParameter("defaultLightState", true) end

    if config.getParameter("inputNodes") then
    processWireInput()
    end

    setLightState(storage.state)
    end

    function onNodeConnectionChange(args)
    processWireInput()
    end

    function onInputNodeChange(args)
    processWireInput()
    end

    function processWireInput()
    if object.isInputNodeConnected(0) then
    storage.state = object.getInputNodeLevel(0)
    setLightState(storage.state)
    elseif self.interactive then
    object.setInteractive(true)
    end
    end

    function setLightState(newState)
    if newState then
    object.setSoundEffectEnabled(true)
    if animator.hasSound("on") then
    animator.playSound("on");
    end
    else
    object.setSoundEffectEnabled(false)
    if animator.hasSound("off") then
    animator.playSound("off");
    end
    end
    end
    "
    Just grab anything between the quotation marks, pour it into Notepad++, name it whatever(as long as it ends with ".lua"), then in an objects file reference it's locale starting from "/objects", and end with the file name.

    EG:
    "scripts" : [ "/objects/subfolder/itemfolder/mymodfolderisdripping.lua" ],
    "scriptDelta" : 60,
     
  3. gMaImNeDs

    gMaImNeDs Void-Bound Voyager

    Well that was easy. I just pasted the repairo.lua in underneath the light.lua in the same file. Problem solved! The vendor plays music, chats, and is still accessible.

    Edit:While just moving around it, going outside and coming back, accessing it, crafting something, and switching power doesn't cause a problem in the expected function, occasionally it just stops working, and it starts playing the music on placement now, rather than when powered. Can still access the menu though.
     
    Last edited: Jan 15, 2021
  4. gMaImNeDs

    gMaImNeDs Void-Bound Voyager

    Fixed the item occasionally losing functionality outside of vending. Took "object.say(self.chatOptions[math.random( 0, #self.chatOptions)])", set it to list the number of chat options(22 minus 1, since starting at 0 seems to be present in many behind the scenes aspects of computers(A byte is 0-255)) "object.say(self.chatOptions[math.random( 21, #self.chatOptions)])", and now it appears to work near perfectly, not screeching to a halt even after a long period of time.

    I said near perfectly, as the music still starts when the item is placed rather than only when powered, which is only a minor problem.
    Edit: The vendor doesn't seem to remember the status is was last left at either, causing a simple trip to&from a planet to cause it to start playing music, even while connected to an unpowered wire.
     
    Last edited: Jan 16, 2021
  5. gMaImNeDs

    gMaImNeDs Void-Bound Voyager

    Mission accomplished. The noted problem this time is that there was two function initializers when I could have lumped them both into one. Dropping completed lua in notepad. Just rename the .txt file extension to ".lua", and modify the "21" to the number of chat options you have, minus one.
     

    Attached Files:

Share This Page