665acf6be0a6c

665acf6be1557
1 Guest is here.
 

Topic: Broken Squirrel Script Service Read 666 times  

665acf6be1bafRoSoDude

665acf6be1c24
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);
}
}
}

665acf6be1e8bRoSoDude

665acf6be1edc
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.

665acf6be1f8eZylonBane

665acf6be1fdf
If you don't destroy the old cursor object, you'll probably end up with a memory leak.
1 Guest is here.
A satisfied smile was evident on the girls face.
Contact SMF 2.0.19 | SMF © 2016, Simple Machines | Terms and Policies
FEEP
665acf6be2ef9