6670dcaf59354

6670dcaf599d4
1 Guest is here.
 

Topic: Broken Squirrel Script Service Read 760 times  

6670dcaf59fbeRoSoDude

6670dcaf5a02b
I came across a broken script service for NewDark's squirrel.osm. BOOL ShockGame.LoadCursor(object obj) doesn't seem to actually exist:

AN ERROR HAS OCCURED [the index 'LoadCursor' does not exist]

For an example, here's the DeadPowerCell script reimplemented in Squirrel. Frobbing a recharging station works, but dragging the dead power cell onto a recharger throws the above error and terminates the script, leaving the created power cell at 0,0,0. I'm also not sure if HRESULT ShockGame.DestroyCursorObj() does anything either, since the dead power cell just drops to the ground instead of being, you know, destroyed.

Code: [Select]
class rsdDeadPowerCell extends SqRootScript {
function OnRecharge() {
local containtype = Container.IsHeld("Player",self);
if (containtype != 2147483647) { //MAXINT
ShockGame.DestroyInvObj(self);
}
else {
ShockGame.DestroyCursorObj();
}
local powercell = Object.Create("Power Cell");
if (GetData("Tool") == 1) {
ShockGame.LoadCursor(powercell);
}
else {
ShockGame.AddInvObj(powercell);
}
if (message().data) {
PostMessage(message().from,"Consume");
}
}

function OnFrobToolEnd() {
local tooldest = message().DstObjId;
if (Object.InheritsFrom(tooldest,"Recharging Station")) {
PostMessage(self,"Recharge");
Sound.PlayEnvSchema(tooldest,"Event Activate",tooldest,0,eEnvSoundLoc.kEnvSoundAtObjLoc);
SetData("Tool",1);
}
}
}

6670dcaf5a240RoSoDude

6670dcaf5a28a
Great, that worked. What about ShockGame.DestroyCursorObj()? That index exists, but it doesn't seem to actually do anything. I ended up just using Object.Destroy(self) but that doesn't seem optimal.

6670dcaf5a321ZylonBane

6670dcaf5a36b
If you don't destroy the old cursor object, you'll probably end up with a memory leak.
1 Guest is here.
I can't remember how this all got started. But I can tell you exactly how it will end.
Contact SMF 2.0.19 | SMF © 2016, Simple Machines | Terms and Policies
FEEP
6670dcaf5d547