Skip to content
Snippets Groups Projects

Make several Lua global variables writable.

Merged Golden requested to merge Golden/SRB2:make-some-lua-globals-rw into next

Gives Lua write access to some of its global variables

Includes:

  • emeralds
  • token
  • gravity
  • displayplayer

Suggestions welcome.

Edited by Golden

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Well, I think this merge would solve #315 (closed)

    I don't have any suggestions on my mind though..

  • Author Contributor

    Didn't even know that issue existed

    Gonna update description now...

    Edited by Golden
  • Golden changed title from Make several Lua global variables writable. to Make several Lua global variables writable. (Closes #315)

    changed title from Make several Lua global variables writable. to Make several Lua global variables writable. (Closes #315)

  • Golden changed the description

    changed the description

  • Author Contributor

    caching sucks sometimes

  • you're gonna change the super transform function here too?

  • Author Contributor

    outside the scope of the mr; i guess maybe it shouldn't close #315 (closed) in that case.

  • Golden changed title from Make several Lua global variables writable. (Closes #315) to Make several Lua global variables writable.

    changed title from Make several Lua global variables writable. (Closes #315) to Make several Lua global variables writable.

  • Golden added 1 commit

    added 1 commit

    • f42dee18 - Make `displayplayer` writable.

    Compare with previous version

  • Golden changed the description

    changed the description

  • Author Contributor

    Gonna add secondarydisplayplayer for parity.

  • Author Contributor

    nvm turns out secondarydisplayplayer is consoleplayer 2: electric boogaloo

  • Let's see here...

    stoppedclock for stopping all player's timers manually

    bluescore and redscore for modifying a team's score in custom gametypes

    timelimit and scorelimit are modifiable via Cvars, which makes me wonder why they're even global variables to begin with???

    There are also a whole bunch of global variables that are modifiable mid-game via a Maincfg SOC, such as skincolor_redteam, underwatertics, and spstage_start, so it'd make sense to expose those to Lua too. Not gonna list of them since there are so many, but there's no reason not to expose them.

    leveltime would be something that'd be extremely useful to have exposed. It'd allow you to bypass or modify certain hardcoded behaviors, such as the Race/Competition countdown. I honestly don't see why you wouldn't expose leveltime. Most of the problems that could arise from modifying something like this would be entirely on the modder, much like other things Lua scripts can do, like modify the savable camera Cvars.

    I'm also checking the source code, and it seems there are screen-fading and tutorial text box global variables? But those would probably be best turned into functions, which is outside the scope of this merge.

  • redscore and bluescore are already exposed and writable. timelimit and scorelimit will be settable once 2.2.9 is out due to !1205 (merged).

    However, leveltime is the only ticker Lua scripters have available for any time-based algorithm: 99% of scripts are reliant on its constance. Letting it be writable is giving anyone easy leeway to break everyone else's scripts.

    Addendum: yes, anyone can make their own ticker by shoving a random counter in a ThinkFrame - exposing leveltime would still be a huge compatibility breaker.

    Edited by Tatsuru
  • I haven't looked into the other variables in detail, but they sound fine to me at a glance.

    However, I wholly and utterly agree that allowing any script to arbitrarily edit the variable that is most universally relied on as a reliable global timer by basically every script in existence, would be a major backward compatibility breaker and a disaster for our modding ecosystem.

  • Author Contributor

    @SMS_Alfredo use player.realtime lmaoo

  • Author Contributor

    also i feel like maincfg stuff shouldn't be touched specifically because of things like unlockables and condition sets

  • Author Contributor

    stoppedclock may or may not have unintended side effects, but i'll expose it anyway as another seperate commit, so if it ends up becoming a problem it can be removed.

  • Golden added 1 commit

    added 1 commit

    • 2b39a971 - Make `stoppedclock` writable.

    Compare with previous version

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading