665bcb016e256

665bcb016edea
1 Guest is here.
 

Topic: Broken Squirrel Script Service Read 667 times  

665bcb016f3b4RoSoDude

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

665bcb016f675RoSoDude

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

665bcb016f756ZylonBane

665bcb016f7a5
If you don't destroy the old cursor object, you'll probably end up with a memory leak.
1 Guest is here.
The aircraft still resides at the museum in a dismantled state, where it carries the designations "10687" and "Aeroflot".
Contact SMF 2.0.19 | SMF © 2016, Simple Machines | Terms and Policies
FEEP
665bcb01727f9