6656d0468fe87

6656d0469045e
1 Guest is here.
 

Topic: Broken Squirrel Script Service Read 656 times  

6656d0469098aRoSoDude

6656d046909f4
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);
}
}
}

6656d04690bf0RoSoDude

6656d04690c49
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.

6656d04690cdfZylonBane

6656d04690d2e
If you don't destroy the old cursor object, you'll probably end up with a memory leak.
1 Guest is here.
If I were a rich man? ...Yubby dibby dibby dibby dibby dibby dibby dum~
Contact SMF 2.0.19 | SMF © 2016, Simple Machines | Terms and Policies
FEEP
6656d04690e00