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
-
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?
-
use shift and set flag to the powerup you want, no need for code.
-
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:
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.
-
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:
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