[ANSWERED] [KS Ex] How to trigger power collection in lua?

  • 3 Replies
  • 7255 Views
[ANSWERED] [KS Ex] How to trigger power collection in lua?
« on: September 25, 2014, 18:41:43 »
I'm trying to mess around with powers in my story's Script.lua using KS Ex

Is there a way to cause a power to be "activated" in the lua script?
For example, upon loading a particular screen (let's say x1001y993) I want to automagically have the Run power.
In my screen function (function x1001y993()) I've tried:
  • vars.Powers["Run"] = true;
  • vars.Run = true;
  • Objects.Powers.Run = true;
  • And many other variations

How do I cause any arbitrary power to be "activated" using a script instead of actually gathering the powerup in-game?
« Last Edit: October 10, 2014, 18:27:13 by momruoy »


*

Offline egomassive

  • 1852
  • 250
    • View Profile
    • egomassive games
Re: [KS Ex] How to trigger power collection in lua?
« Reply #2 on: October 07, 2014, 06:52:40 »
I don't have much experience with KS Ex or lua, but I looked through the script for GrayFace's Extended Version Sample level. I think you might have luck with code like this:
Code: [Select]
function x1000y1000()
 if Objects.Player.Detector == 0 then
  Objects.Player.Detector = 1
 end
Of course you'll have to figure out which word points to the run power. The key is that the ability to run is stored within the player character.
« Last Edit: October 07, 2014, 06:54:54 by egomassive »

Re: [KS Ex] How to trigger power collection in lua?
« Reply #3 on: October 10, 2014, 18:27:00 »
Oh, wow. I can't believe I didn't try that.
It works perfectly, thank you!
For future reference, here are the names of the powerups:
Code: [Select]
function x1001y1000()
Objects.Player.Run = 1
Objects.Player.Climb = 1
Objects.Player.HighJump = 1
Objects.Player.DoubleJump = 1
Objects.Player.Eye = 1
Objects.Player.Detector = 1
Objects.Player.Umbrella = 1
Objects.Player.Hologram = 1
end