Nifflas' Support Forum

Level Editing Support => Knytt Stories Level Editing Support => Knytt Stories - Custom Content => Topic started by: momruoy on September 25, 2014, 18:41:43

Title: [ANSWERED] [KS Ex] How to trigger power collection in lua?
Post by: momruoy 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:

How do I cause any arbitrary power to be "activated" using a script instead of actually gathering the powerup in-game?
Title: Re: [KS Ex] How to trigger power collection in lua?
Post by: Salmoneous on October 05, 2014, 18:23:23
use shift and set flag to the powerup you want, no need for code.
Title: Re: [KS Ex] How to trigger power collection in lua?
Post by: egomassive 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.
Title: Re: [KS Ex] How to trigger power collection in lua?
Post by: momruoy 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