RippedPhreak on 1/9/2021 at 22:28
I started reading up on NVRelayTrap and my eyes glazed over. Maybe I can do more research later.
But something interesting happened: I used an S&R setup to give Garrett a receptron for a new stim (GravStim), such that when he gets stimmed with GravStim, he stims the source back. Then I made a button that stims Garrett with GravStim when it's frobbed.
I then created a "Garrett object" in the game (the brown box with a clown face on it) and adjusted its gravity to 20.
The button, when frobbed, clones the properties of the Garrett model over to the player. So yes indeed, I'm suddenly able to jump high and float down slowly. The only hitch is that this process teleports me to the location of the Garrett model when the cloning happens. So...the effort continues.
vfig on 1/9/2021 at 23:53
ZylonBane is correct but unhelpful.
here is a squirrel script for a simple trap that gives the player low gravity when turned on, and normal gravity when turned off.
Code:
class PlayerLowGravTrap extends SqRootScript {
/* When sent TurnOn, this sets the player's gravity to 20%. When sent
* TurnOff, it sets the player's gravity back to 100%.
*/
function OnTurnOn() {
local player = Object.Named("Player");
if (player) {
Physics.SetGravity(player, 0.2);
}
}
function OnTurnOff() {
local player = Object.Named("Player");
if (player) {
Physics.SetGravity(player, 1.0);
}
}
}
if you havent used squirrel scripts before, you need to:
* in dromed,
script_load squirrel* create a
sq_scripts subfolder in your fm folder
* create a text file in sq_scripts/ called something like
fmscripts.nut (the name can be anything you want, but it must end in .nut)
* copy paste the code above in to that file
for this particular script, create a plain TrapTrig and give it S>Scripts:
PlayerLowGravTrap. to test it out, create an on/off lever and CD link it to the trap.
vfig on 2/9/2021 at 00:00
Quote Posted by RippedPhreak
The button, when frobbed, clones the properties of the Garrett model over to the player. So yes indeed, I'm suddenly able to jump high and float down slowly. The only hitch is that this process teleports me to the location of the Garrett model when the cloning happens. So...the effort continues.
the problem is that physics properties bundle a whole lot of details all together. this makes them not very suitable for copying with S&R from one object to another. you can probably make it work, but it will be fiddly and fragile.
but using scripts allows individual fields in properties to be modified without affecting any other fields in the same property. there is a general purpose way to do this with any property (Property.Set), but since for gravity there is a specific function available to scripts (Physics.SetGravity), i am using that above.
RippedPhreak on 2/9/2021 at 00:09
That's simple and slick, thanks very much! :eek:
ZylonBane on 2/9/2021 at 04:11
Quote Posted by vfig
Code:
function OnTurnOn() {
local player = Object.Named("Player");
if (player) {
Physics.SetGravity(player, 0.2);
}
}
You don't have to do all that. Any script service that takes an object reference can accept it as either an ID number or as a name string (case-insensitive). And, most of the services fail silently if passed a null object reference (sensibly, considering how often objects suddenly disappear in a game engine). Though if the player doesn't exist, you've got bigger problems. Anyway, the above can just be:
Code:
function OnTurnOn() {
Physics.SetGravity("player", 0.2);
}
FireMage on 6/9/2021 at 10:24
Quote Posted by ZylonBane
You don't have to do all that. Any script service that takes an object reference can accept it as either an ID number or as a name string (case-insensitive). And, most of the services fail silently if passed a null object reference (sensibly, considering how often objects suddenly disappear in a game engine). Though if the player doesn't exist, you've got bigger problems. Anyway, the above can just be:
Code:
function OnTurnOn() {
Physics.SetGravity("player", 0.2);
}
Code:
function OnTurnOn() {
Physics.SetGravity(ObjID("player"), 0.2);
}
:)
Just typing the string name should be not a reflex as it doesn't work with all services requiring an ObjID
vfig on 6/9/2021 at 12:12
Quote Posted by FireMage
ObjID("player")
... how did i miss ObjID() all this time? :eek:
ZylonBane on 9/9/2021 at 02:49
Quote Posted by FireMage
Just typing the string name should be not a reflex as it doesn't work with all services requiring an ObjID
Cargo cult programming shouldn't be a reflex either. If it works without ObjID(), there's no reason to use it.
The Squirrel documentation is quite clear on which services accept what. Those that take "object" accept a name or an ID. Those that take "ObjID" only accept an ID.
Quote Posted by vfig
… how did i miss ObjID() all this time? :eek:
It's not a script service, it's a native function, documented in API-reference.txt.
Code:
// returns an ObjID based on an object name
ObjID ObjID(string sObjName);
// returns a link flavor based on a link flavor/type name
RelationID linkkind(string sLinkFlavorName);
// returns the destination of a link (for quick access without using an sLink object)
ObjID LinkDest(LinkID id);