6648f67679722

6648f67679d4d
1 Guest is here.
 

Topic: Broken Squirrel Script Service Read 593 times  

6648f6767a332RoSoDude

6648f6767a3ac
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);
}
}
}

6648f6767a752RoSoDude

6648f6767a7a2
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.

6648f6767a846ZylonBane

6648f6767a894
If you don't destroy the old cursor object, you'll probably end up with a memory leak.
1 Guest is here.
It's time to see it (Then you'll believe it)
Contact SMF 2.0.19 | SMF © 2016, Simple Machines | Terms and Policies
FEEP
6648f6767a98a