From 1909d74d5fa8e6cea151bb5ff6b8e40b197b9f90 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 23 Apr 2008 22:44:59 +0000 Subject: * Patch from Melanie. Mantis 0001037: Add various internal plumbing to the example economy module, implements llSetPayPrice(), money() and llGiveMoney() in scripts. Thanks Melanie! * Moves module loading before the script engine so the script engine can pick up events from modules registering interfaces with scene. --- .../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 49 +++++++++++++++++++++- .../Common/ScriptEngineBase/EventManager.cs | 28 ++++++++++--- .../ScriptEngine/Common/ScriptServerInterfaces.cs | 2 +- 3 files changed, 71 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Common') diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 09cd4af..2d1b02d 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -36,6 +36,7 @@ using libsecondlife; using OpenSim.Framework; using OpenSim.Region.Environment; using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Modules; using OpenSim.Region.Environment.Modules.LandManagement; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase; @@ -1609,8 +1610,42 @@ namespace OpenSim.Region.ScriptEngine.Common public int llGiveMoney(string destination, int amount) { + LLUUID invItemID=InventorySelf(); + if(invItemID == LLUUID.Zero) + return 0; + m_host.AddScriptLPS(1); - NotImplemented("llGiveMoney"); + + if(m_host.TaskInventory[invItemID].PermsGranter == LLUUID.Zero) + return 0; + + if((m_host.TaskInventory[invItemID].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_DEBIT) == 0) + { + LSLError("No permissions to give money"); + return 0; + } + + LLUUID toID=new LLUUID(); + + if(!LLUUID.TryParse(destination, out toID)) + { + LSLError("Bad key in llGiveMoney"); + return 0; + } + + IMoneyModule money=World.RequestModuleInterface(); + + if(money == null) + { + NotImplemented("llGiveMoney"); + return 0; + } + + bool result=money.ObjectGiveMoney(m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount); + + if(result) + return 1; + return 0; } @@ -5101,7 +5136,17 @@ namespace OpenSim.Region.ScriptEngine.Common public void llSetPayPrice(int price, LSL_Types.list quick_pay_buttons) { m_host.AddScriptLPS(1); - NotImplemented("llSetPayPrice"); + + if(quick_pay_buttons.Data.Length != 4) + { + LSLError("List must have 4 elements"); + return; + } + m_host.ParentGroup.RootPart.PayPrice[0]=price; + m_host.ParentGroup.RootPart.PayPrice[1]=(int)quick_pay_buttons.Data[0]; + m_host.ParentGroup.RootPart.PayPrice[2]=(int)quick_pay_buttons.Data[1]; + m_host.ParentGroup.RootPart.PayPrice[3]=(int)quick_pay_buttons.Data[2]; + m_host.ParentGroup.RootPart.PayPrice[4]=(int)quick_pay_buttons.Data[3]; } public LSL_Types.Vector3 llGetCameraPos() diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs index b4789a9..c2e3209 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs @@ -28,6 +28,9 @@ using System; using libsecondlife; using OpenSim.Framework; +using OpenSim.Region.Environment; +using OpenSim.Region.Environment.Modules; +using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase { @@ -68,6 +71,12 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript; myScriptEngine.World.EventManager.OnScriptChangedEvent += changed; // TODO: HOOK ALL EVENTS UP TO SERVER! + IMoneyModule money=myScriptEngine.World.RequestModuleInterface(); + if(money != null) + { + money.OnObjectPaid+=HandleObjectPaid; + } + } } @@ -75,6 +84,15 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase { } + private void HandleObjectPaid(LLUUID objectID, LLUUID agentID, int amount) + { + SceneObjectPart part=myScriptEngine.World.GetSceneObjectPart(objectID); + if(part != null) + { + money(part.LocalId, agentID, amount); + } + } + public void changed(uint localID, uint change) { // Add to queue for all scripts in localID, Object pass change. @@ -112,6 +130,11 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase ); } + public void money(uint localID, LLUUID agentID, int amount) + { + myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "money", EventQueueManager.llDetectNull, new object[] { agentID.ToString(), (int)amount }); + } + // TODO: Replace placeholders below // NOTE! THE PARAMETERS FOR THESE FUNCTIONS ARE NOT CORRECT! // These needs to be hooked up to OpenSim during init of this class @@ -194,11 +217,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "control", EventQueueManager.llDetectNull); } - public void money(uint localID, LLUUID itemID) - { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "money", EventQueueManager.llDetectNull); - } - public void email(uint localID, LLUUID itemID) { myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "email", EventQueueManager.llDetectNull); diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs index 1119fe8..ea17e20 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs @@ -55,7 +55,7 @@ namespace OpenSim.Region.ScriptEngine.Common void sensor(uint localID, LLUUID itemID); void no_sensor(uint localID, LLUUID itemID); void control(uint localID, LLUUID itemID); - void money(uint localID, LLUUID itemID); + void money(uint LocalID, LLUUID agentID, int amount); void email(uint localID, LLUUID itemID); void at_target(uint localID, LLUUID itemID); void not_at_target(uint localID, LLUUID itemID); -- cgit v1.1