Results 1 to 11 of 11

Thread: The Lua API. (Oh God.)

  1. #1

    Lightbulb _

    _____
    Last edited by Zekiar; 09-09-2020 at 11:38 PM.

  2. #2
    Join Date
    May 2016
    Posts
    1,072
    Hey, I gave this a read over. I have some general comments, but it is nice feedback.

    You may be able to place text using the text tool, as part of spawnObject? I'm not sure, I think I remember hearing somebody say they did it, but I don't have a reference saved and its lot listed in the spawnObject KB page.

    "cannot access field" errors may be a result of the "sandboxing" environment we have to work in. Letting you modify the player class could make some things nicer for you, but it might also be abusable. But I'm just posing the possibility, I don't know one way or the other.

    Object scripts ARE able to communicate. In your example you have a manager would use object1.call("cleanup"), object2.call("cleanup"). Details on it are in the object page of the Knowledge Base (KB)

    You can also use setVar/setTable but you may be right about not being able to set a variable to a class directly. You might have to use a helper function to use call on, passing the variable information as the "parameters" argument

    DO NOT TRY TO USE THE NOTEBOOK AS DATA STORAGE, the notebook is buggy and unreliable. It will seem like its working then you will be tracking down some bug only to find out you can't read a notebook tab thats right in front of you or it is returning a notebook tab that was cleared/deleted incorrectly. Just don't haha. You CAN use Global.setVar for storage, or if this is for a specific item, you can write it to the objects save_state data (I can tell you more on this if you're interested).

  3. #3
    Join Date
    Apr 2016
    Posts
    174
    Quote Originally Posted by Zekiar View Post
    So the talk about abuse is kind of redundant.
    Abuse is not redundant. I had hacker spawn a custom object that injected its code onto another random object that simply keep respawning. If you give more power to the scripting engine there will always be someone to abuse it.

    Quote Originally Posted by Zekiar View Post
    once they leave the game it doesn't really matter.
    Not if it crashes your TTS, which is possible.

    I would love more functions, but I also see the need to be careful with just allowing everything.

    Flolania

  4. #4
    @Flolania
    You can't detect "malicious" scripts, there's no definition for that. Only promoted players can spawn stuff in and we're just not supposed to promote random people because they can screw the game up. They don't even need to know scripting - select all, copy, hit paste 50 times and the host crashes. Restricting scripting from some functionalities because it's potentially harmful doesn't make much sense as long as we maintain the situation where only host and promoted players can affect the system at all.

    @Zekiar
    I'm also sad there's no way to directly share/pass functions between objects. If you use Atom editor you can use #include command which will shave off some lines (visually) when editing to keep your sanity. It's much more efficient to include e.g. vector operations in each script than try to cross-call it (and oh god it takes hacks to make that work with reasonable syntax).

  5. #5
    Moved to Scripting Suggestions

  6. #6
    Join Date
    Apr 2016
    Posts
    174
    Quote Originally Posted by dzikakulka View Post
    You can't detect "malicious" scripts, there's no definition for that.
    Huh? I don't think I said anything related to this, but you can "detect" them when your game crashes after you join.

    ... and I was correct about abuse. Just because copy and pasting is one way to crash TTS, it isn't the only way a script can screw with users. Idiots could host tables and still run scripts on people that join random games (TTS does so well). I don't want to go into details, but people can abuse scripting; which is all my comment was about.

    Quote Originally Posted by Zekiar View Post
    Also, your concept of a hacker is very misinformed. There is no fancy words like "injecting codens". There is in fact an object function that will allow you to change the script of a specified object. So... Do you want to remove that just functionality because of one group of people?
    Just so you know, inject means to introduce into something which what happened. Just because I used a term you were unaware with, doesn't mean my example wasn't valid. I know what a hacker is and the difference between script kiddies. I think you should reread my post above and take note of my last statement: "I would love more functions, but I also see the need to be careful with just allowing everything."

    Flolania

  7. #7
    I'm much more worried about promoted players being able to cheat than about them being able to crash the server. If they crash the server then you just reload and continue.

  8. #8
    Yeah, sorry, I should have added "and I'm not very worried about that", because; what you said.

  9. #9
    Hey there. I gave a quick read. I see that some features have been implemented (position of player hand for example). Are there any updates to Pass Turn???

    I've been searching and searching and it puzzles me why this is not available to Modders. I don't understand why the developer would choose to not make turn passing available via LUA scripts. Was this done intentionally or just overlooked?

    I find that interaction with the turns feature critical for a successfully game setup--the work arounds are bandaids. I mean you have Workshop mods that completely bypass the turn system with their own custom code, because it's the only way anyone has figured out how to make any turn based script interaction work correctly in LUA.

    The turn system should be LUA interactive, not require custom LUA scripts and content to bypass a built in game feature.

    Could a developer inform the community how this can be achieved?

    Could anyone explain how to pass current turn with in a script.

    I've been scouring the API and talking to fellow scripters on Discord and nobody seems to know how to pass a turn in a script.

    I imagine it should be a global function you call that passes the current turn to the next player in turn order. However, I cannot find any reference to it. It's obviously in the game with the Pass Turn button in the UI (top center screen). I cannot think why the developers would not give Modders access to this function.

    Also, setting:
    Turns.turn_color = "Green"
    does not set turn to Green

    Thanks!
    [url]https://steamcommunity.com/app/28616...2523069503679/[/url]
    [url]http://www.berserk-games.com/forums/showthread.php?4281-A-Way-fo-Scritps-to-manipulate-the-OFFICIAL-TTS-turn-tracker!&highlight=pass+turn[/url]

  10. #10
    It is far from ideal, but you are able to interact with turns through scripts by reloading it like this

    Code:
    function setTurnOrder(order)
        Turns.type = 2 -- Enable custom turn ordering
        Turns.order = order
    
        -- Yes, really..
        Turns.enable = false
        Turns.enable = true
    end

  11. #11
    So if the turn is set to White before the script is executed, and you execute the script and it sets the first player in the Order to Red. Will this script change the current active player in turns to Red? I've tried this script, or something very close to it and could not get Red activated as current turn.

    Quote Originally Posted by MoreThanTom View Post
    It is far from ideal, but you are able to interact with turns through scripts by reloading it like this

    Code:
    function setTurnOrder(order)
        Turns.type = 2 -- Enable custom turn ordering
        Turns.order = order
    
        -- Yes, really..
        Turns.enable = false
        Turns.enable = true
    end

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •