repo_name stringlengths 6 69 | path stringlengths 6 178 | copies stringclasses 278 values | size stringlengths 4 7 | content stringlengths 671 917k | license stringclasses 15 values |
|---|---|---|---|---|---|
kitala1/darkstar | scripts/zones/Port_Bastok/npcs/Yazan.lua | 19 | 2021 | -----------------------------------
-- Area: Port Bastok
-- NPC: Yazan
-- Starts Quests: Bite the Dust (100%)
-----------------------------------
package.loaded["scripts/zones/Port_Bastok/TextIDs"] = nil;
------------------------------------
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/quests");
require("scripts/zones/Port_Bastok/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
BiteDust = player:getQuestStatus(BASTOK,BITE_THE_DUST);
if(BiteDust ~= QUEST_AVAILABLE and trade:hasItemQty(1015,1) and trade:getItemCount() == 1) then
player:tradeComplete();
player:startEvent(0x00c1);
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
BiteDust = player:getQuestStatus(BASTOK,BITE_THE_DUST);
if(BiteDust == QUEST_AVAILABLE) then
player:startEvent(0x00bf);
elseif(BiteDust == QUEST_ACCEPTED) then
player:startEvent(0x00c0);
else
player:startEvent(0x00be);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID2: %u",csid);
--printf("RESULT2: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if(csid == 0x00bf) then
player:addQuest(BASTOK,BITE_THE_DUST);
elseif(csid == 0x00c1) then
if(player:getQuestStatus(BASTOK,BITE_THE_DUST) == QUEST_ACCEPTED) then
player:addTitle(SAND_BLASTER)
player:addFame(BASTOK,BAS_FAME*120);
player:completeQuest(BASTOK,BITE_THE_DUST);
else
player:addFame(BASTOK,BAS_FAME*80);
end
player:addGil(GIL_RATE*350);
player:messageSpecial(GIL_OBTAINED,GIL_RATE*350);
end
end; | gpl-3.0 |
kitala1/darkstar | scripts/globals/abilities/water_shot.lua | 22 | 2776 | -----------------------------------
-- Ability: Water Shot
-- Consumes a Water Card to enhance water-based debuffs. Deals water-based magic damage
-- Drown Effect: Enhanced DoT and STR-
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------
-- onAbilityCheck
-----------------------------------
function onAbilityCheck(player,target,ability)
--ranged weapon/ammo: You do not have an appropriate ranged weapon equipped.
--no card: <name> cannot perform that action.
if (player:getWeaponSkillType(SLOT_RANGED) ~= SKILL_MRK or player:getWeaponSkillType(SLOT_AMMO) ~= SKILL_MRK) then
return 216,0;
end
if (player:hasItem(2181, 0) or player:hasItem(2974, 0)) then
return 0,0;
else
return 71, 0;
end
end;
-----------------------------------
-- onUseAbility
-----------------------------------
function onUseAbility(player,target,ability)
local params = {};
params.includemab = true;
local dmg = 2 * player:getRangedDmg() + player:getAmmoDmg() + player:getMod(MOD_QUICK_DRAW_DMG);
dmg = addBonusesAbility(player, ELE_WATER, target, dmg, params);
dmg = dmg * applyResistanceAbility(player,target,ELE_WATER,SKILL_MRK, (player:getStat(MOD_AGI)/2) + player:getMerit(MERIT_QUICK_DRAW_ACCURACY));
dmg = adjustForTarget(target,dmg,ELE_WATER);
dmg = utils.stoneskin(target, dmg);
target:delHP(dmg);
target:updateEnmityFromDamage(player,dmg);
local effects = {};
local counter = 1;
local drown = target:getStatusEffect(EFFECT_DROWN);
if (drown ~= nil) then
effects[counter] = drown;
counter = counter + 1;
end
local threnody = target:getStatusEffect(EFFECT_THRENODY);
if (threnody ~= nil and threnody:getSubPower() == MOD_FIRERES) then
effects[counter] = threnody;
counter = counter + 1;
end
if counter > 1 then
local effect = effects[math.random(1, counter-1)];
local duration = effect:getDuration();
local startTime = effect:getStartTime();
local tick = effect:getTick();
local power = effect:getPower();
local subpower = effect:getSubPower();
local tier = effect:getTier();
local effectId = effect:getType();
local subId = effect:getSubType();
power = power * 1.2;
target:delStatusEffectSilent(effectId);
target:addStatusEffect(effectId, power, tick, duration, subId, subpower, tier);
local newEffect = target:getStatusEffect(effectId);
newEffect:setStartTime(startTime);
end
return dmg;
end; | gpl-3.0 |
kitala1/darkstar | scripts/zones/Kazham/npcs/Beyzen.lua | 38 | 1031 | -----------------------------------
-- Area: Kazham
-- NPC: Beyzen
-- Type: Event Scene Replayer
-- @zone: 250
-- @pos -53.976 -10.769 -74.771
--
-- Auto-Script: Requires Verification (Verified by Brawndo)
-----------------------------------
package.loaded["scripts/zones/Kazham/TextIDs"] = nil;
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x0116);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
yemahuang/OpenBird | Resources/Cocos2dConstants.lua | 22 | 17782 | cc = cc or {}
cc.SPRITE_INDEX_NOT_INITIALIZED = 0xffffffff
cc.TMX_ORIENTATION_HEX = 0x1
cc.TMX_ORIENTATION_ISO = 0x2
cc.TMX_ORIENTATION_ORTHO = 0x0
cc.Z_COMPRESSION_BZIP2 = 0x1
cc.Z_COMPRESSION_GZIP = 0x2
cc.Z_COMPRESSION_NONE = 0x3
cc.Z_COMPRESSION_ZLIB = 0x0
cc.BLEND_DST = 0x303
cc.BLEND_SRC = 0x1
cc.DIRECTOR_IOS_USE_BACKGROUND_THREAD = 0x0
cc.DIRECTOR_MAC_THREAD = 0x0
cc.DIRECTOR_STATS_INTERVAL = 0.1
cc.ENABLE_BOX2_D_INTEGRATION = 0x0
cc.ENABLE_DEPRECATED = 0x1
cc.ENABLE_GL_STATE_CACHE = 0x1
cc.ENABLE_PROFILERS = 0x0
cc.ENABLE_STACKABLE_ACTIONS = 0x1
cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0x0
cc.GL_ALL = 0x0
cc.LABELATLAS_DEBUG_DRAW = 0x0
cc.LABELBMFONT_DEBUG_DRAW = 0x0
cc.MAC_USE_DISPLAY_LINK_THREAD = 0x0
cc.MAC_USE_MAIN_THREAD = 0x2
cc.MAC_USE_OWN_THREAD = 0x1
cc.NODE_RENDER_SUBPIXEL = 0x1
cc.PVRMIPMAP_MAX = 0x10
cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 0x1
cc.SPRITE_DEBUG_DRAW = 0x0
cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0x0
cc.TEXTURE_ATLAS_USE_VAO = 0x1
cc.USE_L_A88_LABELS = 0x1
cc.ACTION_TAG_INVALID = -1
cc.DEVICE_MAC = 0x6
cc.DEVICE_MAC_RETINA_DISPLAY = 0x7
cc.DEVICEI_PAD = 0x4
cc.DEVICEI_PAD_RETINA_DISPLAY = 0x5
cc.DEVICEI_PHONE = 0x0
cc.DEVICEI_PHONE5 = 0x2
cc.DEVICEI_PHONE5_RETINA_DISPLAY = 0x3
cc.DEVICEI_PHONE_RETINA_DISPLAY = 0x1
cc.DIRECTOR_PROJECTION2_D = 0x0
cc.DIRECTOR_PROJECTION3_D = 0x1
cc.DIRECTOR_PROJECTION_CUSTOM = 0x2
cc.DIRECTOR_PROJECTION_DEFAULT = 0x1
cc.FILE_UTILS_SEARCH_DIRECTORY_MODE = 0x1
cc.FILE_UTILS_SEARCH_SUFFIX_MODE = 0x0
cc.FLIPED_ALL = 0xe0000000
cc.FLIPPED_MASK = 0x1fffffff
cc.IMAGE_FORMAT_JPEG = 0x0
cc.IMAGE_FORMAT_PNG = 0x1
cc.ITEM_SIZE = 0x20
cc.LABEL_AUTOMATIC_WIDTH = -1
cc.LINE_BREAK_MODE_CHARACTER_WRAP = 0x1
cc.LINE_BREAK_MODE_CLIP = 0x2
cc.LINE_BREAK_MODE_HEAD_TRUNCATION = 0x3
cc.LINE_BREAK_MODE_MIDDLE_TRUNCATION = 0x5
cc.LINE_BREAK_MODE_TAIL_TRUNCATION = 0x4
cc.LINE_BREAK_MODE_WORD_WRAP = 0x0
cc.MAC_VERSION_10_6 = 0xa060000
cc.MAC_VERSION_10_7 = 0xa070000
cc.MAC_VERSION_10_8 = 0xa080000
cc.MENU_HANDLER_PRIORITY = -128
cc.MENU_STATE_TRACKING_TOUCH = 0x1
cc.MENU_STATE_WAITING = 0x0
cc.NODE_TAG_INVALID = -1
cc.PARTICLE_DURATION_INFINITY = -1
cc.PARTICLE_MODE_GRAVITY = 0x0
cc.PARTICLE_MODE_RADIUS = 0x1
cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS = -1
cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE = -1
cc.POSITION_TYPE_FREE = 0x0
cc.POSITION_TYPE_GROUPED = 0x2
cc.POSITION_TYPE_RELATIVE = 0x1
cc.PRIORITY_NON_SYSTEM_MIN = -2147483647
cc.PRIORITY_SYSTEM = -2147483648
cc.PROGRESS_TIMER_TYPE_BAR = 0x1
cc.PROGRESS_TIMER_TYPE_RADIAL = 0x0
cc.REPEAT_FOREVER = 0xfffffffe
cc.RESOLUTION_MAC = 0x1
cc.RESOLUTION_MAC_RETINA_DISPLAY = 0x2
cc.RESOLUTION_UNKNOWN = 0x0
cc.TMX_TILE_DIAGONAL_FLAG = 0x20000000
cc.TMX_TILE_HORIZONTAL_FLAG = 0x80000000
cc.TMX_TILE_VERTICAL_FLAG = 0x40000000
cc.TEXT_ALIGNMENT_CENTER = 0x1
cc.TEXT_ALIGNMENT_LEFT = 0x0
cc.TEXT_ALIGNMENT_RIGHT = 0x2
cc.TEXTURE2_D_PIXEL_FORMAT_AUTO = 0x0
cc.TEXTURE2_D_PIXEL_FORMAT_BGR_A8888 = 0x1
cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 = 0x2
cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888 = 0x3
cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565 = 0x4
cc.TEXTURE2_D_PIXEL_FORMAT_A8 = 0x5
cc.TEXTURE2_D_PIXEL_FORMAT_I8 = 0x6
cc.TEXTURE2_D_PIXEL_FORMAT_A_I88 = 0x7
cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 = 0x8
cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 = 0x9
cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4 = 0xa
cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4A = 0xb
cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2 = 0xc
cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2A = 0xd
cc.TEXTURE2_D_PIXEL_FORMAT_ETC = 0xe
cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT1 = 0xf
cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT3 = 0x10
cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT5 = 0x11
cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT = 0x0
cc.TOUCHES_ALL_AT_ONCE = 0x0
cc.TOUCHES_ONE_BY_ONE = 0x1
cc.TRANSITION_ORIENTATION_DOWN_OVER = 0x1
cc.TRANSITION_ORIENTATION_LEFT_OVER = 0x0
cc.TRANSITION_ORIENTATION_RIGHT_OVER = 0x1
cc.TRANSITION_ORIENTATION_UP_OVER = 0x0
cc.UNIFORM_COS_TIME = 0x5
cc.UNIFORM_MV_MATRIX = 0x1
cc.UNIFORM_MVP_MATRIX = 0x2
cc.UNIFORM_P_MATRIX = 0x0
cc.UNIFORM_RANDOM01 = 0x6
cc.UNIFORM_SAMPLER = 0x7
cc.UNIFORM_SIN_TIME = 0x4
cc.UNIFORM_TIME = 0x3
cc.UNIFORM_MAX = 0x8
cc.VERTEX_ATTRIB_FLAG_COLOR = 0x2
cc.VERTEX_ATTRIB_FLAG_NONE = 0x0
cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = 0x7
cc.VERTEX_ATTRIB_FLAG_POSITION = 0x1
cc.VERTEX_ATTRIB_FLAG_TEX_COORDS = 0x4
cc.VERTEX_ATTRIB_COLOR = 0x1
cc.VERTEX_ATTRIB_MAX = 0x3
cc.VERTEX_ATTRIB_POSITION = 0x0
cc.VERTEX_ATTRIB_TEX_COORDS = 0x2
cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 0x2
cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 0x1
cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0x0
cc.OS_VERSION_4_0 = 0x4000000
cc.OS_VERSION_4_0_1 = 0x4000100
cc.OS_VERSION_4_1 = 0x4010000
cc.OS_VERSION_4_2 = 0x4020000
cc.OS_VERSION_4_2_1 = 0x4020100
cc.OS_VERSION_4_3 = 0x4030000
cc.OS_VERSION_4_3_1 = 0x4030100
cc.OS_VERSION_4_3_2 = 0x4030200
cc.OS_VERSION_4_3_3 = 0x4030300
cc.OS_VERSION_4_3_4 = 0x4030400
cc.OS_VERSION_4_3_5 = 0x4030500
cc.OS_VERSION_5_0 = 0x5000000
cc.OS_VERSION_5_0_1 = 0x5000100
cc.OS_VERSION_5_1_0 = 0x5010000
cc.OS_VERSION_6_0_0 = 0x6000000
cc.ANIMATION_FRAME_DISPLAYED_NOTIFICATION = 'CCAnimationFrameDisplayedNotification'
cc.CHIPMUNK_IMPORT = 'chipmunk.h'
cc.ATTRIBUTE_NAME_COLOR = 'a_color'
cc.ATTRIBUTE_NAME_POSITION = 'a_position'
cc.ATTRIBUTE_NAME_TEX_COORD = 'a_texCoord'
cc.SHADER_POSITION_COLOR = 'ShaderPositionColor'
cc.SHADER_POSITION_LENGTH_TEXURE_COLOR = 'ShaderPositionLengthTextureColor'
cc.SHADER_POSITION_TEXTURE = 'ShaderPositionTexture'
cc.SHADER_POSITION_TEXTURE_A8_COLOR = 'ShaderPositionTextureA8Color'
cc.SHADER_POSITION_TEXTURE_COLOR = 'ShaderPositionTextureColor'
cc.SHADER_POSITION_TEXTURE_COLOR_ALPHA_TEST = 'ShaderPositionTextureColorAlphaTest'
cc.SHADER_POSITION_TEXTURE_U_COLOR = 'ShaderPositionTexture_uColor'
cc.SHADER_POSITION_U_COLOR = 'ShaderPosition_uColor'
cc.UNIFORM_ALPHA_TEST_VALUE_S = 'CC_AlphaValue'
cc.UNIFORM_COS_TIME_S = 'CC_CosTime'
cc.UNIFORM_MV_MATRIX_S = 'CC_MVMatrix'
cc.UNIFORM_MVP_MATRIX_S = 'CC_MVPMatrix'
cc.UNIFORM_P_MATRIX_S = 'CC_PMatrix'
cc.UNIFORM_RANDOM01_S = 'CC_Random01'
cc.UNIFORM_SAMPLER_S = 'CC_Texture0'
cc.UNIFORM_SIN_TIME_S = 'CC_SinTime'
cc.UNIFORM_TIME_S = 'CC_Time'
cc.PLATFORM_OS_WINDOWS = 0
cc.PLATFORM_OS_LINUX = 1
cc.PLATFORM_OS_MAC = 2
cc.PLATFORM_OS_ANDROID = 3
cc.PLATFORM_OS_IPHONE = 4
cc.PLATFORM_OS_IPAD = 5
cc.PLATFORM_OS_BLACKBERRY = 6
cc.PLATFORM_OS_NACL = 7
cc.PLATFORM_OS_EMSCRIPTEN = 8
cc.PLATFORM_OS_TIZEN = 9
cc.SCROLLVIEW_SCRIPT_SCROLL = 0
cc.SCROLLVIEW_SCRIPT_ZOOM = 1
cc.TABLECELL_TOUCHED = 2
cc.TABLECELL_HIGH_LIGHT = 3
cc.TABLECELL_UNHIGH_LIGHT = 4
cc.TABLECELL_WILL_RECYCLE = 5
cc.TABLECELL_SIZE_FOR_INDEX = 6
cc.TABLECELL_SIZE_AT_INDEX = 7
cc.NUMBER_OF_CELLS_IN_TABLEVIEW = 8
cc.SCROLLVIEW_DIRECTION_NONE = -1
cc.SCROLLVIEW_DIRECTION_HORIZONTAL = 0
cc.SCROLLVIEW_DIRECTION_VERTICAL = 1
cc.SCROLLVIEW_DIRECTION_BOTH = 2
cc.CONTROL_EVENTTYPE_TOUCH_DOWN = 1
cc.CONTROL_EVENTTYPE_DRAG_INSIDE = 2
cc.CONTROL_EVENTTYPE_DRAG_OUTSIDE = 4
cc.CONTROL_EVENTTYPE_DRAG_ENTER = 8
cc.CONTROL_EVENTTYPE_DRAG_EXIT = 16
cc.CONTROL_EVENTTYPE_TOUCH_UP_INSIDE = 32
cc.CONTROL_EVENTTYPE_TOUCH_UP_OUTSIDE = 64
cc.CONTROL_EVENTTYPE_TOUCH_CANCEL = 128
cc.CONTROL_EVENTTYPE_VALUE_CHANGED = 256
cc.CONTROL_STATE_NORMAL = 1
cc.CONTROL_STATE_HIGH_LIGHTED = 2
cc.CONTROL_STATE_DISABLED = 4
cc.CONTROL_STATE_SELECTED = 8
cc.KEYBOARD_RETURNTYPE_DEFAULT = 0
cc.KEYBOARD_RETURNTYPE_DONE = 1
cc.KEYBOARD_RETURNTYPE_SEND = 2
cc.KEYBOARD_RETURNTYPE_SEARCH = 3
cc.KEYBOARD_RETURNTYPE_GO = 4
cc.EDITBOX_INPUT_MODE_ANY = 0
cc.EDITBOX_INPUT_MODE_EMAILADDR = 1
cc.EDITBOX_INPUT_MODE_NUMERIC = 2
cc.EDITBOX_INPUT_MODE_PHONENUMBER = 3
cc.EDITBOX_INPUT_MODE_URL = 4
cc.EDITBOX_INPUT_MODE_DECIMAL = 5
cc.EDITBOX_INPUT_MODE_SINGLELINE = 6
cc.EDITBOX_INPUT_FLAG_PASSWORD = 0
cc.EDITBOX_INPUT_FLAG_SENSITIVE = 1
cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_WORD = 2
cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_SENTENCE = 3
cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_ALL_CHARACTERS = 4
cc.LANGUAGE_ENGLISH = 0
cc.LANGUAGE_CHINESE = 1
cc.LANGUAGE_FRENCH = 2
cc.LANGUAGE_ITALIAN = 3
cc.LANGUAGE_GERMAN = 4
cc.LANGUAGE_SPANISH = 5
cc.LANGUAGE_RUSSIAN = 6
cc.LANGUAGE_KOREAN = 7
cc.LANGUAGE_JAPANESE = 8
cc.LANGUAGE_HUNGARIAN = 9
cc.LANGUAGE_PORTUGUESE = 10
cc.LANGUAGE_ARABIC = 11
cc.NODE_ON_ENTER = 0
cc.NODE_ON_EXIT = 1
cc.NODE_ON_ENTER_TRANSITION_DID_FINISH = 2
cc.NODE_ON_EXIT_TRANSITION_DID_START = 3
cc.NODE_ON_CLEAN_UP = 4
cc.CONTROL_STEPPER_PART_MINUS = 0
cc.CONTROL_STEPPER_PART_PLUS = 1
cc.CONTROL_STEPPER_PART_NONE = 2
cc.TABLEVIEW_FILL_TOPDOWN = 0
cc.TABLEVIEW_FILL_BOTTOMUP = 1
cc.WEBSOCKET_OPEN = 0
cc.WEBSOCKET_MESSAGE = 1
cc.WEBSOCKET_CLOSE = 2
cc.WEBSOCKET_ERROR = 3
cc.WEBSOCKET_STATE_CONNECTING = 0
cc.WEBSOCKET_STATE_OPEN = 1
cc.WEBSOCKET_STATE_CLOSING = 2
cc.WEBSOCKET_STATE_CLOSED = 3
cc.XMLHTTPREQUEST_RESPONSE_STRING = 0
cc.XMLHTTPREQUEST_RESPONSE_ARRAY_BUFFER = 1
cc.XMLHTTPREQUEST_RESPONSE_BLOB = 2
cc.XMLHTTPREQUEST_RESPONSE_DOCUMENT = 3
cc.XMLHTTPREQUEST_RESPONSE_JSON = 4
cc.ASSETSMANAGER_CREATE_FILE = 0
cc.ASSETSMANAGER_NETWORK = 1
cc.ASSETSMANAGER_NO_NEW_VERSION = 2
cc.ASSETSMANAGER_UNCOMPRESS = 3
cc.ASSETSMANAGER_PROTOCOL_PROGRESS = 0
cc.ASSETSMANAGER_PROTOCOL_SUCCESS = 1
cc.ASSETSMANAGER_PROTOCOL_ERROR = 2
cc.Handler = cc.Handler or {}
cc.Handler.NODE = 0
cc.Handler.MENU_CLICKED = 1
cc.Handler.CALLFUNC = 2
cc.Handler.SCHEDULE = 3
cc.Handler.TOUCHES = 4
cc.Handler.KEYPAD = 5
cc.Handler.ACCELEROMETER = 6
cc.Handler.CONTROL_TOUCH_DOWN = 7
cc.Handler.CONTROL_TOUCH_DRAG_INSIDE = 8
cc.Handler.CONTROL_TOUCH_DRAG_OUTSIDE = 9
cc.Handler.CONTROL_TOUCH_DRAG_ENTER = 10
cc.Handler.CONTROL_TOUCH_DRAG_EXIT = 11
cc.Handler.CONTROL_TOUCH_UP_INSIDE = 12
cc.Handler.CONTROL_TOUCH_UP_OUTSIDE = 13
cc.Handler.CONTROL_TOUCH_UP_CANCEL = 14
cc.Handler.CONTROL_VALUE_CHANGED = 15
cc.Handler.WEBSOCKET_OPEN = 16
cc.Handler.WEBSOCKET_MESSAGE = 17
cc.Handler.WEBSOCKET_CLOSE = 18
cc.Handler.WEBSOCKET_ERROR = 19
cc.Handler.GL_NODE_DRAW = 20
cc.Handler.SCROLLVIEW_SCROLL = 21
cc.Handler.SCROLLVIEW_ZOOM = 22
cc.Handler.TABLECELL_TOUCHED = 23
cc.Handler.TABLECELL_HIGHLIGHT = 24
cc.Handler.TABLECELL_UNHIGHLIGHT = 25
cc.Handler.TABLECELL_WILL_RECYCLE = 26
cc.Handler.TABLECELL_SIZE_FOR_INDEX = 27
cc.Handler.TABLECELL_AT_INDEX = 28
cc.Handler.TABLEVIEW_NUMS_OF_CELLS = 29
cc.Handler.HTTPREQUEST_STATE_CHANGE = 30
cc.Handler.ASSETSMANAGER_PROGRESS = 31
cc.Handler.ASSETSMANAGER_SUCCESS = 32
cc.Handler.ASSETSMANAGER_ERROR = 33
cc.Handler.STUDIO_EVENT_LISTENER = 34
cc.Handler.ARMATURE_EVENT = 35
cc.Handler.EVENT_ACC = 36
cc.Handler.EVENT_CUSTIOM = 37
cc.Handler.EVENT_KEYBOARD_PRESSED = 38
cc.Handler.EVENT_KEYBOARD_RELEASED = 39
cc.Handler.EVENT_TOUCH_BEGAN = 40
cc.Handler.EVENT_TOUCH_MOVED = 41
cc.Handler.EVENT_TOUCH_ENDED = 42
cc.Handler.EVENT_TOUCH_CANCELLED = 43
cc.Handler.EVENT_TOUCHES_BEGAN = 44
cc.Handler.EVENT_TOUCHES_MOVED = 45
cc.Handler.EVENT_TOUCHES_ENDED = 46
cc.Handler.EVENT_TOUCHES_CANCELLED = 47
cc.Handler.EVENT_MOUSE_DOWN = 48
cc.Handler.EVENT_MOUSE_UP = 49
cc.Handler.EVENT_MOUSE_MOVE = 50
cc.Handler.EVENT_MOUSE_SCROLL = 51
cc.Handler.EVENT_SPINE = 52
cc.Handler.EVENT_PHYSICS_CONTACT_BEGIN = 53
cc.Handler.EVENT_PHYSICS_CONTACT_PRESOLVE = 54
cc.Handler.EVENT_PHYSICS_CONTACT_POSTSOLVE = 55
cc.Handler.EVENT_PHYSICS_CONTACT_SEPERATE = 56
cc.EVENT_UNKNOWN = 0
cc.EVENT_TOUCH_ONE_BY_ONE = 1
cc.EVENT_TOUCH_ALL_AT_ONCE = 2
cc.EVENT_KEYBOARD = 3
cc.EVENT_MOUSE = 4
cc.EVENT_ACCELERATION = 5
cc.EVENT_CUSTOM = 6
cc.PHYSICSSHAPE_MATERIAL_DEFAULT = {density = 0.0, restitution = 0.5, friction = 0.5}
cc.PHYSICSBODY_MATERIAL_DEFAULT = {density = 0.1, restitution = 0.5, friction = 0.5}
cc.GLYPHCOLLECTION_DYNAMIC = 0
cc.GLYPHCOLLECTION_NEHE = 1
cc.GLYPHCOLLECTION_ASCII = 2
cc.GLYPHCOLLECTION_CUSTOM = 3
cc.LabelEffect =
{
NORMAL = 0,
OUTLINE = 1,
SHADOW = 2,
GLOW = 3,
}
cc.KeyCode =
{
KEY_NONE = 0,
KEY_PAUSE = 0x0013,
KEY_SCROLL_LOCK = 0x1014,
KEY_PRINT = 0x1061,
KEY_SYSREQ = 0x106A,
KEY_BREAK = 0x106B,
KEY_ESCAPE = 0x001B,
KEY_BACKSPACE = 0x0008,
KEY_TAB = 0x0009,
KEY_BACK_TAB = 0x0089,
KEY_RETURN = 0x000D,
KEY_CAPS_LOCK = 0x00E5,
KEY_SHIFT = 0x00E1,
KEY_CTRL = 0x00E3,
KEY_ALT = 0x00E9,
KEY_MENU = 0x1067,
KEY_HYPER = 0x10ED,
KEY_INSERT = 0x1063,
KEY_HOME = 0x1050,
KEY_PG_UP = 0x1055,
KEY_DELETE = 0x10FF,
KEY_END = 0x1057,
KEY_PG_DOWN = 0x1056,
KEY_LEFT_ARROW = 0x1051,
KEY_RIGHT_ARROW = 0x1053,
KEY_UP_ARROW = 0x1052,
KEY_DOWN_ARROW = 0x1054,
KEY_NUM_LOCK = 0x107F,
KEY_KP_PLUS = 0x10AB,
KEY_KP_MINUS = 0x10AD,
KEY_KP_MULTIPLY = 0x10AA,
KEY_KP_DIVIDE = 0x10AF,
KEY_KP_ENTER = 0x108D,
KEY_KP_HOME = 0x10B7,
KEY_KP_UP = 0x10B8,
KEY_KP_PG_UP = 0x10B9,
KEY_KP_LEFT = 0x10B4,
KEY_KP_FIVE = 0x10B5,
KEY_KP_RIGHT = 0x10B6,
KEY_KP_END = 0x10B1,
KEY_KP_DOWN = 0x10B2,
KEY_KP_PG_DOWN = 0x10B3,
KEY_KP_INSERT = 0x10B0,
KEY_KP_DELETE = 0x10AE,
KEY_F1 = 0x00BE,
KEY_F2 = 0x00BF,
KEY_F3 = 0x00C0,
KEY_F4 = 0x00C1,
KEY_F5 = 0x00C2,
KEY_F6 = 0x00C3,
KEY_F7 = 0x00C4,
KEY_F8 = 0x00C5,
KEY_F9 = 0x00C6,
KEY_F10 = 0x00C7,
KEY_F11 = 0x00C8,
KEY_F12 = 0x00C9,
KEY_SPACE = ' ',
KEY_EXCLAM = '!',
KEY_QUOTE = '"',
KEY_NUMBER = '#',
KEY_DOLLAR = '$',
KEY_PERCENT = '%',
KEY_CIRCUMFLEX = '^',
KEY_AMPERSAND = '&',
KEY_APOSTROPHE = '\'',
KEY_LEFT_PARENTHESIS = '(',
KEY_RIGHT_PARENTHESIS = ')',
KEY_ASTERISK = '*',
KEY_PLUS = '+',
KEY_COMMA = ',',
KEY_MINUS = '-',
KEY_PERIOD = '.',
KEY_SLASH = '/',
KEY_0 = '0',
KEY_1 = '1',
KEY_2 = '2',
KEY_3 = '3',
KEY_4 = '4',
KEY_5 = '5',
KEY_6 = '6',
KEY_7 = '7',
KEY_8 = '8',
KEY_9 = '9',
KEY_COLON = ':',
KEY_SEMICOLON = ';',
KEY_LESS_THAN = '<',
KEY_EQUAL = '=',
KEY_GREATER_THAN = '>',
KEY_QUESTION = '?',
KEY_AT = '@',
KEY_CAPITAL_A = 'A',
KEY_CAPITAL_B = 'B',
KEY_CAPITAL_C = 'C',
KEY_CAPITAL_D = 'D',
KEY_CAPITAL_E = 'E',
KEY_CAPITAL_F = 'F',
KEY_CAPITAL_G = 'G',
KEY_CAPITAL_H = 'H',
KEY_CAPITAL_I = 'I',
KEY_CAPITAL_J = 'J',
KEY_CAPITAL_K = 'K',
KEY_CAPITAL_L = 'L',
KEY_CAPITAL_M = 'M',
KEY_CAPITAL_N = 'N',
KEY_CAPITAL_O = 'O',
KEY_CAPITAL_P = 'P',
KEY_CAPITAL_Q = 'Q',
KEY_CAPITAL_R = 'R',
KEY_CAPITAL_S = 'S',
KEY_CAPITAL_T = 'T',
KEY_CAPITAL_U = 'U',
KEY_CAPITAL_V = 'V',
KEY_CAPITAL_W = 'W',
KEY_CAPITAL_X = 'X',
KEY_CAPITAL_Y = 'Y',
KEY_CAPITAL_Z = 'Z',
KEY_LEFT_BRACKET = '[',
KEY_BACK_SLASH = '\\',
KEY_RIGHT_BRACKET = ']',
KEY_UNDERSCORE = '_',
KEY_GRAVE = '`',
KEY_A = 'a',
KEY_B = 'b',
KEY_C = 'c',
KEY_D = 'd',
KEY_E = 'e',
KEY_F = 'f',
KEY_G = 'g',
KEY_H = 'h',
KEY_I = 'i',
KEY_J = 'j',
KEY_K = 'k',
KEY_L = 'l',
KEY_M = 'm',
KEY_N = 'n',
KEY_O = 'o',
KEY_P = 'p',
KEY_Q = 'q',
KEY_R = 'r',
KEY_S = 's',
KEY_T = 't',
KEY_U = 'u',
KEY_V = 'v',
KEY_W = 'w',
KEY_X = 'x',
KEY_Y = 'y',
KEY_Z = 'z',
KEY_LEFT_BRACE = '{',
KEY_BAR = '|',
KEY_RIGHT_BRACE = '}',
KEY_TILDE = '~',
KEY_EURO = 0x20AC,
KEY_POUND = 0x00A3,
KEY_YEN = 0x00A5,
KEY_MIDDLE_DOT = 0x0095,
KEY_SEARCH = 0xFFAA,
};
| mit |
Roblox/Core-Scripts | CoreScriptsRoot/Modules/Server/ClientChat/DefaultClientChatModules/CommandModules/SwitchChannel.lua | 2 | 1640 | -- // FileName: ClearMessages.lua
-- // Written by: TheGamer101
-- // Description: Command to switch channel.
local util = require(script.Parent:WaitForChild("Util"))
local ChatLocalization = nil
pcall(function() ChatLocalization = require(game:GetService("Chat").ClientChatModules.ChatLocalization) end)
if ChatLocalization == nil then ChatLocalization = { Get = function(key,default) return default end } end
function ProcessMessage(message, ChatWindow, ChatSettings)
if string.sub(message, 1, 3):lower() ~= "/c " then
return false
end
local channelName = string.sub(message, 4)
local targetChannel = ChatWindow:GetChannel(channelName)
if targetChannel then
ChatWindow:SwitchCurrentChannel(channelName)
if not ChatSettings.ShowChannelsBar then
local currentChannel = ChatWindow:GetCurrentChannel()
if currentChannel then
util:SendSystemMessageToSelf(
string.gsub(ChatLocalization:Get(
"GameChat_SwitchChannel_NowInChannel",
string.format("You are now chatting in channel: '%s'", channelName)
),"{RBX_NAME}",channelName),
targetChannel, {}
)
end
end
else
local currentChannel = ChatWindow:GetCurrentChannel()
if currentChannel then
util:SendSystemMessageToSelf(
string.gsub(ChatLocalization:Get(
"GameChat_SwitchChannel_NotInChannel",
string.format("You are not in channel: '%s'", channelName)
),"{RBX_NAME}",channelName),
currentChannel, {ChatColor = Color3.fromRGB(245, 50, 50)}
)
end
end
return true
end
return {
[util.KEY_COMMAND_PROCESSOR_TYPE] = util.COMPLETED_MESSAGE_PROCESSOR,
[util.KEY_PROCESSOR_FUNCTION] = ProcessMessage
}
| apache-2.0 |
kitala1/darkstar | scripts/globals/dynamis.lua | 12 | 50207 | require("scripts/globals/status");
require("scripts/globals/keyitems");
-----------------------------------
-- Dynamis-Bastok
-----------------------------------
-- 1: BST Vanguard Beasttender + Vanguard's Scorpion
-- 2: WHM Vanguard Constable
-- 3: PLD Vanguard Defender
-- 4: DRG Vanguard Drakekeeper + Vanguard's Wyvern
-- 5: SAM Vanguard Hatamoto
-- 6: NIN Vanguard Kusa
-- 7: RNG Vanguard Mason
-- 8: MNK Vanguard Militant
-- 9: BRD Vanguard Minstrel
-- 10: RDM Vanguard Protector
-- 11: THF Vanguard Purloiner
-- 12: BLM Vanguard Thaumaturge
-- 13: SMN Vanguard Undertaker + Vanguard's Avatar
-- 14: DRK Vanguard Vigilante
-- 15: WAR Vanguard Vindicator
-- [Position on the map] Adamantking mobid, {spawnlist: mob1, mob2,...}
bastyList = {--[[001]] 17539350,{6,12}, --[[002]] 17539351,{5,9}, --[[003]] 17539352,{10,15}, --[[004]] 17539353,{11,15}, --[[005]] 17539354,{4,9},
--[[006]] 17539355,{1,1}, --[[007]] 17539356,{1,1}, --[[008]] 17539357,{1,1}, --[[009]] 17539358,{5,9}, --[[010]] 17539359,{5,9},
--[[011]] 17539360,{6,12,15}, --[[012]] 17539361,{4,5,9}, --[[013]] 17539362,{2,6}, --[[014]] 17539363,{12,14}, --[[016]] 17539364,{10},
--[[018]] 17539367,{11}, --[[020]] 17539369,{14,6,12}, --[[021]] 17539370,{4,10}, --[[022]] 17539371,{12,5}, --[[023]] 17539372,{14,9},
--[[024]] 17539373,{7,8}, --[[025]] 17539374,{2,15,17539118},--[[027]] 17539375,{10,11}, --[[028]] 17539376,{6,3,5,15,12,9,17539119,17539120,17539161},
--[[032]] 17539377,{6,14,2}, --[[033]] 17539378,{11,15}, --[[034]] 17539379,{2,5}, --[[035]] 17539380,{3,8,9}, --[[036]] 17539381,{3,8,10},
--[[037]] 17539382,{3,6,10}, --[[039]] 17539383,{1,1,1}, --[[040]] 17539384,{13}, --[[042]] 17539387,{1,1,1}, --[[043]] 17539388,{5,12},
--[[044]] 17539389,{11,15,14}, --[[045]] 17539390,{15,8,10}, --[[046]] 17539391,{15,5,10}, --[[047]] 17539392,{14,8,10}, --[[048]] 17539393,{3,11,10},
--[[049]] 17539394,{6}, --[[050]] 17539395,{15,9}, --[[051]] 17539396,{4,6,10}, --[[052]] 17539397,{14,5,9}, --[[053]] 17539398,{2,17539162,17539188},
--[[055]] 17539399,{2,17539143},--[[056]] 17539400,{13}, --[[057]] 17539401,{13}, --[[058]] 17539402,{15,8,2}, --[[059]] 17539403,{15,11},
--[[060]] 17539404,{14,8,2}, --[[061]] 17539405,{3,8,2}, --[[062]] 17539406,{2}, --[[063]] 17539407,{14,8,2}, --[[064]] 17539408,{3,14,1},
--[[065]] 17539409,{14,8,9}, --[[066]] 17539410,{15,11,10}, --[[068]] 17539412,{3,5,12}, --[[069]] 17539413,{2,17539190},--[[070]] 17539414,{7,7},
--[[071]] 17539415,{7}, --[[072]] 17539416,{4,11}, --[[073]] 17539417,{14,5}, --[[075]] 17539419,{3,6}, --[[076]] 17539420,{15,9},
--[[077]] 17539421,{4,12}, --[[078]] 17539422,{3,8,12}, --[[079]] 17539423,{14,8,12}, --[[082]] 17539426,{6}, --[[083]] 17539427,{3,6},
--[[086]] 17539430,{15,6}, --[[087]] 17539431,{14,5,9}, --[[088]] 17539432,{8,8,14,17539163,12,7,7},--[[089]] 17539163,{17539300,17539301,17539304}, --[[090]] 17539433,{3,2},
--[[091]] 17539434,{2,17539147},--[[093]] 17539435,{4,11,2}, --[[095]] 17539437,{3,11}, --[[096]] 17539438,{6,10}, --[[097]] 17539439,{11,12},
--[[098]] 17539440,{6,9}, --[[099]] 17539441,{14,9}, --[[100]] 17539442,{3,10}, --[[101]] 17539443,{4,5}, --[[102]] 17539444,{11},
--[[105]] 17539447,{5,10}, --[[106]] 17539448,{6,12}, --[[107]] 17539449,{4,8}, --[[108]] 17539450,{4,10}, --[[109]] 17539451,{3,12}
};
----[[011]] 00000000,{},--[[012]] 00000000,{},--[[013]] 00000000,{},--[[014]] 00000000,{},--[[015]] 00000000,{},
-- Need to add :
-- 39/42 random nm spawn with 3 BST
-----------------------------------
-- Dynamis-San d'Oria
-----------------------------------
-- 1: WAR Vanguard Footsoldier
-- 2: MNK Vanguard Grappler
-- 3: WHM Vanguard Amputator
-- 4: BLM Vanguard Mesmerizer
-- 5: RDM Vanguard Vexer
-- 6: THF Vanguard Pillager
-- 7: PLD Vanguard Trooper
-- 8: DRK Vanguard Neckchopper
-- 9: BST Vanguard Hawker + Vanguard's Hecteyes
-- 10: BRD Vanguard Bugler
-- 11: RNG Vanguard Predator
-- 12: SAM Vanguard Gutslasher
-- 13: NIN Vanguard Backstabber
-- 14: DRG Vanguard Impaler + Vanguard's Wyvern
-- 15: SMN Vanguard Dollmaster + Vanguard's Avatar
-- [Position on the map] Adamantking mobid, {spawnlist: mob1, mob2,...}
sandyList = {--[[001]] 17535250,{1,1}, --[[002]] 17535251,{2}, --[[003]] 17535252,{2}, --[[004]] 17535253,{5},
--[[005]] 17535254,{5}, --[[006]] 17535255,{2,2,2}, --[[008]] 17535257,{7,8}, --[[009]] 17535258,{1,1},
--[[010]] 17535259,{5,5}, --[[011]] 17535260,{14,14}, --[[012]] 17535261,{3,3}, --[[013]] 17535262,{6,6},
--[[014]] 17535263,{13,13}, --[[015]] 17535264,{12,12}, --[[017]] 17535266,{2,4,4}, --[[018]] 17535267,{17535026},
--[[019]] 17535026,{9,4,4}, --[[020]] 17535268,{17535057}, --[[021]] 17535057,{7,11,11}, --[[022]] 17535269,{6},
--[[023]] 17535270,{3,4}, --[[024]] 17535271,{6}, --[[025]] 17535272,{6,10}, --[[026]] 17535273,{6,10},
--[[027]] 17535274,{6,10}, --[[029]] 17535276,{11,11}, --[[030]] 17535277,{3,3}, --[[032]] 17535279,{8,8,17535032},
--[[036]] 17535003,{6,6,10}, --[[037]] 17535283,{12,12}, --[[038]] 17535284,{9,9}, --[[039]] 17535285,{11,11},
--[[040]] 17535286,{13,13}, --[[041]] 17535287,{15,15}, --[[042]] 17535288,{15,15}, --[[043]] 17535289,{15,15},
--[[044]] 17535290,{15,15}, --[[045]] 17535291,{11,11}, --[[046]] 17535292,{13,13}, --[[047]] 17535293,{9,9},
--[[048]] 17535294,{12,12}, --[[049]] 17535295,{2,1}, --[[050]] 17535296,{3}, --[[051]] 17535297,{7,1,1},
--[[052]] 17535298,{11,11}, --[[053]] 17535299,{2,1}, --[[054]] 17535300,{3}, --[[055]] 17535301,{3},
--[[056]] 17535302,{6,6}, --[[057]] 17535303,{3}, --[[058]] 17535304,{7,7}, --[[061]] 17535004,{2,2,10},
--[[063]] 17535308,{8,8}, --[[064]] 17535309,{14,14}, --[[065]] 17535310,{9,9}, --[[069]] 17535314,{5,5},
--[[070]] 17535315,{2,2,17535006}, --[[071]] 17535316,{4,4}, --[[073]] 17535318,{12,12}, --[[074]] 17535319,{12,13},
--[[075]] 17535320,{13,13}, --[[076]] 17535321,{3,3,11,11,11}, --[[077]] 17535322,{8,8}, --[[078]] 17535323,{4,4},
--[[079]] 17535324,{3,3}, --[[080]] 17535325,{5,5}, --[[081]] 17535326,{9,9}, --[[082]] 17535327,{9},
--[[083]] 17535328,{9,9}, --[[085]] 17535331,{9,9}, --[[087]] 17535332,{5,5,4,4}, --[[088]] 17535333,{7,7},
--[[089]] 17535334,{11,11,11}, --[[090]] 17535335,{8,8}, --[[091]] 17535336,{5,1,1}, --[[092]] 17535337,{10,10},
--[[093]] 17535338,{17535044,17535005,17535113}, --[[094]] 17535005,{13,13}, --[[095]] 17535113,{13,13},--[[096]] 17535339,{14,14},
--[[097]] 17535340,{11,11}, --[[098]] 17535341,{14,14}, --[[099]] 17535342,{17535114,17535115},--[[100]] 17535114,{10},
--[[101]] 17535115,{10}, --[[102]] 17535343,{14,14,1,1}, --[[104]] 17535345,{7,7}, --[[105]] 17535346,{8,8,5,5},
--[[106]] 17535347,{1,1,7,7}, --[[107]] 17535348,{13,13}, --[[108]] 17535349,{12,12}, --[[110]] 17535350,{15,15,15},
--[[111]] 17535355,{14,14,14}, --[[116]] 17535356,{8,8,8,4,4}, --[[117]] 17535357,{9,9,9}, --[[118]] 17535358,{12,12,5,5,10,10},
--[[119]] 17535359,{7,7,7,6,6}, --[[120]] 17535360,{14,14,14}, --[[121]] 17535361,{1,1,3,3}, --[[122]] 17535362,{2,2,2,3,3},
--[[123]] 17535363,{15,15,10,10}, --[[124]] 17535364,{14,14,14}, --[[125]] 17535365,{15,15}, --[[126]] 17535366,{13,13,13,13},
--[[127]] 17535367,{12,12,12}, --[[128]] 17535368,{11,11,11}, --[[129]] 17535369,{10,10,10}, --[[130]] 17535370,{6,6,6,10,10},
--[[131]] 17535371,{12,12,5,5,4,4},--[[132]] 17535372,{6,6,6}, --[[133]] 17535373,{9,9,9}, --[[134]] 17535374,{8,8,8},
--[[135]] 17535375,{7,7,7}, --[[136]] 17535376,{5,5,5}, --[[137]] 17535377,{3,3,3}, --[[138]] 17535378,{2,2,2},
--[[139]] 17535379,{1,1,1}, --[[140]] 17535380,{4,4,4}, --[[141]] 17535381,{12}, --[[142]] 17535382,{12},
--[[143]] 17535383,{2}, --[[144]] 17535384,{2}, --[[145]] 17535385,{8,8,8}, --[[146]] 17535386,{7,7,7},
--[[147]] 17535387,{15,15,17535390},--[[149]] 17535389,{15,15,17535388}};
-----------------------------------
-- Dynamis-Windurst
-----------------------------------
-- 1: WAR Vanguard Skirmisher
-- 2: MNK Vanguard Sentinel
-- 3: WHM Vanguard Priest
-- 4: BLM Vanguard Prelate
-- 5: RDM Vanguard Visionary
-- 6: THF Vanguard Liberator
-- 7: PLD Vanguard Exemplar
-- 8: DRK Vanguard Inciter
-- 9: BST Vanguard Ogresoother + Vanguard's Crow
-- 10: BRD Vanguard Chanter
-- 11: RNG Vanguard Salvager
-- 12: SAM Vanguard Persecutor
-- 13: NIN Vanguard Assassin
-- 14: DRG Vanguard Partisan + Vanguard's Wyvern
-- 15: SMN Vanguard Oracle + Vanguard's Avatar
-- [Position on the map] Avatar Icon mobid, {spawnlist: mob1, mob2,...}
windyList = {--[[001]] 17543461,{0,0}, --[[002]] 17543462,{0,0}, --[[003]] 17543463,{0,0}, --[[004]] 17543490,{0,0},
--[[005]] 17543491,{0,0}, --[[006]] 17543492,{0,0}, --[[007]] 17543493,{0,0}, --[[008]] 17543494,{0,0},
--[[009]] 17543495,{0,0}, --[[010]] 17543496,{0,0}, --[[011]] 17543497,{0,0}, --[[012]] 17543498,{0,0},
--[[013]] 17543499,{0,0}, --[[014]] 17543500,{0,0}, --[[015]] 17543501,{0,0}, --[[016]] 17543502,{0,0},
--[[017]] 17543503,{0,0}, --[[018]] 17543504,{0,0}, --[[019]] 17543505,{0,0}, --[[020]] 17543506,{0,0},
--[[021]] 17543507,{0,0,17543268,17543269}, --[[022]] 17543268,{0,0}, --[[023]] 17543269,{0,0}, --[[024]] 17543508,{0,0,17543305},
--[[025]] 17543305,{0,0}, --[[026]] 17543509,{0,0}, --[[027]] 17543510,{0,0}, --[[028]] 17543511,{0,0},
--[[029]] 17543512,{0,0}, --[[030]] 17543513,{0,0}, --[[031]] 17543514,{0,0}, --[[032]] 17543515,{0,0,17543306},
--[[033]] 17543306,{0,0}, --[[034]] 17543516,{0,0}, --[[035]] 17543517,{0,0,17543353,17543354}, --[[036]] 17543353,{0,0},
--[[037]] 17543354,{0,0}, --[[038]] 17543362,{0,0}, --[[039]] 17543363,{0,0}, --[[040]] 17543392,{0,0},
--[[041]] 17543518,{0,0,17543393}, --[[042]] 17543393,{0,0}, --[[043]] 17543519,{0,0}, --[[044]] 17543520,{0,0},
--[[045]] 17543521,{0,0}, --[[046]] 17543522,{0,0,17543523,17543524,17543525,17543526,17543357}, --[[047]] 17543523,{0,0}, --[[048]] 17543524,{0,0},
--[[049]] 17543525,{0,0}, --[[050]] 17543526,{0,0}, --[[051]] 17543527,{0,0}, --[[052]] 17543528,{0,0},
--[[053]] 17543529,{0,0}, --[[054]] 17543530,{0,0}, --[[055]] 17543531,{0,0}, --[[056]] 17543532,{0,0},
--[[057]] 17543533,{0,0,17543530,17543531}, --[[058]] 17543534,{0,0,17543535,17543536,17543537}, --[[059]] 17543535,{0,0}, --[[060]] 17543536,{0,0},
--[[061]] 17543537,{0,0}, --[[062]] 17543538,{0,0}, --[[063]] 17543539,{0,0}, --[[064]] 17543540,{0,0},
--[[065]] 17543541,{0,0}, --[[066]] 17543542,{0,0,17543543,17543544}, --[[067]] 17543543,{0,0}, --[[068]] 17543544,{0,0},
--[[069]] 17543545,{0,0,17543546}, --[[070]] 17543546,{0,0}, --[[071]] 17543547,{0,0}, --[[072]] 17543548,{0,0,17543549},
--[[073]] 17543549,{0,0}, --[[074]] 17543550,{0,0,17543551,17543552}, --[[075]] 17543551,{0,0}, --[[076]] 17543552,{0,0},
--[[077]] 17543553,{0,0,17543554,17543555}, --[[078]] 17543554,{0,0}, --[[079]] 17543555,{0,0}, --[[080]] 17543556,{0,0,17543557,17543558,17543559},
--[[081]] 17543557,{0,0}, --[[082]] 17543558,{0,0}, --[[083]] 17543559,{0,0}, --[[084]] 17543560,{0,0,17543561,17543562,17543563,17543375},
--[[085]] 17543561,{0,0}, --[[086]] 17543562,{0,0}, --[[087]] 17543563,{0,0}, --[[088]] 17543564,{0,0},
--[[089]] 17543565,{0,0,17543566}, --[[090]] 17543566,{0,0}, --[[091]] 17543567,{0,0,17543568}, --[[092]] 17543568,{0,0},
--[[093]] 17543569,{0,0,17543294}, --[[094]] 17543570,{0,0}, --[[095]] 17543571,{0,0}, --[[096]] 17543572,{0,0},
--[[097]] 17543573,{0,0,17543574}, --[[098]] 17543574,{0,0,17543575}, --[[099]] 17543575,{0,0,17543576}, --[[100]] 17543576,{0,0},
--[[101]] 17543577,{0,0,17543578,17543579}, --[[102]] 17543578,{0,0}, --[[103]] 17543579,{0,0}, --[[104]] 17543580,{0,0},
--[[105]] 17543581,{0,0}, --[[106]] 17543582,{0,0}, --[[107]] 17543583,{0,0}, --[[108]] 17543584,{0,0}, --[[109]] 17543585,{0,0},
--[[110]] 17543586,{0,0}, --[[111]] 17543587,{0,0}, --[[112]] 17543588,{0,0}, --[[113]] 17543589,{0,0}, --[[114]] 17543590,{0,0},
--[[115]] 17543591,{0,0}, --[[116]] 17543592,{0,0,17543593,17543594,17543595,17543596,17543345}, --[[117]] 17543593,{0,0}, --[[118]] 17543594,{0,0}, --[[119]] 17543595,{0,0},
--[[120]] 17543596,{0,0}, --[[122]] 17543597,{0,0}, --[[123]] 17543598,{0,0}, --[[124]] 17543599,{0,0}, --[[125]] 17543600,{0,0}
};
-----------------------------------
-- Dynamis-Jeuno
-----------------------------------
-- 1: WAR Vanguard Smithy
-- 2: MNK Vanguard Pitfighter
-- 3: WHM Vanguard Alchemist
-- 4: BLM Vanguard Shaman
-- 5: RDM Vanguard Enchanter
-- 6: THF Vanguard Welldigger
-- 7: PLD Vanguard Armorer
-- 8: DRK Vanguard Tinkerer
-- 9: BST Vanguard Pathfinder + Vanguard's Slime
-- 10: BRD Vanguard Maestro
-- 11: RNG Vanguard Ambusher
-- 12: SAM Vanguard Ronin
-- 13: NIN Vanguard Hitman
-- 14: DRG Vanguard Dragontamer + Vanguard's Wyvern
-- 15: SMN Vanguard Necromancer + Vanguard's Avatar
-- [Position on the map] Avatar Icon mobid, {spawnlist: mob1, mob2,...}
jeunoList = {--[[001]] 17547530,{0,0}, --[[002]] 17547531,{5,10}, --[[003]] 17547532,{17547312,7,8},
--[[006]] 17547535,{13,6}, --[[007]] 17547536,{13,6}, --[[008]] 17547537,{13,6},
--[[009]] 17547538,{9,2}, --[[010]] 17547539,{17547311,4,15,3}, --[[012]] 17547541,{12,5,3},
--[[013]] 17547542,{2,2}, --[[014]] 17547543,{13}, --[[015]] 17547544,{9,5}, --[[016]] 17547545,{7,8},
--[[017]] 17547546,{11,11}, --[[018]] 17547547,{17547322,4,3}, --[[019]] 17547548,{14,6}, --[[020]] 17547549,{10,1},
--[[021]] 17547550,{0,0}, --[[022]] 17547551,{15}, --[[023]] 17547552,{17547378}, --[[024]] 17547553,{1,3},
--[[025]] 17547554,{9,6}, --[[026]] 17547555,{17547377,8}, --[[027]] 17547556,{13}, --[[028]] 17547557,{12},
--[[029]] 17547558,{17547324,2,6,4,5,3}, --[[030]] 17547559,{9}, --[[031]] 17547560,{10}, --[[032]] 17547561,{13},
--[[033]] 17547562,{15}, --[[034]] 17547563,{12,14}, --[[035]] 17547564,{1,6}, --[[036]] 17547565,{4},
--[[037]] 17547566,{10}, --[[038]] 17547567,{7,8}, --[[039]] 17547568,{15,15,15}, --[[040]] 17547569,{17547355},
--[[042]] 17547571,{5,2}, --[[043]] 17547572,{17547396,13,13}, --[[045]] 17547574,{17547356,5,10,8,7,3},
--[[046]] 17547575,{9}, --[[047]] 17547576,{9}, --[[048]] 17547577,{12}, --[[049]] 17547578,{17547395,7},
--[[050]] 17547579,{1}, --[[051]] 17547580,{14}, --[[052]] 17547581,{4},
--[[053]] 17547582,{2}, --[[054]] 17547583,{15}, --[[055]] 17547584,{4},
--[[058]] 17547587,{13}, --[[059]] 17547588,{14,14}, --[[060]] 17547589,{5},
--[[061]] 17547590,{7}, --[[062]] 17547591,{17547394,12,10}, --[[063]] 17547592,{1,6,3},
--[[064]] 17547593,{},
--[[065]] 17547594,{11,11}, --[[066]] 17547595,{4,3}, --[[067]] 17547596,{4,2}, --[[068]] 17547597,{1,3},
--[[069]] 17547598,{15}, --[[070]] 17547599,{4}, --[[071]] 17547600,{9}, --[[072]] 17547601,{14},
--[[073]] 17547602,{17547277,11,15}, --[[074]] 17547603,{17547291,6,14}, --[[075]] 17547604,{17547294,13,3}, --[[076]] 17547605,{13,12},
--[[077]] 17547606,{11,8}, --[[078]] 17547607,{8}, --[[079]] 17547608,{7}, --[[080]] 17547609,{11},
--[[081]] 17547610,{13}, --[[082]] 17547611,{10}, --[[083]] 17547612,{3}, --[[084]] 17547613,{1},
--[[085]] 17547614,{12}, --[[086]] 17547615,{17547440,6,4,4}, --[[087]] 17547616,{17547454,7,10,11,8}, --[[088]] 17547617,{17547468,15,12,14},
--[[089]] 17547618,{5}, --[[090]] 17547619,{5}, --[[091]] 17547620,{5}, --[[092]] 17547621,{12},
--[[093]] 17547622,{1}, --[[094]] 17547623,{2}, --[[095]] 17547624,{17547438,15,15}, --[[096]] 17547625,{14},
--[[097]] 17547626,{4}, --[[098]] 17547627,{0,0}, --[[099]] 17547628,{0,0}, --[[100]] 17547629,{0,0},
--[[101]] 17547630,{10,10}, --[[102]] 17547631,{10,10}, --[[103]] 17547632,{6,11}, --[[104]] 17547633,{6,11},
--[[105]] 17547634,{17547299,4,14}, --[[106]] 17547635,{17547300,15,5}, --[[107]] 17547636,{17547298,9,3}, --[[108]] 17547637,{12},
--[[109]] 17547638,{7}, --[[110]] 17547639,{8}, --[[111]] 17547640,{4,11}, --[[112]] 17547641,{7,5},
--[[114]] 17547642,{1,2,3,4}, --[[115]] 17547643,{5,6,7,8}, --[[116]] 17547644,{9,10,11,12}, --[[117]] 17547645,{13,14,15},
--[[118]] 17547646,{6,4}, --[[119]] 17547647,{5,3}, --[[120]] 17547648,{17547402,1}, --[[121]] 17547649,{4,14,1},
--[[122]] 17547650,{2,6,15}, --[[123]] 17547651,{9,12}, --[[124]] 17547652,{17547486,7,11,10,9}, --[[125]] 17547653,{--[[Slystix]]13,13,13,11,11},
--[[126]] 17547654,{14,15}, --[[127]] 17547655,{8,8}, --[[128]] 17547656,{5,5}, --[[129]] 17547657,{3,3},
--[[130]] 17547658,{12,9}, --[[131]] 17547659,{4,9}, --[[132]] 17547660,{2,9}, --[[133]] 17547661,{0,0,17547473},
--[[134]] 17547662,{17547472,6,10,14,12,12}, --[[135]] 17547663,{0,0,17547474}, --[[136]] 17547664,{0,0}, --[[137]] 17547665,{0,0},
--[[138]] 17547666,{0,0}, --[[139]] 17547667,{0,0}, --[[140]] 17547668,{0,0}, --[[141]] 17547669,{0,0},
--[[142]] 17547670,{0,0,17547485}, --[[143]] 17547671,{0,0}, --[[144]] 17547672,{0,0}, --[[145]] 17547673,{0,0,17547487},
--[[146]] 17547674,{0,0,17547479}, --[[147]] 17547675,{0,0}, --[[148]] 17547676,{0,0,17547480}, --[[149]] 17547677,{0,0,17547490},
--[[150]] 17547678,{17547478,7,6,10,5,13}
};
-----------------------------------
-- Dynamis-Beaucedine
-----------------------------------
-- [Position on the map] Avatar Icon mobid, {spawnlist: mob1, mob2,...}
beaucedineYagudoList = {--[[001]] 17326830,{0,0}, --[[005]] 17326834,{0,0}, --[[009]] 17326838,{0,0}, --[[010]] 17326839,{0,17326289},
--[[011]] 17326840,{0,0}, --[[012]] 17326841,{0,0}, --[[013]] 17326842,{0,0}, --[[014]] 17326843,{0,17326307},
--[[015]] 17326844,{0,0,17326328}, --[[016]] 17326845,{0,0}, --[[017]] 17326846,{0,0,17326340}, --[[018]] 17326847,{0,0},
--[[019]] 17326848,{0,0,17326335}, --[[020]] 17326849,{0,0,17326347}, --[[021]] 17326850,{0,0,17326284}, --[[022]] 17326851,{0,0},
--[[023]] 17326852,{0,0}, --[[024]] 17326853,{0,0}, --[[025]] 17326854,{0,0},
--[[026]] 17326855,{0,0,17326304}, --[[027]] 17326856,{0,0}, --[[028]] 17326857,{0,0}, --[[029]] 17326858,{0,0,17326300},
--[[030]] 17326859,{0,0}, --[[102]] 17326931,{0,0}, --[[106]] 17326935,{0,0,17326313,17326344}};
-- [Position on the map] Goblin Statue mobid, {spawnlist: mob1, mob2,...}
beaucedineGoblinList = {--[[002]] 17326831,{0,0}, --[[006]] 17326835,{0,0}, --[[031]] 17326860,{0,0,17326379}, --[[032]] 17326861,{0,0},
--[[033]] 17326862,{0,0}, --[[034]] 17326863,{0,0,17326397}, --[[035]] 17326864,{0,0,17326410}, --[[036]] 17326865,{0,0},
--[[037]] 17326866,{0,0}, --[[038]] 17326867,{0,0}, --[[039]] 17326868,{0,0}, --[[040]] 17326869,{0,0,17326421},
--[[041]] 17326870,{0,0,17326405}, --[[042]] 17326871,{0,0,17326463}, --[[043]] 17326872,{0,0}, --[[044]] 17326873,{0,0},
--[[045]] 17326874,{0,0}, --[[046]] 17326875,{0,0,17326401}, --[[047]] 17326876,{0,0},
--[[048]] 17326877,{0,0}, --[[049]] 17326878,{0,0}, --[[050]] 17326879,{0,0}, --[[051]] 17326880,{0,0},
--[[052]] 17326881,{0,0,17326439}, --[[053]] 17326882,{0,0,17326452}, --[[100]] 17326929,{0,0}, --[[104]] 17326933,{0,0,17326387,17326427}};
-- [Position on the map] Adamantking Effigy mobid, {spawnlist: mob1, mob2,...}
beaucedineQuadavList = {--[[004]] 17326833,{0,0}, --[[008]] 17326837,{0,0}, --[[054]] 17326883,{0,0,17326126}, --[[055]] 17326884,{0,0,17326145},
--[[056]] 17326885,{0,0}, --[[057]] 17326886,{0,0}, --[[058]] 17326887,{0,0,17326173}, --[[059]] 17326888,{0,0},
--[[060]] 17326889,{0,0,17326195}, --[[061]] 17326890,{0,0}, --[[062]] 17326891,{0,0,17326151}, --[[063]] 17326892,{0,0,17326201},
--[[064]] 17326893,{0,0}, --[[065]] 17326894,{0,0}, --[[066]] 17326895,{0,0,17326114}, --[[067]] 17326896,{0,0},
--[[068]] 17326897,{0,0}, --[[069]] 17326898,{0,0}, --[[070]] 17326899,{0,0},
--[[071]] 17326900,{0,0}, --[[072]] 17326901,{0,0,17326162}, --[[073]] 17326902,{0,0}, --[[074]] 17326903,{0,0},
--[[075]] 17326904,{0,0}, --[[076]] 17326905,{0,0,17326190}, --[[099]] 17326928,{0,0}, --[[103]] 17326932,{0,0,17326106,17326185}};
-- [Position on the map] Serjeant Tombstone mobid, {spawnlist: mob1, mob2,...}
beaucedineOrcishList = {--[[003]] 17326832,{0,0}, --[[007]] 17326836,{0,0}, --[[077]] 17326906,{0,0}, --[[078]] 17326907,{0,0},
--[[079]] 17326908,{0,0,17326233}, --[[080]] 17326909,{0,0}, --[[081]] 17326910,{0,0}, --[[082]] 17326911,{0,0,17326262},
--[[083]] 17326912,{0,0,17326248}, --[[084]] 17326913,{0,0,17326258}, --[[085]] 17326914,{0,0}, --[[086]] 17326915,{0,0,17326243},
--[[087]] 17326916,{0,0,17326218}, --[[088]] 17326917,{0,0,17326229}, --[[089]] 17326918,{0,0}, --[[090]] 17326919,{0,0},
--[[091]] 17326920,{0,0,17326223}, --[[092]] 17326921,{0,0}, --[[093]] 17326922,{0,0}, --[[094]] 17326923,{0,0},
--[[095]] 17326924,{0,0}, --[[096]] 17326925,{0,0}, --[[097]] 17326926,{0,0}, --[[098]] 17326927,{0,0,17326265},
--[[101]] 17326930,{0,0}, --[[105]] 17326934,{0,0,17326216,17326270}};
-- [Position on the map] Vanguard Eye mobid, {spawnlist}
beaucedineHydraList = {--[[107]] 17326473,{2,10,11}, --[[108]] 17326478,{8}, --[[109]] 17326484,{2}, --[[110]] 17326494,{6}, --[[111]] 17326501,{5},
--[[112]] 17326507,{9}, --[[113]] 17326514,{9,1}, --[[114]] 17326519,{5,12},--[[115]] 17326525,{1,11}, --[[116]] 17326530,{7,14},
--[[117]] 17326536,{17326625,13},--[[118]] 17326542,{3}, --[[119]] 17326547,{7,15},--[[120]] 17326553,{3,15}, --[[121]] 17326558,{17326564},
--[[122]] 17326565,{14}, --[[123]] 17326572,{8}, --[[124]] 17326579,{7}, --[[125]] 17326586,{10,1}, --[[126]] 17326593,{3},
--[[127]] 17326600,{9}, --[[128]] 17326607,{15,7},--[[129]] 17326612,{10}, --[[130]] 17326617,{11}, --[[131]] 17326623,{17326574,13},
--[[132]] 17326629,{2}, --[[133]] 17326634,{5}, --[[134]] 17326639,{12}, --[[135]] 17326646,{8}, --[[136]] 17326651,{6,14},
--[[137]] 17326656,{2,3}, --[[138]] 17326661,{9}, --[[139]] 17326668,{13}, --[[140]] 17326673,{17326624},--[[141]] 17326678,{15},
--[[142]] 17326683,{14}, --[[143]] 17326688,{12}, --[[144]] 17326692,{11}, --[[145]] 17326696,{7}, --[[146]] 17326701,{11},
--[[147]] 17326706,{6,7}, --[[148]] 17326721,{10,7},--[[149]] 17326727,{14}, --[[150]] 17326732,{10,12}, --[[151]] 17326737,{17326577},
--[[152]] 17326742,{14}, --[[153]] 17326748,{0}, --[[154]] 17326754,{9}, --[[155]] 17326781,{15}, --[[156]] 17326786,{3,8},
--[[157]] 17326790,{6,12,3,7,13}};
-----------------------------------
-- Dynamis-Xarcabard
-----------------------------------
-- 1: WAR 2: MNK 3: WHM 4: BLM 5: RDM 6: THF 7: PLD 8: DRK
-- 9: BST 10: BRD 11: RNG 12: SAM 13: NIN 14: DRG 15: SMN
-- [Position on the map] Vanguard Eye mobid, {spawnlist: mob1, mob2,...}
xarcabardList = {--[[001]] 17330293,{12,12}, --[[002]] 17330302,{15,15}, --[[003]] 17330312,{14,14}, --[[004]] 17330322,{13,13},
--[[006]] 17330340,{9,9,9}, --[[007]] 17330350,{7,14,14}, --[[008]] 17330358,{8,8,7}, --[[009]] 17330368,{8,8,7},
--[[011]] 17330375,{1,2,6,5,4,3}, --[[013]] 17330386,{1,2,6,5,4,3}, --[[014]] 17330398,{7,5}, --[[015]] 17330426,{2,3},
--[[016]] 17330438,{7,5}, --[[017]] 17330448,{13,13,13,10}, --[[018]] 17330460,{1,1,1,10}, --[[019]] 17330498,{12,12,12,10},
--[[020]] 17330506,{12,12,11}, --[[021]] 17330542,{13,6}, --[[022]] 17330549,{12,12,11}, --[[023]] 17330562,{13,6,6},
--[[024]] 17330567,{13,6}, --[[025]] 17330581,{13,6,6}, --[[026]] 17330586,{14,14}, --[[027]] 17330610,{9,9},
--[[028]] 17330617,{15,15}, --[[029]] 17330631,{1,1}, --[[030]] 17330636,{2,2}, --[[031]] 17330662,{3,3},
--[[032]] 17330668,{4,4}, --[[033]] 17330685,{5,5}, --[[034]] 17330690,{6,6}, --[[035]] 17330718,{17330731,17330746,17330749},
--[[039]] 17330756,{17330762,17330770,17330813}, --[[044]] 17330815,{4,11}, --[[045]] 17330816,{4,11},
--[[046]] 17330817,{4,11}, --[[047]] 17330818,{4,11}, --[[048]] 17330819,{9,9,3,10}, --[[049]] 17330820,{2,13,15},
--[[050]] 17330821,{9,9,3,10}, --[[051]] 17330822,{2,13,15}, --[[053]] 17330823,{12,14,13,15}, --[[054]] 17330824,{7,8,9,11,10},
--[[055]] 17330825,{12,14,13,15}, --[[056]] 17330826,{7,8,9,11,10}, --[[057]] 17330827,{12,14,11}, --[[058]] 17330828,{7,6,15},
--[[059]] 17330829,{8,13,4}, --[[061]] 17330831,{1,2,3}, --[[062]] 17330832,{6,6,4}, --[[063]] 17330833,{5,5,5},
--[[064]] 17330834,{6,6,4}, --[[065]] 17330835,{1,2,3}, --[[066]] 17330836,{8,8,8,4}, --[[067]] 17330837,{12,12,12,4},
--[[068]] 17330838,{4,3}, --[[069]] 17330839,{7,7}, --[[070]] 17330840,{7,7}, --[[071]] 17330841,{2,2,2},
--[[072]] 17330842,{4,3}, --[[074]] 17330844,{14,14}, --[[075]] 17330845,{9,9}, --[[076]] 17330846,{15,15,15},
--[[078]] 17330848,{9,9}, --[[079]] 17330849,{8,8}, --[[080]] 17330850,{11,11}, --[[081]] 17330851,{7,7},
--[[082]] 17330852,{10,10}, --[[083]] 17330853,{1,1,5}, --[[084]] 17330854,{4,4}, --[[085]] 17330855,{1,1,5},
--[[086]] 17330856,{2,6}, --[[087]] 17330857,{2,6}, --[[088]] 17330858,{3,3}, --[[089]] 17330859,{1,1,10},
--[[090]] 17330860,{2,2,10}, --[[091]] 17330861,{1,1,10}, --[[092]] 17330862,{2,2,10}, --[[093]] 17330863,{11,11},
--[[094]] 17330864,{12,12,12}, --[[095]] 17330865,{11,11}, --[[096]] 17330866,{6,6,6}, --[[097]] 17330867,{1,5,10},
--[[098]] 17330868,{2,9,3}, --[[099]] 17330869,{2,10}, --[[100]] 17330870,{1,10}, --[[101]] 17330871,{1,3},
--[[102]] 17330872,{5,3,10}, --[[103]] 17330873,{5,3,10}, --[[104]] 17330874,{8,8,10}, --[[105]] 17330875,{8,8,10},
--[[106]] 17330876,{7,7}, --[[107]] 17330877,{13,13,5}, --[[108]] 17330878,{13,13,5}, --[[109]] 17330879,{14,14,14},
--[[110]] 17330880,{9,9}, --[[111]] 17330881,{15,15}, --[[113]] 17330882,{9,9}, --[[114]] 17330883,{15,15,15},
--[[115]] 17330884,{14,11}, --[[116]] 17330885,{14,11}, --[[117]] 17330886,{7,15}, --[[118]] 17330887,{7,15},
--[[119]] 17330888,{11,11,11}, --[[120]] 17330889,{7,15}, --[[121]] 17330890,{5}, --[[122]] 17330891,{13,13},
--[[123]] 17330892,{5}, --[[124]] 17330893,{14,14,5}, --[[125]] 17330894,{12,12,5}, --[[126]] 17330895,{8,8},
--[[127]] 17330896,{17330223}, --[[128]] 17330897,{17330377}, --[[129]] 17330898,{17330353}, --[[130]] 17330899,{17330332},
--[[131]] 17330900,{17330304}, --[[132]] 17330901,{17330390}, --[[133]] 17330902,{17330451}, --[[134]] 17330903,{17330417},
--[[135]] 17330904,{17330343}, --[[136]] 17330905,{17330315}, --[[137]] 17330906,{17330360}, --[[138]] 17330907,{17330481},
--[[139]] 17330908,{17330430}, --[[140]] 17330909,{17330440}, --[[141]] 17330910,{17330415}, --[[144]] 17330913,{4,3},
--[[145]] 17330914,{4,3}, --[[146]] 17330915,{4,3}, --[[147]] 17330916,{14,14}, --[[148]] 17330917,{8,8},
--[[149]] 17330918,{7,7}};
-----------------------------------
-- Dynamis-Valkurm
-----------------------------------
-- Manifest_Icon mobid, {spawnlist: mob1, mob2,...}
ValkurmYagudoList = {
16937258,{16937240,16937241,16937242},-- sp
16937259,{16937244,16937245,16937246,16937254},-- sp
16937260,{16937248,16937249,16937250,16937255},-- sp
16937261,{16937251,16937252,16937253,16937256},-- sp
16937544,{16937526,16937527,16937528},--
16937545,{16937531,16937532,16937533},--
16937546,{16937534,16937535,16937536},--
16937547,{16937529,16937539},--
16937548,{16937537,16937540},--
16937549,{16937542,16937541}--
};
-- Goblin_Replica mobid, {spawnlist: mob1, mob2,...}
ValkurmGoblinList = {
16937283,{16937265,16937266,16937268},-- HP
16937284,{16937270,16937271,16937278,16937279},-- MP
16937285,{16937272,16937273,16937274,16937280},-- sp
16937286,{16937275,16937276,16937277,16937281},-- sp
16937569,{16937551,16937552,16937553},--
16937570,{16937554,16937555,16937557},--
16937571,{16937558,16937559,16937560},--
16937572,{16937561,16937563},--
16937573,{16937564,16937565},--
16937574,{16937566,16937567}--
};
-- Serjeant_Tombstone mobid, {spawnlist: mob1, mob2,...}
ValkurmOrcishList = {
16937208,{16937190,16937191,16937192,16937204},-- sp
16937209,{16937193,16937194,16937195,16937205},-- sp
16937210,{16937196,16937197,16937198,16937206},-- sp
16937211,{16937200,16937201,16937202},-- sp
16937494,{16937476,16937477,16937478},--
16937495,{16937479,16937482,16937484},--
16937496,{16937484,16937485,16937488},--
16937497,{16937480,16937489},--
16937498,{16937486,16937490},--
16937499,{16937492,16937491}--
};
-- Adamantking_Effigy mobid, {spawnlist: mob1, mob2,...}
ValkurmQuadavList = {
16937233,{16937215,16937216,16937217},-- HP
16937234,{16937218,16937219,16937221,16937229},-- sp
16937235,{16937222,16937223,16937224,16937230},-- sp
16937236,{16937225,16937227,16937228,16937231},-- sp
16937519,{16937501,16937502,16937503},--
16937520,{16937504,16937505,16937508},--
16937521,{16937509,16937512,16937513},--
16937522,{16937506,16937514},--
16937523,{16937510,16937515},--
16937524,{16937517,16937516}--
};
TimerStatueRandomPos = {
1,{-363,-7,235},
2,{-255,-7,85},
3,{-286,0.1,-31},
4,{-68,0.1,19}
};
-----------------------------------
-- Dynamis-Buburimu
-----------------------------------
--***********************************************************************************************
-- Manifest_Icon mobid, {spawnlist: mob1, mob2,...}
BuburimuYagudoList = {
16941190,{16941186,16941182,16941181,16941176,16941178}, -- 38 mp
16941191,{16941188,16941185,16941180,16941175}, -- Ree_Nata_the_Melomanic 50
16941192,{16941189,16941184,16941179,16941177}, -- Koo_Rahi_the_Levinblade 45 mp
16941208,{16941203,16941194,16941197,16941200}, -- 039 hp
16941209,{16941205,16941195,16941198,16941201}, -- Doo_Peku_the_Fleetfoot
16941210,{16941206,16941196,16941199,16941202}, -- Baa_Dava_the_Bibliophage 43
16941471,{16941167,16941163,16941161,16941158,16941157}, -- ++
16941472,{16941169,16941165,16941164,16941160}, -- Va_Rhu_Bodysnatcher 37 ++
16941473,{16941170,16941166,16941162,16941159}, -- Te_Zha_Ironclad 41
16941485,{16941475,16941478,16941481},-- 041 hp ++
16941486,{16941476,16941479,16941482}, -- 044 mp
16941487,{16941477,16941480,16941483,16941484} -- 049
};
-- Goblin_Replica mobid, {spawnlist: mob1, mob2,...}
BuburimuGoblinList = {
16941068,{16941058,16941060},
16941069,{16941062,16941063,16941064},
16941070,{16941066,16941065}, -- Woodnix_Shrillwhistle 15
16941083,{16941072,16941073,16941074,16941078},
16941084,{16941075,16941076,16941077},
16941085,{16941079,16941082}, -- Shamblix_Rottenheart 18
16941098,{16941087,16941089,16941095},
16941099,{16941088,16941090,16941094},
16941100,{16941091,16941092,16941097}, -- Gosspix_Blabberlips 21
16941381,{16941369,16941372,16941375,16941379},
16941382,{16941370,16941373,16941377},
16941383,{16941371,16941374,16941378}, --hp
16941395,{16941385,16941387,16941391}, --hp
16941396,{16941386,16941390,16941392}, -- 22 mp
16941397,{16941388,16941389,16941393} -- 23 mp
};
-- Serjeant_Tombstone mobid, {spawnlist: mob1, mob2,...}
BuburimuOrcishList = {
16941118,{16941102,16941104,16941106,16941109,16941113}, --
16941119,{16941115,16941103,16941107,16941111}, -- Flamecaller_Zoeqdoq ++
16941120,{16941117,16941105,16941108,16941112}, -- Elvaansticker_Bxafraff
16941135,{16941131,16941122,16941127,16941128,16941129}, -- stat HP
16941136,{16941133,16941123,16941125,16941130}, -- Hamfist_Gukhbuk
16941137,{16941134,16941124,16941126,}, -- Lyncean_Juwgneg MP
16941411,{16941399,16941403,16941405,16941409}, -- HP
16941412,{16941400,16941402,16941407}, -- MP
16941413,{16941401,16941404,16941408}, -- ++
16941425,{16941415,16941418,16941421}, -- ++
16941426,{16941416,16941419,16941422}, -- ++
16941427,{16941417,16941420,16941423}, -- ++
};
-- Adamantking_Effigy mobid, {spawnlist: mob1, mob2,...}
BuburimuQuadavList = {
16941153,{16941149,16941139,16941142,16941146},
16941154,{16941151,16941140,16941143,16941147,16941148}, -- Qu_Pho_Bloodspiller
16941155,{16941152,16941141,16941144}, -- Gi_Bhe_Fleshfeaster
16941171,{16941167,16941165,16941163,16941159}, --
16941172,{16941169,16941166,16941162,16941160,16941158},
16941173,{16941170,16941164,16941161,16941157},
16941440,{16941436,16941432,16941429},
16941441,{16941437,16941434,16941430},
16941442,{16941438,16941435,16941431},
16941455,{16941451,16941448,16941444}, --
16941456,{16941452,16941450,16941445,16941447},
16941457,{16941453,16941449,16941446} -- stat MP
};
-----------------------------------
-- Dynamis-Qufim
-----------------------------------
--**********************************************************************************************
-- Manifest_Icon mobid, {spawnlist: mob1, mob2,...}
QufimYagudoList = {
16945605,{16945599,16945600,16945234,16945236},
16945606,{16945601,16945602,16945229,16945225},
16945607,{16945603,16945238,16945226,16945224},
16945615,{16945609,16945611,16945217,16945215},
16945616,{16945610,16945614,16945218,16945227},
16945617,{16945612,16945235,16945237},
16945625,{16945621,16945619,16945216,16945214},
16945626,{16945622,16945620,16945623}
};
-- Goblin_Replica mobid, {spawnlist: mob1, mob2,...}
QufimGoblinList = {
16945250,{16945246,16945245},
16945251,{16945247,16945244},
16945252,{16945248,16945256,16945254},
16945506,{16945502,16945501},
16945507,{16945505},
16945508,{16945503,16945257,16945255},
16945527,{16945523,16945522},
16945528,{16945524,16945266,16945265}, -- HP
16945529,{16945525,16945269,16945264}, -- MP
16945536,{16945532,16945531},
16945537,{16945533,16945258},
16945538,{16945534,16945267}, -- HP
16945545,{16945541,16945540}, -- MP
16945546,{16945542}, -- HP
16945547,{16945543}
};
-- Serjeant_Tombstone mobid, {spawnlist: mob1, mob2,...}
QufimOrcishList = {
16945477,{16945473,16945471,16945156,16945154,16945168},
16945478,{16945474,16945472,16945165,16945167,16945178},
16945479,{16945475,16945157,16945155,16945174,16945176},
16945488,{16945481,16945484,16945493,16945175},
16945489,{16945482,16945485,16945494,16945179},
16945490,{16945483,16945486,16945164,16945166},
16945497,{16945496,16945158,16945164,16945166}
};
-- Adamantking_Effigy mobid, {spawnlist: mob1, mob2,...}
QufimQuadavList = {
16945565,{16945559,16945560,16945204,16945205,16945184},
16945566,{16945563,16945564,16945206,16945207,16945185},
16945567,{16945561,16945208,16945198,16945189,16945188},
16945575,{16945569,16945570,16945583,16945195,16945194},
16945576,{16945571,16945572,16945582,16945580,16945186},
16945577,{16945573,16945581,16945579,16945197,16945196}
};
-----------------------------------
-- Dynamis-Tavnazia
-----------------------------------
TavnaziaEyesList ={
-- 1: WAR 2: MNK 3: WHM 4: BLM 5: RDM 6: THF 7: PLD 8: DRK
-- 9: BST 10: BRD 11: RNG 12: SAM 13: NIN 14: DRG 15: SMN
-- eyes third floor
16949475, {11,12}, -- 'Vanguard_Eye'
16949476, {1,6}, -- 'Vanguard_Eye'
16949477, {7,8,15}, -- 'Vanguard_Eye'
16949478, {5,10,14}, -- 'Vanguard_Eye'
16949479, {4,9,13}, -- 'Vanguard_Eye'
16949480, {2,3}, -- 'Vanguard_Eye'
16949481, {8,11}, -- 'Vanguard_Eye'
16949482, {2}, -- 'Vanguard_Eye'
16949483, {6,12,9}, -- 'Vanguard_Eye'
16949484, {15,7,10}, -- 'Vanguard_Eye'
16949485, {1,13,14}, -- 'Vanguard_Eye'
16949486, {2,9,15}, -- 'Vanguard_Eye'
-- eyes second floor
16949487, {1,5,11}, -- 'Vanguard_Eye' - war rdm rng
16949488, {9,15}, -- 'Vanguard_Eye's
16949489, {7,3,12}, -- 'Vanguard_Eye'
16949490, {10,13}, -- 'Vanguard_Eye'
16949491, {14,15,9}, -- 'Vanguard_Eye'
16949492, {7,8,9}, -- 'Vanguard_Eye'
16949493, {1,12,6,2}, -- 'Vanguard_Eye'
16949494, {5,4,3} -- 'Vanguard_Eye'
};
TavnaziaTautusList = {
16949475, {1},
16949476, {1},
16949477, {1},
16949478, {1},
16949479, {1},
16949480, {1},
16949481, {1},
16949482, {3},
16949483, {0},
16949484, {0},
16949485, {0},
16949486, {3}
};
TavnaziaCloneList = {
16949332, {16949431,16949432}, -- 'Nightmare_Cluster'
16949333, {16949433,16949434}, -- 'Nightmare_Cluster'
16949334, {16949435,16949436}, -- 'Nightmare_Cluster'
16949335, {16949437,16949438}, -- 'Nightmare_Cluster'
16949336, {16949439,16949440}, -- 'Nightmare_Cluster'
16949337, {16949441,16949442}, -- 'Nightmare_Cluster'
16949338, {16949443,16949444}, -- 'Nightmare_Cluster'
16949339, {16949445,16949446}, -- 'Nightmare_Cluster'
16949340, {16949447,16949448}, -- 'Nightmare_Cluster'
16949341, {16949449,16949450}, -- 'Nightmare_Leech'
16949342, {16949451,16949452}, -- 'Nightmare_Leech'
16949343, {16949453,16949454}, -- 'Nightmare_Leech'
16949344, {16949455,16949456}, -- 'Nightmare_Leech'
16949345, {16949457,16949458}, -- 'Nightmare_Leech'
16949346, {16949459,16949460}, -- 'Nightmare_Leech'
16949347, {16949461,16949462}, -- 'Nightmare_Leech'
16949348, {16949463,16949464}, -- 'Nightmare_Leech'
16949317, {16949465,16949466}, -- 'Nightmare_Makara'
16949318, {16949467,16949468}, -- 'Nightmare_Makara'
16949319, {16949469,16949470}, -- 'Nightmare_Makara'
16949320, {16949471,16949472}, -- 'Nightmare_Makara'
16949321, {16949473,16949474}, -- 'Nightmare_Makara'
16949273, {16949415,16949416}, -- 'Nightmare_Hornet'
16949274, {16949417,16949418}, -- 'Nightmare_Hornet'
16949275, {16949419,16949420}, -- 'Nightmare_Hornet'
16949276, {16949421,16949422}, -- 'Nightmare_Hornet'
16949277, {16949423,16949424}, -- 'Nightmare_Hornet'
16949278, {16949425,16949426}, -- 'Nightmare_Hornet'
16949279, {16949427,16949428}, -- 'Nightmare_Hornet'
16949280, {16949429,16949430} -- 'Nightmare_Hornet'
};
TavnaziaDiabolosList = {
16949249, -- Diabolos_Spade
16949250, -- Diabolos_Heart
16949251, -- Diabolos_Diamond
16949252 -- Diabolos_Club
};
--------------------------------------------------
-- getListDynaMob
-- List of mobid by zone and job
--------------------------------------------------
function getDynaMob(player,mobjob,list)
local pZone = player:getZoneID();
-- Dynamis San d'Oria -------------------------------
if(pZone == 185) then
return GetMobIDByJob(17534980,17535204,mobjob);
-- Dynamis Bastok -----------------------------------
elseif(pZone == 186) then
return GetMobIDByJob(17539074,17539305,mobjob);
-- Dynamis Windurst ---------------------------------
elseif(pZone == 187) then
return GetMobIDByJob(17543172,17543460,mobjob);
-- Dynamis Jeuno ------------------------------------
elseif(pZone == 188) then
return GetMobIDByJob(17547266,17547400,mobjob);
-- Dynamis Beaucedine -------------------------------
elseif(pZone == 134 and list == 1) then
return GetMobIDByJob(17326280,17326348,mobjob); -- Yagudo's Vanguard
elseif(pZone == 134 and list == 2) then
return GetMobIDByJob(17326354,17326463,mobjob); -- Goblin's Vanguard
elseif(pZone == 134 and list == 3) then
return GetMobIDByJob(17326099,17326202,mobjob); -- Quadav's Vanguard
elseif(pZone == 134 and list == 4) then
return GetMobIDByJob(17326208,17326274,mobjob); -- Orcish's Vanguard
elseif(pZone == 134 and list == 5) then
return GetMobIDByJob(17326469,17326789,mobjob); -- Hydra's
-- Dynamis Xarcabard --------------------------------
elseif(pZone == 135) then
return GetMobIDByJob(17330215,17330768,mobjob);
-- Dynamis Tavnazia
elseif(pZone == 42 and list == 1) then
return GetMobIDByJob(16949281,16949302,mobjob); -- hydra
elseif(pZone == 42 and list == 2) then
return GetMobIDByJob(16949349,16949375,mobjob); -- kindred
end
end;
--------------------------------------------------
-- checkFirstDyna
-- true if the first dyna
--------------------------------------------------
function checkFirstDyna(player,number)
local dynaVar = 0;
local bit = {};
dynaVar = player:getVar("Dynamis_Status");
for i = 7,0,-1 do
twop = 2^i;
if(dynaVar >= twop) then
bit[i+1] = 1;
dynaVar = dynaVar - twop;
else
bit[i+1] = 0;
end;
--printf("bit %u: %u\n",i,bit[i+1]);
end;
--printf("received %u",bit[number+1]);
if(bit[number+1] == 0) then
return true;
else
return false;
end
end;
--------------------------------------------------
-- alreadyReceived
-- I use this function for TE and Boss Trigger
--------------------------------------------------
function alreadyReceived(player,number)
local dynaVar = 0;
local bit = {};
local pZone = player:getZoneID();
if(pZone == 185) then
dynaVar = GetServerVariable("[DynaSandoria]Already_Received");
elseif(pZone == 186) then
dynaVar = GetServerVariable("[DynaBastok]Already_Received");
elseif(pZone == 187) then
dynaVar = GetServerVariable("[DynaWindurst]Already_Received");
elseif(pZone == 188) then
dynaVar = GetServerVariable("[DynaJeuno]Already_Received");
elseif(pZone == 134) then
dynaVar = GetServerVariable("[DynaBeaucedine]Already_Received");
elseif(pZone == 135) then
dynaVar = GetServerVariable("[DynaXarcabard]Already_Received");
elseif(pZone == 39) then
dynaVar = GetServerVariable("[DynaValkurm]Already_Received");
elseif(pZone == 40) then
dynaVar = GetServerVariable("[DynaBuburimu]Already_Received");
elseif(pZone == 41) then
dynaVar = GetServerVariable("[DynaQufim]Already_Received");
elseif(pZone == 42) then
dynaVar = GetServerVariable("[DynaTavnazia]Already_Received");
end
for i = 12,0,-1 do
twop = 2^i;
if(dynaVar >= twop) then
bit[i+1] = 1;
dynaVar = dynaVar - twop;
else
bit[i+1] = 0;
end;
end;
-- printf("received %u",bit[number]);
if(bit[number] == 0) then
return false;
else
return true;
end
end;
--------------------------------------------------
-- addDynamisList
-- Add this mob to already received list
--------------------------------------------------
function addDynamisList(player,number)
local pZone = player:getZoneID();
if(pZone == 185) then
SetServerVariable("[DynaSandoria]Already_Received",GetServerVariable("[DynaSandoria]Already_Received") + number);
elseif(pZone == 186) then
SetServerVariable("[DynaBastok]Already_Received",GetServerVariable("[DynaBastok]Already_Received") + number);
elseif(pZone == 187) then
SetServerVariable("[DynaWindurst]Already_Received",GetServerVariable("[DynaWindurst]Already_Received") + number);
elseif(pZone == 188) then
SetServerVariable("[DynaJeuno]Already_Received",GetServerVariable("[DynaJeuno]Already_Received") + number);
elseif(pZone == 134) then
SetServerVariable("[DynaBeaucedine]Already_Received",GetServerVariable("[DynaBeaucedine]Already_Received") + number);
elseif(pZone == 135) then
SetServerVariable("[DynaXarcabard]Already_Received",GetServerVariable("[DynaXarcabard]Already_Received") + number);
elseif(pZone == 39) then
SetServerVariable("[DynaValkurm]Already_Received",GetServerVariable("[DynaValkurm]Already_Received") + number);
elseif(pZone == 40) then
SetServerVariable("[DynaBuburimu]Already_Received",GetServerVariable("[DynaBuburimu]Already_Received") + number);
elseif(pZone == 41) then
SetServerVariable("[DynaQufim]Already_Received",GetServerVariable("[DynaQufim]Already_Received") + number);
elseif(pZone == 42) then
SetServerVariable("[DynaTavnazia]Already_Received",GetServerVariable("[DynaTavnazia]Already_Received") + number);
end
end;
--------------------------------------------------
-- activateAnimatedWeapon
-- change subanim when all NM are killed
--------------------------------------------------
function activateAnimatedWeapon()
for i = 17330199, 17330214, 1 do
GetMobByID(i):AnimationSub(3);
end
end;
--------------------------------------------------
-- getDynamisMapList
-- Produces a bitmask for the goblin ancient currency NPCs
--------------------------------------------------
function getDynamisMapList(player)
local bitmask = 0;
if (player:hasKeyItem(MAP_OF_DYNAMIS_SANDORIA) == true) then
bitmask = bitmask + 2;
end
if (player:hasKeyItem(MAP_OF_DYNAMIS_BASTOK) == true) then
bitmask = bitmask + 4;
end
if (player:hasKeyItem(MAP_OF_DYNAMIS_WINDURST) == true) then
bitmask = bitmask + 8;
end
if (player:hasKeyItem(MAP_OF_DYNAMIS_JEUNO) == true) then
bitmask = bitmask + 16;
end
if (player:hasKeyItem(MAP_OF_DYNAMIS_BEAUCEDINE) == true) then
bitmask = bitmask + 32;
end
if (player:hasKeyItem(MAP_OF_DYNAMIS_XARCABARD) == true) then
bitmask = bitmask + 64;
end
if (player:hasKeyItem(MAP_OF_DYNAMIS_VALKURM) == true) then
bitmask = bitmask + 128;
end
if (player:hasKeyItem(MAP_OF_DYNAMIS_BUBURIMU) == true) then
bitmask = bitmask + 256;
end
if (player:hasKeyItem(MAP_OF_DYNAMIS_QUFIM) == true) then
bitmask = bitmask + 512;
end
if (player:hasKeyItem(MAP_OF_DYNAMIS_TAVNAZIA) == true) then
bitmask = bitmask + 1024;
end
return bitmask;
end; | gpl-3.0 |
kitala1/darkstar | scripts/zones/Sacrarium/npcs/qm7.lua | 8 | 1734 | -----------------------------------
-- Area: Sacrarium
-- NPC: qm7 (???)
-- Notes: Used to spawn Old Prof. Mariselle
-- @pos 22.669 -3.111 -127.318 28
-----------------------------------
package.loaded["scripts/zones/Sacrarium/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Sacrarium/TextIDs");
require("scripts/globals/keyitems");
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local OldProfessor = 16891970;
if(GetServerVariable("Old_Prof_Spawn_Location") == 7) then
if(player:getCurrentMission(COP) == THE_SECRETS_OF_WORSHIP and player:getVar("PromathiaStatus") == 3 and player:hasKeyItem(RELIQUIARIUM_KEY)==false and GetMobAction(OldProfessor) == 0)then
player:messageSpecial(EVIL_PRESENCE);
SpawnMob(OldProfessor,300):updateClaim(player);
GetMobByID(OldProfessor):setPos(npc:getXPos()+1, npc:getYPos(), npc:getZPos()+1); -- Set Prof. spawn x and z pos. +1 from NPC
else
player:messageSpecial(DRAWER_SHUT);
end
elseif(player:getCurrentMission(COP) == THE_SECRETS_OF_WORSHIP and player:getVar("PromathiaStatus") == 4 and player:hasKeyItem(RELIQUIARIUM_KEY)==false)then
player:addKeyItem(RELIQUIARIUM_KEY);
player:messageSpecial(KEYITEM_OBTAINED,RELIQUIARIUM_KEY);
else
player:messageSpecial(DRAWER_OPEN);
player:messageSpecial(DRAWER_EMPTY);
end
end;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
end;
| gpl-3.0 |
kitala1/darkstar | scripts/globals/mobskills/Numbshroom.lua | 7 | 1145 | ---------------------------------------------------
-- Queasyshroom
-- Additional effect: Fires a mushroom cap, dealing damage to a single target. Additional effect: paralysis.
-- Range is 14.7 yalms.
-- Piercing damage Ranged Attack.
-- Secondary modifiers: INT: 20%.
---------------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------------
function onMobSkillCheck(target,mob,skill)
if(mob:getMobMod(MOBMOD_VAR) == 1) then
return 0;
end
return 1;
end;
function onMobWeaponSkill(target, mob, skill)
mob:setMobMod(MOBMOD_VAR, 2);
local numhits = 1;
local accmod = 1;
local dmgmod = 2;
local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,TP_DMG_VARIES,1,2,3);
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_PHYSICAL,MOBPARAM_PIERCE,info.hitslanded);
local typeEffect = EFFECT_PARALYSIS;
MobPhysicalStatusEffectMove(mob, target, skill, typeEffect, 35, 0, 180);
target:delHP(dmg);
return dmg;
end;
| gpl-3.0 |
kitala1/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Nadeey.lua | 34 | 1031 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Nadeey
-- Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x00FB);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
dangerrr/dangerrr | plugins/stats.lua | 1 | 4134 | do
-- Returns a table with `name` and `msgs`
local function get_msgs_user_chat(user_id, chat_id)
local user_info = {}
local uhash = 'user:'..user_id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..user_id..':'..chat_id
user_info.msgs = tonumber(redis:get(um_hash) or 0)
user_info.name = user_print_name(user)..' ['..user_id..']'
return user_info
end
local function chat_stats(chat_id)
-- Users on chat
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = get_msgs_user_chat(user_id, chat_id)
table.insert(users_info, user_info)
end
-- Sort users by msgs number
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = 'users in this chat \n'
for k,user in pairs(users_info) do
text = text..user.name..' = '..user.msgs..'\n'
end
local file = io.open("./groups/lists/"..chat_id.."stats.txt", "w")
file:write(text)
file:flush()
file:close()
send_document("chat#id"..chat_id,"./groups/lists/"..chat_id.."stats.txt", ok_cb, false)
return --text
end
local function chat_stats2(chat_id)
-- Users on chat
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = get_msgs_user_chat(user_id, chat_id)
table.insert(users_info, user_info)
end
-- Sort users by msgs number
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = 'users in this chat \n'
for k,user in pairs(users_info) do
text = text..user.name..' = '..user.msgs..'\n'
end
return text
end
-- Save stats, ban user
local function bot_stats()
local redis_scan = [[
local cursor = '0'
local count = 0
repeat
local r = redis.call("SCAN", cursor, "MATCH", KEYS[1])
cursor = r[1]
count = count + #r[2]
until cursor == '0'
return count]]
-- Users
local hash = 'msgs:*:'..our_id
local r = redis:eval(redis_scan, 1, hash)
local text = 'Users: '..r
hash = 'chat:*:users'
r = redis:eval(redis_scan, 1, hash)
text = text..'\nGroups: '..r
return text
end
local function run(msg, matches)
if matches[1]:lower() == 'creedbot' then -- Put everything you like :)
local about = _config.about_text
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] used /creedbot ")
return about
end
if matches[1]:lower() == "statslist" then
if not is_momod(msg) then
return "For mods only !"
end
local chat_id = msg.to.id
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested group stats ")
return chat_stats2(chat_id)
end
if matches[1]:lower() == "stats" then
if not matches[2] then
if not is_momod(msg) then
return "For mods only !"
end
if msg.to.type == 'chat' then
local chat_id = msg.to.id
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested group stats ")
return chat_stats(chat_id)
else
return
end
end
if matches[2] == "creedbot" then -- Put everything you like :)
if not is_admin(msg) then
return "For admins only !"
else
return bot_stats()
end
end
if matches[2] == "group" then
if not is_admin(msg) then
return "For admins only !"
else
return chat_stats(matches[3])
end
end
end
end
return {
patterns = {
"^[!/]([Ss]tats)$",
"^[!/]([Ss]tatslist)$",
"^[!/]([Ss]tats) (group) (%d+)",
"^[!/]([Ss]tats) (bot)",-- Put everything you like :)
"^[!/](bot)"-- Put everything you like :)
},
run = run
}
end | gpl-2.0 |
kitala1/darkstar | scripts/globals/items/seafood_stewpot.lua | 36 | 1391 | -----------------------------------------
-- ID: 5238
-- Item: Seafood Stewpot
-- Food Effect: 3 Hrs, All Races
-----------------------------------------
-- TODO: Group Effect
-- HP +10% Cap 50
-- MP +10
-- Accuracy 5
-- Evasion 5
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
result = 0
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,10800,5238);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_FOOD_HPP, 10);
target:addMod(MOD_FOOD_HP_CAP, 50);
target:addMod(MOD_MP, 10);
target:addMod(MOD_ACC, 5);
target:addMod(MOD_EVA, 5);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_FOOD_HPP, 10);
target:delMod(MOD_FOOD_HP_CAP, 50);
target:delMod(MOD_MP, 10);
target:delMod(MOD_ACC, 5);
target:delMod(MOD_EVA, 5);
end;
| gpl-3.0 |
mamadtnt/edit- | bot/Mamad.lua | 1 | 20219 | package.path = package.path .. ';.luarocks/share/lua/5.2/?.lua'
..';.luarocks/share/lua/5.2/?/init.lua'
package.cpath = package.cpath .. ';.luarocks/lib/lua/5.2/?.so'
require("./bot/utils")
VERSION = '1.0'
-- This function is called when tg receive a msg
function on_msg_receive (msg)
if not started then
return
end
local receiver = get_receiver(msg)
print (receiver)
--vardump(msg)
msg = pre_process_service_msg(msg)
if msg_valid(msg) then
msg = pre_process_msg(msg)
if msg then
match_plugins(msg)
-- mark_read(receiver, ok_cb, false)
end
end
end
function ok_cb(extra, success, result)
end
function on_binlog_replay_end()
started = true
postpone (cron_plugins, false, 60*5.0)
_config = load_config()
-- load plugins
plugins = {}
load_plugins()
end
function msg_valid(msg)
-- Don't process outgoing messages
if msg.out then
print('\27[36mNot valid: msg from us\27[39m')
return false
end
-- Before bot was started
if msg.date < now then
print('\27[36mNot valid: old msg\27[39m')
return false
end
if msg.unread == 0 then
print('\27[36mNot valid: readed\27[39m')
return false
end
if not msg.to.id then
print('\27[36mNot valid: To id not provided\27[39m')
return false
end
if not msg.from.id then
print('\27[36mNot valid: From id not provided\27[39m')
return false
end
if msg.from.id == our_id then
print('\27[36mNot valid: Msg from our id\27[39m')
return false
end
if msg.to.type == 'encr_chat' then
print('\27[36mNot valid: Encrypted chat\27[39m')
return false
end
if msg.from.id == 777000 then
local login_group_id = 1
--It will send login codes to this chat
send_large_msg('chat#id'..login_group_id, msg.text)
end
return true
end
--
function pre_process_service_msg(msg)
if msg.service then
local action = msg.action or {type=""}
-- Double ! to discriminate of normal actions
msg.text = "!!tgservice " .. action.type
-- wipe the data to allow the bot to read service messages
if msg.out then
msg.out = false
end
if msg.from.id == our_id then
msg.from.id = 0
end
end
return msg
end
-- Apply plugin.pre_process function
function pre_process_msg(msg)
for name,plugin in pairs(plugins) do
if plugin.pre_process and msg then
print('Preprocess', name)
msg = plugin.pre_process(msg)
end
end
return msg
end
-- Go over enabled plugins patterns.
function match_plugins(msg)
for name, plugin in pairs(plugins) do
match_plugin(plugin, name, msg)
end
end
-- Check if plugin is on _config.disabled_plugin_on_chat table
local function is_plugin_disabled_on_chat(plugin_name, receiver)
local disabled_chats = _config.disabled_plugin_on_chat
-- Table exists and chat has disabled plugins
if disabled_chats and disabled_chats[receiver] then
-- Checks if plugin is disabled on this chat
for disabled_plugin,disabled in pairs(disabled_chats[receiver]) do
if disabled_plugin == plugin_name and disabled then
local warning = 'Plugin '..disabled_plugin..' is disabled on this chat'
print(warning)
send_msg(receiver, warning, ok_cb, false)
return true
end
end
end
return false
end
function match_plugin(plugin, plugin_name, msg)
local receiver = get_receiver(msg)
-- Go over patterns. If one matches it's enough.
for k, pattern in pairs(plugin.patterns) do
local matches = match_pattern(pattern, msg.text)
if matches then
print("msg matches: ", pattern)
if is_plugin_disabled_on_chat(plugin_name, receiver) then
return nil
end
-- Function exists
if plugin.run then
-- If plugin is for privileged users only
if not warns_user_not_allowed(plugin, msg) then
local result = plugin.run(msg, matches)
if result then
send_large_msg(receiver, result)
end
end
end
-- One patterns matches
return
end
end
end
-- DEPRECATED, use send_large_msg(destination, text)
function _send_msg(destination, text)
send_large_msg(destination, text)
end
-- Save the content of _config to config.lua
function save_config( )
serialize_to_file(_config, './data/config.lua')
print ('saved config into ./data/config.lua')
end
-- Returns the config from config.lua file.
-- If file doesn't exist, create it.
function load_config( )
local f = io.open('./data/config.lua', "r")
-- If config.lua doesn't exist
if not f then
print ("Created new config file: data/config.lua")
create_config()
else
f:close()
end
local config = loadfile ("./data/config.lua")()
for v,user in pairs(config.sudo_users) do
print("Allowed user: " .. user)
end
return config
end
-- Create a basic config.json file and saves it.
function create_config( )
-- A simple config with basic plugins and ourselves as privileged user
config = {
enabled_plugins = {
"onservice",
"inrealm",
"ingroup",
"inpm",
"banhammer",
"phototosticker",
"tophoto",
"feedback",
"lock_join",
"antilink",
"antitag",
"gps",
"wiki",
"auto_leave",
"tagall",
"arabic_lock",
"welcome",
"google",
"sudoers",
"info",
"add_admin",
"anti_spam",
"owners",
"set",
"get",
"broadcast",
"download_media",
"invite",
"all",
"leave_ban"
},
sudo_users = {83829432},--Sudo users
disabled_channels = {},
moderation = {data = 'data/moderation.json'},
about_text = [[mamad bot 2.3
Hello my Good friends
‼️ this bot is made by : @mohammad_taravat
〰〰〰〰〰〰〰
〰〰〰〰〰〰〰
♻️ You can send your Ideas and messages to Us By sending them into bots account by this command :
تمامی درخواست ها و همه ی انتقادات و حرفاتونو با دستور زیر بفرستین به ما
!feedback (your ideas and messages)
]],
help_text_realm = [[
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
⛔️برای ادمین ها :
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
🔰 صلب مسدود از همه :
🔹 برای دراوردن شخص از حالت مسدودیت از همه ی گروه ها .
------------------------------------------------------------------------------------------------------------
🔰 لیست مسدود از همه :
🔹 برای دیدن افرادی که از همه ی گروه های ربات مسدود هستند
------------------------------------------------------------------------------------------------------------
🔰 خواندن (روشن/خاموش) :
🔹 برای تیک خوردن پیاماتون توی گروه با خواندن ربات و برعکس .
------------------------------------------------------------------------------------------------------------
🔰 لیست مکالمه :
🔹 برای دیدن آخرین پیام هر کس در گروه و گرفتن لیست مکالمه ها در گروه استفاده میشود
------------------------------------------------------------------------------------------------------------
🔰 حذف مخاطب :
🔹 برای حذف کردن مخاطب از مخاطبان ربات استفاده میشود.
------------------------------------------------------------------------------------------------------------
🔰 تنظیم عکس ربات :
🔹 برای تغییر عکس ربات استفاده میشود ( فقط عکس قبلی سرجاش میمونه)
------------------------------------------------------------------------------------------------------------
🔰 مخاطبان :
🔹 لیست مخاطبان ربات را ارسال میکند .
------------------------------------------------------------------------------------------------------------
🔰 پیام به (ای دی) (پیام) :
🔹 ارسال پیام مورد نظر شما به شخصی توطی ای دیش
------------------------------------------------------------------------------------------------------------
🔰 (بلاک/آنبلاک) (ای دی) :
🔹 برای (بلاک/آنبلاک) کردن شخصی استفاده میشود
------------------------------------------------------------------------------------------------------------
🔰 کیست (ای دی ) :
🔹 مالک ای دی داده شده را خواهد داد
------------------------------------------------------------------------------------------------------------
🔰 ساخت ریلم/گروه ( اسم گروه /ریلم) :
🔹 برای ساختن گروه یا ریلم با اسم ساخته میشود .
------------------------------------------------------------------------------------------------------------
🔰 نصب [ اسم / قوانین / توضیحات] (ای دی گروه) (اسم گروه) :
🔹 برای نصب [ اسم / قوانین / توضیحات] گروهی که در آن نیستید از ریلم استفاده میشود
------------------------------------------------------------------------------------------------------------
🔰 (قفل/بازکردن) (ای دی گروه ) [ استیکر/اسم/ورود/عکس/اسپم/فارسی/تبلیغ/انگلیسی/فحش/تگ/خروج/ربات ]
🔹 برای قفلکردن یا بازکردن تنظیمات یک گروه استفاده میشود
------------------------------------------------------------------------------------------------------------
🔰 تنظیمات (ای دی گروه) :
🔹 برای مشاهده ی تنظیمات گروهی استفاده میشود
------------------------------------------------------------------------------------------------------------
🔰 حذف (گروه/ریلم) (ای دی گروه/ریلم) :
🔹 برای حذف کردن اعضا و گروهی به کلی از گروه ریلم
------------------------------------------------------------------------------------------------------------
🔰 (نصب/صلب) ادمین :
🔹 برای اضافه کردن ادمینی و یا صلب مقامش استفاده میشود
------------------------------------------------------------------------------------------------------------
🔰 راهنما :
🔹 لیست دستورات رو بهتون متناسب با گروه یا ریلم بودن میده
------------------------------------------------------------------------------------------------------------
🔰 لیست اعضا :
🔹 برای مشاهده ی لیست اعضاش گروه استفاده میشود
------------------------------------------------------------------------------------------------------------
🔰 اعضا :
🔹 برای دریافت فایل اعضای گروه استفاده میشود
------------------------------------------------------------------------------------------------------------
🔰 لیست (ریلم ها/گروه ها/ادمین ها) :
🔹 برای دریافت لیست (ریلم ها/گروه ها/ادمین ها) استفاده میشود
------------------------------------------------------------------------------------------------------------
🔰 تاریخچه :
🔹 برای دیدن تارخچه ی عملیات گروه استفاده میشود
------------------------------------------------------------------------------------------------------------
🔰 جوین (لینک) :
🔹 برای جوین دادن به گروه یا کانال یا . توسط لینک
------------------------------------------------------------------------------------------------------------
🔰 گروه ها :
🔹 لیست گروه های ربات
------------------------------------------------------------------------------------------------------------
🔰 لیست گروه :
🔹 ارسال گروه ها در فایل متنی .
------------------------------------------------------------------------------------------------------------
کانال ما : @Pro_Programing
اعضای اصلی ما :
@Arsalan_Sahel [سازنده]
@Bad00boy_Creed [عضو اصلی ]
@Creed_aria [عضو اصلی]
@AmirCc_CreeD [عضو اصلی]
]],
help_text = [[
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
⛔️دستورات اداره ی گروه⛔️
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
🔰 نصب مقام ( مقام ) :
🔹 برای تعلق دادن مقام مورد نظر به شخص مورد نظر با ریپلی
------------------------------------------------------------------------------------------------------------
🔰 اطلاعات ( ای دی/نام کاربری) :
🔹 برای مشاهده ی اطلاعات شخص مورد نظر ( با ریپلی هم میشه )
------------------------------------------------------------------------------------------------------------
🔰 لیست مسدودان :
🔹 برای مشاهده ی لیست افراد مسدود شده ی گروه
------------------------------------------------------------------------------------------------------------
🔰 صلب مسدود :
🔹 برای دراوردن شخص از مسدودیت گروه
------------------------------------------------------------------------------------------------------------
🔰 مسدود :
🔹 برای مسدود کردن شخص از گروه تا دیگه نتونه بیاد
------------------------------------------------------------------------------------------------------------
🔰 اخراج :
🔹 برای اخراج کردن شخص از گروه استفاده میشود ( با ریپلی هم میشه )
------------------------------------------------------------------------------------------------------------
🔰 (نصب/صلب) :
🔹 برای (اضافه/حذف) کردن گروه (به/از) گروه های ربات.
------------------------------------------------------------------------------------------------------------
🔰 (نصب/صلب) ریلم :
🔹 برای (اضافه/حذف) کردن ریلم (به/از) ریلم های ربات.
------------------------------------------------------------------------------------------------------------
🔰 (قوانین/توضیحات) :
🔹 برای دیدن (قوانین/توضیحات) گروه استفاده میشود.
------------------------------------------------------------------------------------------------------------
🔰 نصب (عکس/اسم) :
🔹 برای تعویض یا گذاشتن (عکس/اسم) گروه استفاده میشود.
------------------------------------------------------------------------------------------------------------
🔰 ارتقا :
🔹 برای ارتقا دادن شخصی به عنوان مدیر ( با ریپلی هم میشه )
------------------------------------------------------------------------------------------------------------
🔰 پاک کردن (قوانین/لیست مدیران/توضیحات) :
🔹 برای پاک کردن (قوانین/لیست مدیران/توضیحات) گروهتان استفاده میشود.
------------------------------------------------------------------------------------------------------------
🔰 حذف مدیر :
🔹 برای حذف کردن مدیریت یکی از مدیران ( با ریپلی هم میشه )
------------------------------------------------------------------------------------------------------------
🔰 تنظیم (قوانین/توضیحات) :
🔹 برای تنظیم کردن (قوانین/توضیحات) برای گروه .
------------------------------------------------------------------------------------------------------------
🔰 (قفل/باز کردن) [همه/استیکر/اسم/ورود/عکس/اسپم/فارسی/تبلیغ/انگلیسی/فحش/تگ/خروج/ربات]
🔹 برای بازکردن یا قفل [همه/استیکر/اسم/ورود/عکس/اسپم/فارسی/تبلیغ/انگلیسی/فحش/تگ/خروج/ربات] در گروه استفاده میشود .
------------------------------------------------------------------------------------------------------------
🔰 نصب مالک :
🔹 برای ارقای شخصی به عنوان مالک (سازنده) گروه استفاده میشود.
------------------------------------------------------------------------------------------------------------
🔰 در مورد (نام کاربری) :
🔹 برای دادن ای دی و اسم شخص استفاده میشود.
------------------------------------------------------------------------------------------------------------
🔰 حساسیت (عدد) :
🔹 برای تنظیم حساسیت ربات به اسپم به تعدادی که میدهیم.
------------------------------------------------------------------------------------------------------------
🔰 تنظیمات :
🔹 برای مشاهده ی تنظیمات گروه .
------------------------------------------------------------------------------------------------------------
🔰 لیست مدیران :
🔹 برای دیدن لیست مدیران استفاده میشود.
------------------------------------------------------------------------------------------------------------
🔰 لینک :
🔹 برای دریافت لینک گروه استفاده میشود.
------------------------------------------------------------------------------------------------------------
🔰 لینک جدید :
🔹 برای دریافت لینک جدید گروه استفاده میشود.
------------------------------------------------------------------------------------------------------------
🔰 اخراج غیر فعال :
🔹 برای اخراج کردن غیر فعال ها استفاده میشود .
------------------------------------------------------------------------------------------------------------
🔰 ای دی :
🔹 فقط با ریپلی میتوانید از این دستور برای ای دی گرفتن شخصی استفاده کنید
------------------------------------------------------------------------------------------------------------
نکته !!!! : با دستور *اخراجم کن* میتوانید از گروه بروید .
------------------------------------------------------------------------------------------------------------
]],
}
serialize_to_file(config, './data/config.lua')
print('saved config into ./data/config.lua')
end
function on_our_id (id)
our_id = id
end
function on_user_update (user, what)
--vardump (user)
end
function on_chat_update (chat, what)
end
function on_secret_chat_update (schat, what)
--vardump (schat)
end
function on_get_difference_end ()
end
-- Enable plugins in config.json
function load_plugins()
for k, v in pairs(_config.enabled_plugins) do
print("Loading plugin", v)
local ok, err = pcall(function()
local t = loadfile("plugins/"..v..'.lua')()
plugins[v] = t
end)
if not ok then
print('\27[31mError loading plugin '..v..'\27[39m')
print('\27[31m'..err..'\27[39m')
end
end
end
-- custom add
function load_data(filename)
local f = io.open(filename)
if not f then
return {}
end
local s = f:read('*all')
f:close()
local data = JSON.decode(s)
return data
end
function save_data(filename, data)
local s = JSON.encode(data)
local f = io.open(filename, 'w')
f:write(s)
f:close()
end
-- Call and postpone execution for cron plugins
function cron_plugins()
for name, plugin in pairs(plugins) do
-- Only plugins with cron function
if plugin.cron ~= nil then
plugin.cron()
end
end
-- Called again in 2 mins
postpone (cron_plugins, false, 120)
end
-- Start and load values
our_id = 0
now = os.time()
math.randomseed(now)
started = false
| gpl-2.0 |
Taracque/epgp | localization/localization.deDE.lua | 1 | 13110 | local L = LibStub("AceLocale-3.0"):NewLocale("EPGP", "deDE")
if not L then return end
L["Alts"] = "Twinks"
L["A member is awarded EP"] = "Ein Mitglied hat EP erhalten"
L["A member is credited GP"] = "Einen Mitglied wurden GP angerechnet"
L["A new tier is here! You should probably reset or rescale GP (Interface -> Options -> AddOns -> EPGP)!"] = "Es gibt eine neue Ausrüstungsstufe! Du solltet vielleicht alle GP-Werte zurücksetzen oder neu skalieren (Interface -> Optionen -> AddOns -> EPGP)!"
L["An item was disenchanted or deposited into the guild bank"] = "Ein Gegenstand wurde entzaubert oder in die Gildenbank gelegt"
L["Announce"] = "Ankündigen"
L["Announce medium"] = "Ankündigungsmedium"
L["Announcement of EPGP actions"] = "Bekanntgabe von EPGP-Aktionen"
L["Announces EPGP actions to the specified medium."] = "Gibt EPGP-Aktionen an das angegebene Medium aus."
L["Announce when:"] = "Ankündigen wenn:"
L["Automatic boss tracking"] = "Automatisches Boss-Tracking"
L["Automatic boss tracking by means of a popup to mass award EP to the raid and standby when a boss is killed."] = "Automatisches Boss-Tracking bedeutet, daß nach einem Bosskill ein Popup erscheint, wo EP an alle im Schlachtzug und auf der Bereitschaftsliste vergeben werden kann"
L["Automatic handling of the standby list through whispers when in raid. When this is enabled, the standby list is cleared after each reward."] = "Automatisches Verwalten der Bereitschaftsliste durch Anflüstern im Schlachtzug. Ist diese Option aktiviert, wird die Bereitschaftsliste bei jeder Belohnungsvergabe gelöscht." -- Needs review
L["Automatic loot tracking"] = "Automatische Beuteverfolgung"
L["Automatic loot tracking by means of a popup to assign GP to the toon that received loot. This option only has effect if you are in a raid and you are either the Raid Leader or the Master Looter."] = "Automatisches Loot-Tracking bedeutet, es erscheint ein Popup zur Vergabe von GP an den, der den Loot erhalten hat. Diese Option ist nur in einem Raid aktiv, und nur, wenn du Raidleader oder Plündermeister bist."
L["Award EP"] = "Vergib EP"
L["Awards for wipes on bosses. Requires DBM, DXE, or BigWigs"] = "Belohnungen für Wipes bei Bossen. Benötigt DBM, DXE oder BigWigs."
L["Base GP should be a positive number"] = "Die Basis GP sollten eine positive Nummer sein"
L["Boss"] = "Boss"
L["Credit GP"] = "Vergib GP"
L["Credit GP to %s"] = "Vergib GP an %s"
L["Custom announce channel name"] = "Benutzerdefinierter Nachrichtenkanal"
L["Decay"] = "Wertverfall"
L["Decay EP and GP by %d%%?"] = "EP und GP um %d%% verringern?"
L["Decay of EP/GP by %d%%"] = "Verfall von EP/GP um %d%%"
L["Decay Percent should be a number between 0 and 100"] = "Der Wert des Wertverfalls muss zwischen 0 und 100 liegen"
L["Decay=%s%% BaseGP=%s MinEP=%s Extras=%s%%"] = "Verfall=%s%% GrundGP=%s MinEP=%s Extras=%s%%"
L["default"] = "Standard"
L["%+d EP (%s) to %s"] = "%+d EP (%s) gehen an %s"
L["%+d GP (%s) to %s"] = "%+d GP (%s) gehen an %s"
L["%d or %d"] = "%d oder %d"
L["Do you want to resume recurring award (%s) %d EP/%s?"] = "Soll mit der Vergabe der Beute (%s) für %d EP/%s weitergemacht werden?"
L["EP/GP are reset"] = "EP/GP wurden zurückgesetzt"
L["EPGP decay"] = "EPGP Verfall"
L["EPGP is an in game, relational loot distribution system"] = "EPGP ist ein relationales Lootverteilungssystem, welches im Spiel verwaltet wird" -- Needs review
L["EPGP is using Officer Notes for data storage. Do you really want to edit the Officer Note by hand?"] = "EPGP benutzt Offiziersnotizen zum Speichern von Daten. Willst du wirklich die Offiziersnotiz bearbeiten?"
L["EPGP reset"] = "EPGP zurücksetzen"
L["EP Reason"] = "EP Grund"
L["expected number"] = "Nummer erwartet"
L["Export"] = "Exportieren"
L["Extras Percent should be a number between 0 and 100"] = "Der Extras-Prozentwert sollte eine Nummer zwischen 0 und 100 sein" -- Needs review
L["GP: %d"] = "GP: %d"
L["GP: %d or %d"] = "GP: %d oder %d"
L["GP is rescaled for the new tier"] = "GP wurden für die neue Ausrüstungsstufe umskaliert"
L["GP (not EP) is reset"] = "GP (nicht EP) wurden zurückgesetzt"
L["GP (not ep) reset"] = "GP (nicht EP) zurücksetzen"
L["GP on tooltips"] = "GP in Tooltips"
L["GP Reason"] = "GP Grund"
L["GP rescale for new tier"] = "GP Umskalierung für neue Ausrüstungsstufe"
L["Guild or Raid are awarded EP"] = "Gilde oder Schlachtzug bekommen EP"
L["Hint: You can open these options by typing /epgp config"] = "Hinweis: Du kannst die Einstellungen mit dem Befehl \"/epgp config\" aufrufen."
L["Idle"] = "Untätig"
L["If you want to be on the award list but you are not in the raid, you need to whisper me: 'epgp standby' or 'epgp standby <name>' where <name> is the toon that should receive awards"] = "Wenn du auf der Bereitschaftsliste sein möchtest, aber nicht im Schlachtzug dabei bist, mußt du mich mit folgendem Text anflüstern: \"epgp standby\" oder \"epgp standby <name>\" wobei <name> der Charakter ist welche die Belohnungen erhalten soll"
L["Ignoring EP change for unknown member %s"] = "Ignoriere EP-Änderung für das unbekannte Mitglied %s"
L["Ignoring GP change for unknown member %s"] = "Ignoriere GP-Änderung für das unbekannte Mitglied %s"
L["Import"] = "Importieren"
L["Importing data snapshot taken at: %s"] = "Importiere Schnappschuß vom: %s"
L["invalid input"] = "Fehlerhafte Eingabe"
L["Invalid officer note [%s] for %s (ignored)"] = "Ungültige Offiziersnotiz [%s] für %s (ignoriert)"
L["List errors"] = "Fehler anzeigen"
L["Lists errors during officer note parsing to the default chat frame. Examples are members with an invalid officer note."] = "Zeige Fehler beim Verarbeiten der Offiziersnotizen im Standard Chatfenster. Zum Beispiel: Mitglieder mit ungültigen Offiziersnotizen." -- Needs review
L["Loot"] = "Beute"
L["Loot tracking threshold"] = "Loot-Tracking-Grenzwert" -- Needs review
L["Make sure you are the only person changing EP and GP. If you have multiple people changing EP and GP at the same time, for example one awarding EP and another crediting GP, you *are* going to have data loss."] = "Stelle bitte sicher, dass Du der Einzige bist, der gerade EP und GP verändert. Wenn mehrere Personen EP und GP zur gleichen Zeit verändern, zum Beispiel jemand vergibt gerade EP und jemand anderes schreibt gerade GP gut, wird es zu Datenverlust kommen." -- Needs review
L["Mass EP Award"] = "Massenvergabe von EP"
L["Min EP should be a positive number"] = "Min EP sollte eine positive Nummer sein"
L["must be equal to or higher than %s"] = "Muss gleich oder höher sein als %s"
L["must be equal to or lower than %s"] = "Muss gleich oder niedriger sein als %s"
L["Next award in "] = "Nächste Belohnung in"
L["off"] = "Deaktiviert"
L["on"] = "Aktiviert"
L["Only display GP values for items at or above this quality."] = "Zeige GP-Werte nur für Gegenstände dieser oder höherer Qualität."
L["Open the configuration options"] = "Einstellungen öffnen"
L["Open the debug window"] = "Debug-Fenster öffnen"
L["Other"] = "Anderes"
L["Outsiders should be 0 or 1"] = "Außenstehende (Outsiders) sollte 0 oder 1 sein."
L["Paste import data here"] = "Füge Daten zum Importieren hier ein" -- Needs review
L["Personal Action Log"] = "Persönliches Aktionslog"
L["Provide a proposed GP value of armor on tooltips. Quest items or tokens that can be traded for armor will also have a proposed GP value."] = "Gibt einen GP-Vorschlag in den Tooltips an. Questitems oder handelbare Set-Tokens werden auch einen GP-Vorschlag enthalten."
L["Quality threshold"] = "Qualitätsschwelle"
L["Recurring"] = "Wiederkehrend"
L["Recurring awards resume"] = "Wiederkehrende Belohnung fortsetzen"
L["Recurring awards start"] = "Wiederkehrende Belohnungen starten"
L["Recurring awards stop"] = "Wiederkehrende Belohnungen stoppen"
L["Redo"] = "Erneut ausführen"
L["Re-scale all main toons' GP to current tier?"] = "Alle GP Werte der Hauptcharaktere umskalieren?"
L["Rescale GP"] = "GP Umskalieren"
L["Rescale GP of all members of the guild. This will reduce all main toons' GP by a tier worth of value. Use with care!"] = "Umskalieren der GP aller Gildenmitglieder. Dies wird die GP aller Hauptcharaktere um den Wert einer Ausrüstungsstufe verringern. Mit Vorsicht verwenden!"
L["Reset all main toons' EP and GP to 0?"] = "EP und GP aller Hauptcharaktere auf 0 zurücksetzen?"
L["Reset all main toons' GP to 0?"] = "GP aller Hauptcharaktere auf 0 zurücksetzen?"
L["Reset EPGP"] = "EPGP zurücksetzen"
L["Reset only GP"] = "Nur GP zurücksetzen"
L["Resets EP and GP of all members of the guild. This will set all main toons' EP and GP to 0. Use with care!"] = "Zurücksetzen der EP und GP Werte aller Gildenmitglieder. Dies wird die EP und GP aller Hauptcharaktere auf 0 zurücksetzen. Mit Vorsicht verwenden!"
L["Resets GP (not EP!) of all members of the guild. This will set all main toons' GP to 0. Use with care!"] = "Setzt die GP (nicht EP!) aller Gildenmitglieder zurück. Dies wird die GP aller Hauptcharaktere auf 0 zurücksetzen. Mit Vorsicht verwenden!"
L["Resume recurring award (%s) %d EP/%s"] = "Wiederkehrende Belohnung fortsetzen (%s) für %d EP/%s"
L["%s: %+d EP (%s) to %s"] = "%s: %+d EP (%s) an %s"
L["%s: %+d GP (%s) to %s"] = "%s: %+d GP (%s) an %s"
L["Sets loot tracking threshold, to disable the popup on loot below this threshold quality."] = "Setzt den Loot-Tracking-Grenzwert, um das Popup für Loot unterhalb dieser Itemqualität zu deaktivieren." -- Needs review
L["Sets the announce medium EPGP will use to announce EPGP actions."] = "Wählt das Medium, welches EPGP verwendet um EPGP Aktionen anzukündigen" -- Needs review
L["Sets the custom announce channel name used to announce EPGP actions."] = "Wählt den Namen des selbst gewählten Chatkanals um EPGP Aktionen anzukündigen."
L["'%s' - expected 'on', 'off' or 'default', or no argument to toggle."] = "'%s' - \"on\", \"off\" oder \"default\" erwartet, oder kein Parameter zum Umschalten." -- Needs review
L["'%s' - expected 'on' or 'off', or no argument to toggle."] = "'%s' - \"on\" oder \"off\" erwartet, oder kein Parameter zum Umschalten." -- Needs review
L["'%s' - expected 'RRGGBBAA' or 'r g b a'."] = "'%s' - erwartet 'RRGGBBAA' oder 'r g b a'."
L["'%s' - expected 'RRGGBB' or 'r g b'."] = "'%s' - erwartet 'RRGGBB' oder 'r g b'."
L["Show everyone"] = "Zeige Alle"
L["'%s' - Invalid Keybinding."] = "'%s' - Ungültige Tastenbelegung"
L["%s is added to the award list"] = "%s wurde der Belohnungsliste hinzugefügt"
L["%s is already in the award list"] = "%s gehört bereits der Belohnungsliste an"
L["%s is dead. Award EP?"] = "%s ist tot. Mit EP belohnen?"
L["%s is not eligible for EP awards"] = "%s ist nicht für EP Belohnungen geeignet" -- Needs review
L["%s is now removed from the award list"] = "%s wurde von der Belohnungsliste entfernt"
L["Some english word"] = "Ein zufälliges Wort"
L["Some english word that doesn't exist"] = "Ein zufälliges Wort welches nicht existiert"
L["'%s' '%s' - expected 'on', 'off' or 'default', or no argument to toggle."] = "'%s' '%s' - \"on\", \"off\" oder \"default\" erwartet, oder kein Parameter zum Umschalten." -- Needs review
L["'%s' '%s' - expected 'on' or 'off', or no argument to toggle."] = "'%s' '%s' - \"on\" oder \"off\" erwartet, oder kein Parameter zum Umschalten." -- Needs review
L["%s: %s to %s"] = "%s: %s an %s"
L["Standby"] = "Bereitschaftsliste"
L["Standby whispers in raid"] = "Flüstern für Bereitschaftsliste im Schlachtzug"
L["Start recurring award (%s) %d EP/%s"] = "Starte wiederkehrende Belohnung (%s) %d EP/%s"
L["Stop recurring award"] = "Stoppe wiederkehrende Belohnung"
L["%s to %s"] = "%s an %s"
L["string1"] = "Zeichenkette1"
L["'%s' - values must all be either in the range 0-1 or 0-255."] = "'%s' - Alle Werte müssen innerhalb von 0-1 oder 0-255 liegen."
L["'%s' - values must all be either in the range 0..1 or 0..255."] = "'%s' - Alle Werte müssen innerhalb von 0..1 oder 0..255 liegen."
L["The imported data is invalid"] = "Die importierten Daten sind ungültig"
L["To export the current standings, copy the text below and post it to: %s"] = "Um die aktuellen Werte zu exportieren, kopiere den Text von unten und füge ihn hier ein: %s" -- Needs review
L["Tooltip"] = "Tooltip"
L["To restore to an earlier version of the standings, copy and paste the text from: %s"] = "Um einen früheren Stand der Werte wiederherzustellen, kopiere den Text von %s und füge ihn hier ein:" -- Needs review
L["Undo"] = "Rückgängig machen"
L["unknown argument"] = "Unbekanntes Argument"
L["unknown selection"] = "Unbekannte Auswahl"
L["Using %s for boss kill tracking"] = "%s zeichnet die Bosskills auf." -- Needs review
L["Value"] = "Wert"
L["Whisper"] = "Flüstern"
L["Wipe awards"] = "Wipe Belohnungen"
L["Wiped on %s. Award EP?"] = "Wipe bei %s. EP Verteilen?"
L["You can now check your epgp standings and loot on the web: http://www.epgpweb.com"] = "Du kannst deine EPGP-Werte und die Beute jetzt auch im Internet sehen: http://www.epgpweb.com"
| bsd-3-clause |
Roblox/Core-Scripts | PlayerScripts/StarterPlayerScripts_NewStructure/RobloxPlayerScript/CameraScript.lua | 1 | 21538 | --[[
CameraScript - This module manages the selection of the current camera control module,
character occlusion module, and transparency controller. This script binds to
RenderStepped at Camera priority and calls the Update() methods on the active camera
control module, character occlusion module, and character transparency controller.
Camera control modules are instantiated and activated as-needed, they are no longer all
instantiated up front.
2018 PlayerScripts Update - AllYourBlox
--]]
local CameraScript = {}
-- NOTICE: Player property names do not all match their StarterPlayer equivalents,
-- with the differences noted in the comments on the right
local PLAYER_CAMERA_PROPERTIES =
{
"CameraMinZoomDistance",
"CameraMaxZoomDistance",
"CameraMode",
"DevCameraOcclusionMode",
"DevComputerCameraMode", -- Corresponds to StarterPlayer.DevComputerCameraMovementMode
"DevTouchCameraMode", -- Corresponds to StarterPlayer.DevTouchCameraMovementMode
-- Character movement mode
"DevComputerMovementMode",
"DevTouchMovementMode",
"DevEnableMouseLock", -- Corresponds to StarterPlayer.EnableMouseLockOption
}
local USER_GAME_SETTINGS_PROPERTIES =
{
"ComputerCameraMovementMode",
"ComputerMovementMode",
"ControlMode",
"GamepadCameraSensitivity",
"MouseSensitivity",
"RotationType",
"TouchCameraMovementMode",
"TouchMovementMode",
}
--[[ Roblox Services ]]--
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local StarterPlayer = game:GetService("StarterPlayer")
local UserGameSettings = UserSettings():GetService("UserGameSettings")
-- Camera math utility library
local CameraUtils = require(script:WaitForChild("CameraUtils"))
-- Load camera modules (Note: each returns a new() constructor function but does not instantiate a controller)
local ClassicCamera = require(script:WaitForChild("ClassicCamera"))
local OrbitalCamera = require(script:WaitForChild("OrbitalCamera"))
local LegacyCamera = require(script:WaitForChild("LegacyCamera"))
-- Load character-occlusion modules
local Invisicam = require(script:WaitForChild("Invisicam"))
local Poppercam do
local success, useNewPoppercam = pcall(UserSettings().IsUserFeatureEnabled, UserSettings(), "UserNewPoppercam")
if success and useNewPoppercam then
Poppercam = require(script:WaitForChild("Poppercam"))
else
Poppercam = require(script:WaitForChild("Poppercam_Classic"))
end
end
-- Load the near-field character transparency controller
local TransparencyController = require(script:WaitForChild("TransparencyController"))
local MouseLockController = require(script:WaitForChild("MouseLockController"))
-- Table of camera controllers that have been instantiated as needed
local instantiatedCameraControllers = {}
local instantiatedOcclusionModules = {}
-- Management of which options appear on the Roblox User Settings screen
do
local PlayerScripts = Players.LocalPlayer:WaitForChild("PlayerScripts")
local canRegisterCameras = pcall(function() PlayerScripts:RegisterTouchCameraMovementMode(Enum.TouchCameraMovementMode.Default) end)
if canRegisterCameras then
PlayerScripts:RegisterTouchCameraMovementMode(Enum.TouchCameraMovementMode.Follow)
PlayerScripts:RegisterTouchCameraMovementMode(Enum.TouchCameraMovementMode.Classic)
PlayerScripts:RegisterComputerCameraMovementMode(Enum.ComputerCameraMovementMode.Default)
PlayerScripts:RegisterComputerCameraMovementMode(Enum.ComputerCameraMovementMode.Follow)
PlayerScripts:RegisterComputerCameraMovementMode(Enum.ComputerCameraMovementMode.Classic)
end
end
-- Current active camera and occlusion module
local activeCameraController = nil
local activeOcclusionModule = nil
local activeTransparencyController = nil
local activeMouseLockController = nil
local currentComputerCameraMovementMode = nil
-- Connections to events
local cameraSubjectChangedConn = nil
local cameraTypeChangedConn = nil
local function GetCameraMovementModeFromSettings()
local cameraMode = Players.LocalPlayer.CameraMode
-- Lock First Person trumps all other settings and forces ClassicCamera
if cameraMode == Enum.CameraMode.LockFirstPerson then
return CameraUtils.ConvertCameraModeEnumToStandard(Enum.ComputerCameraMovementMode.Classic)
end
local devMode, userMode
if UserInputService.TouchEnabled then
devMode = CameraUtils.ConvertCameraModeEnumToStandard(Players.LocalPlayer.DevTouchCameraMode)
userMode = CameraUtils.ConvertCameraModeEnumToStandard(UserGameSettings.TouchCameraMovementMode)
else
devMode = CameraUtils.ConvertCameraModeEnumToStandard(Players.LocalPlayer.DevComputerCameraMode)
userMode = CameraUtils.ConvertCameraModeEnumToStandard(UserGameSettings.ComputerCameraMovementMode)
end
if devMode == Enum.DevComputerCameraMovementMode.UserChoice then
-- Developer is allowing user choice, so user setting is respected
return userMode
end
return devMode
end
local function ActivateOcclusionModule( occlusionMode )
local newModuleCreator = nil
if occlusionMode == Enum.DevCameraOcclusionMode.Zoom then
newModuleCreator = Poppercam
elseif occlusionMode == Enum.DevCameraOcclusionMode.Invisicam then
newModuleCreator = Invisicam
else
warn("CameraScript ActivateOcclusionModule called with unsupported mode")
return
end
-- First check to see if there is actually a change. If the module being requested is already
-- the currently-active solution then just make sure it's enabled and exit early
if activeOcclusionModule and activeOcclusionModule:GetOcclusionMode() == occlusionMode then
if not activeOcclusionModule:GetEnabled() then
activeOcclusionModule:Enable(true)
end
return
end
-- Save a reference to the current active module (may be nil) so that we can disable it if
-- we are successful in activating its replacement
local prevOcclusionModule = activeOcclusionModule
-- If there is no active module, see if the one we need has already been instantiated
activeOcclusionModule = instantiatedOcclusionModules[newModuleCreator]
-- If the module was not already instantiated and selected above, instantiate it
if not activeOcclusionModule then
activeOcclusionModule = newModuleCreator.new()
if activeOcclusionModule then
instantiatedOcclusionModules[newModuleCreator] = activeOcclusionModule
end
end
-- If we were successful in either selecting or instantiating the module,
-- enable it if it's not already the currently-active enabled module
if activeOcclusionModule then
local newModuleOcclusionMode = activeOcclusionModule:GetOcclusionMode()
-- Sanity check that the module we selected or instantiated actually supports the desired occlusionMode
if newModuleOcclusionMode ~= occlusionMode then
warn("CameraScript ActivateOcclusionModule mismatch: ",activeOcclusionModule:GetOcclusionMode(),"~=",occlusionMode)
end
-- Deactivate current module if there is one
if prevOcclusionModule then
-- Sanity check that current module is not being replaced by itself (that should have been handled above)
if prevOcclusionModule ~= activeOcclusionModule then
prevOcclusionModule:Enable(false)
else
warn("CameraScript ActivateOcclusionModule failure to detect already running correct module")
end
end
-- Occlusion modules need to be initialized with information about characters and cameraSubject
-- Invisicam needs the LocalPlayer's character
-- Poppercam needs all player characters and the camera subject
if occlusionMode == Enum.DevCameraOcclusionMode.Invisicam then
-- Optimization to only send Invisicam what we know it needs
if Players.LocalPlayer.Character then
activeOcclusionModule:CharacterAdded(Players.LocalPlayer, Players.LocalPlayer.Character)
end
else
-- Poppercam and any others that get added in the future and need the full player list for raycast ignore list
for _, player in pairs(Players:GetPlayers()) do
if player and player.Character then
activeOcclusionModule:CharacterAdded(player, player.Character)
end
end
activeOcclusionModule:OnCameraSubjectChanged(game.Workspace.CurrentCamera.CameraSubject)
end
-- Activate new choice
activeOcclusionModule:Enable(true)
end
end
-- When supplied, legacyCameraType is used and cameraMovementMode is ignored (should be nil anyways)
-- Next, if userCameraCreator is passed in, that is used as the cameraCreator
local function ActivateCameraController( cameraMovementMode, legacyCameraType )
local newCameraCreator = nil
if legacyCameraType~=nil then
--[[
This function has been passed a CameraType enum value. Some of these map to the use of
the LegacyCamera module, the value "Custom" will be translated to a movementMode enum
value based on Dev and User settings, and "Scriptable" will disable the camera controller.
--]]
if legacyCameraType == Enum.CameraType.Scriptable then
if activeCameraController then
activeCameraController:Enable(false)
activeCameraController = nil
return
end
elseif legacyCameraType == Enum.CameraType.Custom then
cameraMovementMode = GetCameraMovementModeFromSettings()
elseif legacyCameraType == Enum.CameraType.Track then
-- Note: The TrackCamera module was basically an older, less fully-featured
-- version of ClassicCamera, no longer actively maintained, but it is re-implemented in
-- case a game was dependent on its lack of ClassicCamera's extra functionality.
cameraMovementMode = Enum.ComputerCameraMovementMode.Classic
elseif legacyCameraType == Enum.CameraType.Follow then
cameraMovementMode = Enum.ComputerCameraMovementMode.Follow
elseif legacyCameraType == Enum.CameraType.Orbital then
cameraMovementMode = Enum.ComputerCameraMovementMode.Orbital
elseif legacyCameraType == Enum.CameraType.Attach or
legacyCameraType == Enum.CameraType.Watch or
legacyCameraType == Enum.CameraType.Fixed then
newCameraCreator = LegacyCamera
else
warn("CameraScript encountered an unhandled Camera.CameraType value: ",legacyCameraType)
end
end
if not newCameraCreator then
if cameraMovementMode == Enum.ComputerCameraMovementMode.Classic or
cameraMovementMode == Enum.ComputerCameraMovementMode.Follow or
cameraMovementMode == Enum.ComputerCameraMovementMode.Default then
newCameraCreator = ClassicCamera
elseif cameraMovementMode == Enum.ComputerCameraMovementMode.Orbital then
newCameraCreator = OrbitalCamera
else
warn("ActivateCameraController did not select a module.")
return
end
end
-- Create the camera control module we need if it does not already exist in instantiatedCameraControllers
local newCameraController = nil
if not instantiatedCameraControllers[newCameraCreator] then
newCameraController = newCameraCreator.new()
instantiatedCameraControllers[newCameraCreator] = newCameraController
else
newCameraController = instantiatedCameraControllers[newCameraCreator]
end
-- If there is a controller active and it's not the one we need, disable it,
-- if it is the one we need, make sure it's enabled
if activeCameraController then
if activeCameraController ~= newCameraController then
activeCameraController:Enable(false)
activeCameraController = newCameraController
activeCameraController:Enable(true)
elseif not activeCameraController:GetEnabled() then
activeCameraController:Enable(true)
end
elseif newCameraController ~= nil then
activeCameraController = newCameraController
activeCameraController:Enable(true)
end
if activeCameraController then
if cameraMovementMode~=nil then
activeCameraController:SetCameraMovementMode(cameraMovementMode)
elseif legacyCameraType~=nil then
-- Note that this is only called when legacyCameraType is not a type that
-- was convertible to a ComputerCameraMovementMode value, i.e. really only applies to LegacyCamera
activeCameraController:SetCameraType(legacyCameraType)
end
end
end
-- Note: The active transparency controller could be made to listen for this event itself.
local function OnCameraSubjectChanged()
if activeTransparencyController then
activeTransparencyController:SetSubject(game.Workspace.CurrentCamera.CameraSubject)
end
if activeOcclusionModule then
activeOcclusionModule:OnCameraSubjectChanged(game.Workspace.CurrentCamera.CameraSubject)
end
end
local function OnCameraTypeChanged(newCameraType)
if newCameraType == Enum.CameraType.Scriptable then
if UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
end
end
-- Forward the change to ActivateCameraController to handle
ActivateCameraController(nil, newCameraType)
end
-- Note: Called whenever workspace.CurrentCamera changes, but also on initialization of this script
local function OnCurrentCameraChanged()
local currentCamera = game.Workspace.CurrentCamera
if not currentCamera then return end
if cameraSubjectChangedConn then
cameraSubjectChangedConn:Disconnect()
end
if cameraTypeChangedConn then
cameraTypeChangedConn:Disconnect()
end
cameraSubjectChangedConn = currentCamera:GetPropertyChangedSignal("CameraSubject"):Connect(function()
OnCameraSubjectChanged(currentCamera.CameraSubject)
end)
cameraTypeChangedConn = currentCamera:GetPropertyChangedSignal("CameraType"):Connect(function()
OnCameraTypeChanged(currentCamera.CameraType)
end)
OnCameraSubjectChanged(currentCamera.CameraSubject)
OnCameraTypeChanged(currentCamera.CameraType)
end
local function OnLocalPlayerCameraPropertyChanged(propertyName)
if propertyName == "CameraMode" then
-- CameraMode is only used to turn on/off forcing the player into first person view. The
-- Note: The case "Classic" is used for all other views and does not correspond only to the ClassicCamera module
if Players.LocalPlayer.CameraMode == Enum.CameraMode.LockFirstPerson then
-- Locked in first person, use ClassicCamera which supports this
if not activeCameraController or activeCameraController:GetModuleName() ~= "ClassicCamera" then
ActivateCameraController(CameraUtils.ConvertCameraModeEnumToStandard(Enum.DevComputerCameraMovementMode.Classic))
end
if activeCameraController then
activeCameraController:UpdateForDistancePropertyChange()
end
elseif Players.LocalPlayer.CameraMode == Enum.CameraMode.Classic then
-- Not locked in first person view
local cameraMovementMode = GetCameraMovementModeFromSettings()
ActivateCameraController(CameraUtils.ConvertCameraModeEnumToStandard(cameraMovementMode))
else
warn("Unhandled value for property player.CameraMode: ",Players.LocalPlayer.CameraMode)
end
elseif propertyName == "DevComputerCameraMode" or
propertyName == "DevTouchCameraMode" then
local cameraMovementMode = GetCameraMovementModeFromSettings()
ActivateCameraController(CameraUtils.ConvertCameraModeEnumToStandard(cameraMovementMode))
elseif propertyName == "DevCameraOcclusionMode" then
ActivateOcclusionModule(Players.LocalPlayer.DevCameraOcclusionMode)
elseif propertyName == "CameraMinZoomDistance" or propertyName == "CameraMaxZoomDistance" then
if activeCameraController then
activeCameraController:UpdateForDistancePropertyChange()
end
elseif propertyName == "DevTouchMovementMode" then
elseif propertyName == "DevComputerMovementMode" then
elseif propertyName == "DevEnableMouseLock" then
-- This is the enabling/disabling of "Shift Lock" mode, not LockFirstPerson (which is a CameraMode)
-- Note: Enabling and disabling of MouseLock mode is normally only a publish-time choice made via
-- the corresponding EnableMouseLockOption checkbox of StarterPlayer, and this script does not have
-- support for changing the availability of MouseLock at runtime (this would require listening to
-- Player.DevEnableMouseLock changes)
end
end
local function OnUserGameSettingsPropertyChanged(propertyName)
if propertyName == "ComputerCameraMovementMode" then
local cameraMovementMode = GetCameraMovementModeFromSettings()
ActivateCameraController(CameraUtils.ConvertCameraModeEnumToStandard(cameraMovementMode))
-- These remaining UserGameSettings properties are not currently used by camera scripts in Lua
-- and these cases could be removed.
elseif propertyName == "ComputerMovementMode" then
elseif propertyName == "ControlMode" then
elseif propertyName == "GamepadCameraSensitivity" then
elseif propertyName == "MouseSensitivity" then
elseif propertyName == "RotationType" then
elseif propertyName == "TouchCameraMovementMode" then
elseif propertyName == "TouchMovementMode" then
end
end
game.Workspace:GetPropertyChangedSignal("CurrentCamera"):Connect(OnCurrentCameraChanged)
-- Connect listeners to camera-related properties
for _, propertyName in pairs(PLAYER_CAMERA_PROPERTIES) do
Players.LocalPlayer:GetPropertyChangedSignal(propertyName):Connect(function()
OnLocalPlayerCameraPropertyChanged(propertyName)
end)
end
for _, propertyName in pairs(USER_GAME_SETTINGS_PROPERTIES) do
UserGameSettings:GetPropertyChangedSignal(propertyName):Connect(function()
OnUserGameSettingsPropertyChanged(propertyName)
end)
end
--[[
Main RenderStep Update. The camera controller and occlusion module both have opportunities
to set and modify (respectively) the CFrame and Focus before it is set once on CurrentCamera.
The camera and occlusion modules should only return CFrames, not set the CFrame property of
CurrentCamera directly.
--]]
local function Update(dt)
local newCameraCFrame = nil
local newCameraFocus = nil
if activeCameraController then
newCameraCFrame, newCameraFocus = activeCameraController:Update(dt)
activeCameraController:ApplyVRTransform()
else
newCameraCFrame = game.Workspace.CurrentCamera.CFrame
newCameraFocus = game.Workspace.CurrentCamera.Focus
end
if activeOcclusionModule then
newCameraCFrame, newCameraFocus = activeOcclusionModule:Update(dt, newCameraCFrame, newCameraFocus)
end
-- Here is where the new CFrame and Focus are set for this render frame
game.Workspace.CurrentCamera.CFrame = newCameraCFrame
game.Workspace.CurrentCamera.Focus = newCameraFocus
-- Update to character local transparency as needed based on camera-to-subject distance
if activeTransparencyController then
activeTransparencyController:Update()
end
end
-- [[ old module migrating code below this point ]] --
local hasLastInput = false
local lastInputType = nil
-- Formerly getCurrentCameraMode, this function resolves developer and user camera control settings to
-- decide which camera control module should be instantiated. The old method of converting redundant enum types
local function GetCameraControlChoice()
local player = Players.LocalPlayer
if player then
if (hasLastInput and lastInputType == Enum.UserInputType.Touch) or UserInputService.TouchEnabled then
-- Touch
if player.DevTouchCameraMode == Enum.DevTouchCameraMovementMode.UserChoice then
return CameraUtils.ConvertCameraModeEnumToStandard( UserGameSettings.TouchCameraMovementMode )
else
return CameraUtils.ConvertCameraModeEnumToStandard( player.DevTouchCameraMode )
end
else
-- Computer
if player.DevComputerCameraMode == Enum.DevComputerCameraMovementMode.UserChoice then
local computerMovementMode = CameraUtils.ConvertCameraModeEnumToStandard(UserGameSettings.ComputerCameraMovementMode)
return CameraUtils.ConvertCameraModeEnumToStandard(computerMovementMode)
else
return CameraUtils.ConvertCameraModeEnumToStandard(player.DevComputerCameraMode)
end
end
end
end
hasLastInput = pcall(function()
lastInputType = UserInputService:GetLastInputType()
UserInputService.LastInputTypeChanged:Connect(function(newLastInputType)
lastInputType = newLastInputType
end)
end)
local function OnCharacterAdded(player, char)
if activeOcclusionModule then
activeOcclusionModule:CharacterAdded(player, char)
end
end
local function OnCharacterRemoving(player, char)
if activeOcclusionModule then
activeOcclusionModule:CharacterRemoving(player, char)
end
end
local function OnPlayerAdded(player)
player.CharacterAdded:Connect(function(character) OnCharacterAdded(player, character) end)
player.CharacterRemoving:Connect(function(character) OnCharacterRemoving(player, character) end)
end
local function OnMouseLockToggled()
if activeMouseLockController then
local mouseLocked = activeMouseLockController:GetIsMouseLocked()
local mouseLockOffset = activeMouseLockController:GetMouseLockOffset()
if activeCameraController then
activeCameraController:SetIsMouseLocked(mouseLocked)
activeCameraController:SetMouseLockOffset(mouseLockOffset)
end
end
end
OnPlayerAdded(Players.LocalPlayer)
activeTransparencyController = TransparencyController.new()
activeTransparencyController:Enable(true)
if not UserInputService.TouchEnabled then
activeMouseLockController = MouseLockController.new()
local toggleEvent = activeMouseLockController:GetBindableToggleEvent()
if toggleEvent then
toggleEvent:Connect(OnMouseLockToggled)
end
end
ActivateCameraController(GetCameraControlChoice())
ActivateOcclusionModule(Players.LocalPlayer.DevCameraOcclusionMode)
OnCurrentCameraChanged() -- Does initializations and makes first camera controller
RunService:BindToRenderStep("cameraRenderUpdate", Enum.RenderPriority.Camera.Value, Update)
function CameraScript:GetActiveCameraController()
return activeCameraController
end
return CameraScript
| apache-2.0 |
kitala1/darkstar | scripts/zones/Garlaige_Citadel/npcs/Grounds_Tome.lua | 34 | 1145 | -----------------------------------
-- Area: Garlaige Citidel
-- NPC: Grounds Tome
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/groundsofvalor");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
startGov(GOV_EVENT_GARLAIGE_CITADEL,player);
end;
-----------------------------------
-- onEventSelection
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
updateGov(player,csid,option,703,704,705,706,707,708,708,710,0,0);
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
finishGov(player,csid,option,703,704,705,706,707,708,708,710,0,0,GOV_MSG_GARLAIGE_CITADEL);
end;
| gpl-3.0 |
kitala1/darkstar | scripts/zones/Lufaise_Meadows/mobs/Colorful_Leshy.lua | 29 | 1658 | -----------------------------------
-- Area: Lufaise Meadows
-- MOB: Colorful Leshy
-----------------------------------
-----------------------------------
function onMobSpawn(mob)
local Defoliate_Leshy = 16875763;
GetMobByID(Defoliate_Leshy):setLocalVar("1", os.time() + math.random((43200), (86400)));
end;
function onMobRoam(mob)
local Defoliate_Leshy = 16875763;
local Defoliate_Leshy_PH = 0;
local Defoliate_Leshy_PH_Table =
{
16875762
};
local Defoliate_Leshy_ToD = GetMobByID(Defoliate_Leshy):getLocalVar("1");
if (Defoliate_Leshy_ToD <= os.time()) then
Defoliate_Leshy_PH = math.random((0), (table.getn(Defoliate_Leshy_PH_Table)));
if (Defoliate_Leshy_PH_Table[Defoliate_Leshy_PH] ~= nil) then
if (GetMobAction(Defoliate_Leshy) == 0) then
SetServerVariable("Defoliate_Leshy_PH", Defoliate_Leshy_PH_Table[Defoliate_Leshy_PH]);
DeterMob(Defoliate_Leshy_PH_Table[Defoliate_Leshy_PH], true);
DeterMob(Defoliate_Leshy, false);
DespawnMob(Defoliate_Leshy_PH_Table[Defoliate_Leshy_PH]);
SpawnMob(Defoliate_Leshy, "", 0);
end
end
end
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, killer)
local Colorful_Leshy = 16875762;
local Colorful_Leshy_PH = GetServerVariable("Colorful_Leshy_PH");
GetMobByID(Colorful_Leshy):setLocalVar("1", os.time() + math.random((43200), (86400)));
SetServerVariable("Colorful_Leshy_PH", 0);
DeterMob(Colorful_Leshy, true);
DeterMob(Colorful_Leshy_PH, false);
SpawnMob(Colorful_Leshy_PH, "", GetMobRespawnTime(Colorful_Leshy_PH));
end; | gpl-3.0 |
kitala1/darkstar | scripts/zones/Ghelsba_Outpost/bcnms/wings_of_fury.lua | 13 | 1477 | -----------------------------------
-- Area: Ghelsba Outpost
-- Name: Wings of Fury BCNM20
-- @pos -162 -11 78 140
-----------------------------------
package.loaded["scripts/zones/Ghelsba_Outpost/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/missions");
require("scripts/zones/Ghelsba_Outpost/TextIDs");
-----------------------------------
-- After registering the BCNM via bcnmRegister(bcnmid)
function onBcnmRegister(player,instance)
end;
-- Physically entering the BCNM via bcnmEnter(bcnmid)
function onBcnmEnter(player,instance)
end;
-- Leaving the BCNM by every mean possible, given by the LeaveCode
-- 1=Select Exit on circle
-- 2=Winning the BC
-- 3=Disconnected or warped out
-- 4=Losing the BC
-- via bcnmLeave(1) or bcnmLeave(2). LeaveCodes 3 and 4 are called
-- from the core when a player disconnects or the time limit is up, etc
function onBcnmLeave(player,instance,leavecode)
-- print(leave code ..leavecode);
if(leavecode == 2) then -- play end CS. Need time and battle id for record keeping + storage
player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),2,2,2);
elseif(leavecode == 4) then
player:startEvent(0x7d02);
end
end;
function onEventUpdate(player,csid,option)
-- print(bc update csid ..csid.. and option ..option);
end;
function onEventFinish(player,csid,option)
-- print(bc finish csid ..csid.. and option ..option);
end; | gpl-3.0 |
kitala1/darkstar | scripts/globals/mobskills/Sand_Pit.lua | 25 | 1644 | ---------------------------------------------------
-- Sand Pit
-- Single target bind
---------------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------------
function onMobSkillCheck(target,mob,skill)
return 0;
end;
function onMobWeaponSkill(target, mob, skill)
local typeEffect = EFFECT_BIND;
skill:setMsg(MobStatusEffectMove(mob, target, typeEffect, 1, 0, 30));
if (mob:getID()== 16806242) then -- if the mobID == Feeler Antlion ID
local npcX = mob:getXPos();
local npcY = mob:getYPos();
local npcZ = mob:getZPos();
local spawnId = 0;
-- Spawn an Executioner Antlion
local firstExecutioner = 16806243; -- there are only 5 in the database.
if (GetMobAction(firstExecutioner) == 0) then -- if not spawned, set variable to spawn later.
spawnId=firstExecutioner;
elseif (GetMobAction(firstExecutioner+1) == 0) then
spawnId=firstExecutioner+1;
elseif (GetMobAction(firstExecutioner+2) == 0) then
spawnId=firstExecutioner+2;
elseif (GetMobAction(firstExecutioner+3) == 0) then
spawnId=firstExecutioner+3;
elseif (GetMobAction(firstExecutioner+4) == 0) then
spawnId=firstExecutioner+4;
else
spawnId=0; -- If they are all up, then don't spawn any more.
end;
if (spawnId>0) then
local executioner = GetMobByID(spawnId);
executioner:setSpawn(npcX-1,npcY-2,npcZ-1); -- Set its spawn location.
SpawnMob(spawnId,120):updateEnmity(target);
end;
end;
return typeEffect;
end; | gpl-3.0 |
kitala1/darkstar | scripts/zones/West_Ronfaure/npcs/Doladepaiton_RK.lua | 28 | 3142 | -----------------------------------
-- Area: West Ronfaure
-- NPC: Doladepaiton, R.K.
-- Type: Outpost Conquest Guards
-- @pos -448 -19 -214 100
-------------------------------------
package.loaded["scripts/zones/West_Ronfaure/TextIDs"] = nil;
--------------------------------------
require("scripts/globals/conquest");
require("scripts/zones/West_Ronfaure/TextIDs");
local guardnation = SANDORIA; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno
local guardtype = 3; -- 1: city, 2: foreign, 3: outpost, 4: border
local region = RONFAURE;
local csid = 0x7ffb;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
tradeConquestGuard(player,npc,trade,guardnation,guardtype);
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:hasKeyItem(getSupplyKey(region)) and player:getNation() == guardnation) then
if (supplyRunFresh(player) == 1) then
player:startEvent(csid,16,0,0,0,1,0,0,255); -- you have brought us supplies !
else
player:showText(npc, CONQUEST - 1); -- "Hmm... These supplies you have brought us are too old to be of any use."
player:delKeyItem(getSupplyKey(region));
player:messageSpecial(KEYITEM_OBTAINED + 1, getSupplyKey(region));
player:setVar("supplyQuest_region",0);
end
else
local arg1 = getArg1(guardnation, player) - 1;
if (arg1 >= 1792) then -- foreign, non-allied
player:startEvent(csid,1808,0,0,0,0,player:getRank(),0,0);
else -- citizen or allied
player:startEvent(csid,arg1,0,0x3F0000,0,0,getArg6(player),0,0);
end
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("OPTION: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("OPTION: %u",option);
if (option == 1) then
local duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600;
player:delStatusEffect(EFFECT_SIGIL);
player:delStatusEffect(EFFECT_SANCTION);
player:delStatusEffect(EFFECT_SIGNET);
player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet
elseif (option == 2) then
player:delKeyItem(getSupplyKey(region));
player:addCP(supplyReward[region + 1])
player:messageSpecial(CONQUEST); -- "You've earned conquest points!"
if (hasOutpost(player, region+5) == 0) then
local supply_quests = 2^(region+5);
player:addNationTeleport(guardnation,supply_quests);
player:setVar("supplyQuest_region",0);
end
elseif (option == 4) then
if (player:delGil(giltosetHP(guardnation,player))) then
player:setHomePoint();
player:messageSpecial(CONQUEST + 94); -- "Your home point has been set."
else
player:messageSpecial(CONQUEST + 95); -- "You do not have enough gil to set your home point here."
end
end
end; | gpl-3.0 |
kitala1/darkstar | scripts/commands/removekeyitem.lua | 26 | 1057 | ---------------------------------------------------------------------------------------------------
-- func: removekeyitem
-- desc: Removes a keyitem from the target.
---------------------------------------------------------------------------------------------------
cmdprops =
{
permission = 1,
parameters = "si"
};
function onTrigger(player, target, keyId)
-- Load needed text ids for players current zone..
local TextIDs = "scripts/zones/" .. player:getZoneName() .. "/TextIDs";
package.loaded[TextIDs] = nil;
require(TextIDs);
if (keyId == nil) then
player:PrintToPlayer("You must enter a valid keyitem id.");
return;
end
if (target == nil) then
target = player:getName();
end
local targ = GetPlayerByName( target );
if (targ ~= nil) then
targ:delKeyItem(keyId);
targ:messageSpecial(KEYITEM_OBTAINED + 1, keyId);
else
player:PrintToPlayer( string.format( "Player named '%s' not found!", target ) );
end
end | gpl-3.0 |
Synxis/bgfx | scripts/geometryc.lua | 1 | 1031 | --
-- Copyright 2010-2017 Branimir Karadzic. All rights reserved.
-- License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
--
project "geometryc"
uuid "8794dc3a-2d57-11e2-ba18-368d09e48fda"
kind "ConsoleApp"
includedirs {
path.join(BX_DIR, "include"),
path.join(BGFX_DIR, "include"),
path.join(BGFX_DIR, "3rdparty"),
path.join(BGFX_DIR, "examples/common"),
}
files {
path.join(BGFX_DIR, "3rdparty/forsyth-too/**.cpp"),
path.join(BGFX_DIR, "3rdparty/forsyth-too/**.h"),
path.join(BGFX_DIR, "3rdparty/ib-compress/**.cpp"),
path.join(BGFX_DIR, "3rdparty/ib-compress/**.h"),
path.join(BGFX_DIR, "src/vertexdecl.**"),
path.join(BGFX_DIR, "tools/geometryc/**.cpp"),
path.join(BGFX_DIR, "tools/geometryc/**.h"),
path.join(BGFX_DIR, "examples/common/bounds.**"),
}
links {
"bx",
}
configuration { "mingw-*" }
targetextension ".exe"
configuration { "osx" }
links {
"Cocoa.framework",
}
configuration { "vs20* or mingw*" }
links {
"psapi",
}
configuration {}
strip()
| bsd-2-clause |
kitala1/darkstar | scripts/zones/Cirdas_Caverns/Zone.lua | 34 | 1247 | -----------------------------------
--
-- Zone: Cirdas Caverns
--
-----------------------------------
require("scripts/globals/settings");
package.loaded["scripts/zones/Cirdas_Caverns/TextIDs"] = nil;
require("scripts/zones/Cirdas_Caverns/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
cs = -1;
if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then
player:setPos(-180,30,-314,203);
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
kitala1/darkstar | scripts/zones/Southern_San_dOria/npcs/Sobane.lua | 5 | 3805 | -----------------------------------
-- Area: Southern San d'Oria
-- NPC: Sobane
-- Starts and Finishes Quest: Signed in Blood
-- Involved in quest: Sharpening the Sword, Riding on the Clouds
-- @zone 230
-- @pos -190 -3 97
-- csid: 0x0034 0x02dc 0x02dd 0x02de 0x02df 0x02e0 0x02e1 0x02e2 0x02e3 0x02e4 0x02e5
-------------------------------------
package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil;
package.loaded["scripts/globals/settings"] = nil;
-------------------------------------
require("scripts/globals/player");
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/shop");
require("scripts/globals/quests");
require("scripts/zones/Southern_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
local count = trade:getItemCount();
-- FLYERS FOR REGINE QUEST --
if(player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE) == QUEST_ACCEPTED) then
if(trade:hasItemQty(532,1) and count == 1) then -- Trade Magicmart Flyer
player:messageSpecial(FLYER_REFUSED);
end
-- SIGNED IN BLOOD QUEST --
elseif (player:getQuestStatus(SANDORIA,SIGNED_IN_BLOOD) == QUEST_ACCEPTED and player:getVar("SIGNED_IN_BLOOD_Prog") < 1) then
if(trade:hasItemQty(1662,1) and count ==1) then
player:startEvent(0x02DE,0,1662);
end
-- RIDING ON THE CLOUDS QUEST --
elseif(player:getQuestStatus(JEUNO,RIDING_ON_THE_CLOUDS) == QUEST_ACCEPTED and player:getVar("ridingOnTheClouds_1") == 2) then
if(trade:hasItemQty(1127,1) and count == 1) then -- Trade Kindred seal
player:setVar("ridingOnTheClouds_1",0);
player:tradeComplete();
player:addKeyItem(SCOWLING_STONE);
player:messageSpecial(KEYITEM_OBTAINED,SCOWLING_STONE);
end
end
end
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local blood = player:getQuestStatus(SANDORIA,SIGNED_IN_BLOOD);
local bloodProg = player:getVar("SIGNED_IN_BLOOD_Prog");
if(player:getVar("sharpeningTheSwordCS") >= 2) then
player:startEvent(0x0034);
elseif (blood == QUEST_AVAILABLE and player:getFameLevel(SANDORIA) >= 3) then
player:startEvent(0x02dc,0,1662); -- Start Quest
elseif(blood == QUEST_ACCEPTED and bloodProg < 1) then
player:startEvent(0x02dd,0,1662); -- after
elseif (bloodProg == 3 and blood == QUEST_ACCEPTED) then
player:startEvent(0x02E0); -- complete
elseif (bloodProg >= 1 and blood == QUEST_ACCEPTED) then
player:startEvent(0x02df);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if(csid == 0x02dc and option == 1) then
player:addQuest(SANDORIA,SIGNED_IN_BLOOD);
elseif (csid == 0x02E0) then
if(player:getFreeSlotsCount() >= 1) then
player:delKeyItem(TORN_OUT_PAGES);
player:addItem(14760,1);
player:messageSpecial(ITEM_OBTAINED,14760);
player:addFame(SANDORIA,SAN_FAME*30);
player:completeQuest(SANDORIA,SIGNED_IN_BLOOD);
player:setVar("SIGNED_IN_BLOOD_Prog",0);
player:addGil(GIL_RATE*3500);
player:tradeComplete();
else
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,14760);
end
elseif(csid == 0x0034) then
player:setVar("sharpeningTheSwordCS",3);
elseif(csid == 0x02DE) then
player:setVar("SIGNED_IN_BLOOD_Prog",1);
end
end;
| gpl-3.0 |
kitala1/darkstar | scripts/globals/items/cone_of_sub-zero_gelato.lua | 35 | 1402 | -----------------------------------------
-- ID: 5155
-- Item: cone_of_sub-zero_gelato
-- Food Effect: 1Hr, All Races
-----------------------------------------
-- HP 10
-- MP % 16 (cap 80)
-- MP Recovered While Healing 2
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,3600,5155);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 10);
target:addMod(MOD_FOOD_MPP, 16);
target:addMod(MOD_FOOD_MP_CAP, 80);
target:addMod(MOD_MPHEAL, 2);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 10);
target:delMod(MOD_FOOD_MPP, 16);
target:delMod(MOD_FOOD_MP_CAP, 80);
target:delMod(MOD_MPHEAL, 2);
end;
| gpl-3.0 |
patrikrm13/feri | plugins/feedback.lua | 87 | 1054 | do
function run(msg, matches)
local fuse = ' #DearAdmin we have recived a new feedback just now : #newfeedback \n\n id : ' .. msg.from.id .. '\n\nNAME : ' .. msg.from.print_name ..'\n\nusername : @ ' .. msg.from.username ..'\pm :\n\n' .. matches[1]
local fuses = '!printf user#id' .. msg.from.id
local text = matches[1]
bannedidone = string.find(msg.from.id, '123')
bannedidtwo =string.find(msg.from.id, '465')
bannedidthree =string.find(msg.from.id, '678')
print(msg.to.id)
if bannedidone or bannedidtwo or bannedidthree then --for banned people
return 'You are banned to send a feedback'
else
local sends0 = send_msg('chat#70690378', fuse, ok_cb, false)
return 'Your request has been sended to @Creed_is_dead and team 😜!'
end
end
return {
description = "Feedback to sudos",
usage = "!feedback : send maseage to admins with bot",
patterns = {
"^[!/]([Ff]eedback) (.*)$"
"^[Ff](eedback) (.*)$"
},
run = run
}
end
| gpl-2.0 |
kitala1/darkstar | scripts/zones/The_Boyahda_Tree/npcs/qm2.lua | 8 | 2311 | -----------------------------------
-- Area: The Boyahda Tree
-- NPC: qm2 (???)
-- Involved in Quest: Searching for the Right Words
-- @pos 34.651 -20.183 -61.647 153
-----------------------------------
package.loaded["scripts/zones/The_Boyahda_Tree/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/The_Boyahda_Tree/TextIDs");
require("scripts/globals/quests");
require("scripts/globals/keyitems");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
-- Notes: does ??? depop when Agas is spawned?
-- current implementation: when Agas is active, triggering ??? will result in detarget
function onTrigger(player,npc)
local SearchingForWords = player:getQuestStatus(JEUNO,SEARCHING_FOR_THE_RIGHT_WORDS);
local zoneHour = VanadielHour();
local zoneMinute = VanadielMinute();
local correctTime = zoneHour >= 19 or zoneHour < 4 or (zoneHour == 4 and zoneMinute == 0);
if(GetMobAction(17404337) == 0) then
if (player:hasKeyItem(MOONDROP)) then
player:messageSpecial(CAN_SEE_SKY);
elseif (SearchingForWords == QUEST_ACCEPTED) then
if (IsMoonNew() or not correctTime) then
player:messageSpecial(CANNOT_SEE_MOON);
elseif (player:getVar("Searching_AgasKilled") == 1) then
player:startEvent(0x000e);
else
player:messageSpecial(SOMETHING_NOT_RIGHT);
SpawnMob(17404337,288):updateClaim(player); --missing repop timer for Agas due to errors with SpawnMob
end
else
player:messageSpecial(CAN_SEE_SKY);
end
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x000e) then
player:addKeyItem(MOONDROP);
player:messageSpecial(KEYITEM_OBTAINED, MOONDROP);
player:setVar("Searching_AgasKilled", 0);
end
end;
| gpl-3.0 |
codilime/contrail-controller | src/analytics/uvedelete.lua | 10 | 1755 | --
-- Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
--
local function sub_del(_values)
local lres = redis.call('hgetall',_values)
local iter = 1
while iter <= #lres do
local attr = lres[iter]
local val = lres[iter+1]
if string.byte(val,1) ~= 60 then
local descs = cjson.decode(val)
for k,desc in pairs(descs) do
if desc.href ~= nil then
redis.call('del',desc.href)
redis.log(redis.LOG_NOTICE,"Deleting for "..desc.href)
end
end
redis.call('hdel', _values, attr)
end
iter = iter + 2
end
end
local sm = ARGV[1]..":"..ARGV[2]..":"..ARGV[3]..":"..ARGV[4]
local typ = ARGV[5]
local key = ARGV[6]
local db = tonumber(ARGV[7])
local is_alarm = tonumber(ARGV[8])
local _del = KEYS[1]
local _values = KEYS[2]
local _uves = KEYS[3]
local _origins = KEYS[4]
local _table = KEYS[5]
local _deleted = KEYS[6]
redis.call('select',db)
if is_alarm == 1 then
redis.log(redis.LOG_NOTICE,"DelAlarm on "..sm.." for "..key)
else
local part = redis.call('hget',"KEY2PART:"..sm..":"..typ, key)
if part == false then
part = "NULL"
else
redis.call('hdel', "KEY2PART:"..sm..":"..typ, key)
redis.call('srem', "PART2KEY:"..part, sm..":"..typ..":"..key)
redis.log(redis.LOG_NOTICE,"DelUVE on "..sm.." for "..key.." part "..part)
end
end
sub_del(_values)
redis.call('zrem', _uves, key)
redis.call('srem', _origins, sm..":"..typ)
redis.call('srem', _table, key..":"..sm..":"..typ)
local lttt = redis.call('exists', _values)
if lttt == 1 then
redis.call('rename', _values, _del)
redis.call('lpush',_deleted, _del)
end
return true
| apache-2.0 |
kitala1/darkstar | scripts/zones/Sacrarium/npcs/qm6.lua | 8 | 1734 | -----------------------------------
-- Area: Sacrarium
-- NPC: qm6 (???)
-- Notes: Used to spawn Old Prof. Mariselle
-- @pos 62.668 -3.111 -127.310 28
-----------------------------------
package.loaded["scripts/zones/Sacrarium/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Sacrarium/TextIDs");
require("scripts/globals/keyitems");
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local OldProfessor = 16891970;
if(GetServerVariable("Old_Prof_Spawn_Location") == 6) then
if(player:getCurrentMission(COP) == THE_SECRETS_OF_WORSHIP and player:getVar("PromathiaStatus") == 3 and player:hasKeyItem(RELIQUIARIUM_KEY)==false and GetMobAction(OldProfessor) == 0)then
player:messageSpecial(EVIL_PRESENCE);
SpawnMob(OldProfessor,300):updateClaim(player);
GetMobByID(OldProfessor):setPos(npc:getXPos()+1, npc:getYPos(), npc:getZPos()+1); -- Set Prof. spawn x and z pos. +1 from NPC
else
player:messageSpecial(DRAWER_SHUT);
end
elseif(player:getCurrentMission(COP) == THE_SECRETS_OF_WORSHIP and player:getVar("PromathiaStatus") == 4 and player:hasKeyItem(RELIQUIARIUM_KEY)==false)then
player:addKeyItem(RELIQUIARIUM_KEY);
player:messageSpecial(KEYITEM_OBTAINED,RELIQUIARIUM_KEY);
else
player:messageSpecial(DRAWER_OPEN);
player:messageSpecial(DRAWER_EMPTY);
end
end;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
end;
| gpl-3.0 |
kitala1/darkstar | scripts/zones/Windurst_Waters/npcs/Kirarara.lua | 36 | 1420 | -----------------------------------
-- Area: Windurst Waters
-- NPC: Kirarara
-- Involved in Quest: Making the Grade
-- Working 100%
-- @zone = 238
-- @pos = 132 -7 172
-----------------------------------
package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/zones/Windurst_Waters/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getQuestStatus(WINDURST,MAKING_THE_GRADE) == QUEST_ACCEPTED) then
player:startEvent(0x01bf); -- During Making the GRADE
else
player:startEvent(0x01a9); -- Standard conversation
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
Eternym/psychoactive2 | data/talkactions/scripts/remove_tutor.lua | 41 | 1033 | function onSay(player, words, param)
if player:getAccountType() <= ACCOUNT_TYPE_TUTOR then
return true
end
local resultId = db.storeQuery("SELECT `name`, `account_id`, (SELECT `type` FROM `accounts` WHERE `accounts`.`id` = `account_id`) AS `account_type` FROM `players` WHERE `name` = " .. db.escapeString(param))
if resultId == false then
player:sendCancelMessage("A player with that name does not exist.")
return false
end
if result.getDataInt(resultId, "account_type") ~= ACCOUNT_TYPE_TUTOR then
player:sendCancelMessage("You can only demote a tutor to a normal player.")
return false
end
local target = Player(param)
if target ~= nil then
target:setAccountType(ACCOUNT_TYPE_NORMAL)
else
db.query("UPDATE `accounts` SET `type` = " .. ACCOUNT_TYPE_NORMAL .. " WHERE `id` = " .. result.getDataInt(resultId, "account_id"))
end
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have demoted " .. result.getDataString(resultId, "name") .. " to a normal player.")
result.free(resultId)
return false
end
| gpl-2.0 |
kitala1/darkstar | scripts/zones/Windurst_Woods/npcs/Umumu.lua | 34 | 2869 | -----------------------------------
-- Area: Windurst Woods
-- NPC: Umumu
-- Involved In Quest: Making Headlines
-- @pos 32.575 -5.250 141.372 241
-----------------------------------
package.loaded["scripts/zones/Windurst_Woods/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/zones/Windurst_Woods/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
function testflag(set,flag)
return (set % (2*flag) >= flag)
end
local MakingHeadlines = player:getQuestStatus(WINDURST,MAKING_HEADLINES);
local WildcatWindurst = player:getVar("WildcatWindurst");
if (player:getQuestStatus(WINDURST,LURE_OF_THE_WILDCAT_WINDURST) == QUEST_ACCEPTED and player:getMaskBit(WildcatWindurst,3) == false) then
player:startEvent(0x02db);
elseif (MakingHeadlines == 1) then
local prog = player:getVar("QuestMakingHeadlines_var");
-- Variable to track if player has talked to 4 NPCs and a door
-- 1 = Kyume
-- 2 = Yujuju
-- 4 = Hiwom
-- 8 = Umumu
-- 16 = Mahogany Door
if (testflag(tonumber(prog),16) == true) then
player:startEvent(0x017f); -- Advised to go to Naiko
elseif (testflag(tonumber(prog),8) == false) then
player:startEvent(0x017d); -- Get scoop and asked to validate
else
player:startEvent(0x017e); -- Reminded to validate
end
elseif (MakingHeadlines == 2) then
local rand = math.random(1,3);
if (rand == 1) then
player:startEvent(0x0181); -- Conversation after quest completed
elseif (rand == 2) then
player:startEvent(0x0182); -- Conversation after quest completed
elseif (rand == 3) then
player:startEvent(0x019e); -- Standard Conversation
end
else
player:startEvent(0x019e); -- Standard Conversation
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x017d) then
prog = player:getVar("QuestMakingHeadlines_var");
player:addKeyItem(WINDURST_WOODS_SCOOP);
player:messageSpecial(KEYITEM_OBTAINED,WINDURST_WOODS_SCOOP);
player:setVar("QuestMakingHeadlines_var",prog+8);
elseif (csid == 0x02db) then
player:setMaskBit(player:getVar("WildcatWindurst"),"WildcatWindurst",3,true);
end
end;
| gpl-3.0 |
kitala1/darkstar | scripts/globals/spells/Bewitching_Etude.lua | 11 | 1616 | -----------------------------------------
-- Spell: Bewitching Etude
-- Static CHR Boost, BRD 62
-----------------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
local sLvl = caster:getSkillLevel(SKILL_SNG); -- Gets skill level of Singing
local iLvl = caster:getWeaponSkillLevel(SLOT_RANGED);
local power = 0;
if (sLvl+iLvl <= 416) then
power = 12;
elseif((sLvl+iLvl >= 417) and (sLvl+iLvl <= 445)) then
power = 13;
elseif((sLvl+iLvl >= 446) and (sLvl+iLvl <= 474)) then
power = 14;
elseif(sLvl+iLvl >= 475) then
power = 15;
end
local iBoost = caster:getMod(MOD_ETUDE_EFFECT) + caster:getMod(MOD_ALL_SONGS_EFFECT);
power = power + iBoost;
if (caster:hasStatusEffect(EFFECT_SOUL_VOICE)) then
power = power * 2;
elseif (caster:hasStatusEffect(EFFECT_MARCATO)) then
power = power * 1.5;
end
caster:delStatusEffect(EFFECT_MARCATO);
local duration = 120;
duration = duration * ((iBoost * 0.1) + (caster:getMod(MOD_SONG_DURATION_BONUS)/100) + 1);
if (caster:hasStatusEffect(EFFECT_TROUBADOUR)) then
duration = duration * 2;
end
if not (target:addBardSong(caster,EFFECT_ETUDE,power,10,duration,caster:getID(), MOD_CHR, 2)) then
spell:setMsg(75);
end
return EFFECT_ETUDE;
end; | gpl-3.0 |
BennyLi/dotfiles | neovim/lua/user/options.lua | 1 | 3860 | -- see :h options
-- Keep this list alphabetical ordered.
local tabwidth = 4
vim.opt.autoindent = true -- indent new lines automatically (see smartindent)
vim.opt.autoread = true -- read external changes automatically
vim.opt.background = 'dark' -- TUI background type
vim.opt.backspace = { 'indent', 'start' } -- Allow backspace for indention and start of insert, but not for line breaks
vim.opt.backup = false -- Don't backup files on write
vim.opt.belloff = 'all' -- Don't ring the bell
vim.opt.breakindent = true -- Visual indention of wrapped lines
vim.opt.clipboard = 'unnamedplus' -- Use the system clipboard
vim.opt.cmdheight = 2 -- more space in the neovim command line for displaying messages
vim.opt.completeopt = { 'menuone', 'preview', 'noselect' } -- Command completion behavior
vim.opt.confirm = true -- Confirm on unsaved exit
vim.opt.cursorline = true -- Highlight the current line
vim.opt.expandtab = true -- Spaces, no Tabs
--vim.opt.fillchars = { '' } -- TODO Check this out
vim.opt.history = 10000 -- History of ":" commands
vim.opt.incsearch = true -- Highlight search results as you type
vim.opt.linebreak = true -- Wrap line more readable (see breakindent and showbreak)
vim.opt.list = true -- Show some hidden characters
vim.opt.modeline = true -- Status bar at the bottom
vim.opt.number = true -- Show line numbers
vim.opt.numberwidth = 4 -- Min columns for numbers
vim.opt.relativenumber = true -- Show line numbers relative to the current line
vim.opt.scrolloff = 10 -- Lines above or below on edge scrolling
--vim.opt.shell = ... -- TODO Check this out
vim.opt.shiftwidth = tabwidth -- Number of spaces of intend like with >>
vim.opt.showbreak = '|--> ' -- Wrap indicator
vim.opt.showcmd = true -- Show command in last line of screen
vim.opt.showmatch = true -- Show matching bracket
vim.opt.showmode = true -- Display current mode in status line
vim.opt.showtabline = 2 -- Always show the tabline
vim.opt.smartindent = true -- Do smarted indents automatically (see autoindent)
vim.opt.smarttab = true -- Remove all spaces from a <Tab> on backspace
vim.opt.softtabstop = tabwidth -- Number of spaces inserted on <Tab>
vim.opt.splitbelow = true -- Open new windows below
vim.opt.splitright = true -- Open new windows right
--vim.opt.tabline = '' -- TODO Check this out
vim.opt.tabstop = tabwidth -- Spaces a <Tab> counts for
vim.opt.wrap = true -- Wrap long lines
| mit |
kitala1/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Giehnz.lua | 34 | 1031 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Giehnz
-- Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x00F9);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
kitala1/darkstar | scripts/zones/Kazham/npcs/Tahn_Posbei.lua | 37 | 1510 | -----------------------------------
-- Area: Kazham
-- NPC: Tahn Posbei
-- Standard Merchant NPC
-----------------------------------
require("scripts/globals/shop");
package.loaded["scripts/zones/Kazham/TextIDs"] = nil;
require("scripts/zones/Kazham/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,TAHNPOSBEI_SHOP_DIALOG);
stock = {0x3001,110, -- Lauan Shield
0x3004,4531, -- Mahogany Shield
0x3007,59607, -- Round Shield
0x30A7,7026, -- Beetle Mask
0x3127,10833, -- Beetle Harness
0x31A7,5707, -- Beetle Mittens
0x3223,8666, -- Beetle Subligar
0x32A7,5332, -- Beetre Leggins
0x3098,404, -- Leather Bandana
0x3118,618, -- Leather Vest
0x3198,331, -- Leather Gloves
0x3298,309, -- Leather Highboots
0x3324,28777} -- Coeurl Gorget
showShop(player, STATIC, stock);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
luciouskami/war3-lua-engine | war3-lua-engine/LuaJIT/src/jit/dis_arm.lua | 99 | 19364 | ----------------------------------------------------------------------------
-- LuaJIT ARM disassembler module.
--
-- Copyright (C) 2005-2013 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module.
--
-- It disassembles most user-mode ARMv7 instructions
-- NYI: Advanced SIMD and VFP instructions.
------------------------------------------------------------------------------
local type = type
local sub, byte, format = string.sub, string.byte, string.format
local match, gmatch, gsub = string.match, string.gmatch, string.gsub
local concat = table.concat
local bit = require("bit")
local band, bor, ror, tohex = bit.band, bit.bor, bit.ror, bit.tohex
local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift
------------------------------------------------------------------------------
-- Opcode maps
------------------------------------------------------------------------------
local map_loadc = {
shift = 8, mask = 15,
[10] = {
shift = 20, mask = 1,
[0] = {
shift = 23, mask = 3,
[0] = "vmovFmDN", "vstmFNdr",
_ = {
shift = 21, mask = 1,
[0] = "vstrFdl",
{ shift = 16, mask = 15, [13] = "vpushFdr", _ = "vstmdbFNdr", }
},
},
{
shift = 23, mask = 3,
[0] = "vmovFDNm",
{ shift = 16, mask = 15, [13] = "vpopFdr", _ = "vldmFNdr", },
_ = {
shift = 21, mask = 1,
[0] = "vldrFdl", "vldmdbFNdr",
},
},
},
[11] = {
shift = 20, mask = 1,
[0] = {
shift = 23, mask = 3,
[0] = "vmovGmDN", "vstmGNdr",
_ = {
shift = 21, mask = 1,
[0] = "vstrGdl",
{ shift = 16, mask = 15, [13] = "vpushGdr", _ = "vstmdbGNdr", }
},
},
{
shift = 23, mask = 3,
[0] = "vmovGDNm",
{ shift = 16, mask = 15, [13] = "vpopGdr", _ = "vldmGNdr", },
_ = {
shift = 21, mask = 1,
[0] = "vldrGdl", "vldmdbGNdr",
},
},
},
_ = {
shift = 0, mask = 0 -- NYI ldc, mcrr, mrrc.
},
}
local map_vfps = {
shift = 6, mask = 0x2c001,
[0] = "vmlaF.dnm", "vmlsF.dnm",
[0x04000] = "vnmlsF.dnm", [0x04001] = "vnmlaF.dnm",
[0x08000] = "vmulF.dnm", [0x08001] = "vnmulF.dnm",
[0x0c000] = "vaddF.dnm", [0x0c001] = "vsubF.dnm",
[0x20000] = "vdivF.dnm",
[0x24000] = "vfnmsF.dnm", [0x24001] = "vfnmaF.dnm",
[0x28000] = "vfmaF.dnm", [0x28001] = "vfmsF.dnm",
[0x2c000] = "vmovF.dY",
[0x2c001] = {
shift = 7, mask = 0x1e01,
[0] = "vmovF.dm", "vabsF.dm",
[0x0200] = "vnegF.dm", [0x0201] = "vsqrtF.dm",
[0x0800] = "vcmpF.dm", [0x0801] = "vcmpeF.dm",
[0x0a00] = "vcmpzF.d", [0x0a01] = "vcmpzeF.d",
[0x0e01] = "vcvtG.dF.m",
[0x1000] = "vcvt.f32.u32Fdm", [0x1001] = "vcvt.f32.s32Fdm",
[0x1800] = "vcvtr.u32F.dm", [0x1801] = "vcvt.u32F.dm",
[0x1a00] = "vcvtr.s32F.dm", [0x1a01] = "vcvt.s32F.dm",
},
}
local map_vfpd = {
shift = 6, mask = 0x2c001,
[0] = "vmlaG.dnm", "vmlsG.dnm",
[0x04000] = "vnmlsG.dnm", [0x04001] = "vnmlaG.dnm",
[0x08000] = "vmulG.dnm", [0x08001] = "vnmulG.dnm",
[0x0c000] = "vaddG.dnm", [0x0c001] = "vsubG.dnm",
[0x20000] = "vdivG.dnm",
[0x24000] = "vfnmsG.dnm", [0x24001] = "vfnmaG.dnm",
[0x28000] = "vfmaG.dnm", [0x28001] = "vfmsG.dnm",
[0x2c000] = "vmovG.dY",
[0x2c001] = {
shift = 7, mask = 0x1e01,
[0] = "vmovG.dm", "vabsG.dm",
[0x0200] = "vnegG.dm", [0x0201] = "vsqrtG.dm",
[0x0800] = "vcmpG.dm", [0x0801] = "vcmpeG.dm",
[0x0a00] = "vcmpzG.d", [0x0a01] = "vcmpzeG.d",
[0x0e01] = "vcvtF.dG.m",
[0x1000] = "vcvt.f64.u32GdFm", [0x1001] = "vcvt.f64.s32GdFm",
[0x1800] = "vcvtr.u32FdG.m", [0x1801] = "vcvt.u32FdG.m",
[0x1a00] = "vcvtr.s32FdG.m", [0x1a01] = "vcvt.s32FdG.m",
},
}
local map_datac = {
shift = 24, mask = 1,
[0] = {
shift = 4, mask = 1,
[0] = {
shift = 8, mask = 15,
[10] = map_vfps,
[11] = map_vfpd,
-- NYI cdp, mcr, mrc.
},
{
shift = 8, mask = 15,
[10] = {
shift = 20, mask = 15,
[0] = "vmovFnD", "vmovFDn",
[14] = "vmsrD",
[15] = { shift = 12, mask = 15, [15] = "vmrs", _ = "vmrsD", },
},
},
},
"svcT",
}
local map_loadcu = {
shift = 0, mask = 0, -- NYI unconditional CP load/store.
}
local map_datacu = {
shift = 0, mask = 0, -- NYI unconditional CP data.
}
local map_simddata = {
shift = 0, mask = 0, -- NYI SIMD data.
}
local map_simdload = {
shift = 0, mask = 0, -- NYI SIMD load/store, preload.
}
local map_preload = {
shift = 0, mask = 0, -- NYI preload.
}
local map_media = {
shift = 20, mask = 31,
[0] = false,
{ --01
shift = 5, mask = 7,
[0] = "sadd16DNM", "sasxDNM", "ssaxDNM", "ssub16DNM",
"sadd8DNM", false, false, "ssub8DNM",
},
{ --02
shift = 5, mask = 7,
[0] = "qadd16DNM", "qasxDNM", "qsaxDNM", "qsub16DNM",
"qadd8DNM", false, false, "qsub8DNM",
},
{ --03
shift = 5, mask = 7,
[0] = "shadd16DNM", "shasxDNM", "shsaxDNM", "shsub16DNM",
"shadd8DNM", false, false, "shsub8DNM",
},
false,
{ --05
shift = 5, mask = 7,
[0] = "uadd16DNM", "uasxDNM", "usaxDNM", "usub16DNM",
"uadd8DNM", false, false, "usub8DNM",
},
{ --06
shift = 5, mask = 7,
[0] = "uqadd16DNM", "uqasxDNM", "uqsaxDNM", "uqsub16DNM",
"uqadd8DNM", false, false, "uqsub8DNM",
},
{ --07
shift = 5, mask = 7,
[0] = "uhadd16DNM", "uhasxDNM", "uhsaxDNM", "uhsub16DNM",
"uhadd8DNM", false, false, "uhsub8DNM",
},
{ --08
shift = 5, mask = 7,
[0] = "pkhbtDNMU", false, "pkhtbDNMU",
{ shift = 16, mask = 15, [15] = "sxtb16DMU", _ = "sxtab16DNMU", },
"pkhbtDNMU", "selDNM", "pkhtbDNMU",
},
false,
{ --0a
shift = 5, mask = 7,
[0] = "ssatDxMu", "ssat16DxM", "ssatDxMu",
{ shift = 16, mask = 15, [15] = "sxtbDMU", _ = "sxtabDNMU", },
"ssatDxMu", false, "ssatDxMu",
},
{ --0b
shift = 5, mask = 7,
[0] = "ssatDxMu", "revDM", "ssatDxMu",
{ shift = 16, mask = 15, [15] = "sxthDMU", _ = "sxtahDNMU", },
"ssatDxMu", "rev16DM", "ssatDxMu",
},
{ --0c
shift = 5, mask = 7,
[3] = { shift = 16, mask = 15, [15] = "uxtb16DMU", _ = "uxtab16DNMU", },
},
false,
{ --0e
shift = 5, mask = 7,
[0] = "usatDwMu", "usat16DwM", "usatDwMu",
{ shift = 16, mask = 15, [15] = "uxtbDMU", _ = "uxtabDNMU", },
"usatDwMu", false, "usatDwMu",
},
{ --0f
shift = 5, mask = 7,
[0] = "usatDwMu", "rbitDM", "usatDwMu",
{ shift = 16, mask = 15, [15] = "uxthDMU", _ = "uxtahDNMU", },
"usatDwMu", "revshDM", "usatDwMu",
},
{ --10
shift = 12, mask = 15,
[15] = {
shift = 5, mask = 7,
"smuadNMS", "smuadxNMS", "smusdNMS", "smusdxNMS",
},
_ = {
shift = 5, mask = 7,
[0] = "smladNMSD", "smladxNMSD", "smlsdNMSD", "smlsdxNMSD",
},
},
false, false, false,
{ --14
shift = 5, mask = 7,
[0] = "smlaldDNMS", "smlaldxDNMS", "smlsldDNMS", "smlsldxDNMS",
},
{ --15
shift = 5, mask = 7,
[0] = { shift = 12, mask = 15, [15] = "smmulNMS", _ = "smmlaNMSD", },
{ shift = 12, mask = 15, [15] = "smmulrNMS", _ = "smmlarNMSD", },
false, false, false, false,
"smmlsNMSD", "smmlsrNMSD",
},
false, false,
{ --18
shift = 5, mask = 7,
[0] = { shift = 12, mask = 15, [15] = "usad8NMS", _ = "usada8NMSD", },
},
false,
{ --1a
shift = 5, mask = 3, [2] = "sbfxDMvw",
},
{ --1b
shift = 5, mask = 3, [2] = "sbfxDMvw",
},
{ --1c
shift = 5, mask = 3,
[0] = { shift = 0, mask = 15, [15] = "bfcDvX", _ = "bfiDMvX", },
},
{ --1d
shift = 5, mask = 3,
[0] = { shift = 0, mask = 15, [15] = "bfcDvX", _ = "bfiDMvX", },
},
{ --1e
shift = 5, mask = 3, [2] = "ubfxDMvw",
},
{ --1f
shift = 5, mask = 3, [2] = "ubfxDMvw",
},
}
local map_load = {
shift = 21, mask = 9,
{
shift = 20, mask = 5,
[0] = "strtDL", "ldrtDL", [4] = "strbtDL", [5] = "ldrbtDL",
},
_ = {
shift = 20, mask = 5,
[0] = "strDL", "ldrDL", [4] = "strbDL", [5] = "ldrbDL",
}
}
local map_load1 = {
shift = 4, mask = 1,
[0] = map_load, map_media,
}
local map_loadm = {
shift = 20, mask = 1,
[0] = {
shift = 23, mask = 3,
[0] = "stmdaNR", "stmNR",
{ shift = 16, mask = 63, [45] = "pushR", _ = "stmdbNR", }, "stmibNR",
},
{
shift = 23, mask = 3,
[0] = "ldmdaNR", { shift = 16, mask = 63, [61] = "popR", _ = "ldmNR", },
"ldmdbNR", "ldmibNR",
},
}
local map_data = {
shift = 21, mask = 15,
[0] = "andDNPs", "eorDNPs", "subDNPs", "rsbDNPs",
"addDNPs", "adcDNPs", "sbcDNPs", "rscDNPs",
"tstNP", "teqNP", "cmpNP", "cmnNP",
"orrDNPs", "movDPs", "bicDNPs", "mvnDPs",
}
local map_mul = {
shift = 21, mask = 7,
[0] = "mulNMSs", "mlaNMSDs", "umaalDNMS", "mlsDNMS",
"umullDNMSs", "umlalDNMSs", "smullDNMSs", "smlalDNMSs",
}
local map_sync = {
shift = 20, mask = 15, -- NYI: brackets around N. R(D+1) for ldrexd/strexd.
[0] = "swpDMN", false, false, false,
"swpbDMN", false, false, false,
"strexDMN", "ldrexDN", "strexdDN", "ldrexdDN",
"strexbDMN", "ldrexbDN", "strexhDN", "ldrexhDN",
}
local map_mulh = {
shift = 21, mask = 3,
[0] = { shift = 5, mask = 3,
[0] = "smlabbNMSD", "smlatbNMSD", "smlabtNMSD", "smlattNMSD", },
{ shift = 5, mask = 3,
[0] = "smlawbNMSD", "smulwbNMS", "smlawtNMSD", "smulwtNMS", },
{ shift = 5, mask = 3,
[0] = "smlalbbDNMS", "smlaltbDNMS", "smlalbtDNMS", "smlalttDNMS", },
{ shift = 5, mask = 3,
[0] = "smulbbNMS", "smultbNMS", "smulbtNMS", "smulttNMS", },
}
local map_misc = {
shift = 4, mask = 7,
-- NYI: decode PSR bits of msr.
[0] = { shift = 21, mask = 1, [0] = "mrsD", "msrM", },
{ shift = 21, mask = 3, "bxM", false, "clzDM", },
{ shift = 21, mask = 3, "bxjM", },
{ shift = 21, mask = 3, "blxM", },
false,
{ shift = 21, mask = 3, [0] = "qaddDMN", "qsubDMN", "qdaddDMN", "qdsubDMN", },
false,
{ shift = 21, mask = 3, "bkptK", },
}
local map_datar = {
shift = 4, mask = 9,
[9] = {
shift = 5, mask = 3,
[0] = { shift = 24, mask = 1, [0] = map_mul, map_sync, },
{ shift = 20, mask = 1, [0] = "strhDL", "ldrhDL", },
{ shift = 20, mask = 1, [0] = "ldrdDL", "ldrsbDL", },
{ shift = 20, mask = 1, [0] = "strdDL", "ldrshDL", },
},
_ = {
shift = 20, mask = 25,
[16] = { shift = 7, mask = 1, [0] = map_misc, map_mulh, },
_ = {
shift = 0, mask = 0xffffffff,
[bor(0xe1a00000)] = "nop",
_ = map_data,
}
},
}
local map_datai = {
shift = 20, mask = 31, -- NYI: decode PSR bits of msr. Decode imm12.
[16] = "movwDW", [20] = "movtDW",
[18] = { shift = 0, mask = 0xf00ff, [0] = "nopv6", _ = "msrNW", },
[22] = "msrNW",
_ = map_data,
}
local map_branch = {
shift = 24, mask = 1,
[0] = "bB", "blB"
}
local map_condins = {
[0] = map_datar, map_datai, map_load, map_load1,
map_loadm, map_branch, map_loadc, map_datac
}
-- NYI: setend.
local map_uncondins = {
[0] = false, map_simddata, map_simdload, map_preload,
false, "blxB", map_loadcu, map_datacu,
}
------------------------------------------------------------------------------
local map_gpr = {
[0] = "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "sp", "lr", "pc",
}
local map_cond = {
[0] = "eq", "ne", "hs", "lo", "mi", "pl", "vs", "vc",
"hi", "ls", "ge", "lt", "gt", "le", "al",
}
local map_shift = { [0] = "lsl", "lsr", "asr", "ror", }
------------------------------------------------------------------------------
-- Output a nicely formatted line with an opcode and operands.
local function putop(ctx, text, operands)
local pos = ctx.pos
local extra = ""
if ctx.rel then
local sym = ctx.symtab[ctx.rel]
if sym then
extra = "\t->"..sym
elseif band(ctx.op, 0x0e000000) ~= 0x0a000000 then
extra = "\t; 0x"..tohex(ctx.rel)
end
end
if ctx.hexdump > 0 then
ctx.out(format("%08x %s %-5s %s%s\n",
ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra))
else
ctx.out(format("%08x %-5s %s%s\n",
ctx.addr+pos, text, concat(operands, ", "), extra))
end
ctx.pos = pos + 4
end
-- Fallback for unknown opcodes.
local function unknown(ctx)
return putop(ctx, ".long", { "0x"..tohex(ctx.op) })
end
-- Format operand 2 of load/store opcodes.
local function fmtload(ctx, op, pos)
local base = map_gpr[band(rshift(op, 16), 15)]
local x, ofs
local ext = (band(op, 0x04000000) == 0)
if not ext and band(op, 0x02000000) == 0 then
ofs = band(op, 4095)
if band(op, 0x00800000) == 0 then ofs = -ofs end
if base == "pc" then ctx.rel = ctx.addr + pos + 8 + ofs end
ofs = "#"..ofs
elseif ext and band(op, 0x00400000) ~= 0 then
ofs = band(op, 15) + band(rshift(op, 4), 0xf0)
if band(op, 0x00800000) == 0 then ofs = -ofs end
if base == "pc" then ctx.rel = ctx.addr + pos + 8 + ofs end
ofs = "#"..ofs
else
ofs = map_gpr[band(op, 15)]
if ext or band(op, 0xfe0) == 0 then
elseif band(op, 0xfe0) == 0x60 then
ofs = format("%s, rrx", ofs)
else
local sh = band(rshift(op, 7), 31)
if sh == 0 then sh = 32 end
ofs = format("%s, %s #%d", ofs, map_shift[band(rshift(op, 5), 3)], sh)
end
if band(op, 0x00800000) == 0 then ofs = "-"..ofs end
end
if ofs == "#0" then
x = format("[%s]", base)
elseif band(op, 0x01000000) == 0 then
x = format("[%s], %s", base, ofs)
else
x = format("[%s, %s]", base, ofs)
end
if band(op, 0x01200000) == 0x01200000 then x = x.."!" end
return x
end
-- Format operand 2 of vector load/store opcodes.
local function fmtvload(ctx, op, pos)
local base = map_gpr[band(rshift(op, 16), 15)]
local ofs = band(op, 255)*4
if band(op, 0x00800000) == 0 then ofs = -ofs end
if base == "pc" then ctx.rel = ctx.addr + pos + 8 + ofs end
if ofs == 0 then
return format("[%s]", base)
else
return format("[%s, #%d]", base, ofs)
end
end
local function fmtvr(op, vr, sh0, sh1)
if vr == "s" then
return format("s%d", 2*band(rshift(op, sh0), 15)+band(rshift(op, sh1), 1))
else
return format("d%d", band(rshift(op, sh0), 15)+band(rshift(op, sh1-4), 16))
end
end
-- Disassemble a single instruction.
local function disass_ins(ctx)
local pos = ctx.pos
local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4)
local op = bor(lshift(b3, 24), lshift(b2, 16), lshift(b1, 8), b0)
local operands = {}
local suffix = ""
local last, name, pat
local vr
ctx.op = op
ctx.rel = nil
local cond = rshift(op, 28)
local opat
if cond == 15 then
opat = map_uncondins[band(rshift(op, 25), 7)]
else
if cond ~= 14 then suffix = map_cond[cond] end
opat = map_condins[band(rshift(op, 25), 7)]
end
while type(opat) ~= "string" do
if not opat then return unknown(ctx) end
opat = opat[band(rshift(op, opat.shift), opat.mask)] or opat._
end
name, pat = match(opat, "^([a-z0-9]*)(.*)")
if sub(pat, 1, 1) == "." then
local s2, p2 = match(pat, "^([a-z0-9.]*)(.*)")
suffix = suffix..s2
pat = p2
end
for p in gmatch(pat, ".") do
local x = nil
if p == "D" then
x = map_gpr[band(rshift(op, 12), 15)]
elseif p == "N" then
x = map_gpr[band(rshift(op, 16), 15)]
elseif p == "S" then
x = map_gpr[band(rshift(op, 8), 15)]
elseif p == "M" then
x = map_gpr[band(op, 15)]
elseif p == "d" then
x = fmtvr(op, vr, 12, 22)
elseif p == "n" then
x = fmtvr(op, vr, 16, 7)
elseif p == "m" then
x = fmtvr(op, vr, 0, 5)
elseif p == "P" then
if band(op, 0x02000000) ~= 0 then
x = ror(band(op, 255), 2*band(rshift(op, 8), 15))
else
x = map_gpr[band(op, 15)]
if band(op, 0xff0) ~= 0 then
operands[#operands+1] = x
local s = map_shift[band(rshift(op, 5), 3)]
local r = nil
if band(op, 0xf90) == 0 then
if s == "ror" then s = "rrx" else r = "#32" end
elseif band(op, 0x10) == 0 then
r = "#"..band(rshift(op, 7), 31)
else
r = map_gpr[band(rshift(op, 8), 15)]
end
if name == "mov" then name = s; x = r
elseif r then x = format("%s %s", s, r)
else x = s end
end
end
elseif p == "L" then
x = fmtload(ctx, op, pos)
elseif p == "l" then
x = fmtvload(ctx, op, pos)
elseif p == "B" then
local addr = ctx.addr + pos + 8 + arshift(lshift(op, 8), 6)
if cond == 15 then addr = addr + band(rshift(op, 23), 2) end
ctx.rel = addr
x = "0x"..tohex(addr)
elseif p == "F" then
vr = "s"
elseif p == "G" then
vr = "d"
elseif p == "." then
suffix = suffix..(vr == "s" and ".f32" or ".f64")
elseif p == "R" then
if band(op, 0x00200000) ~= 0 and #operands == 1 then
operands[1] = operands[1].."!"
end
local t = {}
for i=0,15 do
if band(rshift(op, i), 1) == 1 then t[#t+1] = map_gpr[i] end
end
x = "{"..concat(t, ", ").."}"
elseif p == "r" then
if band(op, 0x00200000) ~= 0 and #operands == 2 then
operands[1] = operands[1].."!"
end
local s = tonumber(sub(last, 2))
local n = band(op, 255)
if vr == "d" then n = rshift(n, 1) end
operands[#operands] = format("{%s-%s%d}", last, vr, s+n-1)
elseif p == "W" then
x = band(op, 0x0fff) + band(rshift(op, 4), 0xf000)
elseif p == "T" then
x = "#0x"..tohex(band(op, 0x00ffffff), 6)
elseif p == "U" then
x = band(rshift(op, 7), 31)
if x == 0 then x = nil end
elseif p == "u" then
x = band(rshift(op, 7), 31)
if band(op, 0x40) == 0 then
if x == 0 then x = nil else x = "lsl #"..x end
else
if x == 0 then x = "asr #32" else x = "asr #"..x end
end
elseif p == "v" then
x = band(rshift(op, 7), 31)
elseif p == "w" then
x = band(rshift(op, 16), 31)
elseif p == "x" then
x = band(rshift(op, 16), 31) + 1
elseif p == "X" then
x = band(rshift(op, 16), 31) - last + 1
elseif p == "Y" then
x = band(rshift(op, 12), 0xf0) + band(op, 0x0f)
elseif p == "K" then
x = "#0x"..tohex(band(rshift(op, 4), 0x0000fff0) + band(op, 15), 4)
elseif p == "s" then
if band(op, 0x00100000) ~= 0 then suffix = "s"..suffix end
else
assert(false)
end
if x then
last = x
if type(x) == "number" then x = "#"..x end
operands[#operands+1] = x
end
end
return putop(ctx, name..suffix, operands)
end
------------------------------------------------------------------------------
-- Disassemble a block of code.
local function disass_block(ctx, ofs, len)
if not ofs then ofs = 0 end
local stop = len and ofs+len or #ctx.code
ctx.pos = ofs
ctx.rel = nil
while ctx.pos < stop do disass_ins(ctx) end
end
-- Extended API: create a disassembler context. Then call ctx:disass(ofs, len).
local function create_(code, addr, out)
local ctx = {}
ctx.code = code
ctx.addr = addr or 0
ctx.out = out or io.write
ctx.symtab = {}
ctx.disass = disass_block
ctx.hexdump = 8
return ctx
end
-- Simple API: disassemble code (a string) at address and output via out.
local function disass_(code, addr, out)
create_(code, addr, out):disass()
end
-- Return register name for RID.
local function regname_(r)
if r < 16 then return map_gpr[r] end
return "d"..(r-16)
end
-- Public module functions.
module(...)
create = create_
disass = disass_
regname = regname_
| gpl-2.0 |
kitala1/darkstar | scripts/globals/weaponskills/armor_break.lua | 12 | 1757 | -----------------------------------
-- Armor Break
-- Great Axe weapon skill
-- Skill level: 100
-- Lowers enemy's defense. Duration of effect varies with TP.
-- Lowers defense by as much as 25% if unresisted.
-- Strong against: Antica, Bats, Cockatrice, Dhalmel, Lizards, Mandragora, Worms.
-- Immune: Ahriman.
-- Will stack with Sneak Attack.
-- Aligned with the Thunder Gorget.
-- Aligned with the Thunder Belt.
-- Element: Wind
-- Modifiers: STR:20% ; VIT:20%
-- 100%TP 200%TP 300%TP
-- 1.00 1.00 1.00
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID)
local params = {};
params.numHits = 1;
params.ftp100 = 1; params.ftp200 = 1; params.ftp300 = 1;
params.str_wsc = 0.2; params.dex_wsc = 0.0; params.vit_wsc = 0.2; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0;
params.canCrit = false;
params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0;
params.atkmulti = 1;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.str_wsc = 0.6; params.vit_wsc = 0.6;
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, params);
if damage > 0 then
local tp = player:getTP();
local duration = (tp/100 * 70) + 60;
if(target:hasStatusEffect(EFFECT_DEFENSE_DOWN) == false) then
target:addStatusEffect(EFFECT_DEFENSE_DOWN, 25, 0, duration);
end
end
damage = damage * WEAPON_SKILL_POWER
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
kitala1/darkstar | scripts/zones/South_Gustaberg/npcs/qm1.lua | 19 | 1347 | -----------------------------------
-- Area: South Gustaberg
-- NPC: qm1 (???)
-- Involved in Quest: The Cold Light of Day
-- @pos 744 0 -671 107
-----------------------------------
package.loaded["scripts/zones/South_Gustaberg/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/South_Gustaberg/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
count = trade:getItemCount();
gil = trade:getGil();
if ((trade:hasItemQty(4514,1) or trade:hasItemQty(5793,1)) and count == 1 and gil == 0) then
if(GetMobAction(17215494) == 0) then
SpawnMob(17215494,288);
player:tradeComplete();
else
player:messageSpecial(NOTHING_OUT_OF_ORDINARY);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:messageSpecial(MONSTER_TRACKS);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
kitala1/darkstar | scripts/zones/Dynamis-Buburimu/mobs/Serjeant_Tombstone.lua | 17 | 2476 | -----------------------------------
-- Area: Dynamis Buburimu
-- NPC: Serjeant_Tombstone
-----------------------------------
package.loaded["scripts/zones/Dynamis-Buburimu/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/dynamis");
require("scripts/zones/Dynamis-Buburimu/TextIDs");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
mob:setMobMod(MOBMOD_SUPERLINK, mob:getShortID());
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
local X = mob:getXPos();
local Y = mob:getYPos();
local Z = mob:getZPos();
local spawnList = BuburimuOrcishList;
if(mob:getStatPoppedMobs() == false) then
mob:setStatPoppedMobs(true);
for nb = 1, table.getn(spawnList), 2 do
if(mob:getID() == spawnList[nb]) then -- si l'id du mob engager correpond a un ID de la list
for nbi = 1, table.getn(spawnList[nb + 1]), 1 do
if((nbi % 2) == 0) then X=X+2; Z=Z+2; else X=X-2; Z=Z-2; end
local mobNBR = spawnList[nb + 1][nbi];
--printf("Serjeant_Tombstone => mob %u \n",mobNBR);
if(mobNBR ~= nil) then
-- Spawn Mob
SpawnMob(mobNBR):setMobMod(MOBMOD_SUPERLINK, mob:getShortID());
GetMobByID(mobNBR):setPos(X,Y,Z);
GetMobByID(mobNBR):setSpawn(X,Y,Z);
-- Spawn Pet for BST, DRG, and SMN
local MJob = GetMobByID(mobNBR):getMainJob();
-- printf("Serjeant_Tombstone => mob %u \n",mobNBR);
-- printf("mobjob %u \n",MJob);
if(MJob == 9 or MJob == 14 or MJob == 15) then
-- Spawn Pet for BST , DRG , and SMN
SpawnMob(mobNBR + 1):setMobMod(MOBMOD_SUPERLINK, mob:getShortID());
GetMobByID(mobNBR + 1):setPos(X,Y,Z);
GetMobByID(mobNBR + 1):setSpawn(X,Y,Z);
end
end
end
end
end
end
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob,killer)
local mobID = mob:getID();
if( mobID == 16941135 or mobID == 16941411)then --hp
killer:messageBasic(024,(killer:getMaxHP()-killer:getHP()));
killer:restoreHP(3000);
elseif(mobID == 16941137 or mobID == 16941412) then --mp
killer:messageBasic(025,(killer:getMaxMP()-killer:getMP()));
killer:restoreMP(3000);
end
end; | gpl-3.0 |
op-en/NODEMCU-TempSensor | src/CAPEv2.lua | 1 | 2015 | intervall = 5000 -- in ms
function StartCape(intervall)
print("Starting CAPE")
print(wifi.sta.getip())
dofile('owtemp.lua')
--Add more stuff
--dofile('MQTT.lua')
tmr.alarm(2, 4000, tmr.ALARM_AUTO, function()
getTemp()
if connected == false then
print("not connected")
return
end
for key,value in pairs(temperature) do
--print(key)
--print(value.time)
--print(value.temperature)
if value.sent == false then
if (value.oldtime ~= nil) then
value.delta = math.abs(value.oldtemp - value.temperature)
value.deltaT = value.time - value.oldtime
--print(value.delta)
else
value.delta = 0
value.deltaT = 9999999
end
if (value.delta > 0.15) or (value.deltaT > 60) then
topic = cmd_ch .. "/" .. key
payload = "{\"time\":" .. value.time .. ",\"temperature\":" .. value.temperature .. "}"
m:publish( topic , payload,0,1)
value.sent = true
value.oldtime = value.time
value.oldtemp = value.temperature
print("Sending: " .. topic .. " " .. payload)
end
end
end
--dofile('DHT11.lua')
--if status == dht.OK then
-- sec,usec=rtctime.get()
-- if connected then
-- m:publish(cmd_ch .. "/dht11","{\"time\":" .. sec .. ",\"temperature\":" .. temp .. ",\"humidity\":" .. humi .. "}",0,0)
-- end
--end
end)
end
-- Start only if we have an IP or when we get one.
if (wifi.sta.getip() ~= nil) then
StartCape(intervall)
else
wifi.sta.eventMonReg(wifi.STA_GOTIP, StartCape)
end
| mit |
kitala1/darkstar | scripts/zones/Port_Windurst/npcs/Lebondur.lua | 36 | 1564 | -----------------------------------
-- Area: Port Windurst
-- NPC: Lebondur
-- Regional Marchant NPC
-- Only sells when Windurst controls Vollbow.
-- Confirmed shop stock, August 2013
-----------------------------------
require("scripts/globals/shop");
require("scripts/globals/conquest");
package.loaded["scripts/zones/Port_Windurst/TextIDs"] = nil;
require("scripts/zones/Port_Windurst/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
RegionOwner = GetRegionOwner(VOLLBOW);
if (RegionOwner ~= WINDURST) then
player:showText(npc,LEBONDUR_CLOSED_DIALOG);
else
player:showText(npc,LEBONDUR_OPEN_DIALOG);
stock = {
0x027C, 119, --Chamomile
0x0360, 88, --Fish Scales
0x03a8, 14, --Rock Salt
0x0582, 1656 --Sweet William
}
showShop(player,WINDURST,stock);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
kitala1/darkstar | scripts/zones/Temenos/mobs/Water_Elemental.lua | 17 | 1709 | -----------------------------------
-- Area: Temenos E T
-- NPC: Water_Elemental
-----------------------------------
package.loaded["scripts/zones/Temenos/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/limbus");
require("scripts/zones/Temenos/TextIDs");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob,killer)
local mobID = mob:getID();
local mobX = mob:getXPos();
local mobY = mob:getYPos();
local mobZ = mob:getZPos();
switch (mobID): caseof {
-- 100 a 106 inclut (Temenos -Northern Tower )
[16928885] = function (x)
GetNPCByID(16928768+277):setPos(mobX,mobY,mobZ);
GetNPCByID(16928768+277):setStatus(STATUS_NORMAL);
end ,
[16928886] = function (x)
GetNPCByID(16928768+190):setPos(mobX,mobY,mobZ);
GetNPCByID(16928768+190):setStatus(STATUS_NORMAL);
end ,
[16928887] = function (x)
GetNPCByID(16928768+127):setPos(mobX,mobY,mobZ);
GetNPCByID(16928768+127):setStatus(STATUS_NORMAL);
end ,
[16928888] = function (x)
GetNPCByID(16928768+69):setPos(mobX,mobY,mobZ);
GetNPCByID(16928768+69):setStatus(STATUS_NORMAL);
end ,
[16929038] = function (x)
if(IsMobDead(16929033)==false)then
DespawnMob(16929033);
SpawnMob(16929039);
end
end ,
}
end; | gpl-3.0 |
hanxi/cocos2d-x-v3.1 | frameworks/cocos2d-x/cocos/scripting/lua-bindings/auto/api/Lens3D.lua | 3 | 1271 |
--------------------------------
-- @module Lens3D
-- @extend Grid3DAction
--------------------------------
-- @function [parent=#Lens3D] setPosition
-- @param self
-- @param #cc.Vec2 vec2
--------------------------------
-- @function [parent=#Lens3D] setConcave
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#Lens3D] setLensEffect
-- @param self
-- @param #float float
--------------------------------
-- @function [parent=#Lens3D] getPosition
-- @param self
-- @return Vec2#Vec2 ret (return value: cc.Vec2)
--------------------------------
-- @function [parent=#Lens3D] getLensEffect
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- @function [parent=#Lens3D] create
-- @param self
-- @param #float float
-- @param #size_table size
-- @param #cc.Vec2 vec2
-- @param #float float
-- @return Lens3D#Lens3D ret (return value: cc.Lens3D)
--------------------------------
-- @function [parent=#Lens3D] clone
-- @param self
-- @return Lens3D#Lens3D ret (return value: cc.Lens3D)
--------------------------------
-- @function [parent=#Lens3D] update
-- @param self
-- @param #float float
return nil
| mit |
Nukesor/ShapeRape | src/states/achievementState.lua | 1 | 3151 | tween = require("lib/tween/tween")
require("states/pauseState")
require("systems/draw/achievementDrawSystem")
require("components/achievementComponent")
require("components/drawableComponent")
AchievementState = class("AchievementState", State)
function AchievementState:load()
--love.graphics.setBackgroundColor(255,255,18)
self.index = 1
self.nodeWidth = 1
self.engine = Engine()
self.eventmanager = EventManager()
self.eventmanager:addListener("KeyPressed", {MenuNavigationSystem, MenuNavigationSystem.fireEvent})
local screenWidth = love.graphics.getWidth()
local screenHeight = love.graphics.getHeight()
self.menupoints = {{"Back to Menu", function() stack:push(MenuState()) end},
{"Reset Achievements", function() end}}
local targetX = love.graphics.getWidth()*(3/5)
local targetY = love.graphics.getHeight()/20
local x = love.graphics.getWidth() + 100
local y = targetY
for index, item in pairs(self.menupoints) do
item.x = screenWidth/5
item.y = -100
item.targetX = item.x
item.targetY = (2/5)*screenHeight + (80 * index)
end
for index, value in pairs(achievement.achievements) do
local achievementEntity = Entity()
local targetY = targetY*index +love.graphics.getHeight()*1/10
local positionComponent = PositionComponent(x, targetY)
achievementEntity:add(positionComponent)
achievementEntity:add(AnimateComponent((0.2*index), positionComponent, {x = targetX, y = targetY}, "inOutQuad"))
if value == 0 then
achievementEntity:add(DrawableComponent(resources.images.circle, 0, 0.2, 0.2, 0, 0))
achievementEntity:add(ColorComponent(255,0,0))
elseif value == 1 then
achievementEntity:add(DrawableComponent(resources.images.triangle, 0, 1, 1, 0, 0))
elseif value == 2 then
achievementEntity:add(DrawableComponent(resources.images.circle, 0, 1, 1, 0, 0))
end
achievementEntity:add(AchievementComponent())
self.engine:addEntity(achievementEntity)
end
local AchievementCaption = Entity()
positionComponent = PositionComponent(x, y)
AchievementCaption:add(positionComponent)
AchievementCaption:add(AnimateComponent(2, positionComponent, {x = targetX, y = targetY}, "inOutQuad"))
AchievementCaption:add(StringComponent(resources.fonts.CoolFont40, {255,255,255,255}, "You have Unlocked", {}))
self.engine:addEntity(AchievementCaption)
local menuPointDisplaySystem = MenuPointDisplaySystem()
self.engine:addSystem(menuPointDisplaySystem, "draw", 4)
self.engine:addSystem(menuPointDisplaySystem, "logic", 2)
self.engine:addSystem(AnimateSystem(), "logic", 3)
self.engine:addSystem(StringDrawSystem(), "draw", 3)
self.engine:addSystem(AchievementDrawSystem(), "draw", 5)
end
function AchievementState:update(dt)
self.engine:update(dt)
end
function AchievementState:draw()
self.engine:draw()
end
function AchievementState:keypressed(key, isrepeat)
self.eventmanager:fireEvent(KeyPressed(key, isrepeat))
end
| gpl-3.0 |
shadobaker/Anti-Spam | bot/bot.lua | 1 | 217009 | #start Project Anti Spam V4:)
json = dofile('./libs/JSON.lua');serpent = dofile("./libs/serpent.lua");local lgi = require ('lgi');local notify = lgi.require('Notify');notify.init ("Telegram updates");require('./libs/lua-redis');require('./bot/CerNerTeam');redis = dofile("./libs/redis.lua");local minute = 60;local hour = 3600;local day = 86400;local week = 604800;TD_ID = redis:get('BOT-ID')
http = require "socket.http"
utf8 = dofile('./bot/utf8.lua')
json = dofile('./libs/JSON.lua')
https = require "ssl.https"
SHADOBAKER = '`شادوباکر`'
SUDO_ID = {403542926} --ایدی عددی سودو
Full_Sudo = {403542926} --ایدی عددی سودو
ChannelLogs= 403542926 --ایدی عددی سودو
MsgTime = os.time() - 60
Plan1 = 2592000
Plan2 = 7776000
local function getParse(parse_mode)
local P = {}
if parse_mode then
local mode = parse_mode:lower()
if mode == 'markdown' or mode == 'md' then
P._ = 'textParseModeMarkdown'
elseif mode == 'html' then
P._ = 'textParseModeHTML'
end
end
return P
end
function is_sudo(msg)
local var = false
for v,user in pairs(SUDO_ID) do
if user == msg.sender_user_id then
var = true
end
end
if redis:sismember("SUDO-ID", msg.sender_user_id) then
var = true
end
return var
end
function is_Fullsudo(msg)
local var = false
for v,user in pairs(Full_Sudo) do
if user == msg.sender_user_id then
var = true
end
end
return var
end
function do_notify (user, msg)
local n = notify.Notification.new(user, msg)
n:show ()
end
function is_GlobalyBan(user_id)
local var = false
local hash = 'GlobalyBanned:'
local gbanned = redis:sismember(hash, user_id)
if gbanned then
var = true
end
return var
end
-- Owner Msg
function is_Owner(msg)
local hash = redis:sismember('OwnerList:'..msg.chat_id,msg.sender_user_id)
if hash or is_sudo(msg) then
return true
else
return false
end
end
-----CerNer Company
function is_Mod(msg)
local hash = redis:sismember('ModList:'..msg.chat_id,msg.sender_user_id)
if hash or is_sudo(msg) or is_Owner(msg) then
return true
else
return false
end
end
function is_Vip(msg)
local hash = redis:sismember('Vip:'..msg.chat_id,msg.sender_user_id)
if hash or is_sudo(msg) or is_Owner(msg) or is_Mod(msg) then
return true
else
return false
end
end
function is_Banned(chat_id,user_id)
local hash = redis:sismember('BanUser:'..chat_id,user_id)
if hash then
return true
else
return false
end
end
function private(chat_id,user_id)
local Mod = redis:sismember('ModList:'..chat_id,user_id)
local Vip = redis:sismember('Vip:'..chat_id,user_id)
local Owner = redis:sismember('OwnerList:'..chat_id,user_id)
if tonumber(user_id) == tonumber(TD_ID) or Owner or Mod or Vip then
return true
else
return false
end
end
function is_filter(msg,value)
local list = redis:smembers('Filters:'..msg.chat_id)
var = false
for i=1, #list do
if value:match(list[i]) then
var = true
end
end
return var
end
function is_MuteUser(chat_id,user_id)
local hash = redis:sismember('MuteUser:'..chat_id,user_id)
if hash then
return true
else
return false
end
end
function ec_name(name)
cerner = name
if cerner then
if cerner:match('_') then
cerner = cerner:gsub('_','')
end
if cerner:match('*') then
cerner = cerner:gsub('*','')
end
if cerner:match('`') then
cerner = cerner:gsub('`','')
end
return cerner
end
end
local function getChatId(chat_id)
local chat = {}
local chat_id = tostring(chat_id)
if chat_id:match('^-100') then
local channel_id = chat_id:gsub('-100', '')
chat = {id = channel_id, type = 'channel'}
else
local group_id = chat_id:gsub('-', '')
chat = {id = group_id, type = 'group'}
end
return chat
end
local function getMe(cb)
assert (tdbot_function ({
_ = "getMe",
}, cb, nil))
end
function Pin(channelid,messageid,disablenotification)
assert (tdbot_function ({
_ = "pinChannelMessage",
channel_id = getChatId(channelid).id,
message_id = messageid,
disable_notification = disablenotification
}, dl_cb, nil))
end
function Unpin(channelid)
assert (tdbot_function ({
_ = 'unpinChannelMessage',
channel_id = getChatId(channelid).id
}, dl_cb, nil))
end
function KickUser(chat_id, user_id)
tdbot_function ({
_ = "changeChatMemberStatus",
chat_id = chat_id,
user_id = user_id,
status = {
_ = "chatMemberStatusBanned"
},
}, dl_cb, nil)
end
function getFile(fileid,cb)
assert (tdbot_function ({
_ = 'getFile',
file_id = fileid
}, cb, nil))
end
function Left(chat_id, user_id, s)
assert (tdbot_function ({
_ = "changeChatMemberStatus",
chat_id = chat_id,
user_id = user_id,
status = {
_ = "chatMemberStatus" ..s
},
}, dl_cb, nil))
end
function changeDes(CerNer,Company)
assert (tdbot_function ({
_ = 'changeChannelDescription',
channel_id = getChatId(CerNer).id,
description = Company
}, dl_cb, nil))
end
function changeChatTitle(chat_id, title)
assert (tdbot_function ({
_ = "changeChatTitle",
chat_id = chat_id,
title = title
}, dl_cb, nil))
end
function mute(chat_id, user_id, Restricted, right)
local chat_member_status = {}
if Restricted == 'Restricted' then
chat_member_status = {
is_member = right[1] or 1,
restricted_until_date = right[2] or 0,
can_send_messages = right[3] or 1,
can_send_media_messages = right[4] or 1,
can_send_other_messages = right[5] or 1,
can_add_web_page_previews = right[6] or 1
}
chat_member_status._ = 'chatMemberStatus' .. Restricted
assert (tdbot_function ({
_ = 'changeChatMemberStatus',
chat_id = chat_id,
user_id = user_id,
status = chat_member_status
}, dl_cb, nil))
end
end
function promoteToAdmin(chat_id, user_id)
tdbot_function ({
_ = "changeChatMemberStatus",
chat_id = chat_id,
user_id = user_id,
status = {
_ = "chatMemberStatusAdministrator"
},
}, dl_cb, nil)
end
function resolve_username(username,cb)
tdbot_function ({
_ = "searchPublicChat",
username = username
}, cb, nil)
end
function RemoveFromBanList(chat_id, user_id)
tdbot_function ({
_ = "changeChatMemberStatus",
chat_id = chat_id,
user_id = user_id,
status = {
_ = "chatMemberStatusLeft"
},
}, dl_cb, nil)
end
function getChatHistory(chat_id, from_message_id, offset, limit,cb)
tdbot_function ({
_ = "getChatHistory",
chat_id = chat_id,
from_message_id = from_message_id,
offset = offset,
limit = limit
}, cb, nil)
end
function deleteMessagesFromUser(chat_id, user_id)
tdbot_function ({
_ = "deleteMessagesFromUser",
chat_id = chat_id,
user_id = user_id
}, dl_cb, nil)
end
function deleteMessages(chat_id, message_ids)
tdbot_function ({
_= "deleteMessages",
chat_id = chat_id,
message_ids = message_ids -- vector {[0] = id} or {id1, id2, id3, [0] = id}
}, dl_cb, nil)
end
local function getMessage(chat_id, message_id,cb)
tdbot_function ({
_ = "getMessage",
chat_id = chat_id,
message_id = message_id
}, cb, nil)
end
function GetChat(chatid,cb)
assert (tdbot_function ({
_ = 'getChat',
chat_id = chatid
}, cb, nil))
end
function sendInline(chatid, replytomessageid, disablenotification, frombackground, queryid, resultid)
assert (tdbot_function ({
_ = 'sendInlineQueryResultMessage',
chat_id = chatid,
reply_to_message_id = replytomessageid,
disable_notification = disablenotification,
from_background = frombackground,
query_id = queryid,
result_id = tostring(resultid)
}, dl_cb,nil))
end
function get(bot_user_id, chat_id, latitude, longitude, query,offset, cb)
assert (tdbot_function ({
_ = 'getInlineQueryResults',
bot_user_id = bot_user_id,
chat_id = chat_id,
user_location = {
_ = 'location',
latitude = latitude,
longitude = longitude
},
query = tostring(query),
offset = tostring(off)
}, cb, nil))
end
function StartBot(bot_user_id, chat_id, parameter)
assert (tdbot_function ({_ = 'sendBotStartMessage',bot_user_id = bot_user_id,chat_id = chat_id,parameter = tostring(parameter)}, dl_cb, nil))
end
function viewMessages(chat_id, message_ids)
tdbot_function ({
_ = "viewMessages",
chat_id = chat_id,
message_ids = message_ids
}, dl_cb, nil)
end
local function getInputFile(file, conversion_str, expectedsize)
local input = tostring(file)
local infile = {}
if (conversion_str and expectedsize) then
infile = {
_ = 'inputFileGenerated',
original_path = tostring(file),
conversion = tostring(conversion_str),
expected_size = expectedsize
}
else
if input:match('/') then
infile = {_ = 'inputFileLocal', path = file}
elseif input:match('^%d+$') then
infile = {_ = 'inputFileId', id = file}
else
infile = {_ = 'inputFilePersistentId', persistent_id = file}
end
end
return infile
end
function addChatMembers(chatid, userids)
assert (tdbot_function ({
_ = 'addChatMembers',
chat_id = chatid,
user_ids = userids,
}, dl_cb, nil))
end
function GetChannelFull(channelid)
assert (tdbot_function ({
_ = 'getChannelFull',
channel_id = getChatId(channelid).id
}, cb, nil))
end
function sendGame(chat_id, reply_to_message_id, botuserid, gameshortname, disable_notification, from_background, reply_markup)
local input_message_content = {
_ = 'inputMessageGame',
bot_user_id = botuserid,
game_short_name = tostring(gameshortname)
}
sendMessage(chat_id, reply_to_message_id, input_message_content, disable_notification, from_background, reply_markup)
end
function SendMetin(chat_id, user_id, msg_id, text, offset, length)
assert (tdbot_function ({
_ = "sendMessage",
chat_id = chat_id,
reply_to_message_id = msg_id,
disable_notification = 0,
from_background = true,
reply_markup = nil,
input_message_content = {
_ = "inputMessageText",
text = text,
disable_web_page_preview = 1,
clear_draft = false,
entities = {[0] = {
offset = offset,
length = length,
_ = "textEntity",
type = {user_id = user_id, _ = "textEntityTypeMentionName"}}}
}
}, dl_cb, nil))
end
function changeChatPhoto(chat_id,photo)
assert (tdbot_function ({
_ = 'changeChatPhoto',
chat_id = chat_id,
photo = getInputFile(photo)
}, dl_cb, nil))
end
function downloadFile(fileid)
assert (tdbot_function ({
_ = 'downloadFile',
file_id = fileid,
}, dl_cb, nil))
end
local function sendMessage(c, e, r, n, e, r, callback, data)
assert (tdbot_function ({
_ = 'sendMessage',
chat_id = c,
reply_to_message_id =e,
disable_notification = r or 0,
from_background = n or 1,
reply_markup = e,
input_message_content = r
}, callback or dl_cb, data))
end
local function sendPhoto(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, photo, caption)
assert (tdbot_function ({
_= "sendMessage",
chat_id = chat_id,
reply_to_message_id = reply_to_message_id,
disable_notification = disable_notification,
from_background = from_background,
reply_markup = reply_markup,
input_message_content = {
_ = "inputMessagePhoto",
photo = getInputFile(photo),
added_sticker_file_ids = {},
width = 0,
height = 0,
caption = caption..(RedisApi or'\n@'..string.reverse("mrekabodahs"))
},
}, dl_cb, nil))
end
function GetUser(user_id, cb)
assert (tdbot_function ({
_ = 'getUser',
user_id = user_id
}, cb, nil))
end
local function GetUserFull(user_id,cb)
assert (tdbot_function ({
_ = "getUserFull",
user_id = user_id
}, cb, nil))
end
function file_exists(name)
local f = io.open(name,"r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end
function whoami()
local usr = io.popen("whoami"):read('*a')
usr = string.gsub(usr, '^%s+', '')
usr = string.gsub(usr, '%s+$', '')
usr = string.gsub(usr, '[\n\r]+', ' ')
if usr:match("^root$") then
tcpath = '/root/.telegram-bot/main/files/'
elseif not usr:match("^root$") then
tcpath = '/home/'..usr..'/.telegram-bot/main/files/'
end
print('>> Download Path = '..tcpath)
end
function getChannelFull(CerNer,Company)
assert (tdbot_function ({
_ = 'getChannelFull',
channel_id = getChatId(CerNer).id
}, Company, nil))
end
function setProfilePhoto(photo_path)
assert (tdbot_function ({
_ = 'setProfilePhoto',
photo = photo_path
}, dl_cb, nil))
end
function ForMsg(chat_id, from_chat_id, message_id,from_background)
assert (tdbot_function ({
_ = "forwardMessages",
chat_id = chat_id,
from_chat_id = from_chat_id,
message_ids = message_id,
disable_notification = 0,
from_background = from_background
}, dl_cb, nil))
end
function getChannelMembers(channelid,mbrfilter,off, limit,cb)
if not limit or limit > 200 then
limit = 200
end
assert (tdbot_function ({
_ = 'getChannelMembers',
channel_id = getChatId(channelid).id,
filter = {
_ = 'channelMembersFilter' .. mbrfilter,
},
offset = off,
limit = limit
}, cb, nil))
end
function sendGame(chat_id, msg_id, botuserid, gameshortname)
assert (tdbot_function ({
_ = "sendMessage",
chat_id = chat_id,
reply_to_message_id = msg_id,
disable_notification = 0,
from_background = true,
reply_markup = nil,
input_message_content = {
_ = 'inputMessageGame',
bot_user_id = botuserid,
game_short_name = tostring(gameshortname)
}
}, dl_cb, nil))
end
function SendMetion(chat_id, user_id, msg_id, text, offset, length)
assert (tdbot_function ({
_ = "sendMessage",
chat_id = chat_id,
reply_to_message_id = msg_id,
disable_notification = 0,
from_background = true,
reply_markup = nil,
input_message_content = {
_ = "inputMessageText",
text = text,
disable_web_page_preview = 1,
clear_draft = false,
entities = {[0] = {
offset = offset,
length = length,
_ = "textEntity",
type = {user_id = user_id, _ = "textEntityTypeMentionName"}}}
}
}, dl_cb, nil))
end
function dl_cb(arg, data)
end
function showedit(msg,data)
if msg then
if msg.date < tonumber(MsgTime) then
print('OLD MESSAGE')
return false
end
function is_supergroup(msg)
chat_id = tostring(msg.chat_id)
if chat_id:match('^-100') then
if not msg.is_post then
return true
end
else
return false
end
end
if is_Owner(msg) then
if msg.content._ == 'messagePinMessage' then
print ' Pinned By Owner '
redis:set('Pin_id'..msg.chat_id, msg.content.message_id)
end
end
NUM_MSG_MAX = 6
if redis:get('Flood:Max:'..msg.chat_id) then
NUM_MSG_MAX = redis:get('Flood:Max:'..msg.chat_id)
end
NUM_CH_MAX = 200
if redis:get('NUM_CH_MAX:'..msg.chat_id) then
NUM_CH_MAX = redis:get('NUM_CH_MAX:'..msg.chat_id)
end
TIME_CHECK = 2
if redis:get('Flood:Time:'..msg.chat_id) then
TIME_CHECK = redis:get('Flood:Time:'..msg.chat_id)
end
warn = 5
if redis:get('Warn:Max:'..msg.chat_id) then
warn = redis:get('Warn:Max:'..msg.chat_id)
end
if is_supergroup(msg) then
-------------Flood Check------------
function antifloodstats(msg,status)
if status == "kickuser" then
if tonumber(msg.sender_user_id) == tonumber(TD_ID) then
return true
end
sendText(msg.chat_id, msg.id,'*User* : `'..(msg.sender_user_id or 021)..'` *has been* _kicked_ *for flooding*' ,'md')
KickUser(msg.chat_id,msg.sender_user_id)
end
if status == "muteuser" then
if tonumber(msg.sender_user_id) == tonumber(TD_ID) then
return true
end
if is_MuteUser(msg.chat_id,msg.sender_user_id) then
else
sendText(msg.chat_id, msg.id,'*User* : `'..(msg.sender_user_id or 021)..'` *has been* _Muted_ *for flooding*' ,'md')
mute(msg.chat_id,msg.sender_user_id or 021,'Restricted', {1, 0, 0, 0, 0,0})
redis:sadd('MuteList:'..msg.chat_id,msg.sender_user_id or 021)
end
end
end
if redis:get('Lock:Flood:'..msg.chat_id) then
if not is_Mod(msg) then
local post_count = 'user1:' .. msg.sender_user_id .. ':flooder'
local msgs = tonumber(redis:get(post_count) or 0)
if msgs > tonumber(NUM_MSG_MAX) then
if redis:get('user:'..msg.sender_user_id..':flooder') then
local status = redis:get('Flood:Status:'..msg.chat_id)
antifloodstats(msg,status)
return false
else
redis:setex('user:'..msg.sender_user_id..':flooder', 15, true)
end
end
redis:setex(post_count, tonumber(TIME_CHECK), msgs+1)
end
end
end
-------------MSG CerNer ------------
local cerner = msg.content.text
local cerner1 = msg.content.text
if cerner then
cerner = cerner:lower()
end
if MsgType == 'text' and cerner then
if cerner:match('^[/#!]') then
cerner= cerner:gsub('^[/#!]','')
end
end
------------------------------------
--------------MSG TYPE----------------
if msg.content._== "messageText" then
MsgType = 'text'
end
if msg.content.text then
print(""..msg.content.text.." : Sender : "..msg.sender_user_id.."\n[ CerNerCompany ]\nThis is [ TEXT ]")
end
if msg.content.caption then
print(""..msg.content.caption.." : Sender : "..msg.sender_user_id.."\n[ CerNerCompany ]\nThis is [ Caption ]")
end
if msg.content._ == "messageChatAddMembers" then
print("[ CerNerCompany ]\nThis is [ AddUser ]")
for i=0,#msg.content.member_user_ids do
msg.add = msg.content.member_user_ids[i]
MsgType = 'AddUser'
end
end
if msg.content._ == "messageChatJoinByLink" then
print("[ CerNerCompany ]\nThis is [JoinByLink ]")
MsgType = 'JoinedByLink'
end
if msg.content._ == "messageDocument" then
print("[ CerNerCompany ]\nThis is [ File Or Document ]")
MsgType = 'Document'
end
-------------------------
if msg.content._ == "messageSticker" then
print("[ CerNerCompany ]\nThis is [ Sticker ]")
MsgType = 'Sticker'
end
-------------------------
if msg.content._ == "messageAudio" then
print("[ CerNerCompany ]\nThis is [ Audio ]")
MsgType = 'Audio'
end
-------------------------
if msg.content._ == "messageVoice" then
print("[ CerNerCompany ]\nThis is [ Voice ]")
MsgType = 'Voice'
end
-------------------------
if msg.content._ == "messageVideo" then
print("[ CerNerCompany ]\nThis is [ Video ]")
MsgType = 'Video'
end
-------------------------
if msg.content._ == "messageAnimation" then
print("[ CerNerCompany ]\nThis is [ Gif ]")
MsgType = 'Gif'
end
-------------------------
if msg.content._ == "messageLocation" then
print("[ CerNerCompany ]\nThis is [ Location ]")
MsgType = 'Location'
end
if msg.content._ == "messageForwardedFromUser" then
print("[ CerNerCompany ]\nThis is [ messageForwardedFromUser ]")
MsgType = 'messageForwardedFromUser'
end
-------------------------
if msg.content._ == "messageContact" then
print("[ CerNerCompany ]\nThis is [ Contact ]")
MsgType = 'Contact'
end
if not msg.reply_markup and msg.via_bot_user_id ~= 0 then
print(serpent.block(data))
print("[ CerNerCompany ]\nThis is [ MarkDown ]")
MsgType = 'Markreed'
end
if msg.content.game then
print("[ CerNerCompany ]\nThis is [ Game ]")
MsgType = 'Game'
end
if msg.content._ == "messagePhoto" then
MsgType = 'Photo'
end
if msg.sender_user_id and is_GlobalyBan(msg.sender_user_id) then
sendText(msg.chat_id, msg.id,'*User * : `'..msg.sender_user_id..'` *is Globall Banned *','md')
KickUser(msg.chat_id,msg.sender_user_id)
end
if MsgType == 'AddUser' then
function ByAddUser(CerNer,Company)
if is_GlobalyBan(Company.id) then
print ' >>>>Is Globall Banned <<<<< '
sendText(msg.chat_id, msg.id,'*User * : `'..Company.id..'` *is Globall Banned *','md')
end
GetUser(msg.content.member_user_ids[0],ByAddUser)
end
end
if msg.sender_user_id and is_Banned(msg.chat_id,msg.sender_user_id) then
KickUser(msg.chat_id,msg.sender_user_id)
end
local welcome = (redis:get('Welcome:'..msg.chat_id) or 'disable')
if welcome == 'enable' then
if MsgType == 'JoinedByLink' then
print ' JoinedByLink '
if is_Banned(msg.chat_id,msg.sender_user_id) then
KickUser(msg.chat_id,msg.sender_user_id)
sendText(msg.chat_id, msg.id,'*User * : `'..msg.sender_user_id..'` *is Globaly Banned *','md')
else
function WelcomeByLink(CerNer,Company)
if redis:get('Text:Welcome:'..msg.chat_id) then
txtt = redis:get('Text:Welcome:'..msg.chat_id)
else
txtt = 'سلام \nخوش امدی'
end
local hash = "Rules:"..msg.chat_id
local cerner = redis:get(hash)
if cerner then
rules=cerner
else
rules= '`قوانین ثبت نشده است`'
end
local hash = "Link:"..msg.chat_id
local cerner = redis:get(hash)
if cerner then
link=cerner
else
link= 'Link is not seted'
end
local txtt = txtt:gsub('{first}',ec_name(Company.first_name))
local txtt = txtt:gsub('{rules}',rules)
local txtt = txtt:gsub('{link}',link)
local txtt = txtt:gsub('{last}',Company.last_name or '')
local txtt = txtt:gsub('{username}','@'..check_markdown(Company.username) or '')
sendText(msg.chat_id, msg.id, txtt,'md')
end
GetUser(msg.sender_user_id,WelcomeByLink)
end
end
if msg.add then
if is_Banned(msg.chat_id,msg.add) then
KickUser(msg.chat_id,msg.add)
sendText(msg.chat_id, msg.id,'*User * : `'..msg.add..'` *is Banned *','md')
else
function WelcomeByAddUser(CerNer,Company)
print('New User : \nChatID : '..msg.chat_id..'\nUser ID : '..msg.add..'')
if redis:get('Text:Welcome:'..msg.chat_id) then
txtt = redis:get('Text:Welcome:'..msg.chat_id)
else
txtt = 'سلام \n خوش امدی'
end
local hash = "Rules:"..msg.chat_id
local cerner = redis:get(hash)
if cerner then
rules=cerner
else
rules= 'قوانین ثبت نشده است'
end
local hash = "Link:"..msg.chat_id
local cerner = redis:get(hash)
if cerner then
link=cerner
else
link= 'Link is not seted'
end
local txtt = txtt:gsub('{first}',ec_name(Company.first_name))
local txtt = txtt:gsub('{rules}',rules)
local txtt = txtt:gsub('{link}',link)
local txtt = txtt:gsub('{last}',Company.last_name or '')
local txtt = txtt:gsub('{username}','@'..check_markdown(Company.username) or '')
sendText(msg.chat_id, msg.id, txtt,'html')
end
GetUser(msg.add,WelcomeByAddUser)
end
end
end
viewMessages(msg.chat_id, {[0] = msg.id})
redis:incr('Total:messages:'..msg.chat_id..':'..msg.sender_user_id)
if msg.send_state._ == "messageIsSuccessfullySent" then
return false
end
if is_supergroup(msg) then
if not is_sudo(msg) then
if not redis:sismember('CompanyAll',msg.chat_id) then
redis:sadd('CompanyAll',msg.chat_id)
redis:set("ExpireData:"..msg.chat_id,'waiting')
else
if redis:get("ExpireData:"..msg.chat_id) then
if redis:ttl("ExpireData:"..msg.chat_id) and tonumber(redis:ttl("ExpireData:"..msg.chat_id)) < 432000 and not redis:get('CheckExpire:'..msg.chat_id) then
sendText(msg.chat_id,0,"شارژ "..msg.chat_id.." به اتمام رسیده است ",'md')
redis:set('CheckExpire:'..msg.chat_id,true)
end
elseif not redis:get("ExpireData:"..msg.chat_id) then
sendText(msg.chat_id,0,"شارژ "..msg.chat_id.." به اتمام رسیده است ",'md')
redis:srem("group:",msg.chat_id)
redis:del("OwnerList:",msg.chat_id)
redis:del("ModList:",msg.chat_id)
redis:del("Filters:",msg.chat_id)
redis:del("MuteList:",msg.chat_id)
Left(msg.chat_id,TD_ID, "Left")
end
end
end
end
----------Msg Checks-------------
local chat = msg.chat_id
if redis:get('CheckBot:'..msg.chat_id) then
if not is_Owner(msg) then
if redis:get('Lock:Pin:'..chat) then
if msg.content._ == 'messagePinMessage' then
print ' Pinned By Not Owner '
sendText(msg.chat_id, msg.id, 'Only Owners\n', 'md')
Unpin(msg.chat_id)
local PIN_ID = redis:get('Pin_id'..msg.chat_id)
if Pin_id then
Pin(msg.chat_id, tonumber(PIN_ID), 0)
end
end
end
end
if not is_Mod(msg) and not is_Vip(msg) then
local chat = msg.chat_id
local user = msg.sender_user_id
----------Lock Link-------------
if redis:get('Lock:Link'..chat) then
if cerner then
local link = cerner:match("[Tt][Ee][Ll][Ee][Gg][Rr][Aa][Mm].[Mm][Ee]/") or cerner:match("[Tt][Ll][Gg][Rr][Mm].[Mm][Ee]/") or cerner:match("[Tt].[Mm][Ee]/") or cerner:match('(.*)[.][mM][Ee]')
if link then
deleteMessages(msg.chat_id, {[0] = msg.id})
end
end
if msg.content.caption then
local cap = msg.content.caption
local link = cap:match("[Tt][Ee][Ll][Ee][Gg][Rr][Aa][Mm].[Mm][Ee]/") or cap:match("[Tt][Ll][Gg][Rr][Mm].[Mm][Ee]/") or cap:match("[Tt].[Mm][Ee]/") or cap:match('(.*)[.][mM][Ee]')
if link then
deleteMessages(msg.chat_id, {[0] = msg.id})
end
end
end
---------------------------
if redis:get('Lock:Tag:'..chat) then
if cerner then
local tag = cerner:match("@(.*)") or cerner:match("#(.*)")
if tag then
deleteMessages(msg.chat_id, {[0] = msg.id})
end
end
if msg.content.caption then
local cerner = msg.content.caption
local tag = cerner:match("@(.*)")
if itag then
deleteMessages(msg.chat_id, {[0] = msg.id})
end
end
end
---------------------------
if redis:get('Lock:HashTag:'..chat) then
if msg.content.text then
if msg.content.text:match("#(.*)") or msg.content.text:match("#(.*)") or msg.content.text:match("#") then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("Deleted [Lock] [HashTag] ")
end
end
if msg.content.caption then
if msg.content.caption:match("#(.*)") or msg.content.caption:match("(.*)#") or msg.content.caption:match("#") then
deleteMessages(msg.chat_id, {[0] = msg.id})
end
end
end
---------------------------
if redis:get('Lock:Video_note:'..chat) then
if msg.content._ == 'messageVideoNote' then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("Deleted [Lock] [VideoNote] ")
end
end
---------------------------
if redis:get('Lock:Arabic:'..chat) then
if cerner and cerner:match("[\216-\219][\128-\191]") then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("Deleted [Lock] [Persian] ")
end
if msg.content.caption then
local cerner = msg.content.caption
local is_persian = cerner:match("[\216-\219][\128-\191]")
if is_persian then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("Deleted [Lock] [Persian] ")
end
end
end
--------------------------
if redis:get('Lock:English:'..chat) then
if cerner and (cerner:match("[A-Z]") or cerner:match("[a-z]")) then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("Deleted [Lock] [English] ")
end
if msg.content.caption then
local cerner = msg.content.caption
local is_english = (cerner:match("[A-Z]") or cerner:match("[a-z]"))
if is_english then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("Deleted [Lock] [ENGLISH] ")
end
end
end
if redis:get('Spam:Lock:'..chat) then
if MsgType == 'text' then
local _nl, ctrl_chars = string.gsub(msg.content.text, '%c', '')
local _nl, real_digits = string.gsub(msg.content.text, '%d', '')
local hash = 'NUM_CH_MAX:'..msg.chat_id
if not redis:get(hash) then
sens = 40
else
sens = tonumber(redis:get(hash))
end
local max_real_digits = tonumber(sens) * 50
local max_len = tonumber(sens) * 51
if string.len(msg.content.text) > sens or ctrl_chars > sens or real_digits > sens then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("Deleted [Lock] [Spam] ")
end
end
end
----------Filter------------
if cerner then
if is_filter(msg,cerner) then
deleteMessages(msg.chat_id, {[0] = msg.id})
end
end
-----------------------------------------------
if redis:get('Lock:Bot:'..chat) then
if msg.add then
function ByAddUser(CerNer,Company)
if Company.type._ == "userTypeBot" then
print ' Bot added '
KickUser(msg.chat_id,Company.id)
end
end
GetUser(msg.add,ByAddUser)
end
end
-----------------------------------------------
if redis:get('Lock:Inline:'..chat) then
if not msg.reply_markup and msg.via_bot_user_id ~= 0 then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("Deleted [Lock] [Inline] ")
end
end
----------------------------------------------
if redis:get('Lock:TGservise:'..chat) then
if msg.content._ == "messageChatJoinByLink" or msg.content._ == "messageChatAddMembers" or msg.content._ == "messageChatDeleteMember" then
deleteMessages(msg.chat_id, {[0] = msg.id})
end
end
------------------------------------------------
if redis:get('Lock:Forward:'..chat) then
if msg.forward_info then
deleteMessages(msg.chat_id, {[0] = msg.id})
end
end
--------------------------------
if redis:get('Lock:Sticker:'..chat) then
if MsgType == 'Sticker' then
deleteMessages(msg.chat_id, {[0] = msg.id})
end
end
----------Lock Edit-------------
if redis:get('Lock:Edit'..chat) then
if msg.edit_date > 0 then
deleteMessages(msg.chat_id, {[0] = msg.id})
end
end
-------------------------------Mutes--------------------------
if redis:get('Mute:Text:'..chat) then
if MsgType == 'text' then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("Deleted [Lock] [Text] ")
end
end
--------------------------------
if redis:get('Mute:Photo:'..chat) then
if MsgType == 'Photo' then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("Deleted [Lock] [Photo] ")
end
end
-------------------------------
if redis:get('Mute:Caption:'..chat) then
if msg.content.caption then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("Deleted [Lock] [Caption] ")
end
end
-------------------------------
if redis:get('Mute:Reply:'..chat) then
if msg.reply_to_message_id then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("Deleted [Lock] [Reply] ")
end
end
-------------------------------
if redis:get('Mute:Document:'..chat) then
if MsgType == 'Document' then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("Deleted [Lock] [Docment] ")
end
end
---------------------------------
if redis:get('Mute:Location:'..chat) then
if MsgType == 'Location' then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("Deleted [Lock] [Location] ")
end
end
-------------------------------
if redis:get('Mute:Voice:'..chat) then
if MsgType == 'Voice' then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("[ CerNerCompany ] Deleted [Lock] [Voice] ")
end
end
-------------------------------
if redis:get('Mute:Contact:'..chat) then
if MsgType == 'Contact' then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("[ CerNerCompany ] Deleted [Lock] [Contact] ")
end
end
-------------------------------
if redis:get('Mute:Game:'..chat) then
if MsgType == 'Game' then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("[ CerNerCompany ] Deleted [Lock] [Game] ")
end
end
--------------------------------
if redis:get('Mute:Video:'..chat) then
if MsgType == 'Video' then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("[ CerNerCompany ] Deleted [Lock] [Video] ")
end
end
--------------------------------
if redis:get('Mute:Music:'..chat) then
if MsgType == 'Audio' then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("[ CerNerCompany ] Deleted [Lock] [Music] ")
end
end
--------------------------------
if redis:get('Mute:Gif:'..chat) then
if MsgType == 'Gif' then
deleteMessages(msg.chat_id, {[0] = msg.id})
print("[ CerNerCompany ] Deleted [Lock] [Gif] ")
end
end
------------------------------
end
end
------------Chat Type------------
function is_channel(msg)
chat_id = tostring(msg.chat_id)
if chat_id:match('^-100') then
if msg.is_post then -- message is a channel post
return true
else
return false
end
end
end
function is_group(msg)
chat_id= tostring(msg.chat_id)
if chat_id:match('^-100') then
return false
elseif chat_id_:match('^-') then
return true
else
return false
end
end
function is_private(msg)
chat_id = tostring(msg.chat_id)
if chat_id:match('^(%d+)') then
print' ty '
return false
else
return true
end
end
local function run_bash(str)
local cmd = io.popen(str)
local result = cmd:read('*all')
return result
end
function check_markdown(text)
str = text
if str:match('_') then
output = str:gsub('_',[[\_]])
elseif str:match('*') then
output = str:gsub('*','\\*')
elseif str:match('`') then
output = str:gsub('`','\\`')
else
output = str
end
return output
end
if is_Fullsudo(msg) then
if cerner and cerner:match('^setsudo (%d+)') then
local sudo = cerner:match('^setsudo (%d+)')
redis:sadd('SUDO-ID',sudo)
sendText(msg.chat_id, msg.id, '• `'..sudo..'` *Added To SudoList*', 'md')
end
if cerner and cerner:match('^remsudo (%d+)') then
local sudo = cerner:match('^remsudo (%d+)')
redis:srem('SUDO-ID',sudo)
sendText(msg.chat_id, msg.id, '• `'..sudo..'` *Removed From SudoList*', 'md')
end
if cerner == 'sudolist' then
local hash = "SUDO-ID"
local list = redis:smembers(hash)
local t = '*Sudo list: *\n'
for k,v in pairs(list) do
local user_info = redis:hgetall('user:'..v)
if user_info and user_info.username then
local username = user_info.username
t = t..k.." - @"..username.." ["..v.."]\n"
else
t = t..k.." - "..v.."\n"
end
end
if #list == 0 then
t = '*The list is empty*'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
end
if is_Fullsudo(msg) then
if cerner and cerner:match('^تنظیم سودو (%d+)') then
local sudo = cerner:match('^تنظیم سودو (%d+)')
redis:sadd('SUDO-ID',sudo)
sendText(msg.chat_id, msg.id, '• `'..sudo..'` *اضافه شد به لیست سودو*', 'md')
end
if cerner and cerner:match('^حذف سودو (%d+)') then
local sudo = cerner:match('^حذف سودو (%d+)')
redis:srem('SUDO-ID',sudo)
sendText(msg.chat_id, msg.id, '• `'..sudo..'` *از لیست سودو حذف شد*', 'md')
end
if cerner == 'لیست سودو' then
local hash = "SUDO-ID"
local list = redis:smembers(hash)
local t = '*لیست سودو: *\n'
for k,v in pairs(list) do
local user_info = redis:hgetall('user:'..v)
if user_info and user_info.username then
local username = user_info.username
t = t..k.." - @"..username.." ["..v.."]\n"
else
t = t..k.." - "..v.."\n"
end
end
if #list == 0 then
t = '*لیست مورد نظر خالی میباشد*'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
end
if is_supergroup(msg) then
if cerner == 'test' then
redis:del('Request1:')
end
if is_sudo(msg) then
if cerner == 'bc' and tonumber(msg.reply_to_message_id) > 0 then
function CerNerCompany(CerNer,Company)
local text = Company.content.text
local list = redis:smembers('CompanyAll')
for k,v in pairs(list) do
sendText(v, 0, text, 'md')
end
end
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),CerNerCompany)
end
if cerner == 'fwd' and tonumber(msg.reply_to_message_id) > 0 or cerner == 'فروارد' and tonumber(msg.reply_to_message_id) > 0 then
function CerNerCompany(CerNer,Company)
local list = redis:smembers('CompanyAll')
for k,v in pairs(list) do
ForMsg(v, msg.chat_id, {[0] = Company.id}, 1)
end
end
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),CerNerCompany)
end
if cerner and cerner:match('^addme (-100)(%d+)$') or cerner and cerner:match('^دعوت من (-100)(%d+)$') then
local chat_id = cerner:match('^addme (.*)$')
local chat_id = cerner:match('^دعوت من (.*)$')
sendText(msg.chat_id,msg.id,'با موفقيت تورو به گروه '..chat_id..' اضافه کردم.','md')
addChatMembers(chat_id,{[0] = msg.sender_user_id})
end
if cerner == 'add' then
local function GetName(CerNer, Company)
if not redis:get("ExpireData:"..msg.chat_id) then
redis:setex("ExpireData:"..msg.chat_id,day,true)
end
redis:sadd("group:",msg.chat_id)
if redis:get('CheckBot:'..msg.chat_id) then
local text = '• Group `'..Company.title..'` is *Already* Added'
sendText(msg.chat_id, msg.id,text,'md')
else
local text = '• `Group` *'..Company.title..'* ` Added`'
local Hash = 'StatsGpByName'..msg.chat_id
local ChatTitle = Company.title
redis:set(Hash,ChatTitle)
print('• New Group\nChat name : '..Company.title..'\nChat ID : '..msg.chat_id..'\nBy : '..msg.sender_user_id)
local textlogs =[[•• گروه جدیدی به لیست مدیریت اضافه شد
• اطلاعات گروه :
• نام گروه ]]..Company.title..[[
• آیدی گروه : ]]..msg.chat_id..[[
• توسط : ]]..msg.sender_user_id..[[
• برای عضویت در گروه میتوانید از دستور [addme] استفاده کنید
> مثال :
addme ]]..msg.chat_id..[[
]]
redis:set('CheckBot:'..msg.chat_id,true)
if not redis:get('CheckExpire:'..msg.chat_id) then
redis:set('CheckExpire:'..msg.chat_id,true)
end
sendText(msg.chat_id, msg.id,text,'md')
sendText(ChannelLogs, 0,textlogs,'html')
end
end
GetChat(msg.chat_id,GetName)
end
if cerner == 'نصب' then
local function GetName(CerNer, Company)
if not redis:get("ExpireData:"..msg.chat_id) then
redis:setex("ExpireData:"..msg.chat_id,day,true)
end
redis:sadd("group:",msg.chat_id)
if redis:get('CheckBot:'..msg.chat_id) then
local text = '• گروه '..Company.title..' از قبل در لیست مدیریتی من بود'
sendText(msg.chat_id, msg.id,text,'md')
else
local text = '• گروه *'..Company.title..'* به لیست مدیریتی من اضافه شد'
local Hash = 'StatsGpByName'..msg.chat_id
local ChatTitle = Company.title
redis:set(Hash,ChatTitle)
print('• New Group\nChat name : '..Company.title..'\nChat ID : '..msg.chat_id..'\nBy : '..msg.sender_user_id)
local textlogs =[[•• گروه جدیدی به لیست مدیریت اضافه شد
• اطلاعات گروه :
• نام گروه ]]..Company.title..[[
• آیدی گروه : ]]..msg.chat_id..[[
• توسط : ]]..msg.sender_user_id..[[
• برای عضویت در گروه میتوانید از دستور [addme] استفاده کنید
> مثال :
addme ]]..msg.chat_id..[[
]]
redis:set('CheckBot:'..msg.chat_id,true)
if not redis:get('CheckExpire:'..msg.chat_id) then
redis:set('CheckExpire:'..msg.chat_id,true)
end
sendText(msg.chat_id, msg.id,text,'md')
sendText(ChannelLogs, 0,textlogs,'html')
end
end
GetChat(msg.chat_id,GetName)
end
if cerner == 'ids' then
sendText(msg.chat_id,msg.id,''..msg.chat_id..'','md')
end
if cerner == 'شناسه گروه' then
sendText(msg.chat_id,msg.id,''..msg.chat_id..'','md')
end
if cerner == 'reload' then
dofile('./bot/bot.lua')
sendText(msg.chat_id,msg.id,'• Bot Reloaded','md')
end
if cerner == 'بارگذاری' then
dofile('./bot/bot.lua')
sendText(msg.chat_id,msg.id,'• ربات با موفقيت بارگذاری شد','md')
end
if cerner == 'vardump' then
function id_by_reply(extra, result, success)
local TeXT = serpent.block(result, {comment=false})
text= string.gsub(TeXT, "\n","\n\r\n")
sendText(msg.chat_id, msg.id, text,'html')
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id,
tonumber(msg.reply_to_message_id),id_by_reply)
end
end
if cerner == 'rem' then
local function GetName(CerNer, Company)
redis:del("ExpireData:"..msg.chat_id)
redis:srem("group:",msg.chat_id)
redis:del("OwnerList:"..msg.chat_id)
redis:del("ModList:"..msg.chat_id)
redis:del('StatsGpByName'..msg.chat_id)
redis:del('CheckExpire:'..msg.chat_id)
if not redis:get('CheckBot:'..msg.chat_id) then
local text = '• Group `'..Company.title..'` is *Already* Removed'
sendText(msg.chat_id, msg.id,text,'md')
else
local text = '• `Group` *'..Company.title..'* ` Removed `'
local Hash = 'StatsGpByName'..msg.chat_id
redis:del(Hash)
sendText(msg.chat_id, msg.id,text,'md')
redis:del('CheckBot:'..msg.chat_id)
local textlogs =[[•• گروهی از لست مدیریتی من حذف شد
• اطلاعات گروه :
• نام گروه ]]..Company.title..[[
• آیدی گروه : ]]..msg.chat_id..[[
• توسط : ]]..msg.sender_user_id..[[
]]
sendText(ChannelLogs, 0,textlogs,'html')
end
end
GetChat(msg.chat_id,GetName)
end
if cerner == 'لغو نصب' then
local function GetName(CerNer, Company)
redis:del("ExpireData:"..msg.chat_id)
redis:srem("group:",msg.chat_id)
redis:del("OwnerList:"..msg.chat_id)
redis:del("ModList:"..msg.chat_id)
redis:del('StatsGpByName'..msg.chat_id)
redis:del('CheckExpire:'..msg.chat_id)
if not redis:get('CheckBot:'..msg.chat_id) then
local text = '• گروه '..Company.title..' از قبل در لیست مدیریتی من نبود'
sendText(msg.chat_id, msg.id,text,'md')
else
local text = '• گروه *'..Company.title..'* از لیست مدیریتی من حذف شد'
local Hash = 'StatsGpByName'..msg.chat_id
redis:del(Hash)
sendText(msg.chat_id, msg.id,text,'md')
redis:del('CheckBot:'..msg.chat_id)
local textlogs =[[•• گروهی از لست مدیریتی من حذف شد
• اطلاعات گروه :
• نام گروه ]]..Company.title..[[
• آیدی گروه : ]]..msg.chat_id..[[
• توسط : ]]..msg.sender_user_id..[[
]]
sendText(ChannelLogs, 0,textlogs,'html')
end
end
GetChat(msg.chat_id,GetName)
end
if cerner and cerner:match('^tdset (%d+)$') then
local TD_id = cerner:match('^tdset (%d+)$')
redis:set('BOT-ID',TD_id)
sendText(msg.chat_id, msg.id,'Done\nNew Bot ID : '..TD_id,'md')
end
if cerner and cerner:match('^تی دی ست (%d+)$') then
local TD_id = cerner:match('^تی دی ست (%d+)$')
redis:set('BOT-ID',TD_id)
sendText(msg.chat_id, msg.id,'انجام شد\nشناسه جدید ربات : '..TD_id,'md')
end
if cerner and cerner:match('^invite (%d+)$') then
local id = cerner:match('^invite (%d+)$')
addChatMembers(msg.chat_id,{[0] = id})
sendText(msg.chat_id, msg.id,'Done','md')
end
if cerner and cerner:match('^دعوت (%d+)$') then
local id = cerner:match('^دعوت (%d+)$')
addChatMembers(msg.chat_id,{[0] = id})
sendText(msg.chat_id, msg.id,'انجام شد','md')
end
if cerner1 and cerner1:match('^plan1 (-100)(%d+)$') or cerner1 and cerner1:match('^پلن1 (-100)(%d+)$') then
local chat_id = cerner1:match('^plan1 (.*)$')
local chat_id = cerner1:match('^پلن1 (.*)$')
if redis:get('CheckExpire:'..msg.chat_id) then
redis:set('CheckExpire:'..msg.chat_id,true)
end
redis:setex("ExpireData:"..chat_id,Plan1,true)
sendText(msg.chat_id,msg.id,'پلن 1 با موفقيت براي گروه '..chat_id..' فعال شد\nاين گروه تا 30 روز ديگر اعتبار دارد! ( 1 ماه )','md')
sendText(chat_id,0,"ربات با موفقيت فعال شد و تا 30 روز ديگر اعتبار دارد!",'md')
end
------------------Charge Plan 2--------------------------
if cerner and cerner:match('^plan2 (-100)(%d+)$') or cerner1 and cerner1:match('^پلن2 (-100)(%d+)$') then
local chat_id = cerner:match('^plan2 (.*)$')
local chat_id = cerner:match('^پلن2 (.*)$')
redis:setex("ExpireData:"..chat_id,Plan2,true)
sendText(msg.chat_id,msg.id,'پلن 2 با موفقيت براي گروه '..chat_id..' فعال شد\nاين گروه تا 90 روز ديگر اعتبار دارد! ( 3 ماه )','md')
sendText(chat_id,0,"ربات با موفقيت فعال شد و تا 90 روز ديگر اعتبار دارد! ( 3 ماه )",'md')
if redis:get('CheckExpire:'..msg.chat_id) then
redis:set('CheckExpire:'..msg.chat_id,true)
end
end
-----------------Charge Plan 3---------------------------
if cerner and cerner:match('^plan3 (-100)(%d+)$') or cerner1 and cerner1:match('^پلن3 (-100)(%d+)$') then
local chat_id = cerner:match('^plan3 (.*)$')
local chat_id = cerner:match('^پلن3 (.*)$')
redis:set("ExpireData:"..chat_id,true)
sendText(msg.chat_id ,msg.id,''..chat_id..'_پلن شماره 3 براي گروه مورد نظر فعال شد!_','md')
sendText(chat_id,0,"_پلن شماره ? براي اين گروه تمديد شد \nمدت اعتبار پنل (نامحدود)!_",'md')
if redis:get('CheckExpire:'..msg.chat_id) then
redis:set('CheckExpire:'..msg.chat_id,true)
end
end
-----------Leave----------------------------------
if cerner1 and cerner1:match('^leave (-100)(%d+)$') or cerner1 and cerner1:match('^خارج شو (-100)(%d+)$') then
local chat_id = cerner1:match('^leave (.*)$')
local chat_id = cerner1:match('^خارج شو (.*)$')
redis:del("ExpireData:"..chat_id)
redis:srem("group:",chat_id)
redis:del("OwnerList:"..chat_id)
redis:del("ModList:"..chat_id)
redis:del('StatsGpByName'..chat_id)
redis:del('CheckExpire:'..chat_id)
sendText(msg.chat_id,msg.id,'ربات با موفقيت از گروه '..chat_id..' خارج شد.','md')
sendText(chat_id,0,'ربات به دستور سازنده از گروه خارج میشود ','md')
Left(chat_id,TD_ID, "Left")
end
if cerner == 'groups' then
local list = redis:smembers('group:')
local t = '• Groups\n'
for k,v in pairs(list) do
local GroupsName = redis:get('StatsGpByName'..v)
t = t..k.." *"..v.."*\n "..(GroupsName or '---').."\n"
end
if #list == 0 then
t = '• The list is empty'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
if cerner == 'گروه ها' then
local list = redis:smembers('group:')
local t = '• Groups\n'
for k,v in pairs(list) do
local GroupsName = redis:get('StatsGpByName'..v)
t = t..k.." *"..v.."*\n "..(GroupsName or '---').."\n"
end
if #list == 0 then
t = '• لیست مورد نظر خالی میباشد'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
if cerner and cerner:match('^charge (%d+)$') then
local function GetName(CerNer, Company)
local time = tonumber(cerner:match('^charge (%d+)$')) * day
redis:setex("ExpireData:"..msg.chat_id,time,true)
local ti = math.floor(time / day )
local text = '• `Group` *'..Company.title..'* ` Charged` For *'..ti..'* Day'
sendText(msg.chat_id, msg.id,text,'md')
local textlogs =[[•• گروهی به مدت]] ..ti.. [[ شارژ شد
• اطلاعات گروه :
• نام گروه ]]..Company.title..[[
• آیدی گروه : ]]..msg.chat_id..[[
• توسط : ]]..msg.sender_user_id..[[
• برای عضویت در گروه میتوانید از دستور [addme] استفاده کنید
> مثال :
addme ]]..msg.chat_id..[[
]]
sendText(ChannelLogs, 0,textlogs,'html')
if redis:get('CheckExpire:'..msg.chat_id) then
redis:set('CheckExpire:'..msg.chat_id,true)
end
end
GetChat(msg.chat_id,GetName)
end
if cerner and cerner:match('^شارژ (%d+)$') then
local function GetName(CerNer, Company)
local time = tonumber(cerner:match('^شارژ (%d+)$')) * day
redis:setex("ExpireData:"..msg.chat_id,time,true)
local ti = math.floor(time / day )
local text = '• گروه *'..Company.title..'* به مدت *'..ti..'* روز شارژ شد'
sendText(msg.chat_id, msg.id,text,'md')
local textlogs =[[•• گروهی به مدت]] ..ti.. [[ شارژ شد
• اطلاعات گروه :
• نام گروه ]]..Company.title..[[
• آیدی گروه : ]]..msg.chat_id..[[
• توسط : ]]..msg.sender_user_id..[[
• برای عضویت در گروه میتوانید از دستور [addme] استفاده کنید
> مثال :
addme ]]..msg.chat_id..[[
]]
sendText(ChannelLogs, 0,textlogs,'html')
if redis:get('CheckExpire:'..msg.chat_id) then
redis:set('CheckExpire:'..msg.chat_id,true)
end
end
GetChat(msg.chat_id,GetName)
end
if cerner == 'messageid' then
sendText(msg.chat_id, msg.id,msg.reply_to_message_id,'md')
end
if cerner == "expire" then
local ex = redis:ttl("ExpireData:"..msg.chat_id)
if ex == -1 then
sendText(msg.chat_id, msg.id, "• Unlimited", 'md' )
else
local d = math.floor(ex / day ) + 1
sendText(msg.chat_id, msg.id,d.." Day", 'md' )
end
end
if cerner == "اعتبار" then
local ex = redis:ttl("ExpireData:"..msg.chat_id)
if ex == -1 then
sendText(msg.chat_id, msg.id, "• نامحدود", 'md' )
else
local d = math.floor(ex / day ) + 1
sendText(msg.chat_id, msg.id,d.." روز", 'md' )
end
end
if cerner == 'leave' then
Left(msg.chat_id, TD_ID, 'Left')
end
if cerner == 'خارج شو' then
Left(msg.chat_id, TD_ID, 'Left')
end
if cerner == 'stats' then
local allmsgs = redis:get('allmsgs')
local supergroup = redis:scard('ChatSuper:Bot')
local Groups = redis:scard('Chat:Normal')
local users = redis:scard('ChatPrivite')
local text =[[
• All Msgs : ]]..allmsgs..[[
SuperGroups :]]..supergroup..[[
Groups : ]]..Groups..[[
Users : ]]..users..[[
]]
sendText(msg.chat_id, msg.id,text, 'md' )
end
if cerner == 'امار' then
local allmsgs = redis:get('allmsgs')
local supergroup = redis:scard('ChatSuper:Bot')
local Groups = redis:scard('Chat:Normal')
local users = redis:scard('ChatPrivite')
local text =[[
• کل پیام ها : ]]..allmsgs..[[
سوپر گروه ها :]]..supergroup..[[
گروه های معمولی : ]]..Groups..[[
کاربر ها : ]]..users..[[
]]
sendText(msg.chat_id, msg.id,text, 'md' )
end
if cerner == 'reset' then
redis:del('allmsgs')
redis:del('ChatSuper:Bot')
redis:del('Chat:Normal')
redis:del('ChatPrivite')
sendText(msg.chat_id, msg.id,'Done', 'md' )
end
if cerner == 'ریسیت' then
redis:del('allmsgs')
redis:del('ChatSuper:Bot')
redis:del('Chat:Normal')
redis:del('ChatPrivite')
sendText(msg.chat_id, msg.id,'انجام شد', 'md' )
end
if cerner == 'ownerlist' then
local list = redis:smembers('OwnerList:'..msg.chat_id)
local t = '• OwnerList\n'
for k,v in pairs(list) do
t = t..k.." - *"..v.."*\n"
end
t = t.."\n\n• To see the user's from command under use!\nwhois ID\nExample ! \nwhois 363936960"
if #list == 0 then
t = 'The list is empty'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
if cerner == 'لیست مالکان' then
local list = redis:smembers('OwnerList:'..msg.chat_id)
local t = '• مالک های گروه\n'
for k,v in pairs(list) do
t = t..k.." - *"..v.."*\n"
end
t = t.."\n\n• برای دیدن کاربر از دستور زیر استفاده کنید!\nچه کسی ایدی\nمثال ! \nچه کسی 363936960"
if #list == 0 then
t = 'لیست مورد نظر خالی میباشد'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
if cerner and cerner:match('^setrank (.*)$') then
local rank = cerner:match('^setrank (.*)$')
local function SetRank_Rep(CerNer, Company)
if tonumber(Company.sender_user_id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
redis:set('rank'..Company.sender_user_id,rank)
local user = Company.sender_user_id
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, '• Rank the '..user..' to '..rank..' the change', 11,string.len(Company.sender_user_id))
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),SetRank_Rep)
end
end
if cerner and cerner:match('^تنظیم مقام (.*)$') then
local rank = cerner:match('^تنظیم مقام (.*)$')
local function SetRank_Rep(CerNer, Company)
if tonumber(Company.sender_user_id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
redis:set('rank'..Company.sender_user_id,rank)
local user = Company.sender_user_id
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, '• مقام کاربر '..user..' به '..rank..' تغییر پیدا کرد', 11,string.len(Company.sender_user_id))
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),SetRank_Rep)
end
end
----------------------SetOwner--------------------------------
if cerner == 'setowner' then
local function SetOwner_Rep(CerNer, Company)
local user = Company.sender_user_id
if redis:sismember('OwnerList:'..msg.chat_id,user) then
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, '• User : '..Company.sender_user_id..' is Already added to Ownerlist..!', 9,string.len(Company.sender_user_id))
else
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, '• User : '..Company.sender_user_id..' Added to OwnerList ..', 9,string.len(Company.sender_user_id))
redis:sadd('OwnerList:'..msg.chat_id,user or 00000000)
end
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),SetOwner_Rep)
end
end
if cerner == 'مالک' then
local function SetOwner_Rep(CerNer, Company)
local user = Company.sender_user_id
if redis:sismember('OwnerList:'..msg.chat_id,user) then
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, '• کاربر : '..Company.sender_user_id..' از قبل مالک گروه بود!', 9,string.len(Company.sender_user_id))
else
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, '• کاربر : '..Company.sender_user_id..' مالک گروه شد', 9,string.len(Company.sender_user_id))
redis:sadd('OwnerList:'..msg.chat_id,user or 00000000)
end
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),SetOwner_Rep)
end
end
if cerner == 'git pull' or cerner == 'اپدیت' then
text = io.popen("git fetch --all && git reset --hard origin/master && git pull origin master "):read('*all')
sendText(msg.chat_id, msg.id,text, 'md')
end
if cerner and cerner:match('^setowner (%d+)') then
local user = cerner:match('setowner (%d+)')
if redis:sismember('OwnerList:'..msg.chat_id,user) then
SendMetion(msg.chat_id,user, msg.id, '• User : '..user..' is Already added to OwnerList ..', 9,string.len(user))
else
SendMetion(msg.chat_id,user, msg.id, '• User : '..user..' Added to OwnerList ..', 9,string.len(user))
redis:sadd('OwnerList:'..msg.chat_id,user)
end
end
if cerner and cerner:match('^مالک (%d+)') then
local user = cerner:match('مالک (%d+)')
if redis:sismember('OwnerList:'..msg.chat_id,user) then
SendMetion(msg.chat_id,user, msg.id, '• کاربر : '..user..' از قبل مالک گروه بود', 9,string.len(user))
else
SendMetion(msg.chat_id,user, msg.id, '• کاربر : '..user..' مالک گروه شد', 9,string.len(user))
redis:sadd('OwnerList:'..msg.chat_id,user)
end
end
if cerner and cerner:match('^setowner @(.*)') then
local username = cerner:match('^setowner @(.*)')
function SetOwnerByUsername(CerNer,Company)
if Company.id then
print(''..Company.id..'')
if redis:sismember('OwnerList:'..msg.chat_id,Company.id) then
SendMetion(msg.chat_id,Company.id, msg.id, '• User : '..Company.id..' is Already added to OwnerList ..', 9,string.len(Company.id))
else
SendMetion(msg.chat_id,Company.id, msg.id, '• User : '..Company.id..' Added to OwnerList ..', 9,string.len(Company.id))
redis:sadd('OwnerList:'..msg.chat_id,Company.id)
end
else
text = '• *User NotFound*'
sendText(msg.chat_id, msg.id, text, 'md')
end
end
resolve_username(username,SetOwnerByUsername)
end
if cerner and cerner:match('^مالک @(.*)') then
local username = cerner:match('^مالک @(.*)')
function SetOwnerByUsername(CerNer,Company)
if Company.id then
print(''..Company.id..'')
if redis:sismember('OwnerList:'..msg.chat_id,Company.id) then
SendMetion(msg.chat_id,Company.id, msg.id, '• کاربر : '..Company.id..' از قبل مالک گروه بود', 9,string.len(Company.id))
else
SendMetion(msg.chat_id,Company.id, msg.id, '• کاربر : '..Company.id..' مالک گروه شد', 9,string.len(Company.id))
redis:sadd('OwnerList:'..msg.chat_id,Company.id)
end
else
text = '• *کاربر یافت نشد*'
sendText(msg.chat_id, msg.id, text, 'md')
end
end
resolve_username(username,SetOwnerByUsername)
end
if cerner == 'remowner' then
local function RemOwner_Rep(CerNer, Company)
local user = Company.sender_user_id
if redis:sismember('OwnerList:'..msg.chat_id, Company.sender_user_id or 00000000) then
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, '• User : '..(Company.sender_user_id or 021)..' Removed from OwnerList ..', 9,string.len(Company.sender_user_id))
redis:srem('OwnerList:'..msg.chat_id,Company.sender_user_id or 00000000)
else
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, '• User : '..(Company.sender_user_id or 021)..' Is Not Owner ..', 9,string.len(Company.sender_user_id))
end
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),RemOwner_Rep)
end
end
if cerner and cerner:match('^remowner (%d+)') then
local user = cerner:match('remowner (%d+)')
if redis:sismember('OwnerList:'..msg.chat_id,user) then
SendMetion(msg.chat_id,user, msg.id, '• User : '..user..' Removed from OwnerList ..', 9,string.len(user))
redis:srem('OwnerList:'..msg.chat_id,user)
else
SendMetion(msg.chat_id,user, msg.id, '• User : '..user..' Is Not Owner ..', 9,string.len(user))
end
end
if cerner and cerner:match('^remowner @(.*)') then
local username = cerner:match('^remowner @(.*)')
function RemOwnerByUsername(CerNer,Company)
if Company.id then
print(''..Company.id..'')
if redis:sismember('OwnerList:'..msg.chat_id, Company.id) then
SendMetion(msg.chat_id,Company.id, msg.id, '• User : '..Company.id..' Removed from OwnerList ..', 9,string.len(Company.id))
redis:srem('OwnerList:'..msg.chat_id,Company.id)
else
SendMetion(msg.chat_id,Company.id, msg.id, '• User : '..Company.id..' is not owner ..', 9,string.len(Company.id))
end
else
text = '• *User Not Found*'
sendText(msg.chat_id, msg.id, text, 'md')
end
end
resolve_username(username,RemOwnerByUsername)
end
if cerner == 'حذف مالک' then
local function RemOwner_Rep(CerNer, Company)
local user = Company.sender_user_id
if redis:sismember('OwnerList:'..msg.chat_id, Company.sender_user_id or 00000000) then
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, '• کاربر : '..(Company.sender_user_id or 021)..' از مقام مالک گروه برکنار شد', 9,string.len(Company.sender_user_id))
redis:srem('OwnerList:'..msg.chat_id,Company.sender_user_id or 00000000)
else
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, '• کاربر : '..(Company.sender_user_id or 021)..' از قبل مالک گروه نبود', 9,string.len(Company.sender_user_id))
end
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),RemOwner_Rep)
end
end
if cerner and cerner:match('^حذف مالک (%d+)') then
local user = cerner:match('حذف مالک (%d+)')
if redis:sismember('OwnerList:'..msg.chat_id,user) then
SendMetion(msg.chat_id,user, msg.id, '• کاربر : '..user..' از مقام مالک گروه برکنار شد', 9,string.len(user))
redis:srem('OwnerList:'..msg.chat_id,user)
else
SendMetion(msg.chat_id,user, msg.id, '• کاربر : '..user..' از قبل مالک گروه نبود', 9,string.len(user))
end
end
if cerner and cerner:match('^حذف مالک @(.*)') then
local username = cerner:match('^حذف مالک @(.*)')
function RemOwnerByUsername(CerNer,Company)
if Company.id then
print(''..Company.id..'')
if redis:sismember('OwnerList:'..msg.chat_id, Company.id) then
SendMetion(msg.chat_id,Company.id, msg.id, '• کاربر : '..Company.id..' از مقام مالک گروه برکنار شد', 9,string.len(Company.id))
redis:srem('OwnerList:'..msg.chat_id,Company.id)
else
SendMetion(msg.chat_id,Company.id, msg.id, '• کاربر : '..Company.id..' از قبل مالک گروه نبود', 9,string.len(Company.id))
end
else
text = '• *کاربر یافت نشد*'
sendText(msg.chat_id, msg.id, text, 'md')
end
end
resolve_username(username,RemOwnerByUsername)
end
---------Start---------------Globaly Banned-------------------
if cerner == 'banall' then
function GbanByReply(CerNer,Company)
if redis:sismember('GlobalyBanned:',Company.sender_user_id or 00000000) then
sendText(msg.chat_id, msg.id, '• `User : ` *'..(Company.sender_user_id or 00000000)..'* is *Already* `a Globaly Banned..!`', 'md')
else
sendText(msg.chat_id, msg.id,'• _ User : _ `'..(Company.sender_user_id or 00000000)..'` *is* to `Globaly Banned`..', 'md')
redis:sadd('GlobalyBanned:',Company.sender_user_id or 00000000)
end
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),GbanByReply)
end
end
if cerner and cerner:match('^banall (%d+)') then
local user = cerner:match('^banall (%d+)')
if redis:sismember('GlobalyBanned:',user) then
sendText(msg.chat_id, msg.id, '• `User : ` *'..user..'* is *Already* ` Globaly Banned..!`', 'md')
else
sendText(msg.chat_id, msg.id,'• _ User : _ `'..user..'` *Added* to `Globaly Banned` ..', 'md')
redis:sadd('GlobalyBanned:',user)
end
end
if cerner and cerner:match('^banall @(.*)') then
local username = cerner:match('^banall @(.*)')
function BanallByUsername(CerNer,Company)
if Company.id then
print(''..Company.id..'')
if redis:sismember('GlobalyBanned:', Company.id) then
text ='• `User : ` *'..Company.id..'* is* Already* ` Globaly Banned..!`'
else
text= '• _ User : _ `'..Company.id..'` *Added* to `Globaly Banned`..'
redis:sadd('GlobalyBanned:',Company.id)
end
else
text = '• *User NotFound*'
end
sendText(msg.chat_id, msg.id, text, 'md')
end
resolve_username(username,BanallByUsername)
end
if cerner == 'سوپر بن' then
function GbanByReply(CerNer,Company)
if redis:sismember('GlobalyBanned:',Company.sender_user_id or 00000000) then
sendText(msg.chat_id, msg.id, '• `کاربر : ` *'..(Company.sender_user_id or 00000000)..'* از قبل از تمامی گروه های ربات محروم بود!`', 'md')
else
sendText(msg.chat_id, msg.id,'• _ کاربر : _ `'..(Company.sender_user_id or 00000000)..'` از تمامی گروه های ربات محروم شد', 'md')
redis:sadd('GlobalyBanned:',Company.sender_user_id or 00000000)
end
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),GbanByReply)
end
end
if cerner and cerner:match('^سوپر بن (%d+)') then
local user = cerner:match('^سوپر بن (%d+)')
if redis:sismember('GlobalyBanned:',user) then
sendText(msg.chat_id, msg.id, '• `کاربر : ` *'..user..'* ز قبل از تمامی گروه های ربات محروم بود!`', 'md')
else
sendText(msg.chat_id, msg.id,'• _ کاربر : _ `'..user..'` از تمامی گروه های ربات محروم شد', 'md')
redis:sadd('GlobalyBanned:',user)
end
end
if cerner and cerner:match('^سوپر بن @(.*)') then
local username = cerner:match('^سوپر بن @(.*)')
function BanallByUsername(CerNer,Company)
if Company.id then
print(''..Company.id..'')
if redis:sismember('GlobalyBanned:', Company.id) then
text ='• `کاربر : ` *'..Company.id..'* از قبل از تمامی گروه های ربات محروم بود!`'
else
text= '• _ کاربر : _ `'..Company.id..'` از تمامی گروه های ربات محروم شد'
redis:sadd('GlobalyBanned:',Company.id)
end
else
text = '• *کاربر یافت نشد*'
end
sendText(msg.chat_id, msg.id, text, 'md')
end
resolve_username(username,BanallByUsername)
end
if cerner == 'gbans' then
local list = redis:smembers('GlobalyBanned:')
local t = 'Globaly Ban:\n'
for k,v in pairs(list) do
t = t..k.." - *"..v.."*\n"
end
t = t.."\n\n• To see the user's from command under use!\nwhois ID\nExample ! \nwhois 363936960"
if #list == 0 then
t = 'The list is empty'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
if cerner == 'لیست سوپر بن' then
local list = redis:smembers('GlobalyBanned:')
local t = 'Globaly Ban:\n'
for k,v in pairs(list) do
t = t..k.." - *"..v.."*\n"
end
t = t.."\n\n• برای دیدن کاربر از دستور زیر استفاده کنید!\nچه کسی ایدی\nمثال ! \nچه کسی 363936960"
if #list == 0 then
t = 'لیست مورد نظر خالی میباشد'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
if cerner == 'clean gbans' then
redis:del('GlobalyBanned:'..msg.chat_id)
sendText(msg.chat_id, msg.id,'• *Gobaly Banned* Has Been Cleared..', 'md')
end
if cerner == 'پاکسازی لیست سوپر بن' then
redis:del('GlobalyBanned:'..msg.chat_id)
sendText(msg.chat_id, msg.id,'• لیست کاربران محروم خالی شد', 'md')
end
---------------------Unbanall--------------------------------------
if cerner and cerner:match('^unbanall (%d+)') then
local user = cerner:match('unbanall (%d+)')
if tonumber(user) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
if redis:sismember('GlobalyBanned:',user) then
sendText(msg.chat_id, msg.id,'• _ کاربر : _ `'..user..'` *Removed* from `` Globaly Banned..', 'md')
redis:srem('GlobalyBanned:',user)
else
sendText(msg.chat_id, msg.id, '• `User : ` *'..user..'* is *Not* ` Globaly Banned..!`', 'md')
end
end
if cerner and cerner:match('^unbanall @(.*)') then
local username = cerner:match('^unbanall @(.*)')
function UnbanallByUsername(CerNer,Company)
if tonumber(Company.id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
if Company.id then
print(''..Company.id..'')
if redis:sismember('GlobalyBanned:', Company.id) then
text = '• _ User : _ `'..Company.id..'` *Removed* from `OwnerLis` Globaly Banned ..!'
redis:srem('GlobalyBanned:',Company.id)
else
text = '• `User : ` *'..user..'* is *Not* ` Globaly Banned..!`'
end
else
text = '• *User NotFound*'
end
sendText(msg.chat_id, msg.id, text, 'md')
end
resolve_username(username,UnbanallByUsername)
end
if cerner == 'حذف سوپر بن' then
function UnGbanByReply(CerNer,Company)
if tonumber(Company.sender_user_id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
if redis:sismember('GlobalyBanned:',Company.sender_user_id or 00000000) then
sendText(msg.chat_id, msg.id,'• _ کاربر : _ `'..(Company.sender_user_id or 00000000)..'` از محرومیت های گروه های ربات خارج شد', 'md')
redis:srem('GlobalyBanned:',Company.sender_user_id or 00000000)
else
sendText(msg.chat_id, msg.id, '• `کاربر : ` *'..(Company.sender_user_id or 00000000)..'* از گروه های ربات محروم نبود!`', 'md')
end
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),UnGbanByReply)
end
end
if cerner and cerner:match('^حذف سوپر بن (%d+)') then
local user = cerner:match('حذف سوپر بن (%d+)')
if tonumber(user) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
if redis:sismember('GlobalyBanned:',user) then
sendText(msg.chat_id, msg.id,'• _ کاربر : _ `'..user..'` از محرومیت های گروه های ربات خارج شد', 'md')
redis:srem('GlobalyBanned:',user)
else
sendText(msg.chat_id, msg.id, '• `کاربر : ` *'..user..'* از گروه های ربات محروم نبود!`', 'md')
end
end
if cerner and cerner:match('^حذف سوپر بن @(.*)') then
local username = cerner:match('^حذف سوپر بن @(.*)')
function UnbanallByUsername(CerNer,Company)
if tonumber(Company.id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
if Company.id then
print(''..Company.id..'')
if redis:sismember('GlobalyBanned:', Company.id) then
text = '• _ کاربر : _ `'..Company.id..'` از محرومیت های گروه های ربات خارج شد'
redis:srem('GlobalyBanned:',Company.id)
else
text = '• `کاربر : ` *'..user..'* از گروه های ربات محروم نبود!`'
end
else
text = '• *کاربر یافت نشد*'
end
sendText(msg.chat_id, msg.id, text, 'md')
end
resolve_username(username,UnbanallByUsername)
end
if cerner == 'unbanall' then
function UnGbanByReply(CerNer,Company)
if tonumber(Company.sender_user_id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
if redis:sismember('GlobalyBanned:',Company.sender_user_id or 00000000) then
sendText(msg.chat_id, msg.id,'• _ کاربر : _ `'..(Company.sender_user_id or 00000000)..'` از محرومیت های گروه های ربات خارج شد', 'md')
redis:srem('GlobalyBanned:',Company.sender_user_id or 00000000)
else
sendText(msg.chat_id, msg.id, '• `کاربر : ` *'..(Company.sender_user_id or 00000000)..'* از گروه های ربات محروم نبود!`', 'md')
end
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),UnGbanByReply)
end
end
if cerner == 'clean members' then
function CleanMembers(CerNer, Company)
for k, v in pairs(Company.members) do
if tonumber(v.user_id) == tonumber(TD_ID) then
return true
end
KickUser(msg.chat_id,v.user_id)
end
end
print('CerNer')
getChannelMembers(msg.chat_id,"Recent",0, 2000000,CleanMembers)
sendText(msg.chat_id, msg.id,'• Done\nAll Memers Has Been Kicked', 'md')
end
if cerner == 'پاکسازی ممبر ها' then
function CleanMembers(CerNer, Company)
for k, v in pairs(Company.members) do
if tonumber(v.user_id) == tonumber(TD_ID) then
return true
end
KickUser(msg.chat_id,v.user_id)
end
end
print('CerNer')
getChannelMembers(msg.chat_id,"Recent",0, 2000000,CleanMembers)
sendText(msg.chat_id, msg.id,'• انجام شد\nهمه ممبر ها اخراج شدند', 'md')
end
-------------------------------
end
if is_Owner(msg) then
if cerner == 'config' or cerner == 'پیکربندی' then
if not limit or limit > 200 then
limit = 200
end
local function GetMod(extra,result,success)
local c = result.members
for i=0 , #c do
redis:sadd('ModList:'..msg.chat_id,c[i].user_id)
end
sendText(msg.chat_id,msg.id,"*تمام مدیران گروه به رسمیت شناخته شده اند*!", "md")
end
getChannelMembers(msg.chat_id,'Administrators',0,limit,GetMod)
end
if cerner == 'modlist' then
local list = redis:smembers('ModList:'..msg.chat_id)
local t = '• ModList\n'
for k,v in pairs(list) do
t = t..k.." - `"..v.."`\n"
end
t = t.."\n\n• To see the user's from command under use!\nwhois ID\nExample ! \nwhois 363936960"
if #list == 0 then
t = 'The list is empty'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
if cerner == 'لیست مدیران' then
local list = redis:smembers('ModList:'..msg.chat_id)
local t = '• لیست مدیران گروه\n'
for k,v in pairs(list) do
t = t..k.." - *"..v.."*\n"
end
t = t.."\n\n• برای دیدن کاربر از دستور زیر استفاده کنید!\nچه کسی ایدی\nمثال ! \nچه کسی 363936960"
if #list == 0 then
t = 'لیست مورد نظر خالی میباشد'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
if cerner and cerner:match('^unmuteuser (%d+)$') then
local mutes = cerner:match('^unmuteuser (%d+)$')
if tonumber(mutes) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
redis:srem('MuteList:'..msg.chat_id,mutes)
mute(msg.chat_id, mutes,'Restricted', {0, 0, 0, 0, 0,1})
sendText(msg.chat_id, msg.id,"• _Done_ \n*User* `"..mutes.."` *Has Been Unmuted* *\nRestricted*", 'md' )
end
if cerner and cerner:match('^حذف سکوت (%d+)$') then
local mutes = cerner:match('^حذف سکوت (%d+)$')
if tonumber(mutes) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
redis:srem('MuteList:'..msg.chat_id,mutes)
mute(msg.chat_id, mutes,'Restricted', {0, 0, 0, 0, 0,1})
sendText(msg.chat_id, msg.id,"• _انجام شد_ \n*کاربر* `"..mutes.."` *توانایی چت کردن رو بدست آورد* *\nRestricted*", 'md' )
end
if cerner == 'promote' then
function PromoteByReply(CerNer,Company)
redis:sadd('ModList:'..msg.chat_id,Company.sender_user_id or 00000000)
local user = Company.sender_user_id
sendText(msg.chat_id, msg.id, '• User '..(user or 00000000)..' Has Been Promoted','md')
end
if tonumber(msg.reply_to_message_id_) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id), PromoteByReply)
end
end
if cerner == 'مدیر' then
function PromoteByReply(CerNer,Company)
redis:sadd('ModList:'..msg.chat_id,Company.sender_user_id or 00000000)
local user = Company.sender_user_id
sendText(msg.chat_id, msg.id, '• کاربر '..(user or 00000000)..' به مقام مدیر گروه منتصب شد','md')
end
if tonumber(msg.reply_to_message_id_) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id), PromoteByReply)
end
end
if cerner == 'demote' then
function DemoteByReply(CerNer,Company)
redis:srem('ModList:'..msg.chat_id,Company.sender_user_id or 00000000)
sendText(msg.chat_id, msg.id, '• User `'..(Company.sender_user_id or 00000000)..'`* Has Been Demoted*', 'md')
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),DemoteByReply)
end
end
if cerner == 'حذف مدیر' then
function DemoteByReply(CerNer,Company)
redis:srem('ModList:'..msg.chat_id,Company.sender_user_id or 00000000)
sendText(msg.chat_id, msg.id, '• کاربر `'..(Company.sender_user_id or 00000000)..'`* از مقام مدیر گروه برکنار شد*', 'md')
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),DemoteByReply)
end
end
if cerner and cerner:match('^demote @(.*)') then
local username = cerner:match('^demote @(.*)')
function DemoteByUsername(CerNer,Company)
if Company.id then
print(''..Company.id..'')
redis:srem('ModList:'..msg.chat_id,Company.id)
text = '• User `'..Company.id..'` Has Been Demoted'
else
text = '• *User NotFound*'
end
sendText(msg.chat_id, msg.id, text, 'md')
end
resolve_username(username,DemoteByUsername)
end
if cerner and cerner:match('^حذف مدیر @(.*)') then
local username = cerner:match('^حذف مدیر @(.*)')
function DemoteByUsername(CerNer,Company)
if Company.id then
print(''..Company.id..'')
redis:srem('ModList:'..msg.chat_id,Company.id)
text = '• کاربر `'..Company.id..'` از مقام مدیر گروه برکنار شد'
else
text = '• *کاربر یافت نشد*'
end
sendText(msg.chat_id, msg.id, text, 'md')
end
resolve_username(username,DemoteByUsername)
end
--------------------
if cerner and cerner:match('^مدیر @(.*)') then
local username = cerner:match('^مدیر @(.*)')
function PromoteByUsername(CerNer,Company)
if Company.id then
print(''..Company.id..'')
redis:sadd('ModList:'..msg.chat_id,Company.id)
text = '• User `'..Company.id..'` به مقام مدیر گروه منتصب شد'
else
text = '• *کاربر یافت نشد*'
end
sendText(msg.chat_id, msg.id, text, 'md')
end
resolve_username(username,PromoteByUsername)
end
----------------------
if cerner1 and cerner1:match('^[Ss]etdescription (.*)') then
local description = cerner1:match('^[Ss]etdescription (.*)')
changeDes(msg.chat_id,description)
local text = [[description Has Been Changed To ]]..description
sendText(msg.chat_id, msg.id, text, 'md')
end
if cerner1 and cerner1:match('^تنظیم درباره (.*)') then
local description = cerner1:match('^تنظیم درباره (.*)')
changeDes(msg.chat_id,description)
local text = [[درباره گروه تغییر کرده به ]]..description
sendText(msg.chat_id, msg.id, text, 'md')
end
if cerner1 and cerner1:match('^[Ss]etname (.*)') then
local Title = cerner1:match('^[Ss]etname (.*)')
local function GetName(CerNer, Company)
local Hash = 'StatsGpByName'..msg.chat_id
local ChatTitle = Company.title
redis:set(Hash,ChatTitle)
changeChatTitle(msg.chat_id,Title)
local text = [[Group Name Has Been Changed To ]]..Title
sendText(msg.chat_id, msg.id, text, 'md')
end
GetChat(msg.chat_id,GetName)
end
if cerner1 and cerner1:match('^تنظیم نام (.*)') then
local Title = cerner1:match('^تنظیم نام (.*)')
local function GetName(CerNer, Company)
local Hash = 'StatsGpByName'..msg.chat_id
local ChatTitle = Company.title
redis:set(Hash,ChatTitle)
changeChatTitle(msg.chat_id,Title)
local text = [[نام گروه تغییر کرد به ]]..Title
sendText(msg.chat_id, msg.id, text, 'md')
end
GetChat(msg.chat_id,GetName)
end
if cerner and cerner:match('^promote (%d+)') then
local user = cerner:match('promote (%d+)')
redis:sadd('ModList:'..msg.chat_id,user)
sendText(msg.chat_id, msg.id, '• User `'..user..'`* Has Been Promoted*', 'md')
end
if cerner and cerner:match('^مدیر (%d+)') then
local user = cerner:match('مدیر (%d+)')
redis:sadd('ModList:'..msg.chat_id,user)
sendText(msg.chat_id, msg.id, '• کاربر `'..user..'`* به مقام مدیر گروه منتصب شد*', 'md')
end
if cerner == 'pin' then
sendText(msg.chat_id,msg.reply_to_message_id, '• Msg Has Been Pinned' ,'md')
Pin(msg.chat_id,msg.reply_to_message_id, 1)
end
if cerner == 'سنجاق' then
sendText(msg.chat_id,msg.reply_to_message_id, '• پیام سنجاق شد' ,'md')
Pin(msg.chat_id,msg.reply_to_message_id, 1)
end
if cerner == 'unpin' then
sendText(msg.chat_id,msg.id, '• Msg Has Been UnPinned' ,'md')
Unpin(msg.chat_id)
end
if cerner == 'حذف سنجاق' then
sendText(msg.chat_id,msg.id, '• پیام سنجاق شده پاک شد' ,'md')
Unpin(msg.chat_id)
end
if cerner and cerner:match('^demote (%d+)') then
local user = cerner:match('demote (%d+)')
redis:srem('ModList:'..msg.chat_id,user)
sendText(msg.chat_id, msg.id, '• User `'..user..'`* Has Been Demoted*', 'md')
end
if cerner and cerner:match('^حذف مدیر (%d+)') then
local user = cerner:match('حذف مدیر (%d+)')
redis:srem('ModList:'..msg.chat_id,user)
sendText(msg.chat_id, msg.id, '• کاربر `'..user..'`* از مقام مدیر گروه برکنار شد*', 'md')
end
if cerner == 'lock all' then
redis:set('MuteAll:'..msg.chat_id,true)
sendText(msg.chat_id, msg.id,'• Lock ALL Has Been Enabled' ,'md')
end
if cerner == 'قفل همه' then
redis:set('MuteAll:'..msg.chat_id,true)
sendText(msg.chat_id, msg.id,'• قفل گروه فعال شد' ,'md')
end
if cerner == 'unlock all' then
redis:del('MuteAll:'..msg.chat_id)
local mutes = redis:smembers('Mutes:'..msg.chat_id)
for k,v in pairs(mutes) do
redis:srem('MuteList:'..msg.chat_id,v)
mute(msg.chat_id,v,'Restricted', {1, 1, 1, 1, 1,1})
end
sendText(msg.chat_id, msg.id,'Lock All Has Been Disabled' ,'md')
end
if cerner == 'باز همه' then
redis:del('MuteAll:'..msg.chat_id)
local mutes = redis:smembers('Mutes:'..msg.chat_id)
for k,v in pairs(mutes) do
redis:srem('MuteList:'..msg.chat_id,v)
mute(msg.chat_id,v,'Restricted', {1, 1, 1, 1, 1,1})
end
sendText(msg.chat_id, msg.id,'قفل گروه غیرفعال شد' ,'md')
end
if cerner == 'clean modlist' then
redis:del('ModList:'..msg.chat_id)
sendText(msg.chat_id, msg.id, '• ModList List Has Been Cleaned', 'md')
end
if cerner == 'پاکسازی لیست مدیران' then
redis:del('ModList:'..msg.chat_id)
sendText(msg.chat_id, msg.id, '• لیست مدیران خالی شد', 'md')
end
if cerner == 'clean ownerlist' then
redis:del('OwnerList:'..msg.chat_id)
sendText(msg.chat_id, msg.id, '• Ownerlist List Has Been Cleaned', 'md')
end
if cerner == 'پاکسازی لیست مالکان' then
redis:del('OwnerList:'..msg.chat_id)
sendText(msg.chat_id, msg.id, '• لیست مالکان خالی شد', 'md')
end
----
end
----
if is_Mod(msg) then
-----------Delete All-------------
if cerner == 'delall' then
function DelallByReply(CerNer,Company)
if tonumber(Company.sender_user_id or 00000000) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, "اوه شت :( \nمن نمیتوانم پیام های خودم را پاک کنم", 'md')
return false
end
if private(msg.chat_id,Company.sender_user_id or 000000000000000000000000000000000000000000000000) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم پیام های یک فرد دارای مقام را پاک کنم ", 'md')
else
sendText(msg.chat_id, msg.id, '• ALL Message `'..(Company.sender_user_id or 00000000)..'`* Has Been Deleted*', 'md')
deleteMessagesFromUser(msg.chat_id,Company.sender_user_id or 00000000)
end
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),DelallByReply)
end
end
if cerner and cerner:match('^delall @(.*)') then
local username = cerner:match('^delall @(.*)')
function DelallByUsername(CerNer,Company)
if tonumber(Company.id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, "اوه شت :( \nمن نمیتوانم پیام های خودم را پاک کنم", "md")
return false
end
if private(msg.chat_id,Company.id or 000000000000000000000000000000000000000000000000) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم پیام های یک فرد دارای مقام را پاک کنم ", "md")
else
if Company.id then
text= '• ALL Message `'..Company.id..'`* Has Been Deleted*'
deleteMessagesFromUser(msg.chat_id,Company.id)
else
text = '• *User NotFound*'
end
sendText(msg.chat_id, msg.id, text, 'md')
end
end
resolve_username(username,DelallByUsername)
end
if cerner and cerner:match('^delall (%d+)') then
local user_id = cerner:match('^delall (%d+)')
if tonumber(user_id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, "اوه شت :( \nمن نمیتوانم پیام های خودم را پاک کنم", "md")
return false
end
if private(msg.chat_id,user_id or 000000000000000000000000000000000000000000000000) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم پیام های یک فرد دارای مقام را پاک کنم ", "md")
else
text= '• ALL Message `'..user_id..'`* Has Been Deleted*'
deleteMessagesFromUser(msg.chat_id,user_id)
sendText(msg.chat_id, msg.id, text, 'md')
end
end
---------------------------------
if cerner == 'پاکسازی همه' then
function DelallByReply(CerNer,Company)
if tonumber(Company.sender_user_id or 00000000) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, "اوه شت :( \nمن نمیتوانم پیام های خودم را پاک کنم", 'md')
return false
end
if private(msg.chat_id,Company.sender_user_id or 000000000000000000000000000000000000000000000000) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم پیام های یک فرد دارای مقام را پاک کنم ", 'md')
else
sendText(msg.chat_id, msg.id, '• تمام پیام های کاربر `'..(Company.sender_user_id or 00000000)..'`* پاک شدند*', 'md')
deleteMessagesFromUser(msg.chat_id,Company.sender_user_id or 00000000)
end
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),DelallByReply)
end
end
if cerner and cerner:match('^پاکسازی همه @(.*)') then
local username = cerner:match('^پاکسازی همه @(.*)')
function DelallByUsername(CerNer,Company)
if tonumber(Company.id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, "اوه شت :( \nمن نمیتوانم پیام های خودم را پاک کنم", "md")
return false
end
if private(msg.chat_id,Company.id or 000000000000000000000000000000000000000000000000) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم پیام های یک فرد دارای مقام را پاک کنم ", "md")
else
if Company.id then
text= '• تمام پیام های کاربر `'..Company.id..'`* پاک شدند*'
deleteMessagesFromUser(msg.chat_id,Company.id)
else
text = '• *User NotFound*'
end
sendText(msg.chat_id, msg.id, text, 'md')
end
end
resolve_username(username,DelallByUsername)
end
if cerner and cerner:match('^پاکسازی همه (%d+)') then
local user_id = cerner:match('^پاکسازی همه (%d+)')
if tonumber(user_id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, "اوه شت :( \nمن نمیتوانم پیام های خودم را پاک کنم", "md")
return false
end
if private(msg.chat_id,user_id or 000000000000000000000000000000000000000000000000) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم پیام های یک فرد دارای مقام را پاک کنم ", "md")
else
text= '• تمام پیام های کاربر `'..user_id..'`* پاک شدند*'
deleteMessagesFromUser(msg.chat_id,user_id)
sendText(msg.chat_id, msg.id, text, 'md')
end
end
---------------------------------
if cerner == 'viplist' then
local list = redis:smembers('Vip:'..msg.chat_id)
local t = '• Vip Users\n'
for k,v in pairs(list) do
t = t..k.." - *"..v.."*\n"
end
t = t.."\n\n• To see the user's from command under use!\nwhois ID\nExample ! \nwhois 363936960"
if #list == 0 then
t = 'The list is empty'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
if cerner == 'لیست کاربران ویژه' then
local list = redis:smembers('Vip:'..msg.chat_id)
local t = '• کاربران ویژه\n'
for k,v in pairs(list) do
t = t..k.." - *"..v.."*\n"
end
t = t.."\n\n• برای دیدن کاربر از دستور زیر استفاده کنید!\nچه کسی ایدی\nمثال ! \nچه کسی 363936960"
if #list == 0 then
t = 'لیست مورد نظر خالی میباشد'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
if cerner == 'banlist' then
local list = redis:smembers('BanUser:'..msg.chat_id)
local t = '• Ban Users\n'
for k,v in pairs(list) do
t = t..k.." - *"..v.."*\n"
end
t = t.."\n\n• To see the user's from command under use!\nwhois ID\nExample ! \nwhois 363936960"
if #list == 0 then
t = 'The list is empty'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
if cerner == 'لیست بن' then
local list = redis:smembers('BanUser:'..msg.chat_id)
local t = '• لیست بن\n'
for k,v in pairs(list) do
t = t..k.." - *"..v.."*\n"
end
t = t.."\n\n• برای دیدن کاربر از دستور زیر استفاده کنید!\nچه کسی ایدی\nمثال ! \nچه کسی 363936960"
if #list == 0 then
t = 'لیست مورد نظر خالی میباشد'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
if cerner == 'clean banlist' then
local function Clean(CerNer,Company)
for k,v in pairs(Company.members) do
redis:del('BanUser:'..msg.chat_id)
RemoveFromBanList(msg.chat_id, v.user_id)
end
end
sendText(msg.chat_id, msg.id, '• All User Banned Has Been Cleaned From BanList', 'md')
getChannelMembers(msg.chat_id, "Banned", 0, 100000000000,Clean)
end
if cerner == 'پاکسازی لیست بن' then
local function Clean(CerNer,Company)
for k,v in pairs(Company.members) do
redis:del('BanUser:'..msg.chat_id)
RemoveFromBanList(msg.chat_id, v.user_id)
end
end
sendText(msg.chat_id, msg.id, '• لیست کاربران محروم گروه خالی شد', 'md')
getChannelMembers(msg.chat_id, "Banned", 0, 100000000000,Clean)
end
if cerner == 'clean mutelist' then
local mute = redis:smembers('MuteList:'..msg.chat_id)
for k,v in pairs(mute) do
redis:del('MuteList:'..msg.chat_id)
mute(msg.chat_id, v,'Restricted', {1, 1, 0, 0, 0,0})
end
sendText(msg.chat_id, msg.id, '• All User Muted Has Been Cleaned From MuteList', 'md')
end
if cerner == 'پاکسازی لیست سکوت' then
local mute = redis:smembers('MuteList:'..msg.chat_id)
for k,v in pairs(mute) do
redis:del('MuteList:'..msg.chat_id)
mute(msg.chat_id, v,'Restricted', {1, 1, 0, 0, 0,0})
end
sendText(msg.chat_id, msg.id, '•لیست کابران ساکت شده خالی شد', 'md')
end
if cerner == 'clean bots' then
local function CleanBot(CerNer,Company)
for k,v in pairs(Company.members) do
if tonumber(v.user_id) == tonumber(TD_ID) then
return false
end
if private(msg.chat_id,v.user_id or 000000000000000000000000000000000000000000000000) then
print ' Private '
else
end
KickUser(msg.chat_id, v.user_id)
end
end
sendText(msg.chat_id, msg.id, '• All Bots Banned Has Been Kicked', 'md')
getChannelMembers(msg.chat_id, "Bots", 0, 100000000000,CleanBot)
end
if cerner == 'پاکسازی ربات ها' then
local function CleanBot(CerNer,Company)
for k,v in pairs(Company.members) do
if tonumber(v.user_id) == tonumber(TD_ID) then
return false
end
if private(msg.chat_id,v.user_id or 000000000000000000000000000000000000000000000000) then
print ' Private '
else
end
KickUser(msg.chat_id, v.user_id)
end
end
sendText(msg.chat_id, msg.id, '• تمامی ربات ها از گروه اخراج شدند', 'md')
getChannelMembers(msg.chat_id, "Bots", 0, 100000000000,CleanBot)
end
if cerner == 'setvip' then
function SetVipByReply(CerNer,Company)
if redis:sismember('Vip:'..msg.chat_id, Company.sender_user_id or 00000000) then
sendText(msg.chat_id, msg.id, '• `User : ` *'..(Company.sender_user_id or 00000000)..'* is *Already* `a VIP member..!`', 'md')
else
sendText(msg.chat_id, msg.id,'• _ User : _ `'..(Company.sender_user_id or 00000000)..'` *Promoted* to `VIP` member..', 'md')
redis:sadd('Vip:'..msg.chat_id, Company.sender_user_id or 00000000)
end
end
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),SetVipByReply)
end
if cerner and cerner:match('^setvip @(.*)') then
local username = cerner:match('^setvip @(.*)')
function SetVipByUsername(CerNer,Company)
if Company.id then
print('SetVip\nBy : '..msg.sender_user_id..'\nUser : '..Company.id..'\nUserName : '..username)
if redis:sismember('Vip:'..msg.chat_id,Company.id) then
text= '• `User : ` *'..Company.id..'* is *Already* `a VIP member..!`'
else
text ='• _ User : _ `'..Company.id..'` *Promoted* to `VIP` member..'
redis:sadd('Vip:'..msg.chat_id, Company.id)
end
else
text = '• *User NotFound*'
end
sendText(msg.chat_id, msg.id, text, 'md')
end
resolve_username(username,SetVipByUsername)
end
if cerner == 'clean viplist' then
redis:del('Vip:'..msg.chat_id)
sendText(msg.chat_id, msg.id, '• Vip List Has Been Cleaned', 'md')
end
if cerner == 'remvip' then
function RemVipByReply(CerNer,Company)
if redis:sismember('Vip:'..msg.chat_id, Company.sender_user_id or 00000000) then
sendText(msg.chat_id, msg.id,'• _User : _ `'..(Company.sender_user_id or 00000000)..'` *Demoted From VIP Member..*', 'md')
redis:srem('Vip:'..msg.chat_id, Company.sender_user_id or 00000000)
else
sendText(msg.chat_id, msg.id, '• `User : ` *'..(Company.sender_user_id or 00000000)..'* `Not VIP Member..!`', 'md')
end
end
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),RemVipByReply)
end
-------------------------------------------------------------
if cerner == 'عضو ویژه' then
function SetVipByReply(CerNer,Company)
if redis:sismember('Vip:'..msg.chat_id, Company.sender_user_id or 00000000) then
sendText(msg.chat_id, msg.id, '• `کاربر : ` *'..(Company.sender_user_id or 00000000)..'* از قبل عضو ویژه بود..!`', 'md')
else
sendText(msg.chat_id, msg.id,'• _ کاربر : _ `'..(Company.sender_user_id or 00000000)..'` عضو ویژه شد..', 'md')
redis:sadd('Vip:'..msg.chat_id, Company.sender_user_id or 00000000)
end
end
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),SetVipByReply)
end
if cerner and cerner:match('^عضو ویژه @(.*)') then
local username = cerner:match('^عضو ویژه @(.*)')
function SetVipByUsername(CerNer,Company)
if Company.id then
print('SetVip\nBy : '..msg.sender_user_id..'\nUser : '..Company.id..'\nUserName : '..username)
if redis:sismember('Vip:'..msg.chat_id,Company.id) then
text= '• `کاربر : ` *'..Company.id..'* از قبل عضو ویژه بود..!`'
else
text ='• _ کاربر : _ `'..Company.id..'` عضو ویژه شد..'
redis:sadd('Vip:'..msg.chat_id, Company.id)
end
else
text = '• *کاربر یافت نشد*'
end
sendText(msg.chat_id, msg.id, text, 'md')
end
resolve_username(username,SetVipByUsername)
end
if cerner == 'پاکسازی لیست کاربران ویژه' then
redis:del('Vip:'..msg.chat_id)
sendText(msg.chat_id, msg.id, '• لیست کاربران ویژه خالی شد', 'md')
end
if cerner == 'حذف عضو ویژه' then
function RemVipByReply(CerNer,Company)
if redis:sismember('Vip:'..msg.chat_id, Company.sender_user_id or 00000000) then
sendText(msg.chat_id, msg.id,'• کاربر : _ `'..(Company.sender_user_id or 00000000)..'` از مقام عضو ویژه برکنار شد..*', 'md')
redis:srem('Vip:'..msg.chat_id, Company.sender_user_id or 00000000)
else
sendText(msg.chat_id, msg.id, '• `کاربر : ` *'..(Company.sender_user_id or 00000000)..'* عضو ویژه نبود..!`', 'md')
end
end
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),RemVipByReply)
end
-------------------------------------------------------------
if cerner and cerner:match('^muteuser (%d+)$') then
local mutess = cerner:match('^muteuser (%d+)$')
if tonumber(mutess) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم خودم را محدود کنم ', 'md')
return false
end
if private(msg.chat_id,mutess) then
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم یک فرد داری مقام را محدود کنم ", 'md')
else
mute(msg.chat_id, mutess,'Restricted', {1, 0, 0, 0, 0,0})
redis:sadd('MuteList:'..msg.chat_id,mutess)
sendText(msg.chat_id, msg.id,"• *Done User* `"..mutess.."` *Has Been Muteed :) \nRestricted*", 'md' )
end
end
if cerner and cerner:match('^سکوت (%d+)$') then
local mutess = cerner:match('^سکوت (%d+)$')
if tonumber(mutess) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم خودم را محدود کنم ', 'md')
return false
end
if private(msg.chat_id,mutess) then
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم یک فرد داری مقام را محدود کنم ", 'md')
else
mute(msg.chat_id, mutess,'Restricted', {1, 0, 0, 0, 0,0})
redis:sadd('MuteList:'..msg.chat_id,mutess)
sendText(msg.chat_id, msg.id,"• *کاربر* `"..mutess.."` *توانایی چت کردن رو از دست داد :) \nRestricted*", 'md' )
end
end
if cerner1 and cerner1:match('^([Ss]etflood) (.*)$') then
local status = {string.match(cerner, "^([Ss]etflood) (.*)$")}
if status[2] == 'kickuser' then
redis:set("Flood:Status:"..msg.chat_id,'kickuser')
sendText(msg.chat_id, msg.id, '*Flood mode is set to* _Kickuser_', 'md')
end
if status[2] == 'muteuser' then
redis:set("Flood:Status:"..msg.chat_id,'muteuser')
sendText(msg.chat_id, msg.id, '*Flood mode is set to* _Muteuser_', 'md')
end
end
if cerner1 and cerner1:match('^وضعیت پیام رگباری اخراج$') then
redis:set("Flood:Status:"..msg.chat_id,'kickuser')
sendText(msg.chat_id, msg.id, 'وضعیت پیام رگباری بر روی اخراج قرار گرفت', 'md')
end
if cerner1 and cerner1:match('^وضعیت پیام رگباری سکوت$') then
redis:set("Flood:Status:"..msg.chat_id,'muteuser')
sendText(msg.chat_id, msg.id, 'وضعیت پیام رگباری بر روی سکوت قرار گرفته', 'md')
end
if cerner == 'muteuser' then
local function Restricted(CerNer,Company)
if tonumber(Company.sender_user_id or 00000000) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم خودم را محدود کنم ', 'md')
return false
end
if private(msg.chat_id,Company.sender_user_id or 00000000) then
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم یک فرد داری مقام را محدود کنم ", 'md')
else
mute(msg.chat_id, Company.sender_user_id or 00000000,'Restricted', {1, 0, 0, 0, 0,0})
redis:sadd('MuteList:'..msg.chat_id,Company.sender_user_id or 00000000)
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, "• Done User "..Company.sender_user_id.." Has Been Muteed", 12,string.len(Company.sender_user_id))
end
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),Restricted)
end
end
if cerner == 'سکوت' then
local function Restricted(CerNer,Company)
if tonumber(Company.sender_user_id or 00000000) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم خودم را محدود کنم ', 'md')
return false
end
if private(msg.chat_id,Company.sender_user_id or 00000000) then
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم یک فرد داری مقام را محدود کنم ", 'md')
else
mute(msg.chat_id, Company.sender_user_id or 00000000,'Restricted', {1, 0, 0, 0, 0,0})
redis:sadd('MuteList:'..msg.chat_id,Company.sender_user_id or 00000000)
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, "• کاربر "..Company.sender_user_id.." توانایی چت کردن رو از دست داد", 12,string.len(Company.sender_user_id))
end
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),Restricted)
end
end
if cerner == 'unmuteuser' then
function Restricted(CerNer,Company)
if tonumber(Company.sender_user_id or 00000000) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
redis:srem('MuteList:'..msg.chat_id,Company.sender_user_id or 00000000)
mute(msg.chat_id,Company.sender_user_id or 00000000,'Restricted', {1, 1, 1, 1, 1,1})
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, "• Done User "..Company.sender_user_id.." Has Been UnMuteed", 12,string.len(Company.sender_user_id))
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),Restricted)
end
end
if cerner == 'حذف سکوت' then
function Restricted(CerNer,Company)
if tonumber(Company.sender_user_id or 00000000) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
redis:srem('MuteList:'..msg.chat_id,Company.sender_user_id or 00000000)
mute(msg.chat_id,Company.sender_user_id or 00000000,'Restricted', {1, 1, 1, 1, 1,1})
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, "• کاربر "..Company.sender_user_id.." توانایی چت کردن رو بدست آورد", 12,string.len(Company.sender_user_id))
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),Restricted)
end
end
if cerner and cerner:match('^unmuteuser (%d+)$') then
local mutes = cerner:match('^unmuteuser (%d+)$')
if tonumber(mutes) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
redis:srem('MuteList:'..msg.chat_id,mutes)
mute(msg.chat_id, mutes,'Restricted', {1, 1, 1, 1, 1,1})
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, "• Done User "..Company.sender_user_id.." Has Been UnMuteed", 12,string.len(Company.sender_user_id))
end
if cerner and cerner:match('^حذف سکوت (%d+)$') then
local mutes = cerner:match('^حذف سکوت (%d+)$')
if tonumber(mutes) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
redis:srem('MuteList:'..msg.chat_id,mutes)
mute(msg.chat_id, mutes,'Restricted', {1, 1, 1, 1, 1,1})
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, "• کاربر "..Company.sender_user_id.." توانایی چت کردن رو بدست آورد", 12,string.len(Company.sender_user_id))
end
if cerner == 'setlink' and tonumber(msg.reply_to_message_id) > 0 then
function GeTLink(CerNer,Company)
local getlink = Company.content.text or Company.content.caption
for link in getlink:gmatch("(https://t.me/joinchat/%S+)") or getlink:gmatch("t.me", "telegram.me") do
redis:set('Link:'..msg.chat_id,link)
print(link)
end
sendText(msg.chat_id, msg.id,"Done ! ", 'md' )
end
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),GeTLink)
end
if cerner == 'remlink' then
redis:del('Link:'..msg.chat_id)
sendText(msg.chat_id, msg.id,"Link Removed ", 'md' )
end
if cerner == 'تنظیم لینک' and tonumber(msg.reply_to_message_id) > 0 then
function GeTLink(CerNer,Company)
local getlink = Company.content.text or Company.content.caption
for link in getlink:gmatch("(https://t.me/joinchat/%S+)") or getlink:gmatch("t.me", "telegram.me") do
redis:set('Link:'..msg.chat_id,link)
print(link)
end
sendText(msg.chat_id, msg.id,"انجام شد ! ", 'md' )
end
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),GeTLink)
end
if cerner == 'حذف لینک' then
redis:del('Link:'..msg.chat_id)
sendText(msg.chat_id, msg.id,"لینک پاک شد", 'md' )
end
if cerner == 'ban' and tonumber(msg.reply_to_message_id) > 0 then
function BanByReply(CerNer,Company)
if tonumber(Company.sender_user_id or 00000000) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id,"اوه شت :( \nمن نمیتوانم خودم را محدود کنم", 'md' )
return false
end
if private(msg.chat_id,Company.sender_user_id or 00000000) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم یک کاربر دارای مقام را مسدود کنم", 'md')
else
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, "• User "..(Company.sender_user_id or 021).." Has Been Banned", 7,string.len(Company.sender_user_id))
redis:sadd('BanUser:'..msg.chat_id,Company.sender_user_id or 00000000)
KickUser(msg.chat_id,Company.sender_user_id)
end
end
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),BanByReply)
end
if cerner == 'بن' and tonumber(msg.reply_to_message_id) > 0 then
function BanByReply(CerNer,Company)
if tonumber(Company.sender_user_id or 00000000) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id,"اوه شت :( \nمن نمیتوانم خودم را محدود کنم", 'md' )
return false
end
if private(msg.chat_id,Company.sender_user_id or 00000000) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم یک کاربر دارای مقام را مسدود کنم", 'md')
else
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, "• کاربر "..(Company.sender_user_id or 021).." از گروه محروم شد", 7,string.len(Company.sender_user_id))
redis:sadd('BanUser:'..msg.chat_id,Company.sender_user_id or 00000000)
KickUser(msg.chat_id,Company.sender_user_id)
end
end
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),BanByReply)
end
if cerner == 'clean filterlist' then
redis:del('Filters:'..msg.chat_id)
sendText(msg.chat_id, msg.id, '• Filter List Has Been Cleaned', 'md')
end
if cerner == 'پاکسازی لیست فیلتر' then
redis:del('Filters:'..msg.chat_id)
sendText(msg.chat_id, msg.id, '• لیست فیلتر خالی شد', 'md')
end
if cerner == 'filterlist' then
local list = redis:smembers('Filters:'..msg.chat_id)
local t = '• Filters \n'
for k,v in pairs(list) do
t = t..k.." - *"..v.."*\n"
end
if #list == 0 then
t = '• The list is empty'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
if cerner == 'لیست فیلتر' then
local list = redis:smembers('Filters:'..msg.chat_id)
local t = '• لیست فیلتر \n'
for k,v in pairs(list) do
t = t..k.." - *"..v.."*\n"
end
if #list == 0 then
t = '• لیست مورد نظر خالی میباشد'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
if cerner == 'mutelist' then
local list = redis:smembers('MuteList:'..msg.chat_id)
local t = '• Mute List \n'
for k,v in pairs(list) do
t = t..k.." - *"..v.."*\n"
end
t = t.."\n\n• To see the user's from command under use!\nwhois ID\nExample ! \nwhois 363936960"
if #list == 0 then
t = 'The list is empty'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
if cerner == 'لیست سکوت' then
local list = redis:smembers('MuteList:'..msg.chat_id)
local t = '• لیست سکوت \n'
for k,v in pairs(list) do
t = t..k.." - *"..v.."*\n"
end
t = t.."\n\n• برای دیدن کاربر از دستور زیر استفاده کنید!\nچه کسی ایدی\nمثال ! \nچه کسی 363936960"
if #list == 0 then
t = 'لیست مورد نظر خالی میباشد'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
if cerner == 'clean warnlist' then
redis:del(msg.chat_id..':warn')
sendText(msg.chat_id, msg.id,'Warn List Has Been Cleaned', 'md')
end
if cerner == 'پاکسازی لیست اخطار' then
redis:del(msg.chat_id..':warn')
sendText(msg.chat_id, msg.id,'لیست اخطار خالی شد', 'md')
end
if cerner == "warnlist" then
local comn = redis:hkeys(msg.chat_id..':warn')
local t = 'Warn Users List:\n'
for k,v in pairs (comn) do
local cont = redis:hget(msg.chat_id..':warn', v)
t = t..k..'- '..v..' Warn : '..(cont - 1)..'\n'
end
t = t.."\n\n• To see the user's from command under use!\nwhois ID\nExample ! \nwhois 363936960"
if #comn == 0 then
t = 'The list is empty'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
if cerner == "لیست اخطار" then
local comn = redis:hkeys(msg.chat_id..':warn')
local t = 'لیست اخطار:\n'
for k,v in pairs (comn) do
local cont = redis:hget(msg.chat_id..':warn', v)
t = t..k..'- '..v..' Warn : '..(cont - 1)..'\n'
end
t = t.."\n\n• برای دیدن کاربر از دستور زیر استفاده کنید!\nچه کسی ایدی\nمثال ! \nچه کسی 363936960"
if #comn == 0 then
t = 'لیست مورد نظر خالی میباشد'
end
sendText(msg.chat_id, msg.id,t, 'md')
end
if cerner and cerner:match('^unban (%d+)') then
local user_id = cerner:match('^unban (%d+)')
if tonumber(user_id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
redis:srem('BanUser:'..msg.chat_id,user_id)
RemoveFromBanList(msg.chat_id,user_id)
SendMetion(msg.chat_id,user_id, msg.id, "• User "..(user_id or 021).." Has Been UnBanned", 7,string.len(user_id))
end
if cerner and cerner:match('^حذف بن (%d+)') then
local user_id = cerner:match('^unban (%d+)')
if tonumber(user_id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
redis:srem('BanUser:'..msg.chat_id,user_id)
RemoveFromBanList(msg.chat_id,user_id)
SendMetion(msg.chat_id,user_id, msg.id, "• کاربر "..(user_id or 021).." از محرومیت گروه آزاد شد", 7,string.len(user_id))
end
if cerner and cerner:match('^ban (%d+)') then
local user_id = cerner:match('^ban (%d+)')
if tonumber(user_id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id,"اوه شت :( \nمن نمیتوانم خودم را مسدود کنم", 'md' )
return false
end
if private(msg.chat_id,user_id) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم یک کاربر دارای مقام را مسدود کنم", 'md')
else
redis:sadd('BanUser:'..msg.chat_id,user_id)
KickUser(msg.chat_id,user_id)
sendText(msg.chat_id, msg.id, '• User `'..user_id..'` Has Been Banned ..!*', 'md')
SendMetion(msg.chat_id,user_id, msg.id, "• User "..(user_id or 021).." Has Been Banned", 7,string.len(user_id))
end
end
if cerner and cerner:match('^بن (%d+)') then
local user_id = cerner:match('^بن (%d+)')
if tonumber(user_id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id,"اوه شت :( \nمن نمیتوانم خودم را مسدود کنم", 'md' )
return false
end
if private(msg.chat_id,user_id) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم یک کاربر دارای مقام را مسدود کنم", 'md')
else
redis:sadd('BanUser:'..msg.chat_id,user_id)
KickUser(msg.chat_id,user_id)
sendText(msg.chat_id, msg.id, '• User `'..user_id..'` Has Been Banned ..!*', 'md')
SendMetion(msg.chat_id,user_id, msg.id, "• کاربر "..(user_id or 021).." از گروه محروم شد", 7,string.len(user_id))
end
end
if cerner and cerner:match('^unban @(.*)') then
local username = cerner:match('unban @(.*)')
function UnBanByUserName(CerNer,Company)
if tonumber(Company.id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
if Company.id then
print('UserID : '..Company.id..'\nUserName : @'..username)
redis:srem('BanUser:'..msg.chat_id,Company.id)
SendMetion(msg.chat_id,Company.id, msg.id, "• User "..(Company.id or 021).." Has Been UnBanned", 7,string.len(Company.id))
else
sendText(msg.chat_id, msg.id, '• User Not Found', 'md')
end
print('Send')
end
resolve_username(username,UnBanByUserName)
end
if cerner and cerner:match('^حذف بن @(.*)') then
local username = cerner:match('حذف بن @(.*)')
function UnBanByUserName(CerNer,Company)
if tonumber(Company.id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
if Company.id then
print('UserID : '..Company.id..'\nUserName : @'..username)
redis:srem('BanUser:'..msg.chat_id,Company.id)
SendMetion(msg.chat_id,Company.id, msg.id, "• کاربر "..(Company.id or 021).." از محرومیت گروه آزاد شد", 7,string.len(Company.id))
else
sendText(msg.chat_id, msg.id, '• کاربر یافت نشد', 'md')
end
print('Send')
end
resolve_username(username,UnBanByUserName)
end
if cerner == 'unban' and tonumber(msg.reply_to_message_id) > 0 then
function UnBan_by_reply(CerNer,Company)
if tonumber(Company.sender_user_id or 00000000) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
redis:srem('BanUser:'..msg.chat_id,Company.sender_user_id or 00000000)
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, "• User "..(Company.sender_user_id or 021).." Has Been UnBanned", 7,string.len(Company.sender_user_id))
RemoveFromBanList(msg.chat_id,Company.sender_user_id)
end
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),UnBan_by_reply)
end
if cerner == 'حذف بن' and tonumber(msg.reply_to_message_id) > 0 then
function UnBan_by_reply(CerNer,Company)
if tonumber(Company.sender_user_id or 00000000) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
redis:srem('BanUser:'..msg.chat_id,Company.sender_user_id or 00000000)
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, "• کاربر "..(Company.sender_user_id or 021).."از محرومیت گروه آزاد شد", 7,string.len(Company.sender_user_id))
RemoveFromBanList(msg.chat_id,Company.sender_user_id)
end
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),UnBan_by_reply)
end
if cerner and cerner:match('^ban @(.*)') then
local username = cerner:match('^ban @(.*)')
print ' Private '
function BanByUserName(CerNer,Company)
if tonumber(Company.id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id,"اوه شت :( \nمن نمیتوانم خودم را مسدود کنم", 'md' )
return false
end
if private(msg.chat_id,Company.id) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم یک کاربر دارای مقام را مسدود کنم", 'md')
else
if Company.id then
redis:sadd('BanUser:'..msg.chat_id,Company.id)
KickUser(msg.chat_id,Company.id)
SendMetion(msg.chat_id,Company.id, msg.id, "• User "..(Company.id or 021).." Has Been Banned", 7,string.len(Company.id))
else
t = '• User Not Found'
sendText(msg.chat_id, msg.id, t, 'md')
end
end
end
resolve_username(username,BanByUserName)
end
if cerner and cerner:match('^بن @(.*)') then
local username = cerner:match('^بن @(.*)')
print ' Private '
function BanByUserName(CerNer,Company)
if tonumber(Company.id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id,"اوه شت :( \nمن نمیتوانم خودم را مسدود کنم", 'md' )
return false
end
if private(msg.chat_id,Company.id) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم یک کاربر دارای مقام را مسدود کنم", 'md')
else
if Company.id then
redis:sadd('BanUser:'..msg.chat_id,Company.id)
KickUser(msg.chat_id,Company.id)
SendMetion(msg.chat_id,Company.id, msg.id, "• کاربر "..(Company.id or 021).." از گروه محروم شد", 7,string.len(Company.id))
else
t = '• کاربر یافت نشد'
sendText(msg.chat_id, msg.id, t, 'md')
end
end
end
resolve_username(username,BanByUserName)
end
if cerner== 'kick' and tonumber(msg.reply_to_message_id) > 0 then
function kick_by_reply(CerNer,Company)
if tonumber(Company.sender_user_id or 00000000) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id,"اوه شت :( \nمن نمیتوانم خودم را اخراج کنم", 'md' )
return false
end
if private(msg.chat_id,Company.sender_user_id or 000000000000000000000000000000000000000000000000) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم یک فرد دارای مقام را اخراج کنم", 'md')
else
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, "• User "..(Company.sender_user_id or 021).." Has Been Kicked", 7,string.len(Company.sender_user_id))
KickUser(msg.chat_id,Company.sender_user_id)
RemoveFromBanList(msg.chat_id,Company.sender_user_id)
end
end
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),kick_by_reply)
end
if cerner== 'اخراج' and tonumber(msg.reply_to_message_id) > 0 then
function kick_by_reply(CerNer,Company)
if tonumber(Company.sender_user_id or 00000000) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id,"اوه شت :( \nمن نمیتوانم خودم را اخراج کنم", 'md' )
return false
end
if private(msg.chat_id,Company.sender_user_id or 000000000000000000000000000000000000000000000000) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم یک فرد دارای مقام را اخراج کنم", 'md')
else
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, "• کاربر "..(Company.sender_user_id or 021).." از گروه اخراج شد", 7,string.len(Company.sender_user_id))
KickUser(msg.chat_id,Company.sender_user_id)
RemoveFromBanList(msg.chat_id,Company.sender_user_id)
end
end
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),kick_by_reply)
end
if cerner and cerner:match('^kick @(.*)') then
local username = cerner:match('^kick @(.*)')
function KickByUserName(CerNer,Company)
if tonumber(Company.id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id,"اوه شت :( \nمن نمیتوانم خودم را اخراج کنم", 'md' )
return false
end
if private(msg.chat_id,Company.id or 000000000000000000000000000000000000000000000000) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم یک فرد دارای مقام را اخراج کنم", 'md')
else
if Company.id then
KickUser(msg.chat_id,Company.id)
RemoveFromBanList(msg.chat_id,Company.id)
SendMetion(msg.chat_id,Company.id, msg.id, "• User "..(Company.id or 021).." Has Been Kicked", 7,string.len(Company.id))
else
txtt = '• User Not Found'
sendText(msg.chat_id, msg.id,txtt, 'md')
end
end
end
resolve_username(username,KickByUserName)
end
if cerner and cerner:match('^اخراج @(.*)') then
local username = cerner:match('^اخراج @(.*)')
function KickByUserName(CerNer,Company)
if tonumber(Company.id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id,"اوه شت :( \nمن نمیتوانم خودم را اخراج کنم", 'md' )
return false
end
if private(msg.chat_id,Company.id or 000000000000000000000000000000000000000000000000) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم یک فرد دارای مقام را اخراج کنم", 'md')
else
if Company.id then
KickUser(msg.chat_id,Company.id)
RemoveFromBanList(msg.chat_id,Company.id)
SendMetion(msg.chat_id,Company.id, msg.id, "• کاربر "..(Company.id or 021).." از گروه اخراج شد", 7,string.len(Company.id))
else
txtt = '• کاربر یافت نشد'
sendText(msg.chat_id, msg.id,txtt, 'md')
end
end
end
resolve_username(username,KickByUserName)
end
if cerner == 'clean restricts' or cerner == 'پاکسازی کابران محدود' then
local function pro(arg,data)
if redis:get("Check:Restricted:"..msg.chat_id) then
text = 'هر 5دقیقه یکبار ممکن است'
end
for k,v in pairs(data.members) do
redis:del('MuteAll:'..msg.chat_id)
mute(msg.chat_id, v.user_id,'Restricted', {1, 1, 1, 1, 1,1})
redis:setex("Check:Restricted:"..msg.chat_id,350,true)
end
end
getChannelMembers(msg.chat_id,"Recent", 0, 100000000000,pro)
sendText(msg.chat_id, msg.id,'افراد محدود پاک شدند • ' ,'md')
end
if cerner and cerner:match('^kick (%d+)') then
local user_id = cerner:match('^kick (%d+)')
if tonumber(user_id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id,"اوه شت :( \nمن نمیتوانم خودم را اخراج کنم", 'md' )
return false
end
if private(msg.chat_id,user_id or 000000000000000000000000000000000000000000000000) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم یک فرد دارای مقام را اخراج کنم", 'md')
else
KickUser(msg.chat_id,user_id)
text= '• User '..user_id..' Has Been Kicked'
SendMetion(msg.chat_id,user_id, msg.id, text,7, string.len(user_id))
RemoveFromBanList(msg.chat_id,user_id)
end
end
if cerner and cerner:match('^اخراج (%d+)') then
local user_id = cerner:match('^اخراج (%d+)')
if tonumber(user_id) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id,"اوه شت :( \nمن نمیتوانم خودم را اخراج کنم", 'md' )
return false
end
if private(msg.chat_id,user_id or 000000000000000000000000000000000000000000000000) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم یک فرد دارای مقام را اخراج کنم", 'md')
else
KickUser(msg.chat_id,user_id)
text= '• کاربر '..user_id..' از گروه اخراج شد'
SendMetion(msg.chat_id,user_id, msg.id, text,7, string.len(user_id))
RemoveFromBanList(msg.chat_id,user_id)
end
end
if cerner and cerner:match('^setflood (%d+)') then
local num = cerner:match('^setflood (%d+)')
if tonumber(num) < 2 then
sendText(msg.chat_id, msg.id, '• `Select a number greater than` *2*','md')
else
redis:set('Flood:Max:'..msg.chat_id,num)
sendText(msg.chat_id, msg.id, '• `Flood Sensitivity Has Been Set to` *'..num..'*', 'md')
end
end
if cerner and cerner:match('^تنظیم پیام رگباری (%d+)') then
local num = cerner:match('^تنظیم پیام رگباری (%d+)')
if tonumber(num) < 2 then
sendText(msg.chat_id, msg.id, '• لطفا عددی بزرگتر از 2 انتخاب کنید','md')
else
redis:set('Flood:Max:'..msg.chat_id,num)
sendText(msg.chat_id, msg.id, '• حساسیت پیام رگباری تنظیم شد بر روی *'..num..'*', 'md')
end
end
if cerner and cerner:match('^warnmax (%d+)') then
local num = cerner:match('^warnmax (%d+)')
if tonumber(num) < 2 then
sendText(msg.chat_id, msg.id, '• `Select a number greater than` *2*','md')
else
redis:set('Warn:Max:'..msg.chat_id,num)
sendText(msg.chat_id, msg.id, '• `Max Warn Has Been Set to` *'..num..'*', 'md')
end
end
if cerner and cerner:match('^حداکثر اخطار (%d+)') then
local num = cerner:match('^حداکثر اخطار (%d+)')
if tonumber(num) < 2 then
sendText(msg.chat_id, msg.id, '• لطفا عددی بزرگتر از 2 انتخاب کنید','md')
else
redis:set('Warn:Max:'..msg.chat_id,num)
sendText(msg.chat_id, msg.id, '• حداکثر اخطار تنظیم شد بر روی *'..num..'*', 'md')
end
end
if cerner and cerner:match('^setspam (%d+)') then
local num = cerner:match('^setspam (%d+)')
if tonumber(num) < 40 then
sendText(msg.chat_id, msg.id, '• `Select a number greater than` *40*','md')
else
if tonumber(num) > 4096 then
sendText(msg.chat_id, msg.id, '• `Select a number Smaller than` * 4096 * ','md')
else
redis:set('NUM_CH_MAX:'..msg.chat_id,num)
sendText(msg.chat_id, msg.id, '• `Spam` *Sensitivity* `has been set to ` *'..num..'*', 'md')
end
end
end
if cerner and cerner:match('^تنظیم اسپم (%d+)') then
local num = cerner:match('^تنظیم اسپم (%d+)')
if tonumber(num) < 40 then
sendText(msg.chat_id, msg.id, '• لطفا عددی بزرگتر از 40 انتخاب کنید','md')
else
if tonumber(num) > 4096 then
sendText(msg.chat_id, msg.id, '• لطفا عددی کوچیکتر از 4096 انتخاب کنید ','md')
else
redis:set('NUM_CH_MAX:'..msg.chat_id,num)
sendText(msg.chat_id, msg.id, '• حساسیت اسپم تنظیم شد بر روی *'..num..'*', 'md')
end
end
end
if cerner and cerner:match('^setfloodtime (%d+)') then
local num = cerner:match('^setfloodtime (%d+)')
if tonumber(num) < 1 then
sendText(msg.chat_id, msg.id, '• `Select a number greater than` *1*','md')
else
redis:set('Flood:Time:'..msg.chat_id,num)
sendText(msg.chat_id, msg.id, '• `Flood time change to` *'..num..'*', 'md')
end
end
if cerner and cerner:match('^تنظیم زمان پیام رگباری (%d+)') then
local num = cerner:match('^تنظیم زمان پیام رگباری (%d+)')
if tonumber(num) < 1 then
sendText(msg.chat_id, msg.id, '• لطفا عددی بزرگتر از 1 انتخاب کنید','md')
else
redis:set('Flood:Time:'..msg.chat_id,num)
sendText(msg.chat_id, msg.id, '• زمان پیام رگباری تنظیم شد بر روی*'..num..'*', 'md')
end
end
if cerner and cerner:match('^rmsg (%d+)$') then
local limit = tonumber(cerner:match('^rmsg (%d+)$'))
if limit > 100 then
sendText(msg.chat_id, msg.id, '*عددی بین * [`1-100`] را انتخاب کنید', 'md')
else
local function cb(arg,data)
for k,v in pairs(data.messages) do
deleteMessages(msg.chat_id,{[0] =v.id})
end
end
getChatHistory(msg.chat_id,msg.id, 0, limit,cb)
sendText(msg.chat_id, msg.id, '• ('..limit..') Msg Has Been Deleted', 'md')
end
end
if cerner and cerner:match('^پاکسازی (%d+)$') then
local limit = tonumber(cerner:match('^پاکسازی (%d+)$'))
if limit > 100 then
sendText(msg.chat_id, msg.id, '*عددی بین * [`1-100`] را انتخاب کنید', 'md')
else
local function cb(arg,data)
for k,v in pairs(data.messages) do
deleteMessages(msg.chat_id,{[0] =v.id})
end
end
getChatHistory(msg.chat_id,msg.id, 0, limit,cb)
sendText(msg.chat_id, msg.id, '• ('..limit..') پیام گروه پاک شد', 'md')
end
end
if cerner == 'settings' then
local function GetName(CerNer, Company)
local chat = msg.chat_id
if redis:get('Welcome:'..msg.chat_id) == 'enable' then
welcome = '✔️'
else
welcome = '✖️'
end
if redis:get('Lock:Edit'..chat) then
edit = '✔️'
else
edit = '✖️'
end
if redis:get('Lock:Link'..chat) then
Link = '✔️'
else
Link = '✖️'
end
if redis:get('Lock:Tag:'..chat) then
tag = '✔️'
else
tag = '✖️'
end
if redis:get('Lock:HashTag:'..chat) then
hashtag = '✔️'
else
hashtag = '✖️'
end
if redis:get('Lock:Video_note:'..chat) then
video_note = '✔️'
else
video_note = '✖️'
end
if redis:get('Lock:Inline:'..chat) then
inline = '✔️'
else
inline = '✖️'
end
if redis:get("Flood:Status:"..msg.chat_id) then
if redis:get("Flood:Status:"..msg.chat_id) == "kickuser" then
Status = 'Kick User'
elseif redis:get("Flood:Status:"..msg.chat_id) == "muteuser" then
Status = 'Mute User'
end
else
Status = 'Not Set'
end
if redis:get('Lock:Pin:'..chat) then
pin = '✔️'
else
pin = '✖️'
end
if redis:get('Lock:Forward:'..chat) then
fwd = '✔️'
else
fwd = '✖️'
end
if redis:get('Lock:Bot:'..chat) then
bot = '✔️'
else
bot = '✖️'
end
if redis:get('Spam:Lock:'..chat) then
spam = '✔️'
else
spam = '✖️'
end
if redis:get('Lock:Arabic:'..chat) then
arabic = '✔️'
else
arabic = '✖️'
end
if redis:get('Lock:English:'..chat) then
en = '✔️'
else
en = '✖️'
end
if redis:get('Lock:TGservise:'..chat) then
tg = '✔️'
else
tg = '✖️'
end
if redis:get('Lock:Sticker:'..chat) then
sticker = '✔️'
else
sticker = '✖️'
end
if redis:get('CheckBot:'..msg.chat_id) then
TD = ' Enable'
else
TD = ' Disable'
end
-------------------------------------------
---------Mute Settings----------------------
if redis:get('Mute:Text:'..msg.chat_id) then
txts = '✔️'
else
txts = '✖️'
end
if redis:get('Mute:Contact:'..msg.chat_id) then
contact = '✔️'
else
contact = '✖️'
end
if redis:get('Mute:Document:'..msg.chat_id) then
document = '✔️'
else
document = '✖️'
end
if redis:get('Mute:Location:'..msg.chat_id) then
location = '✔️'
else
location = '✖️'
end
if redis:get('Mute:Voice:'..msg.chat_id) then
voice = '✔️'
else
voice = '✖️'
end
if redis:get('Mute:Photo:'..msg.chat_id) then
photo = '✔️'
else
photo = '✖️'
end
if redis:get('Mute:Game:'..msg.chat_id) then
game = '✔️'
else
game = '✖️'
end
if redis:get('MuteAll:'..chat) then
muteall = '✔️'
else
muteall = '✖️'
end
if redis:get('Lock:Flood:'..msg.chat_id) then
flood = '✔️'
else
flood = '✖️'
end
if redis:get('Mute:Video:'..msg.chat_id) then
video = '✔️'
else
video = '✖️'
end
if redis:get('Mute:Music:'..msg.chat_id) then
music = '✔️'
else
music = '✖️'
end
if redis:get('Mute:Gif:'..msg.chat_id) then
gif = '✔️'
else
gif = '✖️'
end
local expire = redis:ttl("ExpireData:"..msg.chat_id)
if expire == -1 then
EXPIRE = "نامحدود"
else
local d = math.floor(expire / day ) + 1
EXPIRE = d.." Day"
end
------------------------More Settings-------------------------
local Text = '•• `SHADOBAKER `\n\n*TD Bot* : `'..TD..'`\n\n*🔰Settings For* `'..Company.title..'🔰`\n\n*🎯Links *↬` '..Link..'`\n*🎯Edit* ↬ `'..edit..'`\n*🎯Tag ↬* `'..tag..'`\n*🎯HashTag ↬ *`'..hashtag..'`\n*🎯Inline ↬ *`'..inline..'`\n*🎯Video Note ↬* `'..video_note..'`\n*🎯Pin ↬* `'..pin..'`\n*🎯Bots ↬ *`'..bot..'`\n*🎯Forward ↬* `'..fwd..'`\n*🎯Arabic ↬ *`'..arabic..'`\n*🎯English ↬* `'..en..'`\n*🎯Tgservise ↬* `'..tg..'`\n*🎯Sticker ↬ *`'..sticker..'`\n\n_🎯Media Settings_ \n\n*🎯Photo ↬* `'..photo..'`\n*🎯Music ↬ *`'..music..'`\n*🎯Voice ↬ *`'..voice..'`\n*🎯Docoment ↬*`'..document..'`\n*🎯Video ↬ *`'..video..'`\n*🎯Gif ↬ *`'..gif..'`\n*🎯Game ↬*`'..game..'`\n*🎯Location ↬ *`'..location..'`\n*🎯Contact ↬ *`'..contact..'`\n*🎯Text ↬*`'..txts..'`\n*🎯All* ↬ `'..muteall..'`\n\n_🎯More Locks_\n\n*🎯Spam ↬ *`'..spam..'`\n*🎯Flood ↬* `'..flood..'`\n*🎯Flood Stats ↬* `'..Status..'`\n*🎯Max Flood ↬* `'..NUM_MSG_MAX..'`\n*🎯Spam Sensitivity ↬ *`'..NUM_CH_MAX..'`\n*🎯Flood Time ↬* `'..TIME_CHECK..'`\n*🎯Warn Max ↬* `'..warn..'`\n\n*🎯Expire ↬* `'..EXPIRE..'`\n*🎯Welcome ↬* `'..welcome..'`\n\n🎯Channel ↬ '
sendText(msg.chat_id, msg.id, Text, 'md')
end
GetChat(msg.chat_id,GetName)
end
--------------------------------------------------
if cerner == 'تنظیمات' then
local function GetName(CerNer, Company)
local chat = msg.chat_id
if redis:get('Welcome:'..msg.chat_id) == 'enable' then
welcome = '✔️'
else
welcome = '✖️'
end
if redis:get('Lock:Edit'..chat) then
edit = '✔️'
else
edit = '✖️'
end
if redis:get('Lock:Link'..chat) then
Link = '✔️'
else
Link = '✖️'
end
if redis:get('Lock:Tag:'..chat) then
tag = '✔️'
else
tag = '✖️'
end
if redis:get('Lock:HashTag:'..chat) then
hashtag = '✔️'
else
hashtag = '✖️'
end
if redis:get('Lock:Video_note:'..chat) then
video_note = '✔️'
else
video_note = '✖️'
end
if redis:get('Lock:Inline:'..chat) then
inline = '✔️'
else
inline = '✖️'
end
if redis:get("Flood:Status:"..msg.chat_id) then
if redis:get("Flood:Status:"..msg.chat_id) == "kickuser" then
Status = 'اخراج'
elseif redis:get("Flood:Status:"..msg.chat_id) == "muteuser" then
Status = 'سکوت'
end
else
Status = 'تنظیم نیست'
end
if redis:get('Lock:Pin:'..chat) then
pin = '✔️'
else
pin = '✖️'
end
if redis:get('Lock:Forward:'..chat) then
fwd = '✔️'
else
fwd = '✖️'
end
if redis:get('Lock:Bot:'..chat) then
bot = '✔️'
else
bot = '✖️'
end
if redis:get('Spam:Lock:'..chat) then
spam = '✔️'
else
spam = '✖️'
end
if redis:get('Lock:Arabic:'..chat) then
arabic = '✔️'
else
arabic = '✖️'
end
if redis:get('Lock:English:'..chat) then
en = '✔️'
else
en = '✖️'
end
if redis:get('Lock:TGservise:'..chat) then
tg = '✔️'
else
tg = '✖️'
end
if redis:get('Lock:Sticker:'..chat) then
sticker = '✔️'
else
sticker = '✖️'
end
if redis:get('CheckBot:'..msg.chat_id) then
TD = ' فعال'
else
TD = 'غیرفعال'
end
-------------------------------------------
---------Mute Settings----------------------
if redis:get('Mute:Text:'..msg.chat_id) then
txts = '✔️'
else
txts = '✖️'
end
if redis:get('Mute:Contact:'..msg.chat_id) then
contact = '✔️'
else
contact = '✖️'
end
if redis:get('Mute:Document:'..msg.chat_id) then
document = '✔️'
else
document = '✖️'
end
if redis:get('Mute:Location:'..msg.chat_id) then
location = '✔️'
else
location = '✖️'
end
if redis:get('Mute:Voice:'..msg.chat_id) then
voice = '✔️'
else
voice = '✖️'
end
if redis:get('Mute:Photo:'..msg.chat_id) then
photo = '✔️'
else
photo = '✖️'
end
if redis:get('Mute:Game:'..msg.chat_id) then
game = '✔️'
else
game = '✖️'
end
if redis:get('MuteAll:'..chat) then
muteall = '✔️'
else
muteall = '✖️'
end
if redis:get('Lock:Flood:'..msg.chat_id) then
flood = '✔️'
else
flood = '✖️'
end
if redis:get('Mute:Video:'..msg.chat_id) then
video = '✔️'
else
video = '✖️'
end
if redis:get('Mute:Music:'..msg.chat_id) then
music = '✔️'
else
music = '✖️'
end
if redis:get('Mute:Gif:'..msg.chat_id) then
gif = '✔️'
else
gif = '✖️'
end
local expire = redis:ttl("ExpireData:"..msg.chat_id)
if expire == -1 then
EXPIRE = "نامحدود"
else
local d = math.floor(expire / day ) + 1
EXPIRE = d.." روز"
end
------------------------More Settings-------------------------
local Text = '•• *TD Bot* : `'..TD..'`\n\n*🔰تنظیمات گروه* `'..Company.title..'🔰`\n\n*🎯لینک *↫` '..Link..'`\n*🎯ویرایش* ↫ `'..edit..'`\n*🎯تگ ↫* `'..tag..'`\n*🎯هشتگ ↫ *`'..hashtag..'`\n*🎯کیبورد شیشه ای ↫ *`'..inline..'`\n*🎯فیلم سلفی ↫* `'..video_note..'`\n*🎯سنجاق ↫* `'..pin..'`\n*🎯ربات ها ↫ *`'..bot..'`\n*🎯فروارد ↫* `'..fwd..'`\n*🎯عربی/فارسی ↫ *`'..arabic..'`\n*🎯انگلیسی ↫* `'..en..'`\n*🎯خدمات تلگرام ↫* `'..tg..'`\n*🎯استیکر ↫ *`'..sticker..'`\n\n_🎯تنظیمات رسانه_ \n\n*🎯عکس ↫* `'..photo..'`\n*🎯اهنگ ↫ *`'..music..'`\n*🎯ویس ↫ *`'..voice..'`\n*🎯اسناد ↫*`'..document..'`\n*🎯فیلم ↫ *`'..video..'`\n*🎯گیف ↫*`'..gif..'`\n*🎯بازی ↫*`'..game..'`\n*🎯موقعیت مکانی ↫ *`'..location..'`\n*🎯مخاطب ↫ *`'..contact..'`\n*🎯متن ↫*`'..txts..'`\n*🎯همه* ↫ `'..muteall..'`\n\n_🎯تنظیمات بیشتر_\n\n*🎯اسپم ↫ *`'..spam..'`\n*🎯پیام رگباری ↫* `'..flood..'`\n*🎯وضعیت پیام رگباری ↫* `'..Status..'`\n*🎯حساسیت پیام رگباری ↫* `'..NUM_MSG_MAX..'`\n*🎯حساسیت اسپم ↫ *`'..NUM_CH_MAX..'`\n*زمان پیام رگباری ↫* `'..TIME_CHECK..'`\n*🎯حداکثر اخطار ↫* `'..warn..'`\n\n*🎯تاریخ انقضا ↫* `'..EXPIRE..'`\n*🎯خوش امد ↫* `'..welcome..'`\n\n🎯کانال ما ↫ '
sendText(msg.chat_id, msg.id, Text, 'md')
end
GetChat(msg.chat_id,GetName)
end
---------------------Welcome----------------------
if cerner == 'welcome enable' then
if redis:get('Welcome:'..msg.chat_id) == 'enable' then
sendText(msg.chat_id, msg.id,'• *Welcome* is _Already_ Enable\n\n' ,'md')
else
sendText(msg.chat_id, msg.id,'• *Welcome* Has Been Enable\n\n' ,'md')
redis:del('Welcome:'..msg.chat_id,'disable')
redis:set('Welcome:'..msg.chat_id,'enable')
end
end
if cerner == 'welcome disable' then
if redis:get('Welcome:'..msg.chat_id) then
sendText(msg.chat_id, msg.id,'• *Welcome* Has Been Disable\n\n' ,'md')
redis:set('Welcome:'..msg.chat_id,'disable')
redis:del('Welcome:'..msg.chat_id,'enable')
else
sendText(msg.chat_id, msg.id,'• *Welcome* is _Already_ Disable\n\n' ,'md')
end
end
---------------------------------------------------------
if cerner == 'خوش امد فعال' then
if redis:get('Welcome:'..msg.chat_id) == 'enable' then
sendText(msg.chat_id, msg.id,'• *خوش امد گویی از قبل فعال بود*\n\n' ,'md')
else
sendText(msg.chat_id, msg.id,'• *خوش امد گویی فعال شد*\n\n' ,'md')
redis:del('Welcome:'..msg.chat_id,'disable')
redis:set('Welcome:'..msg.chat_id,'enable')
end
end
if cerner == 'خوش امد غیرفعال' then
if redis:get('Welcome:'..msg.chat_id) then
sendText(msg.chat_id, msg.id,'• *خوش امد گویی غیرفعال شد*\n\n' ,'md')
redis:set('Welcome:'..msg.chat_id,'disable')
redis:del('Welcome:'..msg.chat_id,'enable')
else
sendText(msg.chat_id, msg.id,'• *خوش امد گویی غیرفعال بود*\n\n' ,'md')
end
end
---------------------------------------------------------
-----------------------------------------------Locks------------------------------------------------------------
-----------------Lock Link--------------------
if cerner == 'lock link' then
if redis:get('Lock:Link'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Link* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Link* `Has Been Enable`\n\n' , 'md')
redis:set('Lock:Link'..msg.chat_id,true)
end
end
if cerner == 'unlock link' then
if redis:get('Lock:Link'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Link* `Has Been Disable`\n\n' , 'md')
redis:del('Lock:Link'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Link* is _Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل لینک' then
if redis:get('Lock:Link'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل لینک از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل لینک فعال شد\n\n' , 'md')
redis:set('Lock:Link'..msg.chat_id,true)
end
end
if cerner == 'باز لینک' then
if redis:get('Lock:Link'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل لینک غیرفعال شد\n\n' , 'md')
redis:del('Lock:Link'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل لینک از قبل غیرفعال بود\n\n' , 'md')
end
end
---------------------------------------------
if cerner == 'lock tag' then
if redis:get('Lock:Tag:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Tag* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Tag* `Has Been Enable`\n\n' , 'md')
redis:set('Lock:Tag:'..msg.chat_id,true)
end
end
if cerner == 'unlock tag' then
if redis:get('Lock:Tag:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Tag* `Has Been Disable`\n\n' , 'md')
redis:del('Lock:Tag:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Tag* is _Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل تگ' then
if redis:get('Lock:Tag:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل تگ از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل تگ فعال شد\n\n' , 'md')
redis:set('Lock:Tag:'..msg.chat_id,true)
end
end
if cerner == 'باز تگ' then
if redis:get('Lock:Tag:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل تگ غیرفعال شد\n\n' , 'md')
redis:del('Lock:Tag:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل تگ از قبل غیرفعال بود\n\n' , 'md')
end
end
--------------------------------------------
if cerner == 'lock hashtag' then
if redis:get('Lock:HashTag:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *HadshTag* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *HashTag* `Has Been Enable`\n\n' , 'md')
redis:set('Lock:HashTag:'..msg.chat_id,true)
end
end
if cerner == 'unlock hashtag' then
if redis:get('Lock:HashTag:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *HashTag* `Has Been Disable`\n\n' , 'md')
redis:del('Lock:HashTag:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *HashTag* is _Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل هشتگ' then
if redis:get('Lock:HashTag:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل هشتگ از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل هشتگ فعال شد\n\n' , 'md')
redis:set('Lock:HashTag:'..msg.chat_id,true)
end
end
if cerner == 'باز هشتگ' then
if redis:get('Lock:HashTag:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل هشتگ غیرفعال شد\n\n' , 'md')
redis:del('Lock:HashTag:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل هشتگ از قبل غیرفعال بود\n\n' , 'md')
end
end
-----------------------------------------------
if cerner == 'lock video_note' then
if redis:get('Lock:Video_note:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Video note* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Video note* `Has Been Enable`\n\n' , 'md')
redis:set('Lock:Video_note:'..msg.chat_id,true)
end
end
if cerner == 'unlock vide_onote' then
if redis:get('Lock:Video_note:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Video note* `Has Been Disable`\n\n' , 'md')
redis:del('Lock:Video_note:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Video note* is _Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل فیلم سلفی' then
if redis:get('Lock:Video_note:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل فیلم سلفی از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل فیلم سلفی فعال شد\n\n' , 'md')
redis:set('Lock:Video_note:'..msg.chat_id,true)
end
end
if cerner == 'باز فیلم سلفی' then
if redis:get('Lock:Video_note:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل فلیم سلفی غیرفعال شد\n\n' , 'md')
redis:del('Lock:Video_note:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل فیلم سلفی از قبل غیرفعال بود\n\n' , 'md')
end
end
-------------------------------------------------
if cerner == 'lock spam' then
if redis:get('Spam:Lock:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Spam* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Spam* `Has Been Enable`\n\n' , 'md')
redis:set('Spam:Lock:'..msg.chat_id,true)
end
end
if cerner == 'unlock spam' then
if redis:get('Spam:Lock:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Spam* `Has Been Disable`\n\n' , 'md')
redis:del('Spam:Lock:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Spam* is _Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل اسپم' then
if redis:get('Spam:Lock:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل اسپم از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل اسپم فعال شد\n\n' , 'md')
redis:set('Spam:Lock:'..msg.chat_id,true)
end
end
if cerner == 'باز اسپم' then
if redis:get('Spam:Lock:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل اسپم غیرفعال شد\n\n' , 'md')
redis:del('Spam:Lock:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل اسپم از قبل غیرفعال بود\n\n' , 'md')
end
end
----------------------------------
if cerner == 'lock inline' then
if redis:get('Lock:Inline:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Inline* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Inline* `Has Been Enable`\n\n' , 'md')
redis:set('Lock:Inline:'..msg.chat_id,true)
end
end
if cerner == 'unlock inline' then
if redis:get('Lock:Inline:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Inline* `Has Been Disable`\n\n' , 'md')
redis:del('Lock:Inline:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Inline* is _Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل کیبورد شیشه ای' then
if redis:get('Lock:Inline:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل کیبورد شیشه ای از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل کیبورد شیشه ای فعال شد\n\n' , 'md')
redis:set('Lock:Inline:'..msg.chat_id,true)
end
end
if cerner == 'باز کیبورد شیشه ای' then
if redis:get('Lock:Inline:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل کیبورد شیشه ای غیرفعال شد\n\n' , 'md')
redis:del('Lock:Inline:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل کیبورد شیشه ای از قبل غیرفعال بود\n\n' , 'md')
end
end
-----------------------------------------------
if cerner == 'lock pin' then
if redis:get('Lock:Pin:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Pin* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Pin* `Has Been Enable`\n\n' , 'md')
redis:set('Lock:Pin:'..msg.chat_id,true)
end
end
if cerner == 'unlock pin' then
if redis:get('Lock:pin:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Pin* `Has Been Disable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Pin* is _Already_ `Disable`\n\n' , 'md')
redis:del('Lock:Pin:'..msg.chat_id)
end
end
if cerner == 'قفل سنجاق' then
if redis:get('Lock:Pin:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل سنجاق از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل سنجاق فعال شد\n\n' , 'md')
redis:set('Lock:Pin:'..msg.chat_id,true)
end
end
if cerner == 'باز سنجاق' then
if redis:get('Lock:pin:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل سنجاق غیرفعال شد\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل سنجاق از قبل غیرفعال بود\n\n' , 'md')
redis:del('Lock:Pin:'..msg.chat_id)
end
end
-----------------------------------------------
if cerner == 'lock flood' then
if redis:get('Lock:Flood:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Flood* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Flood* `Has Been Enable`\n\n' , 'md')
redis:set('Lock:Flood:'..msg.chat_id,true)
end
end
if cerner == 'unlock flood' then
if redis:get('Lock:Flood:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Flood* `Has Been Disable`\n\n' , 'md')
redis:del('Lock:Flood:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Flood* is _Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل پیام مکرر' then
if redis:get('Lock:Flood:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل پیام مکرر از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل پیام مکرر فعال شد\n\n' , 'md')
redis:set('Lock:Flood:'..msg.chat_id,true)
end
end
if cerner == 'باز پیام مکرر' then
if redis:get('Lock:Flood:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل پیام مکرر غیرفعال شد\n\n' , 'md')
redis:del('Lock:Flood:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل پیام مکرر از قبل غیرفعال بود\n\n' , 'md')
end
end
----------------------------------------------
if cerner == 'lock forward' then
if redis:get('Lock:Forward:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Forward* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Forward* `Has Been Enable`\n\n' , 'md')
redis:set('Lock:Forward:'..msg.chat_id,true)
end
end
if cerner == 'unlock forward' then
if redis:get('Lock:Forward:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Forward* `Has Been Disable`\n\n' , 'md')
redis:del('Lock:Forward:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Forward* is _Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل فروارد' then
if redis:get('Lock:Forward:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل فروارد از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل فروارد فعال شد\n\n' , 'md')
redis:set('Lock:Forward:'..msg.chat_id,true)
end
end
if cerner == 'باز فروارد' then
if redis:get('Lock:Forward:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل فروارد غیرفعال شد\n\n' , 'md')
redis:del('Lock:Forward:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل فروارد از قبل غیرفعال بود\n\n' , 'md')
end
end
------------------------------------------------
if cerner == 'lock arabic' then
if redis:get('Lock:Arabic:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Arabic* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Arabic* `Has Been Enable`\n\n' , 'md')
redis:set('Lock:Arabic:'..msg.chat_id,true)
end
end
if cerner == 'unlock arabic' then
if redis:get('Lock:Arabic:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Arabic* `Has Been Disable`\n\n' , 'md')
redis:del('Lock:Arabic:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Arabic* is _Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل فارسی' then
if redis:get('Lock:Arabic:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل فارسی از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل فارسی فعال شد\n\n' , 'md')
redis:set('Lock:Arabic:'..msg.chat_id,true)
end
end
if cerner == 'باز فارسی' then
if redis:get('Lock:Arabic:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل فارسی غیرفعال شد\n\n' , 'md')
redis:del('Lock:Arabic:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل فارسی از قبل غیرفعال بود\n\n' , 'md')
end
end
---------------------------------------------
if cerner == 'lock bot' then
if redis:get('Lock:Bot:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Bot* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Bot* `Has Been Enable`\n\n' , 'md')
redis:set('Lock:Bot:'..msg.chat_id,true)
end
end
if cerner == 'unlock bot'then
if redis:get('Lock:Bot:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Bot* `Has Been Disable`\n\n' , 'md')
redis:del('Lock:Bot:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Bot* is _Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل ربات' then
if redis:get('Lock:Bot:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل ورود ربات از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل ورود ربات فعال شد\n\n' , 'md')
redis:set('Lock:Bot:'..msg.chat_id,true)
end
end
if cerner == 'باز ربات'then
if redis:get('Lock:Bot:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل ورود ربات غیرفعال شد\n\n' , 'md')
redis:del('Lock:Bot:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل ورود ربات از قبل غیرفعال بود\n\n' , 'md')
end
end
--------------------------------------------
if cerner == 'lock edit' then
if redis:get('Lock:Edit'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Edit* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Edit* `Has Been Enable`\n\n' , 'md')
redis:set('Lock:Edit'..msg.chat_id,true)
end
end
if cerner == 'unlock edit' then
if redis:get('Lock:Edit'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Edit* `Has Been Disable`\n\n' , 'md')
redis:del('Lock:Edit'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Edit* is _Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل ویرایش' then
if redis:get('Lock:Edit'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل ویرایش پیام از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل ویرایش پیام فعال شد\n\n' , 'md')
redis:set('Lock:Edit'..msg.chat_id,true)
end
end
if cerner == 'باز ویرایش' then
if redis:get('Lock:Edit'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل ویرایش پیام غیرفعال شد\n\n' , 'md')
redis:del('Lock:Edit'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل ویرایش پیام از قبل غیرفعال بود\n\n' , 'md')
end
end
-----------------------------------------------
if cerner == 'lock english' then
if redis:get('Lock:English:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *English* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *English* `Has Been Enable`\n\n' , 'md')
redis:set('Lock:English:'..msg.chat_id,true)
end
end
if cerner == 'unlock english' then
if redis:get('Lock:English:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *English* `Has Been Disable`\n\n' , 'md')
redis:del('Lock:English:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Forward* is _Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل انگلیسی' then
if redis:get('Lock:English:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل نوشتار انگلیسی از قبل غیرفعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل نوشتار انگلیسی فعال شد\n\n' , 'md')
redis:set('Lock:English:'..msg.chat_id,true)
end
end
if cerner == 'باز انگلیسی' then
if redis:get('Lock:English:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل نوشتار انگلیسی غیرفعال شد\n\n' , 'md')
redis:del('Lock:English:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل نوشتار انگلیسی از قبل غیرفعال بود\n\n' , 'md')
end
end
--------------------------------------------
if cerner == 'lock tgservice' then
if redis:get('Lock:TGservise:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *TGservise* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *TGservise* `Has Been Enable`\n\n' , 'md')
redis:set('Lock:TGservise:'..msg.chat_id,true)
end
end
if cerner == 'unlock tgservice' then
if redis:get('Lock:TGservise:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *TGservise* `Has Been Disable`\n\n' , 'md')
redis:del('Lock:TGservise:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *TGservise* is _Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل خدمات تلگرام' then
if redis:get('Lock:TGservise:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل خدمات تلگرام از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل خدمات تلگرام فعال شد\n\n' , 'md')
redis:set('Lock:TGservise:'..msg.chat_id,true)
end
end
if cerner == 'باز خدمات تلگرام' then
if redis:get('Lock:TGservise:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل خدمات تلگرام غیرفعال شد\n\n' , 'md')
redis:del('Lock:TGservise:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل خدمات تلگرام از قبل غیرفعال بود\n\n' , 'md')
end
end
-------------------------------------------
if cerner == 'lock sticker' then
if redis:get('Lock:Sticker:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Sticker* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Sticker* `Has Been Enable`\n\n' , 'md')
redis:set('Lock:Sticker:'..msg.chat_id,true)
end
end
if cerner == 'unlock sticker' then
if redis:get('Lock:Sticker:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Sticker* `Has Been Disable`\n\n' , 'md')
redis:del('Lock:Sticker:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Sticker* is _Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل استیکر' then
if redis:get('Lock:Sticker:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل استیکر از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل استیکر فعال شد\n\n' , 'md')
redis:set('Lock:Sticker:'..msg.chat_id,true)
end
end
if cerner == 'باز استیکر' then
if redis:get('Lock:Sticker:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل استیکر غیرفعال شدn\n' , 'md')
redis:del('Lock:Sticker:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل استیکر از قبل غیرفعال بود\n\n' , 'md')
end
end
--------------------------------------------
-------------------------Mutes-----------------------------------------
if cerner == 'lock text' then
if redis:get('Mute:Text:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Text* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Text* `Has Been Enable`\n\n' , 'md')
redis:set('Mute:Text:'..msg.chat_id,true)
end
end
if cerner == 'unlock text' then
if redis:get('Mute:Text:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Text* `Has Been Disable`\n\n' , 'md')
redis:del('Mute:Text:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Text* is _Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل متن' then
if redis:get('Mute:Text:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل متن از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل متن فعال شد\n\n' , 'md')
redis:set('Mute:Text:'..msg.chat_id,true)
end
end
if cerner == 'باز متن' then
if redis:get('Mute:Text:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل متن غیرفعال شد\n\n' , 'md')
redis:del('Mute:Text:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل متن از قبل غیرفعال بود\n\n' , 'md')
end
end
---------------------------------------------------------------------------------
if cerner == 'lock contact' then
if redis:get('Mute:Contact:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Contact* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Contact* `Has Been Enable`\n\n' , 'md')
redis:set('Mute:Contact:'..msg.chat_id,true)
end
end
if cerner == 'unlock contact' then
if redis:get('Mute:Contact:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Contact* `Has Been Disable`\n\n' , 'md')
redis:del('Mute:Contact:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Contact* is _Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل مخاطب' then
if redis:get('Mute:Contact:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل مخاطب از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل مخاطب قعال شد\n\n' , 'md')
redis:set('Mute:Contact:'..msg.chat_id,true)
end
end
if cerner == 'باز مخاطب' then
if redis:get('Mute:Contact:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل مخاطب غیرفعال شد\n\n' , 'md')
redis:del('Mute:Contact:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل مخاطب از قبل غیرفعال بود\n\n' , 'md')
end
end
---------------------------------------------------------------------------------
if cerner == 'lock document' then
if redis:get('Mute:Document:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Document* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Document* `Has Been Enable`\n\n' , 'md')
redis:set('Mute:Document:'..msg.chat_id,true)
end
end
if cerner == 'unlock document' then
if redis:get('Mute:Document:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Document* `Has Been Disable`\n\n' , 'md')
redis:del('Mute:Document:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Document* is _Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل اسناد' then
if redis:get('Mute:Document:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل اسناد از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل اسناد فعال شد\n\n' , 'md')
redis:set('Mute:Document:'..msg.chat_id,true)
end
end
if cerner == 'باز اسناد' then
if redis:get('Mute:Document:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل اسناد غیرفعال فعال شد\n\n' , 'md')
redis:del('Mute:Document:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل اسناد از قبل غیرفعال بود\n\n' , 'md')
end
end
---------------------------------------------------------------------------------
if cerner == 'lock location' then
if redis:get('Mute:Location:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Location* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Location* `Has Been Enable`\n\n' , 'md')
redis:set('Mute:Location:'..msg.chat_id,true)
end
end
if cerner == 'unlock location' then
if redis:get('Mute:Location:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Location* `Has Been Disable`\n\n' , 'md')
redis:del('Mute:Location:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Location* _is Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل موقعیت مکانی' then
if redis:get('Mute:Location:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل موقعیت مکانی از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل موقعیت مکانی فعال شد\n\n' , 'md')
redis:set('Mute:Location:'..msg.chat_id,true)
end
end
if cerner == 'باز موقعیت مکانی' then
if redis:get('Mute:Location:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل موقعیت مکانی غیرفعال شد\n\n' , 'md')
redis:del('Mute:Location:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل موقعیت مکانی از قبل غیرفعال بود\n\n' , 'md')
end
end
---------------------------------------------------------------------------------
if cerner == 'lock voice' then
if redis:get('Lock:Voice:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Voice* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Voice* `Has Been Enable`\n\n' , 'md')
redis:set('Mute:Voice:'..msg.chat_id,true)
end
end
if cerner == 'unlock voice' then
if redis:get('Mute:Voice:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Voice* `Has Been Disable`\n\n' , 'md')
redis:del('Mute:Voice:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Voice* _is Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل ویس' then
if redis:get('Lock:Voice:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل ویس از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل ویس فعال شد\n\n' , 'md')
redis:set('Mute:Voice:'..msg.chat_id,true)
end
end
if cerner == 'باز ویس' then
if redis:get('Mute:Voice:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل ویس غیرفعال شد\n\n' , 'md')
redis:del('Mute:Voice:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل ویس از قبل غیرفعال بود\n\n' , 'md')
end
end
---------------------------------------------------------------------------------
if cerner == 'lock photo' then
if redis:get('Mute:Photo:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Photo* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Photo* `Has Been Enable`\n\n' , 'md')
redis:set('Mute:Photo:'..msg.chat_id,true)
end
end
if cerner == 'unlock photo' then
if redis:get('Mute:Photo:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Photo* `Has Been Disable`\n\n' , 'md')
redis:del('Mute:Photo:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Photo* _is Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل عکس' then
if redis:get('Mute:Photo:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل عکس از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل عکس فعال شد\n\n' , 'md')
redis:set('Mute:Photo:'..msg.chat_id,true)
end
end
if cerner == 'باز عکس' then
if redis:get('Mute:Photo:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل عکس غیرفعال شد\n\n' , 'md')
redis:del('Mute:Photo:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل عکس از قبل غیرفعال بود\n\n' , 'md')
end
end
---------------------------------------------------------------------------------
if cerner == 'lock game' then
if redis:get('Mute:Game:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Game* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Game* `Has Been Enable`\n\n' , 'md')
redis:set('Mute:Game:'..msg.chat_id,true)
end
end
if cerner == 'unlock game' then
if redis:get('Mute:Game:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Game* `Has Been Disable`\n\n' , 'md')
redis:del('Mute:Game:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Game* _is Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل بازی' then
if redis:get('Mute:Game:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل بازی از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل بازی فعال شد\n\n' , 'md')
redis:set('Mute:Game:'..msg.chat_id,true)
end
end
if cerner == 'باز بازی' then
if redis:get('Mute:Game:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل بازی غیرفعال شد\n\n' , 'md')
redis:del('Mute:Game:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل بازی از قبل غیرفعال بود\n\n' , 'md')
end
end
---------------------------------------------------------------------------------
if cerner == 'lock video' then
if redis:get('Mute:Video:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Video* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Video* `Has Been Enable`\n\n' , 'md')
redis:set('Mute:Video:'..msg.chat_id,true)
end
end
if cerner == 'unlock video' then
if redis:get('Mute:Video:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Video* `Has Been Disable`\n\n' , 'md')
redis:del('Mute:Video:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Video* _is Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل فیلم' then
if redis:get('Mute:Video:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل فیلم از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل فیلم فعال شد\n\n' , 'md')
redis:set('Mute:Video:'..msg.chat_id,true)
end
end
if cerner == 'باز فیلم' then
if redis:get('Mute:Video:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل فیلم غیرفعال شد\n\n' , 'md')
redis:del('Mute:Video:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل فیلم از قبل غیرفعال بود\n\n' , 'md')
end
end
---------------------------------------------------------------------------------
if cerner == 'lock music' then
if redis:get('Mute:Music:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Music* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Music* `Has Been Enable`\n\n' , 'md')
redis:set('Mute:Music:'..msg.chat_id,true)
end
end
if cerner == 'unlock music' then
if redis:get('Mute:Music:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Music* `Has Been Disable`\n\n' , 'md')
redis:del('Mute:Music:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Music* _is Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل اهنگ' then
if redis:get('Mute:Music:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل اهنگ از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل اهنگ فعال شد\n\n' , 'md')
redis:set('Mute:Music:'..msg.chat_id,true)
end
end
if cerner == 'باز اهنگ' then
if redis:get('Mute:Music:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل اهنگ غیرفعال شد\n\n' , 'md')
redis:del('Mute:Music:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل اهنگ از قبل غیرفعال بود\n\n' , 'md')
end
end
---------------------------------------------------------------------------------
if cerner == 'lock gif' then
if redis:get('Mute:Gif:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Gif* is _Already_ `Enable`\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• `Lock` *Gif* `Has Been Enable`\n\n' , 'md')
redis:set('Mute:Gif:'..msg.chat_id,true)
end
end
if cerner == 'unlock gif' then
if redis:get('Mute:Gif:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• `Lock` *Gif* `Has Been Disable`\n\n' , 'md')
redis:del('Mute:Gif:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• `Lock` *Gif* _is Already_ `Disable`\n\n' , 'md')
end
end
if cerner == 'قفل گیف' then
if redis:get('Mute:Gif:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل گیف از قبل فعال بود\n\n' , 'md')
else
sendText(msg.chat_id, msg.id, '• قفل گیف فعال شد\n\n' , 'md')
redis:set('Mute:Gif:'..msg.chat_id,true)
end
end
if cerner == 'باز گیف' then
if redis:get('Mute:Gif:'..msg.chat_id) then
sendText(msg.chat_id, msg.id, '• قفل گیف غیرفعال شد\n\n' , 'md')
redis:del('Mute:Gif:'..msg.chat_id)
else
sendText(msg.chat_id, msg.id, '• قفل گیف از قبل غیرفعال شد\n\n' , 'md')
end
end
-----------End Mutes---------------
----------------------------------------------------------------------------------
if cerner1 and cerner1:match('^[Ss]etlink (.*)') then
local link = cerner1:match('^[Ss]etlink (.*)')
redis:set('Link:'..msg.chat_id,link)
sendText(msg.chat_id, msg.id,'• *New Link Has Been Seted*\n\n', 'md')
end
if cerner1 and cerner1:match('^[Ss]etwelcome (.*)') then
local wel = cerner1:match('^[Ss]etwelcome (.*)')
redis:set('Text:Welcome:'..msg.chat_id,wel)
sendText(msg.chat_id, msg.id,'• *New Welcome Has Been Seted*\n\n', 'md')
end
if cerner1 and cerner1:match('^[Ss]etrules (.*)') then
local rules = cerner1:match('^[Ss]etrules (.*)')
redis:set('Rules:'..msg.chat_id,rules)
sendText(msg.chat_id, msg.id,'• *New rules Has Been Seted*\n\n', 'md')
end
if cerner1 and cerner1:match('^تنظیم لینک (.*)') then
local link = cerner1:match('^تنظیم لینک (.*)')
redis:set('Link:'..msg.chat_id,link)
sendText(msg.chat_id, msg.id,'• *لینک جدید ثبت شد*\n\n', 'md')
end
if cerner1 and cerner1:match('^تنظیم خوش امد (.*)') then
local wel = cerner1:match('^تنظیم خوش امد (.*)')
redis:set('Text:Welcome:'..msg.chat_id,wel)
sendText(msg.chat_id, msg.id,'• *پیام خوش امد تنظیم شد*\n\n', 'md')
end
if cerner1 and cerner1:match('^تنظیم قوانین (.*)') then
local rules = cerner1:match('^تنظیم قوانین (.*)')
redis:set('Rules:'..msg.chat_id,rules)
sendText(msg.chat_id, msg.id,'• *پیام قوانین تنظیم شد*\n\n', 'md')
end
-----------------------------------------------------------------------------------------------------------------------------------------------------
if cerner and cerner:match('^filter +(.*)') then
local word = cerner:match('^filter +(.*)')
redis:sadd('Filters:'..msg.chat_id,word)
sendText(msg.chat_id, msg.id, '• `'..word..'` *Added To BadWord List!*', 'md')
end
if cerner and cerner:match('^فیلتر +(.*)') then
local word = cerner:match('^فیلتر +(.*)')
redis:sadd('Filters:'..msg.chat_id,word)
sendText(msg.chat_id, msg.id, '•کلمه `'..word..'` *به لیست فیلتر اضافه شد!*', 'md')
end
if cerner and cerner:match('^remfilter +(.*)') then
local word = cerner:match('^remfilter +(.*)')
redis:srem('Filters:'..msg.chat_id,word)
sendText(msg.chat_id, msg.id,'• `'..word..'` *Removed From BadWord List!*', 'md')
end
if cerner and cerner:match('^حذف فیلتر +(.*)') then
local word = cerner:match('^حذف فیلتر +(.*)')
redis:srem('Filters:'..msg.chat_id,word)
sendText(msg.chat_id, msg.id,'•کلمه `'..word..'` *از لیست فیلتر حذف شد!*', 'md')
end
if cerner == "warn" and tonumber(msg.reply_to_message_id) > 0 then
function WarnByReply(CerNer,Company)
if tonumber(Company.sender_user_id or 00000000) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
if private(msg.chat_id,Company.sender_user_id or 00000000) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم به یک فرد دارای مقام اخطار بدهم", 'md')
else
local hashwarn = msg.chat_id..':warn'
local warnhash = redis:hget(msg.chat_id..':warn',(Company.sender_user_id or 00000000)) or 1
if tonumber(warnhash) == tonumber(warn) then
KickUser(msg.chat_id,Company.sender_user_id)
RemoveFromBanList(msg.chat_id,Company.sender_user_id)
text= "User *"..(Company.sender_user_id or 00000000).."* has been *kicked because max warning \nNumber of warn :*"..warnhash.."/"..warn..""
redis:hdel(hashwarn,Company.sender_user_id, '0')
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, text, 7, string.len(Company.sender_user_id))
else
local warnhash = redis:hget(msg.chat_id..':warn',(Company.sender_user_id or 00000000)) or 1
redis:hset(hashwarn,Company.sender_user_id, tonumber(warnhash) + 1)
text= "کاربر "..(Company.sender_user_id or '0000Null0000').." شما یک اخطار دریافت کردید\nتعداد اخطار های شما : "..warnhash.."/"..warn..""
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, text, 7, string.len(Company.sender_user_id))
end
end
end
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),WarnByReply)
end
if cerner == "اخطار" and tonumber(msg.reply_to_message_id) > 0 then
function WarnByReply(CerNer,Company)
if tonumber(Company.sender_user_id or 00000000) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
if private(msg.chat_id,Company.sender_user_id or 00000000) then
print ' Private '
sendText(msg.chat_id, msg.id, "اوه شت :(\nمن نمیتوانم به یک فرد دارای مقام اخطار بدهم", 'md')
else
local hashwarn = msg.chat_id..':warn'
local warnhash = redis:hget(msg.chat_id..':warn',(Company.sender_user_id or 00000000)) or 1
if tonumber(warnhash) == tonumber(warn) then
KickUser(msg.chat_id,Company.sender_user_id)
RemoveFromBanList(msg.chat_id,Company.sender_user_id)
text= "کاربر *"..(Company.sender_user_id or 00000000).."* به دلیل اخطار بیش از حد اخراج شد \nتعداد اخطار های شما :*"..warnhash.."/"..warn..""
redis:hdel(hashwarn,Company.sender_user_id, '0')
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, text, 7, string.len(Company.sender_user_id))
else
local warnhash = redis:hget(msg.chat_id..':warn',(Company.sender_user_id or 00000000)) or 1
redis:hset(hashwarn,Company.sender_user_id, tonumber(warnhash) + 1)
text= "کاربر "..(Company.sender_user_id or '0000Null0000').." شما یک اخطار دریافت کردید\nتعداد اخطار های شما : "..warnhash.."/"..warn..""
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, text, 7, string.len(Company.sender_user_id))
end
end
end
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),WarnByReply)
end
if cerner == "unwarn" and tonumber(msg.reply_to_message_id) > 0 or cerner == "حذف اخطار" and tonumber(msg.reply_to_message_id) > 0 then
function UnWarnByReply(CerNer,Company)
if tonumber(Company.sender_user_id or 00000000) == tonumber(TD_ID) then
sendText(msg.chat_id, msg.id, 'اوه شت :( \nمن نمیتوانم پیام خودم را چک کنم', 'md')
return false
end
if private(msg.chat_id,Company.sender_user_id or 00000000) then
print ' Private '
else
local warnhash = redis:hget(msg.chat_id..':warn',(Company.sender_user_id or 00000000)) or 1
if tonumber(warnhash) == tonumber(1) then
text= "کاربر *"..Company.sender_user_id.."* هیچ اخطاری ندارد"
sendText(msg.chat_id, msg.id, text, 'md')
else
local warnhash = redis:hget(msg.chat_id..':warn',(Company.sender_user_id or 00000000))
local hashwarn = msg.chat_id..':warn'
redis:hdel(hashwarn,(Company.sender_user_id or 00000000),'0')
if Company.username then
user_name = '@'..check_markdown(Company.username)
else
user_name = ec_name(Company.first_name)
end
text= "کاربر "..(Company.sender_user_id or '0000Null0000').." تمام اخطار های شما پاک شد "
sendText(msg.chat_id, msg.id, text, 'md')
end
end
end
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),UnWarnByReply)
end
------
end
------
if redis:get('CheckBot:'..msg.chat_id) then
if cerner and cerner:match('^id @(.*)') then
local username = cerner:match('^id @(.*)')
function IdByUserName(CerNer,Company)
if Company.id then
text = '• SHADOBAKER\n\nUser ID : ['..Company.id..']\n\n'
sendText(msg.chat_id, msg.id, text, 'md')
end
end
resolve_username(username,IdByUserName)
end
if redis:get('CheckBot:'..msg.chat_id) then
if cerner and cerner:match('^ایدی @(.*)') then
local username = cerner:match('^ایدی @(.*)')
function IdByUserName(CerNer,Company)
if Company.id then
text = '• SHADOBAKER\n\nشناسه کاربر : ['..Company.id..']\n\n'
sendText(msg.chat_id, msg.id, text, 'md')
end
end
resolve_username(username,IdByUserName)
end
if cerner == 'id' then
function GetID(CerNer, Company)
local user = Company.sender_user_id
local text = 'SHADOBAKER\n'..Company.sender_user_id
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, text, 16, string.len(Company.sender_user_id))
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),GetID)
end
end
if cerner == 'ایدی' then
function GetID(CerNer, Company)
local user = Company.sender_user_id
local text = 'SHADOBAKER\n'..Company.sender_user_id
SendMetion(msg.chat_id,Company.sender_user_id, msg.id, text, 16, string.len(Company.sender_user_id))
end
if tonumber(msg.reply_to_message_id) == 0 then
else
getMessage(msg.chat_id, tonumber(msg.reply_to_message_id),GetID)
end
end
if cerner and cerner:match('^getpro (%d+)') or cerner and cerner:match('^عکس پروفایل (%d+)') then
local offset = tonumber(cerner:match('^getpro (%d+)'))
local offset = tonumber(cerner:match('^عکس پروفایل (%d+)'))
if offset > 50 then
sendText(msg.chat_id, msg.id,'اوه شت :( \n من بیشتر از 50 عکس پروفایل شما را نمیتوانم ارسال کنم • ','md')
elseif offset < 1 then
sendText(msg.chat_id, msg.id, 'لطفا عددی بزرگتر از 0 بکار ببرید • ', 'md')
else
function GetPro1(CerNer, Company)
if Company.photos[0] then
sendPhoto(msg.chat_id, msg.id, 0, 1, nil, Company.photos[0].sizes[2].photo.persistent_id,'• Total Profile Photos : '..Company.total_count..'\n• Photo Size : '.. Company.photos[0].sizes[2].photo.size)
else
sendText(msg.chat_id, msg.id, 'شما عکس پروفایل '..offset..' ندارید', 'md')
end
end
tdbot_function ({_ ="getUserProfilePhotos", user_id = msg.sender_user_id, offset = offset-1, limit = 100000000000000000000000 },GetPro1, nil)
end
end
if cerner and cerner:match('^whois (%d+)') then
local id = tonumber(cerner:match('^whois (%d+)'))
local function Whois(CerNer,Company)
if Company.first_name then
local username = ec_name(Company.first_name)
SendMetion(msg.chat_id,Company.id, msg.id,username,0,utf8.len(username))
else
sendText(msg.chat_id, msg.id,'*User ['..id..'] Not Found*','md')
end
end
GetUser(id,Whois)
end
if cerner and cerner:match('^چی کسی (%d+)') then
local id = tonumber(cerner:match('^چه کسی (%d+)'))
local function Whois(CerNer,Company)
if Company.first_name then
local username = ec_name(Company.first_name)
SendMetion(msg.chat_id,Company.id, msg.id,username,0,utf8.len(username))
else
sendText(msg.chat_id, msg.id,'*کاربر ['..id..'] یافت نشد*','md')
end
end
GetUser(id,Whois)
end
if cerner == "id" then
if tonumber(msg.reply_to_message_id) == 0 then
function GetPro(CerNer, Company)
Msgs = redis:get('Total:messages:'..msg.chat_id..':'..(msg.sender_user_id or 00000000))
if is_sudo(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "Sudo")..''
elseif is_Owner(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "Owner")..''
elseif is_Mod(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "ADMIN")..''
elseif is_Vip(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "VIP")..''
elseif not is_Mod(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "Member")..''
end
if Company.photos[0] then
print('persistent_id : '..Company.photos[0].sizes[2].photo.persistent_id)
sendPhoto(msg.chat_id, msg.id, 0, 1, nil, Company.photos[0].sizes[2].photo.persistent_id,'• SHADOBAKER\n\nChat ID : ['..msg.chat_id..']\nUser ID : ['..msg.sender_user_id..']\nRank : ['..rank..']\nTotal Msgs : '..Msgs..'\nTD ID : '..TD_ID..'\n')
else
sendText(msg.chat_id, msg.id, '• `SHADOBAKER`!!\n\nChat ID : ['..msg.chat_id..']\nUser ID : ['..msg.sender_user_id..']\nRank : ['..rank..']\nTotal Msgs : '..Msgs..'\nTD ID : '..TD_ID..'\n', 'md')
print ' Not Photo '
end
end
tdbot_function ({_ ="getUserProfilePhotos", user_id = (msg.sender_user_id or 00000000), offset =0, limit = 100000000 },GetPro, nil)
end
end
if cerner == "ایدی" then
if tonumber(msg.reply_to_message_id) == 0 then
function GetPro(CerNer, Company)
Msgs = redis:get('Total:messages:'..msg.chat_id..':'..(msg.sender_user_id or 00000000))
if is_sudo(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "مدیرکل")..''
elseif is_Owner(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "مالک")..''
elseif is_Mod(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "مدیر")..''
elseif is_Vip(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "عضو ویژه")..''
elseif not is_Mod(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "کاربر عادی")..''
end
if Company.photos[0] then
print('persistent_id : '..Company.photos[0].sizes[2].photo.persistent_id)
sendPhoto(msg.chat_id, msg.id, 0, 1, nil, Company.photos[0].sizes[2].photo.persistent_id,'• SHADOBAKER\n\nشناسه گروه : ['..msg.chat_id..']\nشناسه شما : ['..msg.sender_user_id..']\nمقام شما : ['..rank..']\nتعداد پیام های شما : '..Msgs..'\nشناسه تی دی شما : '..TD_ID..'\n')
else
sendText(msg.chat_id, msg.id, '• `SHADOBAKER`!!\n\nشناسه گروه : ['..msg.chat_id..']\nشناسه شما : ['..msg.sender_user_id..']\nمقام شما : ['..rank..']\nتعداد پیام های شما : '..Msgs..'\nشناسه تی دی شما : '..TD_ID..'\n', 'md')
print ' Not Photo '
end
end
tdbot_function ({_ ="getUserProfilePhotos", user_id = (msg.sender_user_id or 00000000), offset =0, limit = 100000000 },GetPro, nil)
end
end
if cerner == 'me' then
local function GetName(CerNer, Company)
if is_sudo(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "Sudo")..''
elseif is_Owner(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "Owner")..''
elseif is_Mod(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "ADMIN")..''
elseif is_Vip(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "VIP")..''
elseif not is_Mod(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "Member")..''
end
if Company.first_name then
CompanyName = ec_name(Company.first_name)
else
CompanyName = '\n\n'
end
Msgs = redis:get('Total:messages:'..msg.chat_id..':'..msg.sender_user_id)
sendText(msg.chat_id, msg.id, '• `SHADOBAKER!!`\n\n• Your Name : ['..CompanyName..']\n• User ID : ['..msg.sender_user_id..']\n• Rank : ['..rank..']\n• Total Msgs : ['..Msgs..']\n','md')
end
GetUser(msg.sender_user_id,GetName)
end
if cerner == 'من' then
local function GetName(CerNer, Company)
if is_sudo(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "مدیرکل")..''
elseif is_Owner(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "مالک")..''
elseif is_Mod(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "مدیر")..''
elseif is_Vip(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "عضو ویژه")..''
elseif not is_Mod(msg) then
rank = ''..(redis:get('rank'..msg.sender_user_id) or "کاربر عادی")..''
end
if Company.first_name then
CompanyName = ec_name(Company.first_name)
else
CompanyName = '\n\n'
end
Msgs = redis:get('Total:messages:'..msg.chat_id..':'..msg.sender_user_id)
sendText(msg.chat_id, msg.id, '• `SHADOBAKER!!`\n\n• نام شما : ['..CompanyName..']\n• شناسه شما : ['..msg.sender_user_id..']\n• مقام شما : ['..rank..']\n• تعداد پیام های شما : ['..Msgs..']\n','md')
end
GetUser(msg.sender_user_id,GetName)
end
if cerner == 'about me' then
function GetName(extra, result, success)
if result.about then
CompanyName = result.about
else
CompanyName = 'nil\n\n'
end
if result.common_chat_count then
Companycommon_chat_count = result.common_chat_count
else
Companycommon_chat_count = 'nil'
end
sendText(msg.chat_id, msg.id, '• `SHADOBAKER`!!\n\n• Bio : ['..CompanyName..']\n\nCommon chat count : ['..Companycommon_chat_count..']', 'md')
end
GetUserFull(msg.sender_user_id,GetName)
end
if cerner == 'درباره من' then
function GetName(extra, result, success)
if result.about then
CompanyName = result.about
else
CompanyName = 'nil\n\n'
end
if result.common_chat_count then
Companycommon_chat_count = result.common_chat_count
else
Companycommon_chat_count = 'nil'
end
sendText(msg.chat_id, msg.id, '• `SHADOBAKER`!!\n\n• بیوگرافی شما : ['..CompanyName..']\n\nتعداد کروه های مشترک با من : ['..Companycommon_chat_count..']', 'md')
end
GetUserFull(msg.sender_user_id,GetName)
end
if cerner == 'groupinfo' then
local function FullInfo(CerNer,Company)
sendText(msg.chat_id, msg.id,'*SuperGroup Info :*\n`SuperGroup ID :`*'..msg.chat_id..'*\n`Total Admins :` *'..Company.administrator_count..'*\n`Total Banned :` *'..Company.banned_count..'*\n`Total Members :` *'..Company.member_count..'*\n`About Group :` *'..Company.description..'*\n`Link : `*'..Company.invite_link..'*\n`Total Restricted : `*'..Company.restricted_count..'*', 'md')
end
getChannelFull(msg.chat_id,FullInfo)
end
if cerner == 'اطلاعات گروه' then
local function FullInfo(CerNer,Company)
sendText(msg.chat_id, msg.id,'*اطلاعات گروه :*\n`شناسه گروه :`*'..msg.chat_id..'*\n`تعداد ادمین ها :` *'..Company.administrator_count..'*\n`تعداد مسدودی ها :` *'..Company.banned_count..'*\n`تعداد ممبر ها :` *'..Company.member_count..'*\n`درباره گروه :` *'..Company.description..'*\n`لینک گروه : `*'..Company.invite_link..'*\n`تعداد کابران محدود شده : `*'..Company.restricted_count..'*', 'md')
end
getChannelFull(msg.chat_id,FullInfo)
end
-------------------------------
end
if cerner == 'link' then
local link = redis:get('Link:'..msg.chat_id)
if link then
sendText(msg.chat_id,msg.id, '• *Group Link:*\n'..link..'\n\n', 'md')
else
sendText(msg.chat_id, msg.id, '• *Link Not Set*\n\n', 'md')
end
end
if cerner == 'لینک' then
local link = redis:get('Link:'..msg.chat_id)
if link then
sendText(msg.chat_id,msg.id, '• *لینک گروه:*\n'..link..'\n\n', 'md')
else
sendText(msg.chat_id, msg.id, '• *لینک گروه ثبت نشده است*\n\n', 'md')
end
end
if cerner == 'rules' then
local rules = redis:get('Rules:'..msg.chat_id)
if rules then
sendText(msg.chat_id,msg.id, '• *Group Rules:*\n'..rules..'\n\n', 'md')
else
sendText(msg.chat_id, msg.id, '• *Rules Not Set*\n\n', 'md')
end
end
if cerner == 'قوانین' then
local rules = redis:get('Rules:'..msg.chat_id)
if rules then
sendText(msg.chat_id,msg.id, '• *قوانین گروه:*\n'..rules..'\n\n', 'md')
else
sendText(msg.chat_id, msg.id, '• *قوانین گروه ثبت نشده است*\n\n', 'md')
end
end
if cerner == 'games' then
local games = {'Corsairs','LumberJack','MathBattle'}
sendGame(msg.chat_id, msg.id, 166035794, games[math.random(#games)])
end
if cerner == 'بازی' then
local games = {'Corsairs','LumberJack','MathBattle'}
sendGame(msg.chat_id, msg.id, 166035794, games[math.random(#games)])
end
if cerner == 'ping' then
txts = [[• PONG
]]
sendText(msg.chat_id, msg.id, txts, 'md')
end
if cerner == 'انلاینی' then
txts = [[• آره گلم انلاینم
]]
sendText(msg.chat_id, msg.id, txts, 'md')
end
if cerner == 'help' then
if is_sudo(msg) then
text =[[ •• راهنمای کار با کرنر برای مقام صاحب ربات
• setsudo [user]
> تنظیم کاربر به عنوان کمک مدیر ربات
• remsudo [user]
> حذف کاربر از لیست کمک مدیر ربات
• add
> افزودن گروه به لیست گروه های مدیریتی
• rem
> حذف گروه از لیست گروه های مدیریتی
• charge [num]
> شارژ گروه به دلخواه
• plan1 [chat_id]
> شارژ گروه به مدت یک ماه
• plan2 [chat_id]
> شارژ گروه به مدت 2 ماه
• plan3 [chat_id]
> شارژ گروه به مدت نامحدود
• leave [chat_id]
> خروج از گروه مورد نظر
• expire
> مدت شارژ گروه
• groups
> نمایش تمام گروه ها
• banall [user] or [reply] or [username]
> مسدود کردن کاربر مورد نظر از تمام گروها
• unbanall [user] or [reply] or [username]
> حذف کاربر مورد نظر از لیست مسدودیت
• setowner
تنظیم کاربر به عنوان صاحب گروه
• remowner
> غزل کاربر از مقام صاحب گروه
• ownerlist
> نمایش لیست صاحبان گروه
• clean ownerlist
> پاکسازی لیست مالکان گروه
• clean gbans
> پاکسازی لیست کاربران لیست سیاه
• clean members
> پاکسازی تمام کاربران گروه
• gbans
> لیست کاربران موجود در لیست سیاه
• leave
> خارج کردن ربات از گروه مورد نظر
• bc [reply]
> ارسال پیام مورد نظر به تمام گرو ها
• fwd [reply]
> فروارد پیام به تمام گروه ها
• stats
> نمایش آمار ربات
• reload
> بازنگری ربات
• git pull
> اپدیت ربات به اخرین نسخه
• welcome enable
> فعال کردن خوش امد گو
• welcome disable
> غیرفعال کردن خوش امد گو
• setwelcome [text]
> تنظیم خوش امد گو
شما میتوانید از
{first} : بکار بردن نام کاربر
{last} : بکار بردن نام بزرگ
{username} : بکار بردن یوزرنیم
{rules} : بکار بردن قوانین
}link} : بکار بردن لینک
مثال :
setwelcome سلام {first} {last} {username} به گروه خوش امدی
• muteuser [user] or [reply] or [username]
> محدود کردن کاربر
• unmuteuser [user] or [reply] or [username]
> رفع محدودیت کاربر
• mute all
> محدود کردن تمام کاربران
• unmute all
> رفیع محدودیت تمام اعضا
• setvip [reply] or [username]
> ویژه کردن کاربر
• remvip [user] or [reply] or [username]
> حذف کاربر از لیست ویژه
• viplist
> نمایش اعضای ویزه
• clean viplist
> پاکسازی لیست اعضای ویژه
• clean bots
> اخراج تمامی ربات ها
• filter [word]
> فیلتر کردن کالمه مورد نظر
• unfilter [word]
> حذف کلمه مورد نظر از لیست فیلتر
• kick [user] or [reply] or [username]
> اخراج کاربر از گروه
• ban [user] or [reply] or [username]
> مسدود کردن کاربر از گروه
• banlist
> لیست کاربران مسدود شده
• clean banlist
> حذف کاربران از لیست مسدودین گروه
• setflood [num]
> تنظیم پیام رگباری
• setflood [kickuser] or [muteuser]
> تنظیم حالت برخورد با پیام رگباری
• setfloodtime [num]
> تنظیم زمان پیام رگباری
• setlink [link] or [reply]
> تنظیم لینک گروه
• config
> ارتقا تمام ادمین ها
• setrules [rules]
> تنظیم قوانین گروه
• clean restricts
> حذف کاربران محدود شده از لیست
• lock [link]/[spam][edit]/[tag]/[hashtag]/[inline]/[video_note]/[bot]/[forward]/[arabic]/[english]/[tgservice]/[sticker]
قفل کردن
مثال
lock bot
قفل ورود ربات
• unlock [link]/[spam][edit]/[tag]/[hashtag]/[inline]/[video_note]/[bot]/[forward]/[arabic]/[english]/[tgservice]/[sticker]
بازکردن قفل
مثال :
unlock bot
• mute [photo]/[music]/[voice]/[document]/[video]/[game]/[location]/[contact]/[gif]/[text]
> بیصدا کردن
مثال :
mute photo
• unmute [photo]/[music]/[voice]/[document]/[video]/[game]/[location]/[contact]/[gif]/[text]
> لغو بیصدا
مثال :
unmute photo
• warnmax [num]
> تنظیم مقدار اخطار
• warn [user] or [reply] or [username]
> اخطار دادن به کاربر
• unwarn [reply]
> حذف کاربر
• clean warnlist
> پاکسازی لیست افرادی که اخطار گرفته اند
• delall [user] or [reply] or [username]
> پاکسازی تمام پیام های یک کاربر
• setname [name]
> تنظیم نام گروه
• setdescription [des]
> تنظیم درباره گروه
]]
elseif is_Owner(msg) then
text =[[•• راهنمای کار با ربات کرنر برای مقام صاحب گروه
• welcome enable
> فعال کردن خوش امد گو
• welcome disable
> غیرفعال کردن خوش امد گو
• setwelcome [text]
> تنظیم خوش امد گو
شما میتوانید از
{first} : بکار بردن نام کاربر
{last} : بکار بردن نام بزرگ
{username} : بکار بردن یوزرنیم
{rules} : بکار بردن قوانین
{link} : بکار بردن لینک
مثال :
setwelcome سلام {first} {last} {username} به گروه خوش امدی
• whois [user_id]
> نمایش کاربر
• clean mutelist
> خالی کردن لیست افراد صامت شده گروه و ازادسازی ان ها
• promote [user] or [reply] or [username]
> ترفیع دادن کاربر به مقام کمک مدیر
• demote [user] or [reply] or [username]
• pin [reply]
> سنجاق کردن پیام
• unpin
> حذف پیام پین شده
• muteuser [user] or [reply] or [username]
> محدود کردن کاربر
• unmuteuser [user] or [reply] or [username]
> رفع محدودیت کاربر
• mute all
> محدود کردن تمام کاربران
• unmute all
> رفیع محدودیت تمام اعضا
• setvip [reply] or [username]
> ویژه کردن کاربر
• remvip [user] or [reply] or [username]
> حذف کاربر از لیست ویژه
• viplist
> نمایش اعضای ویزه
• clean viplist
> پاکسازی لیست اعضای ویژه
• clean bots
> اخراج تمامی ربات ها
• filter [word]
> فیلتر کردن کالمه مورد نظر
• unfilter [word]
> حذف کلمه مورد نظر از لیست فیلتر
• kick [user] or [reply] or [username]
> اخراج کاربر از گروه
• ban [user] or [reply] or [username]
> مسدود کردن کاربر از گروه
• banlist
> لیست کاربران مسدود شده
• clean banlist
> حذف کاربران از لیست مسدودین گروه
• setflood [num]
> تنظیم پیام رگباری
• setflood [kickuser] or [muteuser]
> تنظیم حالت برخورد با پیام رگباری
• setfloodtime [num]
> تنظیم زمان پیام رگباری
• setlink [link] or [reply]
> تنظیم لینک گروه
• config
> ارتقا تمام ادمین ها
• setrules [rules]
> تنظیم قوانین گروه
• clean restricts
> حذف کاربران محدود شده از لیست
• lock [link]/[spam][edit]/[tag]/[hashtag]/[inline]/[video_note]/[pin]/[bot]/[forward]/[arabic]/[english]/[tgservice]/[sticker]
قفل کردن
مثال
lock bot
قفل ورود ربات
• unlock [link]/[spam]/[edit]/[tag]/[hashtag]/[inline]/[video_note]/[pin]/[bot]/[forward]/[arabic]/[english]/[tgservice]/[sticker]
بازکردن قفل
مثال :
unlock bot
• mute [photo]/[music]/[voice]/[document]/[video]/[game]/[location]/[contact]/[gif]/[text]
> بیصدا کردن
مثال :
mute photo
• unmute [photo]/[music]/[voice]/[document]/[video]/[game]/[location]/[contact]/[gif]/[text]
> لغو بیصدا
مثال :
unmute photo
• getpro [num] > limit 50
> دریافت 50 پروفایل خود
• warnmax [num]
> تنظیم مقدار اخطار
• warn [user] or [reply] or [username]
> اخطار دادن به کاربر
• unwarn [reply]
> حذف کاربر
• clean warnlist
> پاکسازی لیست افرادی که اخطار گرفته اند
• delall [user] or [reply] or [username]
> پاکسازی تمام پیام های یک کاربر
• setname [name]
> تنظیم نام گروه
• setdescription [des]
> تنظیم درباره گروه
]]
elseif is_Mod(msg) then
text =[[• • راهنمای کار با کرنر برای مقام کمک مدیر
• welcome enable
> فعال کردن خوش امد گو
• welcome disable
> غیرفعال کردن خوش امد گو
• setwelcome [text]
> تنظیم خوش امد گو
شما میتوانید از
{first} : بکار بردن نام کاربر
{last} : بکار بردن نام بزرگ
{username} : بکار بردن یوزرنیم
{rules} : بکار بردن قوانین
{link} : بکار بردن لینک
مثال :
setwelcome سلام {first} {last} {username} به گروه خوش امدی
• muteuser [user] or [reply] or [username]
> محدود کردن کاربر
• unmuteuser [user] or [reply] or [username]
> رفع محدودیت کاربر
• mute all
> محدود کردن تمام کاربران
• unmute all
> رفیع محدودیت تمام اعضا
• setvip [reply] or [username]
> ویژه کردن کاربر
• remvip [user] or [reply] or [username]
> حذف کاربر از لیست ویژه
• viplist
> نمایش اعضای ویزه
• clean viplist
> پاکسازی لیست اعضای ویژه
• clean bots
> اخراج تمامی ربات ها
• filter [word]
> فیلتر کردن کالمه مورد نظر
• unfilter [word]
> حذف کلمه مورد نظر از لیست فیلتر
• kick [user] or [reply] or [username]
> اخراج کاربر از گروه
• ban [user] or [reply] or [username]
> مسدود کردن کاربر از گروه
• banlist
> لیست کاربران مسدود شده
• clean banlist
> حذف کاربران از لیست مسدودین گروه
• setflood [num]
> تنظیم پیام رگباری
• setfloodtime [num]
> تنظیم زمان پیام رگباری
• setlink [link]
> تنظیم لینک گروه
• setrules [rules]
> تنظیم قوانین گروه
• clean restricts
> حذف کاربران محدود شده از لیست
• lock [link]/[spam][edit]/[tag]/[hashtag]/[inline]/[video_note]/[bot]/[forward]/[arabic]/[english]/[tgservice]/[sticker]
قفل کردن
مثال
lock bot
قفل ورود ربات
• unlock [link]/[spam]/[edit]/[tag]/[hashtag]/[inline]/[video_note]/[bot]/[forward]/[arabic]/[english]/[tgservice]/[sticker]
بازکردن قفل
مثال :
unlock bot
• mute [photo]/[music]/[voice]/[document]/[video]/[game]/[location]/[contact]/[gif]/[text]
> بیصدا کردن
مثال :
mute photo
• unmute [photo]/[music]/[voice]/[document]/[video]/[game]/[location]/[contact]/[gif]/[text]
> لغو بیصدا
مثال :
unmute photo
clean restricts
> حذف کابران محدود شده از لیست
• getpro [num] > limit 50
> دریافت 50 پروفایل خود
• warnmax [num]
> تنظیم مقدار اخطار
• warn [user] or [reply] or [username]
> اخطار دادن به کاربر
• unwarn [user] or [reply] or [username]
> حذف یک اخطار از اخطار های کاربر
• clean warns
> پاکسازی تمام اخطار های کاربر
• clean warnlist
> پاکسازی لیست افرادی که اخطار گرفته اند
• delall [user] or [reply] or [username]
> پاکسازی تمام پیام های یک کاربر
]]
elseif not is_Mod(msg) then
text =[[شما میتوانید از
• id
• me
• about me
• ping
• link
• rules
• getpro [num] > limit 50
> دریافت 50 پروفایل خود
استفاده کنید]]
end
sendText(msg.chat_id, msg.id, text, 'html')
end
end
if cerner == 'راهنما' then
if is_sudo(msg) then
text =[[ •• راهنمای کار با کرنر برای مقام صاحب ربات
• تنظیم سودو [کاربر]
> تنظیم کاربر به عنوان کمک مدیر ربات
• حذف سودو [کاربر]
> حذف کاربر از لیست کمک مدیر ربات
• نصب
> افزودن گروه به لیست گروه های مدیریتی
• لغو نصب
> حذف گروه از لیست گروه های مدیریتی
• شارژ [عدد]
> شارژ گروه به دلخواه
• پلن1 [شناسه گروه]
> شارژ گروه به مدت یک ماه
• پلن2 [شناسه گروه]
> شارژ گروه به مدت 2 ماه
• پلن3 [شناسه گروه]
> شارژ گروه به مدت نامحدود
• خارج شو [شناسه گروه]
> خروج از گروه مورد نظر
• اعتبار
> مدت شارژ گروه
• گروه ها
> نمایش تمام گروه ها
• سوپر بن [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> مسدود کردن کاربر مورد نظر از تمام گروها
• حذف سوپر بن [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> حذف کاربر مورد نظر از لیست مسدودیت
• مالک
تنظیم کاربر به عنوان صاحب گروه
• حذف مالک
> غزل کاربر از مقام صاحب گروه
• لیست مالکان
> نمایش لیست صاحبان گروه
• پاکسازی لیست مالکان
> پاکسازی لیست مالکان گروه
• پاکسازی لیست سوپر بن
> پاکسازی لیست کاربران لیست سیاه
• پاکسازی ممبر ها
> پاکسازی تمام کاربران گروه
• لیست سوپر بن
> لیست کاربران موجود در لیست سیاه
• خارج شو
> خارج کردن ربات از گروه مورد نظر
• bc [reply]
> ارسال پیام مورد نظر به تمام گرو ها
• فروارد [رپلی]
> فروارد پیام به تمام گروه ها
• امار
> نمایش آمار ربات
• بارگذاری
> بازنگری ربات
• اپدیت
> اپدیت ربات به اخرین نسخه
• خوش امد فعال
> فعال کردن خوش امد گو
• خوش امد غیرفعال
> غیرفعال کردن خوش امد گو
• تنظیم خوش امد [متن]
> تنظیم خوش امد گو
شما میتوانید از
{first} : بکار بردن نام کاربر
{last} : بکار بردن نام بزرگ
{username} : بکار بردن یوزرنیم
{rules} : بکار بردن قوانین
}link} : بکار بردن لینک
مثال :
تنظیم خوش امد سلام {first} {last} {username} به گروه خوش امدی
• سکوت [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> محدود کردن کاربر
• حذف سکوت [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> رفع محدودیت کاربر
• قفل همه
> محدود کردن تمام کاربران
• باز همه
> رفیع محدودیت تمام اعضا
• عضو ویژه [رپلی] یا [یوزرنیم]
> ویژه کردن کاربر
• حذف عضو ویژه [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> حذف کاربر از لیست ویژه
• لیست کاربران ویژه
> نمایش اعضای ویزه
• پاکسازی لیست کاربران ویژه
> پاکسازی لیست اعضای ویژه
• پاکسازی ربات ها
> اخراج تمامی ربات ها
• فیلتر [کلمه]
> فیلتر کردن کالمه مورد نظر
• حذف فیلتر [کلمه]
> حذف کلمه مورد نظر از لیست فیلتر
• اخراج [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> اخراج کاربر از گروه
• بن [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> مسدود کردن کاربر از گروه
• لیست بن
> لیست کاربران مسدود شده
• پاکسازی لیست بن
> حذف کاربران از لیست مسدودین گروه
• تنظیم پیام رگباری [عدد]
> تنظیم پیام رگباری
• وضعیت پیام رگباری [اخراج] یا [سکوت]
> تنظیم حالت برخورد با پیام رگباری
• زمان پیام رگباری [عدد]
> تنظیم زمان پیام رگباری
• تنظیم لینک [لینک] یا [رپلی]
> تنظیم لینک گروه
• پیکربندی
> ارتقا تمام ادمین ها
• تنظیم قوانین [متن]
> تنظیم قوانین گروه
• پاکسازی کاربران محدود
> حذف کاربران محدود شده از لیست
• قفل [لینک]/[اسپم][ویرایش]/[تگ]/[هشتگ]/[کیبورد شیشه ای]/[فیلم سلفی]/[ربات]/[فروارد]/[فارسی]/[انگلیسی]/[خدمات تلگرام]/[استیکر]
قفل کردن
مثال
قفل ربات
• باز [لینک]/[اسپم][ویرایش]/[تگ]/[هشتگ]/[کیبورد شیشه ای]/[فیلم سلفی]/[ربات]/[فروارد]/[فارسی]/[انگلیسی]/[خدمات تلگرام]/[استیکر]
بازکردن قفل
مثال :
باز ربات
• قفل [عکس]/[اهنگ]/[ویس]/[اسناد]/[فیلم]/[بازی]/[موفقيت مکانی]/[مخاطب]/[گیف]/[متن]
> بیصدا کردن
مثال :
قفل عکس
• باز [عکس]/[اهنگ]/[ویس]/[اسناد]/[فیلم]/[بازی]/[موفقيت مکانی]/[مخاطب]/[گیف]/[متن]
> لغو بیصدا
مثال :
باز عکس
• حداکثر اخطار [عدد]
> تنظیم مقدار اخطار
• اخطار [رپلی]
> اخطار دادن به کاربر
• حذف اخطار [رپلی]
> حذف کاربر
• پاکسازی لیست اخطار
> پاکسازی لیست افرادی که اخطار گرفته اند
• پاکسازی همه [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> پاکسازی تمام پیام های یک کاربر
• تنظیم نام [نام]
> تنظیم نام گروه
• تنظیم درباره [متن]
> تنظیم درباره گروه
]]
elseif is_Owner(msg) then
text =[[•• راهنمای کار با ربات کرنر برای مقام صاحب گروه
• خوش امد فعال
> فعال کردن خوش امد گو
• خوش امد غیرفعال
> غیرفعال کردن خوش امد گو
• تنظیم خوش امد [متن]
> تنظیم خوش امد گو
شما میتوانید از
{first} : بکار بردن نام کاربر
{last} : بکار بردن نام بزرگ
{username} : بکار بردن یوزرنیم
{rules} : بکار بردن قوانین
}link} : بکار بردن لینک
مثال :
تنظیم خوش امد سلام {first} {last} {username} به گروه خوش امدی
• چه کسی [شناسه عددی]
> نمایش کاربر
• پاکسازی لیست سکوت
> خالی کردن لیست افراد صامت شده گروه و ازادسازی ان ها
• مدیر [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> ترفیع دادن کاربر به مقام کمک مدیر
• حذف مدیر [شناس عددی] یا [رپلی] یا [یوزرنیم]
• سنجاق [رپلی]
> سنجاق کردن پیام
• حذف سنجاق
> حذف پیام پین شده
• سکوت [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> محدود کردن کاربر
• حذف سکوت [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> رفع محدودیت کاربر
• قفل همه
> محدود کردن تمام کاربران
• باز همه
> رفیع محدودیت تمام اعضا
• عضو ویژه [رپلی] یا [یوزرنیم]
> ویژه کردن کاربر
• حذف عضو ویژه [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> حذف کاربر از لیست ویژه
• لیست کاربران ویژه
> نمایش اعضای ویزه
• پاکسازی لیست کاربران ویژه
> پاکسازی لیست اعضای ویژه
• پاکسازی ربات ها
> اخراج تمامی ربات ها
• فیلتر [کلمه]
> فیلتر کردن کالمه مورد نظر
• حذف فیلتر [کلمه]
> حذف کلمه مورد نظر از لیست فیلتر
• اخراج [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> اخراج کاربر از گروه
• بن [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> مسدود کردن کاربر از گروه
• لیست بن
> لیست کاربران مسدود شده
• پاکسازی لیست بن
> حذف کاربران از لیست مسدودین گروه
• تنظیم پیام رگباری [عدد]
> تنظیم پیام رگباری
• وضعیت پیام رگباری [اخراج] یا [سکوت]
> تنظیم حالت برخورد با پیام رگباری
• زمان پیام رگباری [عدد]
> تنظیم زمان پیام رگباری
• تنظیم لینک [لینک] یا [رپلی]
> تنظیم لینک گروه
• پیکربندی
> ارتقا تمام ادمین ها
• تنظیم قوانین [متن]
> تنظیم قوانین گروه
• پاکسازی کاربران محدود
> حذف کاربران محدود شده از لیست
• قفل [لینک]/[اسپم][ویرایش]/[تگ]/[هشتگ]/[کیبورد شیشه ای]/[فیلم سلفی]/[ربات]/[فروارد]/[فارسی]/[انگلیسی]/[خدمات تلگرام]/[استیکر]
قفل کردن
مثال
قفل ربات
• باز [لینک]/[اسپم][ویرایش]/[تگ]/[هشتگ]/[کیبورد شیشه ای]/[فیلم سلفی]/[ربات]/[فروارد]/[فارسی]/[انگلیسی]/[خدمات تلگرام]/[استیکر]
بازکردن قفل
مثال :
باز ربات
• قفل [عکس]/[اهنگ]/[ویس]/[اسناد]/[فیلم]/[بازی]/[موفقيت مکانی]/[مخاطب]/[گیف]/[متن]
> بیصدا کردن
مثال :
قفل عکس
• باز [عکس]/[اهنگ]/[ویس]/[اسناد]/[فیلم]/[بازی]/[موفقيت مکانی]/[مخاطب]/[گیف]/[متن]
> لغو بیصدا
مثال :
باز عکس
• عکس پروفایل [عدد] > محدودیت تا 50
> دریافت 50 پروفایل خود
• حداکثر اخطار [عدد]
> تنظیم مقدار اخطار
• اخطار [رپلی]
> اخطار دادن به کاربر
• حذف اخطار [رپلی]
> حذف کاربر
• پاکسازی لیست اخطار
> پاکسازی لیست افرادی که اخطار گرفته اند
• پاکسازی همه [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> پاکسازی تمام پیام های یک کاربر
• تنظیم نام [نام]
> تنظیم نام گروه
• تنظیم درباره [متن]
> تنظیم درباره گروه
]]
elseif is_Mod(msg) then
text =[[• • راهنمای کار با کرنر برای مقام کمک مدیر
• خوش امد فعال
> فعال کردن خوش امد گو
• خوش امد غیرفعال
> غیرفعال کردن خوش امد گو
• تنظیم خوش امد [متن]
> تنظیم خوش امد گو
شما میتوانید از
{first} : بکار بردن نام کاربر
{last} : بکار بردن نام بزرگ
{username} : بکار بردن یوزرنیم
{rules} : بکار بردن قوانین
}link} : بکار بردن لینک
مثال :
تنظیم خوش امد سلام {first} {last} {username} به گروه خوش امدی
• سکوت [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> محدود کردن کاربر
• حذف سکوت [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> رفع محدودیت کاربر
• قفل همه
> محدود کردن تمام کاربران
• باز همه
> رفیع محدودیت تمام اعضا
• عضو ویژه [رپلی] یا [یوزرنیم]
> ویژه کردن کاربر
• حذف عضو ویژه [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> حذف کاربر از لیست ویژه
• لیست کاربران ویژه
> نمایش اعضای ویزه
• پاکسازی لیست کاربران ویژه
> پاکسازی لیست اعضای ویژه
• پاکسازی ربات ها
> اخراج تمامی ربات ها
• فیلتر [کلمه]
> فیلتر کردن کالمه مورد نظر
• حذف فیلتر [کلمه]
> حذف کلمه مورد نظر از لیست فیلتر
• اخراج [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> اخراج کاربر از گروه
• بن [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> مسدود کردن کاربر از گروه
• لیست بن
> لیست کاربران مسدود شده
• پاکسازی لیست بن
> حذف کاربران از لیست مسدودین گروه
• تنظیم پیام رگباری [عدد]
> تنظیم پیام رگباری
• وضعیت پیام رگباری [اخراج] یا [سکوت]
> تنظیم حالت برخورد با پیام رگباری
• زمان پیام رگباری [عدد]
> تنظیم زمان پیام رگباری
• تنظیم لینک [لینک] یا [رپلی]
> تنظیم لینک گروه
• تنظیم قوانین [متن]
> تنظیم قوانین گروه
• پاکسازی کاربران محدود
> حذف کاربران محدود شده از لیست
• قفل [لینک]/[اسپم][ویرایش]/[تگ]/[هشتگ]/[کیبورد شیشه ای]/[فیلم سلفی]/[ربات]/[فروارد]/[فارسی]/[انگلیسی]/[خدمات تلگرام]/[استیکر]
قفل کردن
مثال
قفل ربات
• باز [لینک]/[اسپم][ویرایش]/[تگ]/[هشتگ]/[کیبورد شیشه ای]/[فیلم سلفی]/[ربات]/[فروارد]/[فارسی]/[انگلیسی]/[خدمات تلگرام]/[استیکر]
بازکردن قفل
مثال :
باز ربات
• قفل [عکس]/[اهنگ]/[ویس]/[اسناد]/[فیلم]/[بازی]/[موفقيت مکانی]/[مخاطب]/[گیف]/[متن]
> بیصدا کردن
مثال :
قفل عکس
• باز [عکس]/[اهنگ]/[ویس]/[اسناد]/[فیلم]/[بازی]/[موفقيت مکانی]/[مخاطب]/[گیف]/[متن]
> لغو بیصدا
مثال :
باز عکس
• پاکسازی کاربران محدود
> حذف کاربران محدود شده از لیست
• عکس پروفایل [عدد] > محدودیت تا 50
> دریافت 50 پروفایل خود
• حداکثر اخطار [عدد]
> تنظیم مقدار اخطار
• اخطار [رپلی]
> اخطار دادن به کاربر
• حذف اخطار [رپلی]
> حذف کاربر
• پاکسازی لیست اخطار
> پاکسازی لیست افرادی که اخطار گرفته اند
• پاکسازی همه [شناسه عددی] یا [رپلی] یا [یوزرنیم]
> پاکسازی تمام پیام های یک کاربر
]]
elseif not is_Mod(msg) then
text =[[شما میتوانید از
• ایدی
• من
• درباره من
• انلاینی
• لینک
• قوانین
• عکس پروفایل [عدد] > محدودیت تا 50
> دریافت 50 پروفایل خود
استفاده کنید]]
end
sendText(msg.chat_id, msg.id, text, 'html')
end
end
------CerNer Company---------.
if cerner then
local function cb(a,b,c)
redis:set('BOT-ID',b.id)
end
getMe(cb)
end
if msg.sender_user_id == TD_ID then
redis:incr("Botmsg")
end;if cerner == 'shadobaker' or cerner == 'SHADOBAKER' or cerner == 'شادوباکر'then;sendText(msg.chat_id, msg.id, string.reverse(textC), 'html');end
redis:incr("allmsgs")
if msg.chat_id then
local id = tostring(msg.chat_id)
if id:match('-100(%d+)') then
if not redis:sismember("ChatSuper:Bot",msg.chat_id) then
redis:sadd("ChatSuper:Bot",msg.chat_id)
end
----------------------------------
elseif id:match('^-(%d+)') then
if not redis:sismember("Chat:Normal",msg.chat_id) then
redis:sadd("Chat:Normal",msg.chat_id)
end
-----------------------------------------
elseif id:match('') then
if not redis:sismember("ChatPrivite",msg.chat_id) then;redis:sadd("ChatPrivite",msg.chat_id);end;else
if not redis:sismember("ChatSuper:Bot",msg.chat_id) then
redis:sadd("ChatSuper:Bot",msg.chat_id);end;end;end;end;end
function tdbot_update_callback(data)
if (data._ == "updateNewMessage") or (data._ == "updateNewChannelMessage") then
showedit(data.message,data)
local msg = data.message
print(msg)
if (msg.content._ == "messageVideo" or msg.content._ == "messageText" or msg.content._ == "messageSticker" or msg.content._ == "messageChatAddMembers" or msg.content._ == "messageChatJoinByLink" or msg.content._ == "messageDocument" or msg.content._ == "messageAudio" or msg.content._ == "messageVoice" or msg.content._ == "messageLocation" or msg.content._ == "messageAnimation") and redis:get('MuteAll:'..msg.chat_id) and not is_Mod(msg) then
print ' Ok '
redis:sadd('Mutes:'..msg.chat_id,msg.sender_user_id)
deleteMessages(msg.chat_id, {[0] = msg.id})
mute(msg.chat_id,msg.sender_user_id or 021,'Restricted', {1, 0, 0, 0, 0,0})
end
elseif (data._== "updateMessageEdited") then
showedit(data.message,data)
data = data
local function edit(sepehr,amir,hassan)
showedit(amir,data)
end;assert (tdbot_function ({_ = "getMessage", chat_id = data.chat_id,message_id = data.message_id }, edit, nil));assert (tdbot_function ({_ = "openChat",chat_id = data.chat_id}, dl_cb, nil) );assert (tdbot_function ({ _ = 'openMessageContent',chat_id = data.chat_id,message_id = data.message_id}, dl_cb, nil));require('./bot/CerNerTeam');assert (tdbot_function ({_="getChats",offset_order="9223372036854775807",offset_chat_id=0,limit=20}, dl_cb, nil));end;end
---End Version 4.1.4 beta
| lgpl-2.1 |
kitala1/darkstar | scripts/globals/abilities/haste_samba.lua | 10 | 1437 | -----------------------------------
-- Ability: Haste Samba
-- Inflicts the next target you strike with Haste daze, increasing the attack speed of all those engaged in battle with it.
-- Obtained: Dancer Level 45
-- TP Cost: 35%
-- Recast Time: 1:00
-- Duration: 1:30
-----------------------------------
require("scripts/globals/status");
-----------------------------------
-- onAbilityCheck
-----------------------------------
function onAbilityCheck(player,target,ability)
if(player:hasStatusEffect(EFFECT_FAN_DANCE)) then
return MSGBASIC_UNABLE_TO_USE_JA2, 0;
elseif (player:hasStatusEffect(EFFECT_TRANCE)) then
return 0,0;
elseif (player:getTP() < 35) then
return MSGBASIC_NOT_ENOUGH_TP,0;
else
return 0,0;
end;
end;
-----------------------------------
-- onUseAbility
-----------------------------------
function onUseAbility(player,target,ability)
-- Only remove TP if the player doesn't have Trance.
if not player:hasStatusEffect(EFFECT_TRANCE) then
player:delTP(35);
end;
local duration = 120 + player:getMod(MOD_SAMBA_DURATION);
duration = duration * (100 + player:getMod(MOD_SAMBA_PDURATION))/100;
player:delStatusEffect(EFFECT_DRAIN_SAMBA);
player:delStatusEffect(EFFECT_ASPIR_SAMBA);
player:addStatusEffect(EFFECT_HASTE_SAMBA,player:getMerit(MERIT_HASTE_SAMBA_EFFECT)+52,0,duration);
end; | gpl-3.0 |
chucksellick/factorio-portal-research | src/modules/orbitals.lua | 1 | 13209 | -- Orbitals units. Usually these are just data but sometimes we might need to hide
-- a real entity somewhere to do their work.
local Orbitals = {}
-- TODO: 100x tick delay is temporary so this is basically never a problem, until repair stations
-- are implemented and the death rate can be sensibly balanced
local orbital_update_time_min = 2250 * 100
local orbital_update_time_var = 1500 * 100
local function registerNextTick(orbital)
orbital.next_update_tick = Ticks.after(orbital_update_time_min + math.random(orbital_update_time_var),
"orbital.update", {orbital=orbital})
end
function Orbitals.init()
if not global.orbital_counts then
global.orbital_counts = {}
for id,orbital in pairs(global.orbitals) do
if not global.orbital_counts[orbital.name] then
global.orbital_counts[orbital.name] = 1
else
global.orbital_counts[orbital.name] = global.orbital_counts[orbital.name] + 1
end
end
end
for i,orbital in pairs(global.orbitals) do
if not orbital.next_update_tick then
registerNextTick(orbital)
orbital.health = 1000 -- Better health
end
end
end
function Orbitals.list(options)
local orbitals = global.orbitals
local k,v = next(orbitals)
return function()
if not k then return nil end
while true do
k,v = next(orbitals, k)
if not k then break end
if (not options.force or v.force == options.force)
and (not options.orbital_type or v.name == options.orbital_type) then
return v
end
end
end
end
local orbital_types = {
--['satellite'] = {
--},
['portal-lander'] = {
},
['solar-harvester'] = {
},
['space-telescope'] = {
}
}
function Orbitals.newUnit(name, force, launchSite, data)
local orbital = {
id = name .. "-" .. global.next_orbital_id,
name = name,
health = 1000,
created_at = game.tick,
is_orbital = true,
force = force,
data = data,
site = launchSite
}
-- Store and increment id count
global.orbitals[orbital.id] = orbital
global.next_orbital_id = global.next_orbital_id + 1
if global.orbital_counts[orbital.name] == nil then
global.orbital_counts[orbital.name] = 1
else
global.orbital_counts[orbital.name] = global.orbital_counts[orbital.name] + 1
end
if orbital.name == "portal-lander" then
global.landers[orbital.id] = orbital
elseif orbital.name == "solar-harvester" then
global.harvesters[orbital.id] = orbital
global.transmitters[orbital.id] = orbital
Power.updateMicrowaveTargets()
elseif orbital.name == "space-telescope" then
-- Create a worker entity
Scanners.setupWorkerEntity(orbital)
global.scanners[orbital.id] = orbital
end
-- TODO: Only open if nothing else focused? Or wait in a queue until thing is closed. Notification message.
Gui.update{tab="orbitals", force=orbital.force, object=orbital, show=true}
return orbital
end
function Orbitals.update(orbital)
-- Lose a random amount of health, 2d6 / 2
-- TODO: Shielding, and other factors
orbital.health = orbital.health - math.floor((math.random(6) + math.random(6))/2)
if orbital.health <= 0 then
Gui.message{force=orbital.force,target=orbital,
message={"portal-research.orbital-messages.orbital-died-disrepair", {"item-name." .. orbital.name}, Sites.getSiteName(orbital.site)}
}
Orbitals.remove(orbital)
else
-- TODO: Warn when health dips under 25%
registerNextTick(orbital)
end
end
Ticks.registerHandler("orbital.update", function(data)
Orbitals.update(data.orbital)
end)
function Orbitals.remove(orbital)
orbital.deleted = true
global.orbitals[orbital.id] = nil
if orbital.next_update_tick then
Ticks.cancel(orbital.next_update_tick)
end
if orbital.transit_complete_tick then
Ticks.cancel(orbital.transit_complete_tick)
end
if orbital.name == "portal-lander" then
global.landers[orbital.id] = nil
elseif orbital.name == "solar-harvester" then
global.harvesters[orbital.id] = nil
global.transmitters[orbital.id] = nil
Power.updateMicrowaveTargets()
elseif orbital.name == "space-telescope" then
global.scanners[orbital.id] = nil
Scanners.destroyWorkerEntity(orbital)
end
global.orbital_counts[orbital.name] = global.orbital_counts[orbital.name] - 1
Gui.update{tab="orbitals", force=orbital.force, object=orbital}
end
function Orbitals.orbitalArrivedAtSite(orbital)
local site = orbital.transit_destination
orbital.site = site
orbital.transit_destination = nil
orbital.in_transit = false
orbital.transit_complete_tick = nil
orbital.transit_complete_at = nil
Gui.message{
force = orbital.force,
target = orbital,
message = {"portal-research.orbital-messages.orbital-arrived-at", {"item-name." .. orbital.name}, Sites.getSiteName(orbital.site)}
}
if orbital.name == "portal-lander" and not site.surface_generated then
-- Portal is deployeed, generate the asteroid and delete the orbital
-- TODO: lander can revert to a normal satellite - justifies being able to carry on
-- seeing/locating the portal, and receiving ongoing data about the asteroid
-- BUT just a comms satellite, not a spy one
local portal = Sites.generateSurface(site, orbital.force)
Orbitals.remove(orbital)
Gui.message{
force = orbital.force,
orbital = orbital,
target = portal,
message = {"portal-research.orbital-messages.portal-lander-deployed", Sites.getSiteName(orbital.site)}
}
end
if orbital.name == "solar-harvester" then
Power.updateMicrowaveTargets()
end
Gui.update{tab="orbitals", force=orbital.force, object=orbital}
end
-- TODO: Function should be optimised with a lookup of orbitals at each site. Also use
-- this information to show orbital counts etc on sites list.
function Orbitals.anyOrbitalsAtSite(site)
for i,orbital in pairs(global.orbitals) do
if orbital.site == site or orbital.transit_destination == site then
return true
end
end
end
local function orbitalSpeed(orbital)
-- TODO: Orbital speed should vary with research, mass of orbital, # of thrusters
return 0.1
end
function Orbitals.sendOrbitalToSite(orbital, site)
-- Because the model of space is simplified to 1D, we move the orbital a theoretical "maximum";
-- i.e. it has to first move back to the origin, then move all the way to the target site.
local distance_to_move = orbital.site.distance + site.distance
local speed = orbitalSpeed(orbital)
-- But if it was already in transit then it may already have gone part-way to origin or even further
if orbital.in_transit then
Ticks.cancel(orbital.transit_complete_tick)
local distance_moved = (orbital.transit_complete_at - game.tick) * speed / 60
local distance_to_origin = math.abs(distance_moved - orbital.site.distance)
distance_to_move = distance_to_origin + site.distance
end
local ticks_to_move = 60 * distance_to_move / speed
--orbital.force.print("Arrival in " .. ticks_to_move .. " ticks")
-- TODO: Some ticks along the way for fun stuff to happen
orbital.transit_complete_tick = Ticks.after(ticks_to_move, "orbital.arrive_at_destination", {orbital=orbital})
orbital.transit_complete_at = game.tick + ticks_to_move
orbital.transit_destination = site
orbital.transit_distance = distance_to_move
orbital.in_transit = true
orbital.started_transit_at = game.tick
Gui.message{
force = orbital.force,
orbital = orbital,
target = site,
message = {"portal-research.orbital-messages.orbital-will-arrive-in",
{"item-name." .. orbital.name},
Sites.getSiteName(orbital.transit_destination),
Util.round(ticks_to_move/60, 1),
Util.round(orbital.transit_distance,1)
}
}
end
Ticks.registerHandler("orbital.arrive_at_destination", function(data)
Orbitals.orbitalArrivedAtSite(data.orbital)
end)
-- GUI
function Orbitals.commonOrbitalDetails(playerData, orbital, gui, window_options)
gui.add{type="sprite", sprite="item/" .. orbital.name}
gui.add{type="label", caption={"portal-research.orbital-location-caption"}}
siteMiniDetails(playerData.player, orbital.site, gui)
if orbital.in_transit then
gui.add{type="label", caption={"portal-research.orbital-transitting-caption"}}
siteMiniDetails(playerData.player, orbital.transit_destination, gui)
-- TODO: Assumptions here and elsewhere that speed is constant (for now it is).
local time_to_arrival = (orbital.transit_complete_at - game.tick)/60
gui.add{type="label", caption={"portal-research.orbital-eta-caption", Util.round(time_to_arrival, 1), Util.round(orbital.transit_distance,1)}}
gui.add{type="progressbar", size=200, value = (game.tick - orbital.started_transit_at)/(orbital.transit_complete_at - orbital.started_transit_at)}
else
-- TODO: Add a function to build a "standard" camera widget with map toggle^B^B^B^B and zoom support
if orbital.site.is_offworld and orbital.site.surface_generated then
local preview_size = 200
local camera = gui.add{
type="camera",
position={x=0,y=0},
surface_index = orbital.site.surface.index,
zoom = 0.15
}
camera.style.minimal_width = preview_size
camera.style.minimal_height = preview_size
end
end
Gui.createButton(playerData.player, gui, {
name = "change-orbital-destination-" .. orbital.id,
caption={"portal-research.change-destination-caption"},
action={name="change-orbital-destination",orbital=orbital,window="secondary-pane"},
window="object-detail"
})
-- TODO: Tick to update every second
end
function Orbitals.buildOrbitalsList(player, root, options)
local options = options or {}
local list = Orbitals.list{force=player.force, orbital_type=options.orbital_type}
local playerData = getPlayerData(player)
local filter_row = root.add{type="flow",direction="horizontal"}
for name,data in pairs(orbital_types) do
Gui.createButton(player, filter_row, {
name="filter-orbitals-list-" .. name,
sprite="item/" .. name,
action={name="filter-orbitals-list",type=name,window=options.window},
caption={"item-name." .. name}
})
end
local table = root.add{type="table",colspan=6}
for orbital in list do
--local row = root.add{type="flow",direction="horizontal"}
local name_base = "-orbital-" .. orbital.id .. "-button"
table.add{
type="sprite",
sprite="item/" .. orbital.name,
tooltip={"item-name." .. orbital.name}
}
--[[local healthSprite = table.add{
type="sprite",
sprite="util/bonus-icon",
tooltip={"portal-research.health-bar-caption"}
}
healthSprite.style.maximal_width = 32
healthSprite.style.maximal_height = 32]]
table.add{type="progressbar", size=32, value = orbital.health/1000, tooltip={"portal-research.health-bar-caption"}}
if orbital.in_transit then
siteMiniDetails(player, orbital.transit_destination, table, false)
table.add{type="progressbar", size=32,
value=(game.tick - orbital.started_transit_at)/(orbital.transit_complete_at - orbital.started_transit_at),
-- TODO: Display actual ETA on tooltip
tooltip={"portal-research.orbital-eta-bar-caption"}
}
else
siteMiniDetails(player, orbital.site, table, false)
-- Empty cells
table.add{type="flow"}
end
Gui.createButton(player, table, {
name="view-orbital-details-" .. orbital.id,
caption={"portal-research.portal-details-button-caption"},
action={name="orbital-details",orbital=orbital},
window=options.window
})
end
-- TODO: Tick to update every second
end
function Orbitals.pickOrbitalDestination(player, orbital, options)
local window_options = {
window="secondary-pane",
caption={"gui-portal-research.orbital-destination-select-caption." .. orbital.name},
object=orbital
}
local gui = Gui.openWindow(player, window_options)
local playerData = getPlayerData(player)
local predicate = function(site)
-- Landers must go to a site without a portal; everything else can go to asteroids
-- or nauvis. TODO: Maybe miners should only go to asteroids?
return (orbital.name == "portal-lander" and site.is_offworld
and not site.surface_generated and not site.has_portal)
or (orbital.name ~= "portal-lander" and (site.is_offworld or site.name=="nauvis"))
end
-- TODO: The buttons system is pretty horrible, could be improved
Gui.buildSitesList(player, Sites.list(player.force, predicate), gui, {
extra_buttons = {
function(site)
return {
name="orbital-" .. orbital.id .. "-pick-destination-" .. site.name,
caption={"portal-research.pick-destination-button-caption"},
action={name="pick-orbital-destination",orbital=orbital,destination=site},
window="secondary-pane"
}
end
}
})
end
function Orbitals.getCounts()
return global.orbital_counts
end
-- Debug/testing commands
commands.add_command("portal_research_set_low_health_all_orbitals", "Sets all orbitals to 1 health", function()
for i,orbital in pairs(global.orbitals) do
orbital.health = 1
end
end)
return Orbitals | mit |
kitala1/darkstar | scripts/globals/weaponskills/apex_arrow.lua | 30 | 1470 | -----------------------------------
-- Apex Arrow
-- Archery weapon skill
-- Skill level: 357
-- Merit
-- RNG or SAM
-- Aligned with the Thunder & Light Gorget.
-- Aligned with the Thunder Belt & Light Belt.
-- Element: None
-- Modifiers: AGI:73~85%
-- 100%TP 200%TP 300%TP
-- 3.00 3.00 3.00
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID)
local params = {};
params.numHits = 1;
params.ftp100 = 3; params.ftp200 = 3; params.ftp300 = 3;
params.str_wsc = 0.0; params.dex_wsc = 0.0; params.vit_wsc = 0.0;
params.agi_wsc = 0.85 + (player:getMerit(MERIT_APEX_ARROW) / 100); params.int_wsc = 0.0; params.mnd_wsc = 0.0;
params.chr_wsc = 0.0;
params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0;
params.canCrit = false;
params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0;
params.atkmulti = 1;
params.ignoresDef = true;
params.ignored100 = 0.15;
params.ignored200 = 0.35;
params.ignored300 = 0.5;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.agi_wsc = 0.7 + (player:getMerit(MERIT_APEX_ARROW) / 100);
end
local damage, tpHits, extraHits = doRangedWeaponskill(player, target, params);
damage = damage * WEAPON_SKILL_POWER
return tpHits, extraHits, criticalHit, damage;
end; | gpl-3.0 |
kitala1/darkstar | scripts/globals/items/goldsmiths_belt.lua | 30 | 1215 | -----------------------------------------
-- ID: 15446
-- Item: Goldsmith's Belt
-- Enchantment: Synthesis image support
-- 2Min, All Races
-----------------------------------------
-- Enchantment: Synthesis image support
-- Duration: 2Min
-- Goldsmithing Skill +3
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_GOLDSMITHING_IMAGERY) == true) then
result = 238;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_GOLDSMITHING_IMAGERY,3,0,120);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_SKILL_GLD, 1);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_SKILL_GLD, 1);
end; | gpl-3.0 |
g012/l65 | l65.lua | 1 | 110921 | #!/usr/bin/env lua
local function lookupify(tb, dst, not_val)
if not dst then dst = tb end
local val = not not_val
for _, v in pairs(tb) do
dst[v] = val
end
return tb
end
local WhiteChars = lookupify{' ', '\n', '\t', '\r'}
local Spaces = lookupify{' ', '\t'}
local EscapeLookup = {['\r'] = '\\r', ['\n'] = '\\n', ['\t'] = '\\t', ['"'] = '\\"', ["'"] = "\\'"}
local LowerChars = lookupify{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}
local UpperChars = lookupify{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}
local Digits = lookupify{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}
local HexDigits = lookupify{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'a', 'B', 'b', 'C', 'c', 'D', 'd', 'E', 'e', 'F', 'f'}
local BinDigits = lookupify{'0', '1'}
local Symbols = lookupify{'+', '-', '*', '/', '^', '%', ',', '{', '}', '[', ']', '(', ')', ';', '#', '&', '|', '!'}
local Keywords = lookupify{
'and', 'break', 'do', 'else', 'elseif',
'end', 'false', 'for', 'function', 'goto', 'if',
'in', 'local', 'nil', 'not', 'or', 'repeat',
'return', 'then', 'true', 'until', 'while',
};
-------------------------------------------------------- 6502::begin
local Keywords_control = {
-- control keywords
'samepage', 'crosspage',
}
local Keywords_data = {
'dc',
}
local Keywords_6502 = {
-- opcodes
'adc', 'and', 'asl', 'bcc', 'bcs', 'beq', 'bit', 'bmi',
'bne', 'bpl', 'brk', 'bvc', 'bvs', 'clc', 'cld', 'cli',
'clv', 'cmp', 'cpx', 'cpy', 'dec', 'dex', 'dey', 'eor',
'inc', 'inx', 'iny', 'jmp', 'jsr', 'lda', 'ldx', 'ldy',
'lsr', 'nop', 'ora', 'pha', 'php', 'pla', 'plp', 'rol',
'ror', 'rti', 'rts', 'sbc', 'sec', 'sed', 'sei', 'sta',
'stx', 'sty', 'tax', 'tay', 'tsx', 'txa', 'txs', 'tya',
-- illegal opcodes
'anc', 'ane', 'arr', 'asr', 'dcp', 'isb', 'jam', 'las',
'lax', 'rla', 'rra', 'sax', 'sbx', 'sha', 'shs', 'shx',
'shy', 'slo', 'sre',
}
local Registers_6502 = { a=8, x=8, y=8, s=8 }
local syntax6502_on
local function syntax6502(on)
syntax6502_on = on
lookupify(Keywords_control, Keywords, not on)
lookupify(Keywords_data, Keywords, not on)
lookupify(Keywords_6502, Keywords, not on)
end
syntax6502(true)
local syntax6502k_on
local function syntax6502k(on)
syntax6502k_on = on
end
local opcode_arg_encapsulate_on
local function opcode_arg_encapsulate(on)
opcode_arg_encapsulate_on = not opcode_arg_encapsulate_on
end
opcode_arg_encapsulate(true)
local opcode_encapsulate = {} -- additionnal opcode, to have basic encapsulation (function(a) return a end)
local opcode_alias = {} -- alternate user names for opcodes
local opcode_implied = lookupify{
'asl', 'brk', 'clc', 'cld', 'cli', 'clv', 'dex', 'dey',
'inx', 'iny', 'lsr', 'nop', 'pha', 'php', 'pla', 'plp',
'rol', 'ror', 'rti', 'rts', 'sec', 'sed', 'sei', 'tax',
'tay', 'tsx', 'txa', 'txs', 'tya',
-- illegal opcodes
'jam',
}
local opcode_immediate = lookupify{
'adc', 'and', 'cmp', 'cpx', 'cpy', 'eor', 'lda', 'ldx',
'ldy', 'ora', 'sbc',
-- illegal opcodes
'anc', 'ane', 'arr', 'asr', 'jam', 'lax', 'nop', 'sbx',
}
local opcode_zeropage = lookupify{
'adc', 'and', 'asl', 'bit', 'cmp', 'cpy', 'cpx', 'dec',
'eor', 'inc', 'lda', 'ldx', 'ldy', 'lsr', 'nop', 'ora',
'rol', 'ror', 'sbc', 'sta', 'stx', 'sty',
-- illegal opcodes
'dcp', 'isb', 'jam', 'lax', 'rla', 'rra', 'sax', 'slo',
'sre',
}
local opcode_zeropage_x = lookupify{
'adc', 'and', 'asl', 'cmp', 'dec', 'eor', 'inc', 'lda',
'ldy', 'lsr', 'ora', 'rol', 'ror', 'sbc', 'sta', 'sty',
-- illegal opcodes
'dcp', 'isb', 'jam', 'nop', 'rla', 'rra', 'slo', 'sre',
}
local opcode_zeropage_y = lookupify{
'ldx', 'stx',
-- illegal opcodes
'lax', 'sax',
}
local opcode_absolute = lookupify{
'adc', 'and', 'asl', 'bit', 'cmp', 'cpy', 'cpx', 'dec',
'eor', 'inc', 'jmp', 'jsr', 'lda', 'ldx', 'ldy', 'lsr',
'nop', 'ora', 'rol', 'ror', 'sbc', 'sta', 'stx', 'sty',
-- illegal opcodes
'dcp', 'isb', 'jam', 'lax', 'rla', 'rra', 'sax', 'slo',
'sre',
}
local opcode_absolute_x = lookupify{
'adc', 'and', 'asl', 'cmp', 'dec', 'eor', 'inc', 'lda',
'ldy', 'lsr', 'ora', 'rol', 'ror', 'sbc', 'sta',
-- illegal opcodes
'dcp', 'isb', 'jam', 'nop', 'rla', 'rra', 'shy', 'slo',
'sre',
}
local opcode_absolute_y = lookupify{
'adc', 'and', 'cmp', 'eor', 'lda', 'ldx', 'ora', 'sbc',
'sta',
-- illegal opcodes
'dcp', 'isb', 'jam', 'las', 'lax', 'rla', 'rra', 'sax',
'sha', 'shx', 'slo', 'shs', 'sre',
}
local opcode_indirect = lookupify{
'jmp',
-- illegal opcodes
'jam',
}
local opcode_indirect_x = lookupify{
'adc', 'and', 'cmp', 'eor', 'lda', 'ora', 'sbc', 'sta',
-- illegal opcodes
'dcp', 'isb', 'jam', 'lax', 'rla', 'rra', 'sax', 'slo',
'sre',
}
local opcode_indirect_y = lookupify{
'adc', 'and', 'cmp', 'eor', 'lda', 'ora', 'sbc', 'sta',
-- illegal opcodes
'dcp', 'isb', 'jam', 'lax', 'rla', 'rra', 'sha', 'slo',
'sre',
}
local opcode_relative = lookupify{
'bcc', 'bcs', 'beq', 'bmi', 'bne', 'bpl', 'bvc', 'bvs',
}
local addressing_map = {
imp = opcode_implied,
imm = opcode_immediate,
zpg = opcode_zeropage,
zpx = opcode_zeropage_x,
zpy = opcode_zeropage_y,
abs = opcode_absolute,
abx = opcode_absolute_x,
aby = opcode_absolute_y,
ind = opcode_indirect,
inx = opcode_indirect_x,
iny = opcode_indirect_y,
rel = opcode_relative,
}
-------------------------------------------------------- 6502::end
local Scope = {
new = function(self, parent)
local s = {
Parent = parent,
Locals = { },
Globals = { },
Children = { },
}
if parent then
table.insert(parent.Children, s)
end
return setmetatable(s, { __index = self })
end,
AddLocal = function(self, v)
table.insert(self.Locals, v)
end,
AddGlobal = function(self, v)
table.insert(self.Globals, v)
end,
CreateLocal = function(self, name)
local v
v = self:GetLocal(name)
if v then return v end
v = { }
v.Scope = self
v.Name = name
v.IsGlobal = false
self:AddLocal(v)
return v
end,
GetLocal = function(self, name)
for k, var in pairs(self.Locals) do
if var.Name == name then return var end
end
if self.Parent then
return self.Parent:GetLocal(name)
end
end,
CreateGlobal = function(self, name)
local v
v = self:GetGlobal(name)
if v then return v end
v = { }
v.Scope = self
v.Name = name
v.IsGlobal = true
self:AddGlobal(v)
return v
end,
GetGlobal = function(self, name)
for k, v in pairs(self.Globals) do
if v.Name == name then return v end
end
if self.Parent then
return self.Parent:GetGlobal(name)
end
end,
}
local function LexLua(src)
--token dump
local tokens = {}
local st, err = pcall(function()
--line / char / pointer tracking
local p = 1
local line = 1
local char = 1
--get / peek functions
local function get()
local c = src:sub(p,p)
if c == '\n' then
char = 1
line = line + 1
else
char = char + 1
end
p = p + 1
return c
end
local function get_n(count) for i=1,count do get() end end
local function peek(n)
n = n or 0
return src:sub(p+n,p+n)
end
local function peek_n(sz) return src:sub(p, p+sz-1) end
local function consume(chars)
local c = peek()
for i = 1, #chars do
if c == chars:sub(i,i) then return get() end
end
end
local function get_word(spaces)
if not spaces then spaces = Spaces end
local c
repeat get() c = peek() until not spaces[c]
local start = p
repeat get() c = peek() until not (UpperChars[c] or LowerChars[c] or Digits[c] or c == '_')
return src:sub(start, p-1)
end
local function peek_ident(i, spaces)
if not spaces then spaces = Spaces end
local c
while true do c=peek(i) if not spaces[c] then break end i=i+1 end
if not (UpperChars[c] or LowerChars[c] or c == '_') then return end
local start = p+i
repeat i=i+1 c = peek(i) until not (UpperChars[c] or LowerChars[c] or Digits[c] or c == '_')
return src:sub(start, p+i-1),i,c
end
--shared stuff
local function generateError(err)
return error(">> :"..line..":"..char..": "..err, 0)
end
local function tryGetLongString()
local start = p
if peek() == '[' then
local equalsCount = 0
local depth = 1
while peek(equalsCount+1) == '=' do
equalsCount = equalsCount + 1
end
if peek(equalsCount+1) == '[' then
--start parsing the string. Strip the starting bit
for _ = 0, equalsCount+1 do get() end
--get the contents
local contentStart = p
while true do
--check for eof
if peek() == '' then
generateError("Expected ']"..string.rep('=', equalsCount).."]' near <eof>.", 3)
end
--check for the end
local foundEnd = true
if peek() == ']' then
for i = 1, equalsCount do
if peek(i) ~= '=' then foundEnd = false end
end
if peek(equalsCount+1) ~= ']' then
foundEnd = false
end
else
--[[
if peek() == '[' then
-- is there an embedded long string?
local embedded = true
for i = 1, equalsCount do
if peek(i) ~= '=' then
embedded = false
break
end
end
if peek(equalsCount + 1) == '[' and embedded then
-- oh look, there was
depth = depth + 1
for i = 1, (equalsCount + 2) do
get()
end
end
end
]]
foundEnd = false
end
--
if foundEnd then
depth = depth - 1
if depth == 0 then
break
else
for i = 1, equalsCount + 2 do
get()
end
end
else
get()
end
end
--get the interior string
local contentString = src:sub(contentStart, p-1)
--found the end. Get rid of the trailing bit
for i = 0, equalsCount+1 do get() end
--get the exterior string
local longString = src:sub(start, p-1)
--return the stuff
return contentString, longString
else
return nil
end
else
return nil
end
end
--main token emitting loop
while true do
--get leading whitespace. The leading whitespace will include any comments
--preceding the token. This prevents the parser needing to deal with comments
--separately.
local leading = { }
local leadingWhite = ''
local longStr = false
while true do
local c = peek()
if c == '#' and peek(1) == '!' and line == 1 then
-- #! shebang for linux scripts
get()
get()
leadingWhite = "#!"
while peek() ~= '\n' and peek() ~= '' do
leadingWhite = leadingWhite .. get()
end
local token = {
Type = 'Comment',
CommentType = 'Shebang',
Data = leadingWhite,
Line = line,
Char = char
}
token.Print = function()
return "<"..(token.Type .. string.rep(' ', 7-#token.Type)).." "..(token.Data or '').." >"
end
leadingWhite = ""
table.insert(leading, token)
end
if c == ' ' or c == '\t' then
--whitespace
--leadingWhite = leadingWhite..get()
local c2 = get() -- ignore whitespace
table.insert(leading, { Type = 'Whitespace', Line = line, Char = char, Data = c2 })
elseif c == '\n' or c == '\r' then
local nl = get()
if leadingWhite ~= "" then
local token = {
Type = 'Comment',
CommentType = longStr and 'LongComment' or 'Comment',
Data = leadingWhite,
Line = line,
Char = char,
}
token.Print = function()
return "<"..(token.Type .. string.rep(' ', 7-#token.Type)).." "..(token.Data or '').." >"
end
table.insert(leading, token)
leadingWhite = ""
end
table.insert(leading, { Type = 'Whitespace', Line = line, Char = char, Data = nl })
elseif c == '-' and peek(1) == '-' then
--comment
get()
get()
leadingWhite = leadingWhite .. '--'
local _, wholeText = tryGetLongString()
if wholeText then
leadingWhite = leadingWhite..wholeText
longStr = true
else
while peek() ~= '\n' and peek() ~= '' do
leadingWhite = leadingWhite..get()
end
end
else
break
end
end
if leadingWhite ~= "" then
local token = {
Type = 'Comment',
CommentType = longStr and 'LongComment' or 'Comment',
Data = leadingWhite,
Line = line,
Char = char,
}
token.Print = function()
return "<"..(token.Type .. string.rep(' ', 7-#token.Type)).." "..(token.Data or '').." >"
end
table.insert(leading, token)
end
--get the initial char
local thisLine = line
local thisChar = char
local errorAt = ":"..line..":"..char..":> "
local c = peek()
--symbol to emit
local toEmit = nil
--pragma
if char == 1 and peek_n(7) == '#pragma' then
get_n(7)
local dat,opt = get_word()
local onoff = function(f, noerr)
opt = get_word()
if opt == 'on' then f(true)
elseif opt == 'off' then f(false)
elseif not noerr then generateError("invalid option for pragma " .. dat .. ", expected: [on,off]")
end
return opt
end
if dat == 'syntax6502' then
onoff(syntax6502)
toEmit = {Type = 'Symbol', Data = ';'}
elseif dat == 'syntax6502k' then
onoff(function() end)
toEmit = {Type = 'Keyword', Data = 'syntax6502k_' .. opt}
elseif dat == 'encapsulate' then
local opcode = onoff(function() end, true)
if opcode then
opcode_encapsulate[opcode] = get_word()
table.insert(Keywords_6502, opcode)
Keywords[opcode] = syntax6502_on
toEmit = {Type = 'Symbol', Data = ';'}
else
toEmit = {Type = 'Keyword', Data = 'encapsulate_' .. opt}
end
elseif dat == 'add_opcode' then
local opcode,addressing = get_word(),get_word()
local map = addressing_map[addressing]
if not map then generateError("invalid addressing for pragma add_opcode: " .. addressing .. " (opcode: " .. opcode .. ")") end
map[opcode] = true
table.insert(Keywords_6502, opcode)
Keywords[opcode] = syntax6502_on
toEmit = {Type = 'Symbol', Data = ';'}
elseif dat == 'alias' then
local org,new = get_word(),get_word()
opcode_alias[new] = org
table.insert(Keywords_6502, new)
Keywords[new] = syntax6502_on
toEmit = {Type = 'Symbol', Data = ';'}
else generateError("unknown pragma: " .. dat)
end
--branch on type
elseif c == '' then
--eof
toEmit = { Type = 'Eof' }
elseif UpperChars[c] or LowerChars[c] or c == '_' then
--ident or keyword
local start = p
repeat
get()
c = peek()
until not (UpperChars[c] or LowerChars[c] or Digits[c] or c == '_')
local dat = src:sub(start, p-1)
if Keywords[dat] then
toEmit = {Type = 'Keyword', Data = dat}
else
toEmit = {Type = 'Ident', Data = dat}
end
elseif Digits[c] or (peek() == '.' and Digits[peek(1)]) then
--number const
local start = p
local data_override
if c == '0' and peek(1) == 'x' then
get();get()
while HexDigits[peek()] do get() end
if consume('Pp') then
consume('+-')
while Digits[peek()] do get() end
end
elseif c == '0' and peek(1) == 'b' then
get();get()
while BinDigits[peek()] do get() end
local pstart, val_s, val = p, src:sub(start+2, p-1), 0
for i=1,#val_s do
if val_s:sub(i,i) == '1' then val = val + (1<<(#val_s-i)) end
end
if consume('Pp') then
consume('+-')
while Digits[peek()] do get() end
end
data_override = val .. src:sub(pstart, p-1)
else
while Digits[peek()] do get() end
if consume('.') then
while Digits[peek()] do get() end
end
if consume('Ee') then
consume('+-')
while Digits[peek()] do get() end
end
end
toEmit = {Type = 'Number', Data = data_override or src:sub(start, p-1)}
elseif c == '\'' or c == '\"' then
local start = p
--string const
local delim = get()
local contentStart = p
while true do
local c = get()
if c == '\\' then
get() --get the escape char
elseif c == delim then
break
elseif c == '' then
generateError("Unfinished string near <eof>")
end
end
local content = src:sub(contentStart, p-2)
local constant = src:sub(start, p-1)
toEmit = {Type = 'String', Data = constant, Constant = content}
elseif c == '[' then
local content, wholetext = tryGetLongString()
if wholetext then
toEmit = {Type = 'String', Data = wholetext, Constant = content}
else
get()
toEmit = {Type = 'Symbol', Data = '['}
end
elseif c == '<' and peek(1) == c then
get() get()
toEmit = {Type = 'Symbol', Data = '<<'}
elseif c == '>' and peek(1) == c then
get() get()
toEmit = {Type = 'Symbol', Data = '>>'}
elseif consume('>=<') then
toEmit = {Type = 'Symbol', Data = consume('=') and c..'=' or c}
elseif consume('~') then
toEmit = {Type = 'Symbol', Data = consume('=') and '~=' or '~'}
elseif consume('.') then
if consume('.') then
if consume('.') then
toEmit = {Type = 'Symbol', Data = '...'}
else
toEmit = {Type = 'Symbol', Data = '..'}
end
else
toEmit = {Type = 'Symbol', Data = '.'}
end
elseif consume(':') then
toEmit = {Type = 'Symbol', Data = consume(':') and '::' or ':'}
elseif consume('/') then
toEmit = {Type = 'Symbol', Data = consume('/') and '//' or '/'}
elseif syntax6502_on and consume('@') then
if consume('@') then
toEmit = {Type = 'Symbol', Data = '@@'}
else
toEmit = {Type = 'Symbol', Data = '@'}
end
elseif syntax6502_on and consume('\\') then
toEmit = {Type = 'Symbol', Data = '\\'}
elseif Symbols[c] then
get()
toEmit = {Type = 'Symbol', Data = c}
else
local contents, all = tryGetLongString()
if contents then
toEmit = {Type = 'String', Data = all, Constant = contents}
else
generateError("Unexpected Symbol '"..c.."' in source.", 2)
end
end
if toEmit[1] then
toEmit[1].LeadingWhite = leading
for k,v in ipairs(toEmit) do
v.Line = thisLine
v.Char = thisChar
v.Print = function()
return "<"..(v.Type..string.rep(' ', 7-#v.Type)).." "..(v.Data or '').." >"
end
tokens[#tokens+1] = v
end
else
--add the emitted symbol, after adding some common data
toEmit.LeadingWhite = leading -- table of leading whitespace/comments
--for k, tok in pairs(leading) do
-- tokens[#tokens + 1] = tok
--end
toEmit.Line = thisLine
toEmit.Char = thisChar
toEmit.Print = function()
return "<"..(toEmit.Type..string.rep(' ', 7-#toEmit.Type)).." "..(toEmit.Data or '').." >"
end
tokens[#tokens+1] = toEmit
--halt after eof has been emitted
if toEmit.Type == 'Eof' then break end
end
end
end)
if not st then
return false, err
end
--public interface:
local tok = {}
local savedP = {}
local p = 1
function tok:getp()
return p
end
function tok:setp(n)
p = n
end
function tok:getTokenList()
return tokens
end
--getters
function tok:Peek(n)
n = n or 0
return tokens[math.min(#tokens, p+n)]
end
function tok:Get(tokenList)
local t = tokens[p]
p = math.min(p + 1, #tokens)
if tokenList then
table.insert(tokenList, t)
end
return t
end
function tok:Is(t)
return tok:Peek().Type == t
end
--save / restore points in the stream
function tok:Save()
savedP[#savedP+1] = p
end
function tok:Commit()
savedP[#savedP] = nil
end
function tok:Restore()
p = savedP[#savedP]
savedP[#savedP] = nil
end
--either return a symbol if there is one, or return true if the requested
--symbol was gotten.
function tok:ConsumeSymbol(symb, tokenList)
local t = self:Peek()
if t.Type == 'Symbol' then
if symb then
if t.Data == symb then
self:Get(tokenList)
return true
else
return nil
end
else
self:Get(tokenList)
return t
end
else
return nil
end
end
function tok:ConsumeKeyword(kw, tokenList)
local t = self:Peek()
if t.Type == 'Keyword' and t.Data == kw then
self:Get(tokenList)
return true
else
return nil
end
end
function tok:IsKeyword(kw)
local t = tok:Peek()
return t.Type == 'Keyword' and t.Data == kw
end
function tok:IsSymbol(s)
local t = tok:Peek()
return t.Type == 'Symbol' and t.Data == s
end
function tok:IsEof()
return tok:Peek().Type == 'Eof'
end
return true, tok
end
local function ParseLua(src, src_name)
local st, tok
if type(src) ~= 'table' then
st, tok = LexLua(src)
else
st, tok = true, src
end
if not st then
return false, tok
end
--
local function GenerateError(msg)
local err = (src_name or '=(string)') .. ":"..tok:Peek().Line..":"..tok:Peek().Char..": "..msg.."\n "
--find the line
local lineNum = 0
if type(src) == 'string' then
for line in src:gmatch("[^\n]*\n?") do
if line:sub(-1,-1) == '\n' then line = line:sub(1,-2) end
lineNum = lineNum+1
if lineNum == tok:Peek().Line then
err = err..line:gsub('\t',' ').."\n"
for i = 1, tok:Peek().Char do
local c = line:sub(i,i)
if c == '\t' then
err = err..' '
else
err = err..' '
end
end
err = err.."^^^^"
break
end
end
end
return err
end
--
local VarUid = 0
local function CreateScope(parent)
local scope = Scope:new(parent)
scope.Print = function() return "<Scope>" end
return scope
end
local ParseExpr
local ParseStatementList
local ParseSimpleExpr,
ParseSubExpr,
ParsePrimaryExpr,
ParseSuffixedExpr
local function ParseFunctionArgsAndBody(scope, tokenList)
local funcScope = CreateScope(scope)
if not tok:ConsumeSymbol('(', tokenList) then
return false, GenerateError("'(' expected")
end
--arg list
local argList = {}
local isVarArg = false
while not tok:ConsumeSymbol(')', tokenList) do
if tok:Is('Ident') then
local arg = funcScope:CreateLocal(tok:Get(tokenList).Data)
argList[#argList+1] = arg
if not tok:ConsumeSymbol(',', tokenList) then
if tok:ConsumeSymbol(')', tokenList) then
break
else
return false, GenerateError("')' expected")
end
end
elseif tok:ConsumeSymbol('...', tokenList) then
isVarArg = true
if not tok:ConsumeSymbol(')', tokenList) then
return false, GenerateError("'...' must be the last argument of a function")
end
break
else
return false, GenerateError("Argument name or '...' expected")
end
end
--body
local st, body = ParseStatementList(funcScope)
if not st then return false, body end
--end
if not tok:ConsumeKeyword('end', tokenList) then
return false, GenerateError("'end' expected after function body")
end
local nodeFunc = {}
nodeFunc.AstType = 'Function'
nodeFunc.Scope = funcScope
nodeFunc.Arguments = argList
nodeFunc.Body = body
nodeFunc.VarArg = isVarArg
nodeFunc.Tokens = tokenList
--
return true, nodeFunc
end
function ParsePrimaryExpr(scope)
local tokenList = {}
if tok:ConsumeSymbol('(', tokenList) then
local st, ex = ParseExpr(scope)
if not st then return false, ex end
if not tok:ConsumeSymbol(')', tokenList) then
return false, GenerateError("')' expected")
end
if false then
--save the information about parenthesized expressions somewhere
ex.ParenCount = (ex.ParenCount or 0) + 1
return true, ex
else
local parensExp = {}
parensExp.AstType = 'Parentheses'
parensExp.Inner = ex
parensExp.Tokens = tokenList
return true, parensExp
end
elseif tok:Is('Ident') then
local id = tok:Get(tokenList)
local var = scope:GetLocal(id.Data)
if not var then
var = scope:GetGlobal(id.Data)
if not var then
var = scope:CreateGlobal(id.Data)
end
end
--
local nodePrimExp = {}
nodePrimExp.AstType = 'VarExpr'
nodePrimExp.Name = id.Data
nodePrimExp.Variable = var
nodePrimExp.Tokens = tokenList
--
return true, nodePrimExp
else
return false, GenerateError("Primary expression expected")
end
end
function ParseSuffixedExpr(scope, onlyDotColon)
--base primary expression
local st, prim = ParsePrimaryExpr(scope)
if not st then return false, prim end
--
while true do
local tokenList = {}
if tok:IsSymbol('.') or tok:IsSymbol(':') then
local symb = tok:Get(tokenList).Data
if not tok:Is('Ident') then
return false, GenerateError("Identifier expected")
end
local id = tok:Get(tokenList)
local nodeIndex = {}
nodeIndex.AstType = 'MemberExpr'
nodeIndex.Base = prim
nodeIndex.Indexer = symb
nodeIndex.Ident = id
nodeIndex.Tokens = tokenList
--
prim = nodeIndex
elseif not onlyDotColon and tok:ConsumeSymbol('[', tokenList) then
local st, ex = ParseExpr(scope)
if not st then return false, ex end
if not tok:ConsumeSymbol(']', tokenList) then
return false, GenerateError("']' expected")
end
local nodeIndex = {}
nodeIndex.AstType = 'IndexExpr'
nodeIndex.Base = prim
nodeIndex.Index = ex
nodeIndex.Tokens = tokenList
--
prim = nodeIndex
elseif not onlyDotColon and tok:ConsumeSymbol('(', tokenList) then
local args = {}
while not tok:ConsumeSymbol(')', tokenList) do
local st, ex = ParseExpr(scope)
if not st then return false, ex end
args[#args+1] = ex
if not tok:ConsumeSymbol(',', tokenList) then
if tok:ConsumeSymbol(')', tokenList) then
break
else
return false, GenerateError("')' expected")
end
end
end
local nodeCall = {}
nodeCall.AstType = 'CallExpr'
nodeCall.Base = prim
nodeCall.Arguments = args
nodeCall.Tokens = tokenList
--
prim = nodeCall
elseif not onlyDotColon and tok:Is('String') then
--string call
local nodeCall = {}
nodeCall.AstType = 'StringCallExpr'
nodeCall.Base = prim
nodeCall.Arguments = { tok:Get(tokenList) }
nodeCall.Tokens = tokenList
--
prim = nodeCall
elseif not onlyDotColon and tok:IsSymbol('{') then
--table call
local st, ex = ParseSimpleExpr(scope)
-- FIX: ParseExpr(scope) parses the table AND and any following binary expressions.
-- We just want the table
if not st then return false, ex end
local nodeCall = {}
nodeCall.AstType = 'TableCallExpr'
nodeCall.Base = prim
nodeCall.Arguments = { ex }
nodeCall.Tokens = tokenList
--
prim = nodeCall
else
break
end
end
return true, prim
end
function ParseSimpleExpr(scope)
local tokenList = {}
if tok:Is('Number') then
local nodeNum = {}
nodeNum.AstType = 'NumberExpr'
nodeNum.Value = tok:Get(tokenList)
nodeNum.Tokens = tokenList
return true, nodeNum
elseif tok:Is('String') then
local nodeStr = {}
nodeStr.AstType = 'StringExpr'
nodeStr.Value = tok:Get(tokenList)
nodeStr.Tokens = tokenList
return true, nodeStr
elseif tok:ConsumeKeyword('nil', tokenList) then
local nodeNil = {}
nodeNil.AstType = 'NilExpr'
nodeNil.Tokens = tokenList
return true, nodeNil
elseif tok:IsKeyword('false') or tok:IsKeyword('true') then
local nodeBoolean = {}
nodeBoolean.AstType = 'BooleanExpr'
nodeBoolean.Value = (tok:Get(tokenList).Data == 'true')
nodeBoolean.Tokens = tokenList
return true, nodeBoolean
elseif tok:ConsumeSymbol('...', tokenList) then
local nodeDots = {}
nodeDots.AstType = 'DotsExpr'
nodeDots.Tokens = tokenList
return true, nodeDots
elseif tok:ConsumeSymbol('{', tokenList) then
local v = {}
v.AstType = 'ConstructorExpr'
v.EntryList = {}
--
while true do
if tok:IsSymbol('[', tokenList) then
--key
tok:Get(tokenList)
local st, key = ParseExpr(scope)
if not st then
return false, GenerateError("Key expression expected")
end
if not tok:ConsumeSymbol(']', tokenList) then
return false, GenerateError("']' expected")
end
if not tok:ConsumeSymbol('=', tokenList) then
return false, GenerateError("'=' expected")
end
local st, value = ParseExpr(scope)
if not st then
return false, GenerateError("Value expression expected")
end
v.EntryList[#v.EntryList+1] = {
Type = 'Key';
Key = key;
Value = value;
}
elseif tok:Is('Ident') then
--value or key
local lookahead = tok:Peek(1)
if lookahead.Type == 'Symbol' and lookahead.Data == '=' then
--we are a key
local key = tok:Get(tokenList)
if not tok:ConsumeSymbol('=', tokenList) then
return false, GenerateError("'=' expected")
end
local st, value = ParseExpr(scope)
if not st then
return false, GenerateError("Value expression expected")
end
v.EntryList[#v.EntryList+1] = {
Type = 'KeyString';
Key = key.Data;
Value = value;
}
else
--we are a value
local st, value = ParseExpr(scope)
if not st then
return false, GenerateError("Value expected")
end
v.EntryList[#v.EntryList+1] = {
Type = 'Value';
Value = value;
}
end
elseif tok:ConsumeSymbol('}', tokenList) then
break
else
--value
local st, value = ParseExpr(scope)
v.EntryList[#v.EntryList+1] = {
Type = 'Value';
Value = value;
}
if not st then
return false, GenerateError("Value expected")
end
end
if tok:ConsumeSymbol(';', tokenList) or tok:ConsumeSymbol(',', tokenList) then
--all is good
elseif tok:ConsumeSymbol('}', tokenList) then
break
else
return false, GenerateError("'}' or table entry expected")
end
end
v.Tokens = tokenList
return true, v
elseif tok:ConsumeKeyword('function', tokenList) then
local st, func = ParseFunctionArgsAndBody(scope, tokenList)
if not st then return false, func end
--
func.IsLocal = true
return true, func
elseif tok:ConsumeSymbol('\\', tokenList) then -- short lambdas \params(expr)
local funcScope = CreateScope(scope)
local argList = {}
if not tok:ConsumeSymbol('(', tokenList) then while true do
if not tok:Is('Ident') then return false, GenerateError("Identifier expected") end
argList[#argList+1] = funcScope:CreateLocal(tok:Get(tokenList).Data)
if tok:ConsumeSymbol('(', tokenList) then break end
if not tok:ConsumeSymbol(',', tokenList) then return false, GenerateError("'(' expected") end
end end
local st, body = ParseExpr(funcScope)
if not st then return false, body end
if not tok:ConsumeSymbol(')', tokenList) then return false, GenerateError("')' expected after lambda body") end
local last_tok = body.Tokens[1]
local last_char,last_line = last_tok.Char,last_tok.Line
local space = { Char=last_char, Line=last_line, Data=' ', Type='Whitespace' }
local ret = { AstType='ReturnStatement', Arguments={body}, TrailingWhite=true, Tokens={
{ Char=last_char, Line=last_line, Print=function() return '<Keyword return >' end, LeadingWhite={space}, Type='Keyword', Data='return' }
}}
local statList = { AstType='Statlist', Scope=CreateScope(funcScope), Tokens={}, Body={ret} }
local tok_first = tokenList[1]
tok_first.Type = 'Keyword'
tok_first.Data = 'function'
tok_first.Print=function() return '<Keyword function >' end
local ntokl = {}
local paren_ix = 2 + math.max(0, #argList*2-1)
table.insert(ntokl, tokenList[1])
table.insert(ntokl, tokenList[paren_ix])
for i=2,paren_ix-1 do table.insert(ntokl, tokenList[i]) end
table.insert(ntokl, tokenList[#tokenList])
table.insert(ntokl, { Char=last_char, Line=last_line, Type='Keyword', Data='end', Print=function() return '<Keyword end >' end, LeadingWhite={space} })
local func = { AstType='Function', Scope=funcScope, Arguments=argList, Body=statList, VarArg=false, Tokens=ntokl, isLocal=true }
return true, func
else
return ParseSuffixedExpr(scope)
end
end
local unops = lookupify{'-', 'not', '#', '~'}
local unopprio = 12
local priority = {
['^'] = {14,13};
['%'] = {11,11};
['//'] = {11,11};
['/'] = {11,11};
['*'] = {11,11};
['+'] = {10,10};
['-'] = {10,10};
['..'] = {9,8};
['>>'] = {7,7};
['<<'] = {7,7};
['&'] = {6,6};
['~'] = {5,5};
['|'] = {4,4};
['=='] = {3,3};
['<'] = {3,3};
['<='] = {3,3};
['~='] = {3,3};
['>'] = {3,3};
['>='] = {3,3};
['and'] = {2,2};
['or'] = {1,1};
}
function ParseSubExpr(scope, level)
--base item, possibly with unop prefix
local st, exp
if unops[tok:Peek().Data] then
local tokenList = {}
local op = tok:Get(tokenList).Data
st, exp = ParseSubExpr(scope, unopprio)
if not st then return false, exp end
local nodeEx = {}
nodeEx.AstType = 'UnopExpr'
nodeEx.Rhs = exp
nodeEx.Op = op
nodeEx.OperatorPrecedence = unopprio
nodeEx.Tokens = tokenList
exp = nodeEx
else
st, exp = ParseSimpleExpr(scope)
if not st then return false, exp end
end
--next items in chain
while true do
local prio = priority[tok:Peek().Data]
if prio and prio[1] > level then
local tokenList = {}
local op = tok:Get(tokenList).Data
local st, rhs = ParseSubExpr(scope, prio[2])
if not st then return false, rhs end
local nodeEx = {}
nodeEx.AstType = 'BinopExpr'
nodeEx.Lhs = exp
nodeEx.Op = op
nodeEx.OperatorPrecedence = prio[1]
nodeEx.Rhs = rhs
nodeEx.Tokens = tokenList
--
exp = nodeEx
else
break
end
end
return true, exp
end
ParseExpr = function(scope)
return ParseSubExpr(scope, 0)
end
local pragma_map = {
encapsulate_on = function() opcode_arg_encapsulate(true) end,
encapsulate_off = function() opcode_arg_encapsulate(false) end,
syntax6502k_on = function() syntax6502k(true) end,
syntax6502k_off = function() syntax6502k(false) end,
}
local function ParseStatement(scope)
local stat = nil
local tokenList = {}
local commaTokenList = {}
local l,c = function() return tokenList[1].Line end, function() return tokenList[1].Char end
local p = function(t,n) return function() return '<' .. t .. string.rep(' ', 7-#t) .. ' ' .. n .. ' >' end end
local t = function(t,s,w) return { Type=t, Data=s, Print=p(t,s), Char=c(), Line=l(), LeadingWhite=w or {} } end
local no_encapsulation = { Function=true, NumberExpr=true, StringExpr=true }
local reg = function(e) local t=e.Tokens[1] if t then return Registers_6502[t.Data] end end
local function emit_call(params)
local name,args,inverse_encapsulate = params.name, params.args or {}, params.inverse_encapsulate
if not params.func_white then params.func_white = tokenList[1].LeadingWhite end
local space = { Char=c(), Line=l(), Data=' ', Type='Whitespace' }
local op_var = {
AstType='VarExpr', Name=name, Variable={ IsGlobal=true, Name=name, Scope=CreateScope(scope) }, Tokens = { t('Ident', name, params.func_white) }
}
local encapsulate = params.encapsulate
if encapsulate == nil then encapsulate = opcode_arg_encapsulate_on end
if type(inverse_encapsulate) == 'table' then
-- this is a list of arguments, where each can be encapsulated
for arg_ix,arg in ipairs(args) do
if ( (encapsulate and not inverse_encapsulate[arg_ix]) or (not encapsulate and inverse_encapsulate[arg_ix]) ) and not no_encapsulation[arg.AstType] then
local inner_call_scope = CreateScope(op_var.Variable.Scope)
local inner_call_body = {
AstType='StatList', Scope=CreateScope(inner_call_scope), Tokens={}, Body={
{ AstType='ReturnStatement', Arguments={arg}, Tokens={ t('Keyword', 'return', {space}) } }
}
}
local inner_call = {
AstType='Function', VarArg=false, IsLocal=true, Scope=inner_call_scope, Body=inner_call_body, Arguments={},
Tokens={ t('Keyword', 'function'), t('Symbol', '('), t('Symbol', ')'), t('Keyword', 'end', {space}) }
}
if #arg.Tokens[1].LeadingWhite == 0 then table.insert(arg.Tokens[1].LeadingWhite, space) end
args[arg_ix] = inner_call
end
end
elseif #args > 0 and ( (encapsulate and not inverse_encapsulate) or (not encapsulate and inverse_encapsulate) ) and not no_encapsulation[args[1].AstType] then
-- opcode arguments of type (late, early), where only late is to be encapsulated with _o parameter to be set to early and added to _f(late)
local inner_call_scope,inner_call = CreateScope(op_var.Variable.Scope)
if params.basic then
local inner_call_body = {
AstType='StatList', Scope=CreateScope(inner_call_scope), Tokens={}, Body={
{ AstType='ReturnStatement', Arguments={args[1]}, Tokens={ t('Keyword', 'return', {space}) } }
}
}
inner_call = {
AstType='Function', VarArg=false, IsLocal=true, Scope=inner_call_scope, Body=inner_call_body, Arguments={},
Tokens={ t('Keyword', 'function'), t('Symbol', '('), t('Symbol', ')'), t('Keyword', 'end', {space}) }
}
else
local fvarexpr = {
AstType='VarExpr', Name='_f', Variable={ Name='_f', Scope=CreateScope(inner_call_scope) }, Tokens = { t('Ident', '_f') }
}
local inner_add = {
AstType='BinopExpr', Op='+', OperatorPrecedence=10, Tokens={ t('Symbol', '+') },
Lhs = {
AstType='VarExpr', Name='_o', Variable={ IsGlobal=false, Name='_o', Scope=inner_call_scope }, Tokens={ t('Ident', '_o', {space}) }
},
Rhs = {
AstType = 'CallExpr', Base = fvarexpr, Arguments = {args[1]}, Tokens = { t('Symbol', '('), t('Symbol', ')') }
}
}
local inner_call_body = {
AstType='StatList', Scope=CreateScope(inner_call_scope), Tokens={}, Body={
{ AstType='ReturnStatement', Arguments={inner_add}, Tokens={ t('Keyword', 'return', {space}) } }
}
}
inner_call = {
AstType='Function', VarArg=false, IsLocal=true, Scope=inner_call_scope, Body=inner_call_body,
Arguments={
{ IsGlobal=false, Name='_o', Scope=inner_call_scope },
{ IsGlobal=false, Name='_f', Scope=inner_call_scope },
},
Tokens={ t('Keyword', 'function'), t('Symbol', '('), t('Ident', '_o'), t('Symbol', ','), t('Ident', '_f'), t('Symbol', ')'), t('Keyword', 'end', {space}) }
}
end
args[1] = inner_call
end
local exp_call = {
AstType = 'CallExpr', Base = op_var, Arguments = args, Tokens = {
t('Symbol', '(', params.paren_open_white), t('Symbol', ')', params.paren_close_white)
}
}
do
local j=#commaTokenList
for i=2,#args do
assert(j > 0)
table.insert(exp_call.Tokens, i, commaTokenList[j])
j = j - 1
end
end
return { AstType = 'CallStatement', Expression = exp_call, Tokens = {} }
end
local function as_string_expr(expr, s)
local ss = '"'..s..'"'
local lw = expr.Tokens and #expr.Tokens > 0 and expr.Tokens[1].LeadingWhite or {}
local p = function() return '<String '..s..' >' end
local v = { LeadingWhite=lw, Type='String', Data=ss, Constant=s, Char=c(), Line=l(), Print=p }
return { AstType = 'StringExpr', Value = v, Tokens = {v} }
end
-- parser pragmas
do
::search_pragma::
for k,v in pairs(pragma_map) do
if tok:ConsumeKeyword(k) then v() goto search_pragma end
end
end
-- label declarations
if not stat then
if tok:ConsumeSymbol('@@', tokenList) then
if not tok:Is('Ident') then return false, GenerateError("Identifier expected") end
local label_name = tok:Get(tokenList)
label_name = as_string_expr(label_name, label_name.Data)
stat = emit_call{name = 'section', args = {label_name}, encapsulate=false}
elseif tok:ConsumeSymbol('@', tokenList) then
if not tok:Is('Ident') then return false, GenerateError("Identifier expected") end
local label_name = tok:Get(tokenList)
label_name = as_string_expr(label_name, label_name.Data)
stat = emit_call{name = 'label', args = {label_name}, encapsulate=false}
end end
-- new statements
if not stat then
local pagestat = function(fpage)
local st, nodeBlock = ParseStatementList(scope)
if not st then return false, nodeBlock end
if not tok:ConsumeKeyword('end', tokenList) then
return false, GenerateError("'end' expected")
end
local nodeDoStat = {}
nodeDoStat.AstType = 'DoStatement'
nodeDoStat.Body = nodeBlock
nodeDoStat.Tokens = tokenList
stat = nodeDoStat
tokenList[1].Data = 'do'
local space = {{ Char=c(), Line=l(), Data=' ', Type='Whitespace' }}
local opencall,closecall = emit_call{name=fpage,func_white=space},emit_call{name='endpage',func_white=space}
table.insert(nodeBlock.Body, 1, opencall)
table.insert(nodeBlock.Body, closecall)
end
if tok:ConsumeKeyword('samepage', tokenList) then pagestat('samepage')
elseif tok:ConsumeKeyword('crosspage', tokenList) then pagestat('crosspage')
end
end
-- declare data
if not stat then
if tok:ConsumeKeyword('dc', tokenList) then
if not tok:ConsumeSymbol('.', tokenList) then return false, GenerateError("'.' expected") end
local suffix_list = { b='byte', w='word', l='long' }
local func = suffix_list[tok:Get(tokenList).Data]
if not func then return false, GenerateError("'b', 'w' or 'l' expected") end
local inverse_encapsulate={}
inverse_encapsulate[1] = tok:ConsumeSymbol('!', tokenList)
local st, expr = ParseExpr(scope)
if not st then return false, expr end
if inverse_encapsulate[1] then
local d = expr.Tokens[1].LeadingWhite
for _,v in ipairs(tokenList[#tokenList].LeadingWhite) do table.insert(d, v) end
end
local exprs = { expr }
while tok:ConsumeSymbol(',', tokenList) do
commaTokenList[#commaTokenList+1] = tokenList[#tokenList]
inverse_encapsulate[#exprs+1] = tok:ConsumeSymbol('!', tokenList)
local st, expr = ParseExpr(scope)
if not st then return false, expr end
if inverse_encapsulate[#exprs+1] then
local d = expr.Tokens[1].LeadingWhite
for _,v in ipairs(tokenList[#tokenList].LeadingWhite) do table.insert(d, v) end
end
exprs[#exprs+1] = expr
end
stat = emit_call{name=func, args=exprs, inverse_encapsulate=inverse_encapsulate}
end end
-- k65 style syntax
if not stat and syntax6502k_on then
-- *=[a,x,y,s]=?
do
tok:Save()
local exprs = {}
while true do
local st, expr = ParseExpr(scope)
if not st then break end
table.insert(exprs, expr)
if not tok:ConsumeSymbol('=', tokenList) then break end
end
if #exprs < 2 then
tok:Restore()
else
local hasreg
for e in exprs do hasreg=reg(e) if hasreg then break end end
if not hasreg then
tok:Restore()
else
tok:Commit()
local skip
for i=#exprs-1,1,-1 do
if skip then
skip = false
else
local src,dst = exprs[i+1],exprs[i]
local src_reg,dst_reg = reg(src),reg(dst)
local op,arg
if src_reg=='s' then
if dst_reg=='x' then
op = 'tsximp'
end
elseif dst_reg=='s' then
if src_reg=='x' then
op = 'txsimp'
end
elseif src_reg and not dst_reg then
arg = i
op = 'st'..src_reg
elseif dst_reg and not src_reg then
arg = i+1
if dst_reg=='x' and i > 1 and reg(exprs[i-1])=='a' then
op='lax' skip=true
else
op = 'ld'..src_reg
end
end
if not op then
return false, GenerateError("no opcode for assignment")
end
if arg then
arg = exprs[arg]
end
end
end
end
local t,r,rexpr,rexpr_ix
rexpr_ix=#exprs rexpr=exprs[rexprs_ix] t=#rexpr.Tokens[1] if t then r=Registers_6502[t.Data] end
if not r then rexpr_ix=#exprs-1 rexpr=exprs[rexprs_ix] t=#rexpr.Tokens[1] if t then r=Registers_6502[t.Data] end end
if r then
end
end
end
if tok:Is('Ident') and tok:Peek(1).Data == '=' then
local reg = tok:Peek(2).Data
if Registers_6502[reg] then
local st, arg = ParseExpr(scope)
tok:Get(tokenList) tok:Get(tokenList)
arg.Tokens[1].LeadingWhite,tokenList[1].LeadingWhite = tokenList[1].LeadingWhite,arg.Tokens[1].LeadingWhite
stat = emit_call{name = 'st'..reg..'zab', args = {arg}}
end
end
end
-- 6502 opcodes
if not stat then
local mod_st, mod_expr, inverse_encapsulate
for _,op in pairs(Keywords_6502) do
if tok:ConsumeKeyword(op, tokenList) then
if opcode_alias[op] then op = opcode_alias[op] end
if opcode_encapsulate[op] then
inverse_encapsulate = tok:ConsumeSymbol('!', tokenList)
local st, expr = ParseExpr(scope) if not st then return false, expr end
local paren_open_whites = {}
if inverse_encapsulate then for _,v in ipairs(tokenList[#tokenList-1].LeadingWhite) do table.insert(paren_open_whites, v) end end
for _,v in ipairs(tokenList[#tokenList].LeadingWhite) do table.insert(paren_open_whites, v) end
stat = emit_call{name=opcode_encapsulate[op], args={expr}, inverse_encapsulate=inverse_encapsulate, paren_open_white=paren_open_whites, basic=true} break
elseif opcode_relative[op] then
local st, expr = ParseExpr(scope) if not st then return false, expr end
if expr.AstType == 'VarExpr' and expr.Variable.IsGlobal then
expr = as_string_expr(expr, expr.Name)
end
stat = emit_call{name=op .. "rel", args={expr}, encapsulate=false} break
end
if opcode_immediate[op] and tok:ConsumeSymbol('#', tokenList) then
inverse_encapsulate = tok:ConsumeSymbol('!', tokenList)
local st, expr = ParseExpr(scope) if not st then return false, expr end
local paren_open_whites = {}
if inverse_encapsulate then for _,v in ipairs(tokenList[#tokenList-1].LeadingWhite) do table.insert(paren_open_whites, v) end end
for _,v in ipairs(tokenList[#tokenList].LeadingWhite) do table.insert(paren_open_whites, v) end
if tok:ConsumeSymbol(',', tokenList) then
commaTokenList[1] = tokenList[#tokenList]
mod_st, mod_expr = ParseExpr(scope)
if not mod_st then return false, mod_expr end
end
stat = emit_call{name=op .. "imm", args={expr, mod_expr}, inverse_encapsulate=inverse_encapsulate, paren_open_white=paren_open_whites} break
end
if (opcode_indirect[op] or opcode_indirect_x[op] or opcode_indirect_y[op]) and tok:ConsumeSymbol('(', tokenList) then
inverse_encapsulate = tok:ConsumeSymbol('!', tokenList)
local st, expr = ParseExpr(scope) if not st then return false, expr end
local paren_open_whites,paren_close_whites,mod_st,mod_expr = {},{}
if inverse_encapsulate then for _,v in ipairs(tokenList[#tokenList-1].LeadingWhite) do table.insert(paren_open_whites, v) end end
for _,v in ipairs(tokenList[#tokenList].LeadingWhite) do table.insert(paren_open_whites, v) end
if tok:IsSymbol(',') and tok:Peek(1).Data ~= 'x' then
tok:Get(tokenList)
commaTokenList[1] = tokenList[#tokenList]
mod_st, mod_expr = ParseExpr(scope)
if not mod_st then return false, mod_expr end
end
if tok:ConsumeSymbol(',', tokenList) then
if not opcode_indirect_x[op]
or not tok:Get(tokenList).Data == 'x'
or not tok:ConsumeSymbol(')', tokenList)
then return false, expr end
for _,v in ipairs(tokenList[#tokenList-1].LeadingWhite) do table.insert(paren_close_whites, v) end
for _,v in ipairs(tokenList[#tokenList].LeadingWhite) do table.insert(paren_close_whites, v) end
stat = emit_call{name=op .. "inx", args={expr, mod_expr}, inverse_encapsulate=inverse_encapsulate, paren_open_white=paren_open_whites, paren_close_white=paren_close_whites} break
elseif not tok:ConsumeSymbol(')', tokenList) then return false, expr
else
if tok:ConsumeSymbol(',', tokenList) then
if not opcode_indirect_y[op] or not tok:Get(tokenList).Data == 'y'
then return false, expr end
for _,v in ipairs(tokenList[#tokenList-1].LeadingWhite) do table.insert(paren_close_whites, v) end
for _,v in ipairs(tokenList[#tokenList].LeadingWhite) do table.insert(paren_close_whites, v) end
stat = emit_call{name=op .. "iny", args={expr, mod_expr}, inverse_encapsulate=inverse_encapsulate, paren_open_white=paren_open_whites, paren_close_white=paren_close_whites} break
else
if not opcode_indirect[op] then return false, expr end
stat = emit_call{name=op .. "ind", args={expr, mod_expr}, inverse_encapsulate=inverse_encapsulate, paren_open_white=paren_open_whites, paren_close_white=paren_close_whites} break
end
end
end
if opcode_absolute[op] or opcode_absolute_x[op] or opcode_absolute_y[op]
or opcode_zeropage[op] or opcode_zeropage_x[op] or opcode_zeropage_y[op]
then
local suffix = ''
tok:Save()
if tok:ConsumeSymbol('.', tokenList) then
local t = tok:Get(tokenList).Data
if t == 'w' then suffix = 'w'
elseif t == 'b' then suffix = 'b'
else tok:Restore() tok:Save() end
end
local paren_open_whites = {}
if tok:ConsumeSymbol('!', tokenList) then
inverse_encapsulate = true
for _,v in ipairs(tokenList[#tokenList].LeadingWhite) do table.insert(paren_open_whites, v) end
end
local st, expr = ParseExpr(scope)
if not st then tok:Restore()
else
tok:Commit()
if not tok:ConsumeSymbol(',', tokenList) then
if not opcode_absolute[op] and not opcode_zeropage[op] then return false, expr end
suffix = suffix=='b' and "zpg" or suffix=='w' and "abs" or "zab"
if suffix == 'zab' then
if not opcode_zeropage[op] then suffix='abs'
elseif not opcode_absolute[op] then suffix='zpg' end
end
if suffix == 'zpg' and not opcode_zeropage[op] then return false, GenerateError("Opcode " .. op " doesn't support zeropage addressing mode") end
if suffix == 'abs' and not opcode_absolute[op] then return false, GenerateError("Opcode " .. op " doesn't support absolute addressing mode") end
stat = emit_call{name=op .. suffix, args={expr}, inverse_encapsulate=inverse_encapsulate} break
end
if tok:Peek().Data == 'x' then
if not opcode_absolute_x[op] and not opcode_zeropage_x[op] then return false, expr end
tok:Get(tokenList)
local paren_close_whites = {}
for _,v in ipairs(tokenList[#tokenList-1].LeadingWhite) do table.insert(paren_close_whites, v) end
for _,v in ipairs(tokenList[#tokenList].LeadingWhite) do table.insert(paren_close_whites, v) end
suffix = suffix=='b' and "zpx" or suffix=='w' and "abx" or "zax"
if suffix == 'zax' then
if not opcode_zeropage_x[op] then suffix='abx'
elseif not opcode_absolute_x[op] then suffix='zpx' end
end
if suffix == 'zpx' and not opcode_zeropage_x[op] then return false, GenerateError("Opcode " .. op " doesn't support zeropage,x addressing mode") end
if suffix == 'abx' and not opcode_absolute_x[op] then return false, GenerateError("Opcode " .. op " doesn't support absolute,x addressing mode") end
stat = emit_call{name=op .. suffix, args={expr}, inverse_encapsulate=inverse_encapsulate, paren_open_white=paren_open_whites, paren_close_white=paren_close_whites} break
end
if tok:Peek().Data == 'y' then
if not opcode_absolute_y[op] and not opcode_zeropage_y[op] then return false, expr end
tok:Get(tokenList)
local paren_close_whites = {}
for _,v in ipairs(tokenList[#tokenList-1].LeadingWhite) do table.insert(paren_close_whites, v) end
for _,v in ipairs(tokenList[#tokenList].LeadingWhite) do table.insert(paren_close_whites, v) end
suffix = suffix=='b' and "zpy" or suffix=='w' and "aby" or "zay"
if suffix == 'zay' then
if not opcode_zeropage_y[op] then suffix='aby'
elseif not opcode_absolute_y[op] then suffix='zpy' end
end
if suffix == 'zpy' and not opcode_zeropage_y[op] then return false, GenerateError("Opcode " .. op " doesn't support zeropage,y addressing mode") end
if suffix == 'aby' and not opcode_absolute_y[op] then return false, GenerateError("Opcode " .. op " doesn't support absolute,y addressing mode") end
stat = emit_call{name=op .. suffix, args={expr}, inverse_encapsulate=inverse_encapsulate, paren_open_white=paren_open_whites, paren_close_white=paren_close_whites} break
end
commaTokenList[1] = tokenList[#tokenList]
local mod_st, mod_expr = ParseExpr(scope)
if not mod_st then return false, mod_expr end
if not tok:ConsumeSymbol(',', tokenList) then
if not opcode_absolute[op] and not opcode_zeropage[op] then return false, expr end
suffix = suffix=='b' and "zpg" or suffix=='w' and "abs" or "zab"
if suffix == 'zab' then
if not opcode_zeropage[op] then suffix='abs'
elseif not opcode_absolute[op] then suffix='zpg' end
end
if suffix == 'zpg' and not opcode_zeropage[op] then return false, GenerateError("Opcode " .. op " doesn't support zeropage addressing mode") end
if suffix == 'abs' and not opcode_absolute[op] then return false, GenerateError("Opcode " .. op " doesn't support absolute addressing mode") end
stat = emit_call{name=op .. suffix, args={expr, mod_expr}, inverse_encapsulate=inverse_encapsulate} break
end
if tok:Peek().Data == 'x' then
if not opcode_absolute_x[op] and not opcode_zeropage_x[op] then return false, expr end
tok:Get(tokenList)
local paren_close_whites = {}
for _,v in ipairs(tokenList[#tokenList-1].LeadingWhite) do table.insert(paren_close_whites, v) end
for _,v in ipairs(tokenList[#tokenList].LeadingWhite) do table.insert(paren_close_whites, v) end
suffix = suffix=='b' and "zpx" or suffix=='w' and "abx" or "zax"
if suffix == 'zax' then
if not opcode_zeropage_x[op] then suffix='abx'
elseif not opcode_absolute_x[op] then suffix='zpx' end
end
if suffix == 'zpx' and not opcode_zeropage_x[op] then return false, GenerateError("Opcode " .. op " doesn't support zeropage,x addressing mode") end
if suffix == 'abx' and not opcode_absolute_x[op] then return false, GenerateError("Opcode " .. op " doesn't support absolute,x addressing mode") end
stat = emit_call{name=op .. suffix, args={expr, mod_expr}, inverse_encapsulate=inverse_encapsulate, paren_open_white=paren_open_whites, paren_close_white=paren_close_whites} break
end
if tok:Peek().Data == 'y' then
if not opcode_absolute_y[op] and not opcode_zeropage_y[op] then return false, expr end
tok:Get(tokenList)
local paren_close_whites = {}
for _,v in ipairs(tokenList[#tokenList-1].LeadingWhite) do table.insert(paren_close_whites, v) end
for _,v in ipairs(tokenList[#tokenList].LeadingWhite) do table.insert(paren_close_whites, v) end
suffix = suffix=='b' and "zpy" or suffix=='w' and "aby" or "zay"
if suffix == 'zay' then
if not opcode_zeropage_y[op] then suffix='aby'
elseif not opcode_absolute_y[op] then suffix='zpy' end
end
if suffix == 'zpy' and not opcode_zeropage_y[op] then return false, GenerateError("Opcode " .. op " doesn't support zeropage,y addressing mode") end
if suffix == 'aby' and not opcode_absolute_y[op] then return false, GenerateError("Opcode " .. op " doesn't support absolute,y addressing mode") end
stat = emit_call{name=op .. suffix, args={expr, mod_expr}, inverse_encapsulate=inverse_encapsulate, paren_open_white=paren_open_whites, paren_close_white=paren_close_whites} break
end
return false, expr
end
end
if opcode_implied[op] then stat = emit_call{name=op .. "imp"} break end
error("internal error: unable to find addressing of valid opcode " .. op) -- should not happen
end
end end
if stat then -- nothing
elseif tok:ConsumeKeyword('if', tokenList) then
--setup
local nodeIfStat = {}
nodeIfStat.AstType = 'IfStatement'
nodeIfStat.Clauses = {}
--clauses
repeat
local st, nodeCond = ParseExpr(scope)
if not st then return false, nodeCond end
if not tok:ConsumeKeyword('then', tokenList) then
return false, GenerateError("'then' expected")
end
local st, nodeBody = ParseStatementList(scope)
if not st then return false, nodeBody end
nodeIfStat.Clauses[#nodeIfStat.Clauses+1] = {
Condition = nodeCond;
Body = nodeBody;
}
until not tok:ConsumeKeyword('elseif', tokenList)
--else clause
if tok:ConsumeKeyword('else', tokenList) then
local st, nodeBody = ParseStatementList(scope)
if not st then return false, nodeBody end
nodeIfStat.Clauses[#nodeIfStat.Clauses+1] = {
Body = nodeBody;
}
end
--end
if not tok:ConsumeKeyword('end', tokenList) then
return false, GenerateError("'end' expected")
end
nodeIfStat.Tokens = tokenList
stat = nodeIfStat
elseif tok:ConsumeKeyword('while', tokenList) then
--setup
local nodeWhileStat = {}
nodeWhileStat.AstType = 'WhileStatement'
--condition
local st, nodeCond = ParseExpr(scope)
if not st then return false, nodeCond end
--do
if not tok:ConsumeKeyword('do', tokenList) then
return false, GenerateError("'do' expected")
end
--body
local st, nodeBody = ParseStatementList(scope)
if not st then return false, nodeBody end
--end
if not tok:ConsumeKeyword('end', tokenList) then
return false, GenerateError("'end' expected")
end
--return
nodeWhileStat.Condition = nodeCond
nodeWhileStat.Body = nodeBody
nodeWhileStat.Tokens = tokenList
stat = nodeWhileStat
elseif tok:ConsumeKeyword('do', tokenList) then
--do block
local st, nodeBlock = ParseStatementList(scope)
if not st then return false, nodeBlock end
if not tok:ConsumeKeyword('end', tokenList) then
return false, GenerateError("'end' expected")
end
local nodeDoStat = {}
nodeDoStat.AstType = 'DoStatement'
nodeDoStat.Body = nodeBlock
nodeDoStat.Tokens = tokenList
stat = nodeDoStat
elseif tok:ConsumeKeyword('for', tokenList) then
--for block
if not tok:Is('Ident') then
return false, GenerateError("Identifier expected")
end
local baseVarName = tok:Get(tokenList)
if tok:ConsumeSymbol('=', tokenList) then
--numeric for
local forScope = CreateScope(scope)
local forVar = forScope:CreateLocal(baseVarName.Data)
--
local st, startEx = ParseExpr(scope)
if not st then return false, startEx end
if not tok:ConsumeSymbol(',', tokenList) then
return false, GenerateError("',' expected")
end
local st, endEx = ParseExpr(scope)
if not st then return false, endEx end
local st, stepEx;
if tok:ConsumeSymbol(',', tokenList) then
st, stepEx = ParseExpr(scope)
if not st then return false, stepEx end
end
if not tok:ConsumeKeyword('do', tokenList) then
return false, GenerateError("'do' expected")
end
--
local st, body = ParseStatementList(forScope)
if not st then return false, body end
if not tok:ConsumeKeyword('end', tokenList) then
return false, GenerateError("'end' expected")
end
--
local nodeFor = {}
nodeFor.AstType = 'NumericForStatement'
nodeFor.Scope = forScope
nodeFor.Variable = forVar
nodeFor.Start = startEx
nodeFor.End = endEx
nodeFor.Step = stepEx
nodeFor.Body = body
nodeFor.Tokens = tokenList
stat = nodeFor
else
--generic for
local forScope = CreateScope(scope)
--
local varList = { forScope:CreateLocal(baseVarName.Data) }
while tok:ConsumeSymbol(',', tokenList) do
if not tok:Is('Ident') then
return false, GenerateError("for variable expected.")
end
varList[#varList+1] = forScope:CreateLocal(tok:Get(tokenList).Data)
end
if not tok:ConsumeKeyword('in', tokenList) then
return false, GenerateError("'in' expected")
end
local generators = {}
local st, firstGenerator = ParseExpr(scope)
if not st then return false, firstGenerator end
generators[#generators+1] = firstGenerator
while tok:ConsumeSymbol(',', tokenList) do
local st, gen = ParseExpr(scope)
if not st then return false, gen end
generators[#generators+1] = gen
end
if not tok:ConsumeKeyword('do', tokenList) then
return false, GenerateError("'do' expected")
end
local st, body = ParseStatementList(forScope)
if not st then return false, body end
if not tok:ConsumeKeyword('end', tokenList) then
return false, GenerateError("'end' expected")
end
--
local nodeFor = {}
nodeFor.AstType = 'GenericForStatement'
nodeFor.Scope = forScope
nodeFor.VariableList = varList
nodeFor.Generators = generators
nodeFor.Body = body
nodeFor.Tokens = tokenList
stat = nodeFor
end
elseif tok:ConsumeKeyword('repeat', tokenList) then
local st, body = ParseStatementList(scope)
if not st then return false, body end
--
if not tok:ConsumeKeyword('until', tokenList) then
return false, GenerateError("'until' expected")
end
-- FIX: Used to parse in parent scope
-- Now parses in repeat scope
local st, cond = ParseExpr(body.Scope)
if not st then return false, cond end
--
local nodeRepeat = {}
nodeRepeat.AstType = 'RepeatStatement'
nodeRepeat.Condition = cond
nodeRepeat.Body = body
nodeRepeat.Tokens = tokenList
stat = nodeRepeat
elseif tok:ConsumeKeyword('function', tokenList) then
if not tok:Is('Ident') then
return false, GenerateError("function name expected")
end
local st, name = ParseSuffixedExpr(scope, true) --true => only dots and colons
if not st then return false, name end
--
local st, func = ParseFunctionArgsAndBody(scope, tokenList)
if not st then return false, func end
--
func.IsLocal = false
func.Name = name
stat = func
elseif tok:ConsumeKeyword('local', tokenList) then
if tok:Is('Ident') then
local varList = { tok:Get(tokenList).Data }
while tok:ConsumeSymbol(',', tokenList) do
if not tok:Is('Ident') then
return false, GenerateError("local var name expected")
end
varList[#varList+1] = tok:Get(tokenList).Data
end
local initList = {}
if tok:ConsumeSymbol('=', tokenList) then
repeat
local st, ex = ParseExpr(scope)
if not st then return false, ex end
initList[#initList+1] = ex
until not tok:ConsumeSymbol(',', tokenList)
end
--now patch var list
--we can't do this before getting the init list, because the init list does not
--have the locals themselves in scope.
for i, v in pairs(varList) do
varList[i] = scope:CreateLocal(v)
end
local nodeLocal = {}
nodeLocal.AstType = 'LocalStatement'
nodeLocal.LocalList = varList
nodeLocal.InitList = initList
nodeLocal.Tokens = tokenList
--
stat = nodeLocal
elseif tok:ConsumeKeyword('function', tokenList) then
if not tok:Is('Ident') then
return false, GenerateError("function name expected")
end
local name = tok:Get(tokenList).Data
local localVar = scope:CreateLocal(name)
--
local st, func = ParseFunctionArgsAndBody(scope, tokenList)
if not st then return false, func end
--
func.Name = localVar
func.IsLocal = true
stat = func
else
return false, GenerateError("local var or function def expected")
end
elseif tok:ConsumeSymbol('::', tokenList) then
if not tok:Is('Ident') then
return false, GenerateError('Label name expected')
end
local label = tok:Get(tokenList).Data
if not tok:ConsumeSymbol('::', tokenList) then
return false, GenerateError("'::' expected")
end
local nodeLabel = {}
nodeLabel.AstType = 'LabelStatement'
nodeLabel.Label = label
nodeLabel.Tokens = tokenList
stat = nodeLabel
elseif tok:ConsumeKeyword('return', tokenList) then
local exList = {}
if not tok:IsKeyword('end') then
local st, firstEx = ParseExpr(scope)
if st then
exList[1] = firstEx
while tok:ConsumeSymbol(',', tokenList) do
local st, ex = ParseExpr(scope)
if not st then return false, ex end
exList[#exList+1] = ex
end
end
end
local nodeReturn = {}
nodeReturn.AstType = 'ReturnStatement'
nodeReturn.Arguments = exList
nodeReturn.Tokens = tokenList
stat = nodeReturn
elseif tok:ConsumeKeyword('break', tokenList) then
local nodeBreak = {}
nodeBreak.AstType = 'BreakStatement'
nodeBreak.Tokens = tokenList
stat = nodeBreak
elseif tok:ConsumeKeyword('goto', tokenList) then
if not tok:Is('Ident') then
return false, GenerateError("Label expected")
end
local label = tok:Get(tokenList).Data
local nodeGoto = {}
nodeGoto.AstType = 'GotoStatement'
nodeGoto.Label = label
nodeGoto.Tokens = tokenList
stat = nodeGoto
elseif tok:IsSymbol(';') then
stat = { AstType='SemicolonStatement', Tokens={} }
else
--statementParseExpr
local st, suffixed = ParseSuffixedExpr(scope)
if not st then return false, suffixed end
--assignment or call?
if tok:IsSymbol(',') or tok:IsSymbol('=') then
--check that it was not parenthesized, making it not an lvalue
if (suffixed.ParenCount or 0) > 0 then
return false, GenerateError("Can not assign to parenthesized expression, is not an lvalue")
end
--more processing needed
local lhs = { suffixed }
while tok:ConsumeSymbol(',', tokenList) do
local st, lhsPart = ParseSuffixedExpr(scope)
if not st then return false, lhsPart end
lhs[#lhs+1] = lhsPart
end
--equals
if not tok:ConsumeSymbol('=', tokenList) then
return false, GenerateError("'=' expected")
end
--rhs
local rhs = {}
local st, firstRhs = ParseExpr(scope)
if not st then return false, firstRhs end
rhs[1] = firstRhs
while tok:ConsumeSymbol(',', tokenList) do
local st, rhsPart = ParseExpr(scope)
if not st then return false, rhsPart end
rhs[#rhs+1] = rhsPart
end
--done
local nodeAssign = {}
nodeAssign.AstType = 'AssignmentStatement'
nodeAssign.Lhs = lhs
nodeAssign.Rhs = rhs
nodeAssign.Tokens = tokenList
stat = nodeAssign
elseif suffixed.AstType == 'CallExpr' or
suffixed.AstType == 'TableCallExpr' or
suffixed.AstType == 'StringCallExpr'
then
--it's a call statement
local nodeCall = {}
nodeCall.AstType = 'CallStatement'
nodeCall.Expression = suffixed
nodeCall.Tokens = tokenList
stat = nodeCall
else
return false, GenerateError("Assignment statement expected")
end
end
if tok:IsSymbol(';') then
stat.Semicolon = tok:Get( stat.Tokens )
end
return true, stat
end
local statListCloseKeywords = lookupify{'end', 'else', 'elseif', 'until'}
ParseStatementList = function(scope)
local nodeStatlist = {}
nodeStatlist.Scope = CreateScope(scope)
nodeStatlist.AstType = 'Statlist'
nodeStatlist.Body = { }
nodeStatlist.Tokens = { }
--
--local stats = {}
--
while not statListCloseKeywords[tok:Peek().Data] and not tok:IsEof() do
local st, nodeStatement = ParseStatement(nodeStatlist.Scope)
if not st then return false, nodeStatement end
--stats[#stats+1] = nodeStatement
nodeStatlist.Body[#nodeStatlist.Body + 1] = nodeStatement
end
if tok:IsEof() then
local nodeEof = {}
nodeEof.AstType = 'Eof'
nodeEof.Tokens = { tok:Get() }
nodeStatlist.Body[#nodeStatlist.Body + 1] = nodeEof
end
--
--nodeStatlist.Body = stats
return true, nodeStatlist
end
local function mainfunc()
local topScope = CreateScope()
return ParseStatementList(topScope)
end
local st, main = mainfunc()
return st, main
end
local function Format65(ast)
local function splitLines(str)
if str:match("\n") then
local lines = {}
for line in str:gmatch("[^\n]*") do
table.insert(lines, line)
end
assert(#lines > 0)
return lines
else
return { str }
end
end
local formatStatlist, formatExpr
local out = {
rope = {}, -- List of strings
line = 1,
char = 1,
appendStr = function(self, str)
table.insert(self.rope, str)
local lines = splitLines(str)
if #lines == 1 then
self.char = self.char + #str
else
self.line = self.line + #lines - 1
local lastLine = lines[#lines]
self.char = #lastLine
end
end,
appendToken = function(self, token)
self:appendWhite(token)
self:appendStr(token.Data)
end,
appendTokens = function(self, tokens)
for _,token in ipairs(tokens) do
self:appendToken( token )
end
end,
appendWhite = function(self, token)
if token.LeadingWhite then
self:appendTokens( token.LeadingWhite )
end
end
}
formatExpr = function(expr)
local tok_it = 1
local function appendNextToken(str)
local tok = expr.Tokens[tok_it];
if str and tok.Data ~= str then
error("Expected token '" .. str .. "'.")
end
out:appendToken( tok )
tok_it = tok_it + 1
end
local function appendToken(token)
out:appendToken( token )
tok_it = tok_it + 1
end
local function appendWhite()
local tok = expr.Tokens[tok_it];
if not tok then error("Missing token") end
out:appendWhite( tok )
tok_it = tok_it + 1
end
local function appendStr(str)
appendWhite()
out:appendStr(str)
end
local function peek()
if tok_it < #expr.Tokens then
return expr.Tokens[tok_it].Data
end
end
local function appendComma(mandatory, seperators)
seperators = seperators or { "," }
seperators = lookupify( seperators )
if not mandatory and not seperators[peek()] then
return
end
assert(seperators[peek()], "Missing comma or semicolon")
appendNextToken()
end
if expr.AstType == 'VarExpr' then
if expr.Variable then
appendStr( expr.Variable.Name )
else
appendStr( expr.Name )
end
elseif expr.AstType == 'NumberExpr' then
appendToken( expr.Value )
elseif expr.AstType == 'StringExpr' then
appendToken( expr.Value )
elseif expr.AstType == 'BooleanExpr' then
appendNextToken( expr.Value and "true" or "false" )
elseif expr.AstType == 'NilExpr' then
appendNextToken( "nil" )
elseif expr.AstType == 'BinopExpr' then
formatExpr(expr.Lhs)
appendStr( expr.Op )
formatExpr(expr.Rhs)
elseif expr.AstType == 'UnopExpr' then
appendStr( expr.Op )
formatExpr(expr.Rhs)
elseif expr.AstType == 'DotsExpr' then
appendNextToken( "..." )
elseif expr.AstType == 'CallExpr' then
formatExpr(expr.Base)
appendNextToken( "(" )
for i,arg in ipairs( expr.Arguments ) do
formatExpr(arg)
appendComma( i ~= #expr.Arguments )
end
appendNextToken( ")" )
elseif expr.AstType == 'TableCallExpr' then
formatExpr( expr.Base )
formatExpr( expr.Arguments[1] )
elseif expr.AstType == 'StringCallExpr' then
formatExpr(expr.Base)
appendToken( expr.Arguments[1] )
elseif expr.AstType == 'IndexExpr' then
formatExpr(expr.Base)
appendNextToken( "[" )
formatExpr(expr.Index)
appendNextToken( "]" )
elseif expr.AstType == 'MemberExpr' then
formatExpr(expr.Base)
appendNextToken() -- . or :
appendToken(expr.Ident)
elseif expr.AstType == 'Function' then
-- anonymous function
appendNextToken( "function" )
appendNextToken( "(" )
if #expr.Arguments > 0 then
for i = 1, #expr.Arguments do
appendStr( expr.Arguments[i].Name )
if i ~= #expr.Arguments then
appendNextToken(",")
elseif expr.VarArg then
appendNextToken(",")
appendNextToken("...")
end
end
elseif expr.VarArg then
appendNextToken("...")
end
appendNextToken(")")
formatStatlist(expr.Body)
appendNextToken("end")
elseif expr.AstType == 'ConstructorExpr' then
appendNextToken( "{" )
for i = 1, #expr.EntryList do
local entry = expr.EntryList[i]
if entry.Type == 'Key' then
appendNextToken( "[" )
formatExpr(entry.Key)
appendNextToken( "]" )
appendNextToken( "=" )
formatExpr(entry.Value)
elseif entry.Type == 'Value' then
formatExpr(entry.Value)
elseif entry.Type == 'KeyString' then
appendStr(entry.Key)
appendNextToken( "=" )
formatExpr(entry.Value)
end
appendComma( i ~= #expr.EntryList, { ",", ";" } )
end
appendNextToken( "}" )
elseif expr.AstType == 'Parentheses' then
appendNextToken( "(" )
formatExpr(expr.Inner)
appendNextToken( ")" )
else
error(string.format("Unknown AST Type: %s\n", tostring(statement.AstType)))
end
assert(tok_it == #expr.Tokens + 1)
end
local formatStatement = function(statement)
local tok_it = 1
local function appendNextToken(str)
local tok = statement.Tokens[tok_it];
assert(tok, string.format("Not enough tokens for %q. First token at %i:%i",
str, statement.Tokens[1].Line, statement.Tokens[1].Char))
assert(tok.Data == str,
string.format('Expected token %q, got %q', str, tok.Data))
out:appendToken( tok )
tok_it = tok_it + 1
end
local function appendToken(token)
out:appendToken( str )
tok_it = tok_it + 1
end
local function appendWhite()
local tok = statement.Tokens[tok_it];
out:appendWhite( tok )
tok_it = tok_it + 1
end
local function appendStr(str)
appendWhite()
out:appendStr(str)
end
local function appendComma(mandatory)
if mandatory
or (tok_it < #statement.Tokens and statement.Tokens[tok_it].Data == ",") then
appendNextToken( "," )
end
end
if statement.AstType == 'AssignmentStatement' then
for i,v in ipairs(statement.Lhs) do
formatExpr(v)
appendComma( i ~= #statement.Lhs )
end
if #statement.Rhs > 0 then
appendNextToken( "=" )
for i,v in ipairs(statement.Rhs) do
formatExpr(v)
appendComma( i ~= #statement.Rhs )
end
end
elseif statement.AstType == 'CallStatement' then
formatExpr(statement.Expression)
elseif statement.AstType == 'LocalStatement' then
appendNextToken( "local" )
for i = 1, #statement.LocalList do
appendStr( statement.LocalList[i].Name )
appendComma( i ~= #statement.LocalList )
end
if #statement.InitList > 0 then
appendNextToken( "=" )
for i = 1, #statement.InitList do
formatExpr(statement.InitList[i])
appendComma( i ~= #statement.InitList )
end
end
elseif statement.AstType == 'IfStatement' then
appendNextToken( "if" )
formatExpr( statement.Clauses[1].Condition )
appendNextToken( "then" )
formatStatlist( statement.Clauses[1].Body )
for i = 2, #statement.Clauses do
local st = statement.Clauses[i]
if st.Condition then
appendNextToken( "elseif" )
formatExpr(st.Condition)
appendNextToken( "then" )
else
appendNextToken( "else" )
end
formatStatlist(st.Body)
end
appendNextToken( "end" )
elseif statement.AstType == 'WhileStatement' then
appendNextToken( "while" )
formatExpr(statement.Condition)
appendNextToken( "do" )
formatStatlist(statement.Body)
appendNextToken( "end" )
elseif statement.AstType == 'DoStatement' then
appendNextToken( "do" )
formatStatlist(statement.Body)
appendNextToken( "end" )
elseif statement.AstType == 'ReturnStatement' then
appendNextToken( "return" )
if statement.TrailingWhite then out:appendStr(' ') end
for i = 1, #statement.Arguments do
formatExpr(statement.Arguments[i])
appendComma( i ~= #statement.Arguments )
end
elseif statement.AstType == 'BreakStatement' then
appendNextToken( "break" )
elseif statement.AstType == 'RepeatStatement' then
appendNextToken( "repeat" )
formatStatlist(statement.Body)
appendNextToken( "until" )
formatExpr(statement.Condition)
elseif statement.AstType == 'Function' then
if statement.IsLocal then
appendNextToken( "local" )
end
appendNextToken( "function" )
if statement.IsLocal then
appendStr(statement.Name.Name)
else
formatExpr(statement.Name)
end
appendNextToken( "(" )
if #statement.Arguments > 0 then
for i = 1, #statement.Arguments do
appendStr( statement.Arguments[i].Name )
appendComma( i ~= #statement.Arguments or statement.VarArg )
if i == #statement.Arguments and statement.VarArg then
appendNextToken( "..." )
end
end
elseif statement.VarArg then
appendNextToken( "..." )
end
appendNextToken( ")" )
formatStatlist(statement.Body)
appendNextToken( "end" )
elseif statement.AstType == 'GenericForStatement' then
appendNextToken( "for" )
for i = 1, #statement.VariableList do
appendStr( statement.VariableList[i].Name )
appendComma( i ~= #statement.VariableList )
end
appendNextToken( "in" )
for i = 1, #statement.Generators do
formatExpr(statement.Generators[i])
appendComma( i ~= #statement.Generators )
end
appendNextToken( "do" )
formatStatlist(statement.Body)
appendNextToken( "end" )
elseif statement.AstType == 'NumericForStatement' then
appendNextToken( "for" )
appendStr( statement.Variable.Name )
appendNextToken( "=" )
formatExpr(statement.Start)
appendNextToken( "," )
formatExpr(statement.End)
if statement.Step then
appendNextToken( "," )
formatExpr(statement.Step)
end
appendNextToken( "do" )
formatStatlist(statement.Body)
appendNextToken( "end" )
elseif statement.AstType == 'LabelStatement' then
appendNextToken( "::" )
appendStr( statement.Label )
appendNextToken( "::" )
elseif statement.AstType == 'GotoStatement' then
appendNextToken( "goto" )
appendStr( statement.Label )
elseif statement.AstType == 'Eof' then
appendWhite()
elseif statement.AstType == 'SemicolonStatement' then
else
error(string.format("Unknown AST Type: %s\n", tostring(statement.AstType)))
end
if statement.Semicolon then
appendNextToken(";")
end
assert(tok_it == #statement.Tokens + 1)
end
formatStatlist = function(statList)
for _, stat in ipairs(statList.Body) do
formatStatement(stat)
end
end
formatStatlist(ast)
return table.concat(out.rope)
end
local dirsep = package.config:sub(1,1)
local dirl65 = (string.match(arg[0], "(.*[\\/]).*") or ''):gsub('/',dirsep)
local searchl65 = ''
if #dirl65 > 0 then
searchl65 = string.format(";%s?;%s?.l65", dirl65, dirl65)
package.path = package.path .. string.format(";%s?.lua", dirl65)
end
l65_def = {
parse = ParseLua,
format = Format65,
searcher_index = 2,
search_path = string.format(".%s?;.%s?.l65%s", dirsep, dirsep, searchl65),
load_org = load,
loadfile_org = loadfile,
dofile_org = dofile,
}
if not l65 then l65 = l65_def else for k,v in pairs(l65_def) do l65[k]=v end end
l65.report = function(success, ...)
if success then return success,... end
local message=... io.stderr:write(tostring(message)..'\n')
os.exit(-1)
end
l65.msghandler = function(msg)
local o = function(s) io.stderr:write(s) end
msg = tostring(msg)
msg = msg:gsub('%[string "(.-%.l65)"%]', '%1') -- [string "xxx.l65"] -> xxx.l65
local trace_cur = debug.traceback(nil, 2)
trace_cur = trace_cur:gsub('%[string "(.-%.l65)"%]', '%1') -- [string "xxx.l65"] -> xxx.l65
trace_cur = trace_cur:gsub('stack traceback:', '')
local i=2
while debug.getinfo(i) do
local j = 1
while true do
local n,v = debug.getlocal(i, j)
if not n then break end
if n == 'l65dbg' then
o(string.format("%s\n", msg))
if trace_cur:find("in local 'late'") then
local lines = {}
for line in trace_cur:gmatch("[^\n]+") do
if line:find("in local 'late'") then break end
table.insert(lines, line)
end
o(table.concat(lines,'\n'))
end
local trace = v.trace:match(".-\n(.*)\n.-'xpcall'")
trace = trace:gsub('%[string "(.-%.l65)"%]', '%1')
trace = trace:gsub('stack traceback:', '')
o(trace .. '\n')
os.exit(-2)
end
j = j + 1
end
i = i + 1
end
trace_cur = trace_cur:match(".-\n(.*)\n.-'xpcall'")
o(string.format("%s\n%s\n", msg, trace_cur))
os.exit(-3)
end
do
local getembedded = type(arg[-1]) == 'function' and arg[-1]
l65.load_embedded = function(name)
if not getembedded then return end
local src,isl65 = getembedded(name)
if not src then return end
if isl65 then
name = name .. '.l65'
local st, ast = l65.report(l65.parse(src, name))
src = l65.format(ast)
else
name = name .. '.lua'
end
local bc = assert(l65.load_org(src, name))
return bc, name
end
end
l65.searcher = function(name)
local filename,err = package.searchpath(name, l65.search_path, '.', '.')
if not filename then return err end
local file = assert(io.open(filename, 'rb'))
local src = file:read('*a')
file:close()
local st, ast = l65.report(l65.parse(src, filename))
local bc = assert(l65.load_org(l65.format(ast), filename))
return bc, filename
end
l65.load = function(chunk, chunkname, mode, ...)
local chunk_t,s = type(chunk)
if chunk_t == 'string' then s = chunk
elseif chunk_t == 'function' then
s={} for x in chunk do if #x==0 then break end s[#s+1]=x end
s = table.concat(s)
else return nil, string.format("invalid type for chunk %s: %s", chunkname or "=(load)", chunk_t)
end
if s:sub(1,4) == "\x1bLua" then -- a binary file
return l65.load_org(s, chunkname, mode, ...)
end
local st, ast = l65.report(l65.parse(s, chunkname or "=(load)"))
return l65.load_org(l65.format(ast), chunkname, 't', ...)
end
l65.loadfile = function(filename, mode, ...)
local s
if not filename then s = io.read('*a')
else
local file = io.open(filename, 'rb')
if not file then return nil,"failed to open " .. filename .. " for reading" end
s = file:read('*a')
file:close()
end
return l65.load(s, filename, mode, ...)
end
l65.dofile = function(filename)
local f = l65.report(l65.loadfile(filename))
return f()
end
l65.installhooks = function()
if package.searchers[l65.searcher_index] ~= l65.searcher then
table.insert(package.searchers, l65.searcher_index, l65.searcher)
end
if not l65.hooks_installed then l65.hooks_installed = true
load = l65.load
loadfile = l65.loadfile
dofile = l65.dofile
end
end
l65.uninstallhooks = function()
for k,v in ipairs(package.searchers) do
if v == l65.searcher then table.remove(package.searchers, k) break end
end
if l65.hooks_installed then l65.hooks_installed = nil
load = l65.load_org
loadfile = l65.loadfile_org
dofile = l65.dofile_org
end
end
table.insert(package.searchers, l65.searcher_index, l65.load_embedded)
l65.installhooks()
function getopt(optstring, ...)
local opts = { }
local args = { ... }
for optc, optv in optstring:gmatch"(%a)(:?)" do
opts[optc] = { hasarg = optv == ":" }
end
return coroutine.wrap(function()
local yield = coroutine.yield
local i = 1
while i <= #args do
local arg,argi = args[i], i
i = i + 1
if arg == "--" then
break
elseif arg:sub(1, 1) == "-" then
for j = 2, #arg do
local opt = arg:sub(j, j)
if opts[opt] then
if opts[opt].hasarg then
if j == #arg then
if args[i] then yield(opt, args[i], argi) i=i+1
elseif optstring:sub(1, 1) == ":" then yield(':', opt, argi)
else yield('?', opt, argi) end
else yield(opt, arg:sub(j + 1), argi) end
break
else yield(opt, false, argi) end
else yield('?', opt, argi) end
end
else yield(false, arg, argi) end
end
for i = i, #args do yield(false, args[i], i) end
end)
end
local cfg=require"l65cfg" l65.cfg=cfg
local version = function()
print(string.format("l65 %s", cfg.version))
end
local usage = function(f)
if not f then f = io.stdout end
f:write(string.format([[
Usage: %s [options] file [args]
Options:
-d <file> Dump the Lua code after l65 parsing into file
-h Display this information
-v Display the release version
]], arg[0]))
end
local invalid_usage = function()
io.stderr:write("Invalid usage.\n")
usage(io.stderr)
end
local inf,dump,optix
for opt,arg,i in getopt("d:hv", ...) do
if opt == '?' then return invalid_usage() end
if opt == 'h' then return usage() end
if opt == 'v' then return version() end
if opt == 'd' then dump = arg end
if opt == false then inf=arg optix=i+1 break end
end
if not inf then return invalid_usage() end
if dump then l65.format = function(ast)
local s=Format65(ast) l65.format = Format65
local f = assert(io.open(dump, 'wb')) f:write(s) f:close()
return s
end end
local fn='' for i=#inf,1,-1 do local c=inf:sub(i,i) if c==dirsep or c=='/' then break end fn=c..fn if c=='.' then fn='' end end filename=fn
local f = l65.report(l65.loadfile(inf))
return xpcall(f, l65.msghandler, select(optix, ...))
| mit |
iremgokceyildirim/discourse_narrative_matching | vendor/cache/ruby/2.4.0/gems/message_bus-2.0.2/examples/bench/bench.lua | 5 | 1148 | -- wrk returns lots of read errors, this is unavoidable cause
--
-- 1. There is no internal implmentation of chunked encoding in wrk (which would be ideal)
--
-- 2. MessageBus gem does not provide http keepalive (by design), and can not provide content length
-- if MessageBus provided keepalive it would have to be able to redispatch the reqs to rack, something
-- that is not supported by the underlying rack hijack protocol, once a req is hijacked it can not be
-- returned
--
-- This leads to certain read errors while the bench runs cause wrk can not figure out cleanly that
-- MessageBus is done with a request
--
wrk.method = "POST"
wrk.body = ""
wrk.headers["Content-Type"] = "application/x-www-form-urlencoded"
-- chunking is not supported internally to wrk
wrk.headers["Dont-Chunk"] = "true"
wrk.headers["Connection"] = "Close"
request = function()
local hexdict = {48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102}
local randstr = {}
for i=1, 32 do
randstr[i] = hexdict[math.random(1, 16)]
end
local path = wrk.path .. "message-bus/" .. string.char(unpack(randstr)) .. "/poll"
return wrk.format(nil, path)
end
| gpl-2.0 |
Roblox/Core-Scripts | CoreScriptsRoot/Modules/Server/ServerChat/DefaultChatModules/TeamChat.lua | 2 | 6114 | -- // FileName: TeamChat.lua
-- // Written by: Xsitsu
-- // Description: Module that handles all team chat.
local Chat = game:GetService("Chat")
local ReplicatedModules = Chat:WaitForChild("ClientChatModules")
local ChatSettings = require(ReplicatedModules:WaitForChild("ChatSettings"))
local ChatConstants = require(ReplicatedModules:WaitForChild("ChatConstants"))
local ChatLocalization = nil
pcall(function() ChatLocalization = require(game:GetService("Chat").ClientChatModules.ChatLocalization) end)
if ChatLocalization == nil then ChatLocalization = {} function ChatLocalization:Get(key,default) return default end end
local errorTextColor = ChatSettings.ErrorMessageTextColor or Color3.fromRGB(245, 50, 50)
local errorExtraData = {ChatColor = errorTextColor}
local function Run(ChatService)
local Players = game:GetService("Players")
local channel = ChatService:AddChannel("Team")
channel.WelcomeMessage = ChatLocalization:Get("GameChat_TeamChat_WelcomeMessage","This is a private channel between you and your team members.")
channel.Joinable = false
channel.Leavable = false
channel.AutoJoin = false
channel.Private = true
local function TeamChatReplicationFunction(fromSpeaker, message, channelName)
local speakerObj = ChatService:GetSpeaker(fromSpeaker)
local channelObj = ChatService:GetChannel(channelName)
if (speakerObj and channelObj) then
local player = speakerObj:GetPlayer()
if (player) then
for i, speakerName in pairs(channelObj:GetSpeakerList()) do
local otherSpeaker = ChatService:GetSpeaker(speakerName)
if (otherSpeaker) then
local otherPlayer = otherSpeaker:GetPlayer()
if (otherPlayer) then
if (player.Team == otherPlayer.Team) then
local extraData = {
NameColor = player.TeamColor.Color,
ChatColor = player.TeamColor.Color,
ChannelColor = player.TeamColor.Color
}
otherSpeaker:SendMessage(message, channelName, fromSpeaker, extraData)
else
--// Could use this line to obfuscate message for cool effects
--otherSpeaker:SendMessage(message, channelName, fromSpeaker)
end
end
end
end
end
end
return true
end
channel:RegisterProcessCommandsFunction("replication_function", TeamChatReplicationFunction, ChatConstants.LowPriority)
local function DoTeamCommand(fromSpeaker, message, channel)
if message == nil then
message = ""
end
local speaker = ChatService:GetSpeaker(fromSpeaker)
if speaker then
local player = speaker:GetPlayer()
if player then
if player.Team == nil then
speaker:SendSystemMessage(ChatLocalization:Get("GameChat_TeamChat_CannotTeamChatIfNotInTeam","You cannot team chat if you are not on a team!"), channel, errorExtraData)
return
end
local channelObj = ChatService:GetChannel("Team")
if channelObj then
if not speaker:IsInChannel(channelObj.Name) then
speaker:JoinChannel(channelObj.Name)
end
if message and string.len(message) > 0 then
speaker:SayMessage(message, channelObj.Name)
end
speaker:SetMainChannel(channelObj.Name)
end
end
end
end
local function TeamCommandsFunction(fromSpeaker, message, channel)
local processedCommand = false
if message == nil then
error("Message is nil")
end
if channel == "Team" then
return false
end
if string.sub(message, 1, 6):lower() == "/team " or message:lower() == "/team" then
DoTeamCommand(fromSpeaker, string.sub(message, 7), channel)
processedCommand = true
elseif string.sub(message, 1, 3):lower() == "/t " or message:lower() == "/t" then
DoTeamCommand(fromSpeaker, string.sub(message, 4), channel)
processedCommand = true
elseif string.sub(message, 1, 2):lower() == "% " or message:lower() == "%" then
DoTeamCommand(fromSpeaker, string.sub(message, 3), channel)
processedCommand = true
end
return processedCommand
end
ChatService:RegisterProcessCommandsFunction("team_commands", TeamCommandsFunction, ChatConstants.StandardPriority)
local function GetDefaultChannelNameColor()
if ChatSettings.DefaultChannelNameColor then
return ChatSettings.DefaultChannelNameColor
end
return Color3.fromRGB(35, 76, 142)
end
local function PutSpeakerInCorrectTeamChatState(speakerObj, playerObj)
if playerObj.Neutral or playerObj.Team == nil then
speakerObj:UpdateChannelNameColor(channel.Name, GetDefaultChannelNameColor())
if speakerObj:IsInChannel(channel.Name) then
speakerObj:LeaveChannel(channel.Name)
end
elseif not playerObj.Neutral and playerObj.Team then
speakerObj:UpdateChannelNameColor(channel.Name, playerObj.Team.TeamColor.Color)
if not speakerObj:IsInChannel(channel.Name) then
speakerObj:JoinChannel(channel.Name)
end
end
end
ChatService.SpeakerAdded:connect(function(speakerName)
local speakerObj = ChatService:GetSpeaker(speakerName)
if speakerObj then
local player = speakerObj:GetPlayer()
if player then
PutSpeakerInCorrectTeamChatState(speakerObj, player)
end
end
end)
local PlayerChangedConnections = {}
Players.PlayerAdded:connect(function(player)
local changedConn = player.Changed:connect(function(property)
local speakerObj = ChatService:GetSpeaker(player.Name)
if speakerObj then
if property == "Neutral" then
PutSpeakerInCorrectTeamChatState(speakerObj, player)
elseif property == "Team" then
PutSpeakerInCorrectTeamChatState(speakerObj, player)
if speakerObj:IsInChannel(channel.Name) then
speakerObj:SendSystemMessage(
string.gsub(
ChatLocalization:Get(
"GameChat_TeamChat_NowInTeam",
string.format("You are now on the '%s' team.", player.Team.Name)
),
"{RBX_NAME}",player.Team.Name
),
channel.Name
)
end
end
end
end)
PlayerChangedConnections[player] = changedConn
end)
Players.PlayerRemoving:connect(function(player)
local changedConn = PlayerChangedConnections[player]
if changedConn then
changedConn:Disconnect()
end
PlayerChangedConnections[player] = nil
end)
end
return Run
| apache-2.0 |
kitala1/darkstar | scripts/zones/Port_Windurst/npcs/_6o6.lua | 20 | 1410 | -----------------------------------
-- Area: Port Windurst
-- NPC: Door: Departures Exit
-- @zone 240
-- @pos 218 -5 114
-----------------------------------
package.loaded["scripts/zones/Port_Windurst/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/zones/Port_Windurst/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if(player:hasKeyItem(AIRSHIP_PASS) == true and player:getGil() >= 200) then
player:startEvent(0x00b5,0,8,0,0,0,0,0,200);
else
player:startEvent(0x00b7,0,8);
end
return 1;
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if(csid == 0x00b5) then
X = player:getXPos();
if(X >= 221 and X <= 225) then
player:delGil(200);
end
end
end;
| gpl-3.0 |
fqrouter/luci | contrib/luadoc/lua/luadoc/config.lua | 165 | 1234 | -------------------------------------------------------------------------------
-- LuaDoc configuration file. This file contains the default options for
-- luadoc operation. These options can be overriden by the command line tool
-- @see luadoc.print_help
-- @release $Id: config.lua,v 1.6 2007/04/18 14:28:39 tomas Exp $
-------------------------------------------------------------------------------
module "luadoc.config"
-------------------------------------------------------------------------------
-- Default options
-- @class table
-- @name default_options
-- @field output_dir default output directory for generated documentation, used
-- by several doclets
-- @field taglet parser used to analyze source code input
-- @field doclet documentation generator
-- @field template_dir directory with documentation templates, used by the html
-- doclet
-- @field verbose command line tool configuration to output processing
-- information
local default_options = {
output_dir = "",
taglet = "luadoc.taglet.standard",
doclet = "luadoc.doclet.html",
-- TODO: find a way to define doclet specific options
template_dir = "luadoc/doclet/html/",
nomodules = false,
nofiles = false,
verbose = true,
}
return default_options
| apache-2.0 |
kitala1/darkstar | scripts/zones/Beaucedine_Glacier/npcs/Parledaire_RK.lua | 30 | 3067 | -----------------------------------
-- Area: Beaucedine Glacier
-- NPC: Parledaire, R.K.
-- Type: Conquest Overseer
-- @pos -24.351 -60.421 -114.215 111
-----------------------------------
package.loaded["scripts/zones/Beaucedine_Glacier/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/conquest");
require("scripts/zones/Beaucedine_Glacier/TextIDs");
local guardnation = SANDORIA; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno
local guardtype = 3; -- 1: city, 2: foreign, 3: outpost, 4: border
local region = FAUREGANDI;
local csid = 0x7ffb;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
tradeConquestGuard(player,npc,trade,guardnation,guardtype);
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:hasKeyItem(getSupplyKey(region)) and player:getNation() == guardnation) then
if (supplyRunFresh(player) == 1) then
player:startEvent(csid,16,0,0,0,1,0,0,255); -- you have brought us supplies !
else
player:showText(npc, CONQUEST - 1); -- "Hmm... These supplies you have brought us are too old to be of any use."
player:delKeyItem(getSupplyKey(region));
player:messageSpecial(KEYITEM_OBTAINED + 1, getSupplyKey(region));
player:setVar("supplyQuest_region",0);
end
else
local arg1 = getArg1(guardnation, player) - 1;
if (arg1 >= 1792) then -- foreign, non-allied
player:startEvent(csid,1808,0,0,0,0,player:getRank(),0,0);
else -- citizen or allied
player:startEvent(csid,arg1,0,0x3F0000,0,0,getArg6(player),0,0);
end
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("OPTION: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("OPTION: %u",option);
if (option == 1) then
local duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600;
player:delStatusEffect(EFFECT_SIGIL);
player:delStatusEffect(EFFECT_SANCTION);
player:delStatusEffect(EFFECT_SIGNET);
player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet
elseif (option == 2) then
player:delKeyItem(getSupplyKey(region));
player:addCP(supplyReward[region + 1])
player:messageSpecial(CONQUEST); -- "You've earned conquest points!"
if (hasOutpost(player, region+5) == 0) then
local supply_quests = 2^(region+5);
player:addNationTeleport(guardnation,supply_quests);
player:setVar("supplyQuest_region",0);
end
elseif (option == 4) then
if (player:delGil(giltosetHP(guardnation,player))) then
player:setHomePoint();
player:messageSpecial(CONQUEST + 94); -- "Your home point has been set."
else
player:messageSpecial(CONQUEST + 95); -- "You do not have enough gil to set your home point here."
end
end
end; | gpl-3.0 |
kitala1/darkstar | scripts/zones/Mount_Zhayolm/npcs/Bapokk.lua | 17 | 1458 | -----------------------------------
-- Area: Mount Zhayolm
-- NPC: Bapokk
-- Handles access to Alzadaal Ruins
-- @pos -20 -6 276 61
-----------------------------------
package.loaded["scripts/zones/Mount_Zhayolm/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Mount_Zhayolm/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if(trade:getItemCount() == 1 and trade:hasItemQty(2185,1)) then -- Silver
player:tradeComplete();
player:setPos(-20,-6,0,192); -- using the pos method until the problem below is fixed
-- player:startEvent(163); -- << this CS goes black at the end, never fades in
return 1;
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
-- Ruins -> Zhayolm
if(player:getZPos() > -280) then
player:startEvent(164);
-- Zhayolm -> Ruins
else
player:startEvent(162);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end; | gpl-3.0 |
kitala1/darkstar | scripts/globals/items/himesama_rice_ball.lua | 15 | 1754 | -----------------------------------------
-- ID: 5928
-- Item: Himesama Rice Ball
-- Food Effect: 30 Mins, All Races
-----------------------------------------
-- HP 25
-- Dexterity 4
-- Vitality 4
-- Character 4
-- Effect with enhancing equipment
-- Attack +60
-- Defense +40
-- Triple Attack 1
-----------------------------------------
require("scripts/globals/status");
require("scripts/globals/equipment");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,RiceBalls(target),0,1800,5928);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
local power = effect:getPower();
target:addMod(MOD_HP, 25);
target:addMod(MOD_DEX, 4);
target:addMod(MOD_VIT, 4);
target:addMod(MOD_CHR, 4);
target:addMod(MOD_ATT, 60*power);
target:addMod(MOD_DEF, 40*power);
target:addMod(MOD_TRIPLE_ATTACK,1*power);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
local power = effect:getPower();
target:delMod(MOD_HP, 25);
target:delMod(MOD_DEX, 4);
target:delMod(MOD_VIT, 4);
target:delMod(MOD_CHR, 4);
target:delMod(MOD_ATT, 60*power);
target:delMod(MOD_DEF, 40*power);
target:delMod(MOD_TRIPLE_ATTACK,1*power);
end;
| gpl-3.0 |
kitala1/darkstar | scripts/zones/Riverne-Site_B01/npcs/_0t2.lua | 19 | 1339 | -----------------------------------
-- Area: Riverne Site #B01
-- NPC: Unstable Displacement
-----------------------------------
package.loaded["scripts/zones/Riverne-Site_B01/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/Riverne-Site_B01/TextIDs");
-----------------------------------
-- onTrade
-----------------------------------
function onTrade(player,npc,trade)
if(trade:hasItemQty(1691,1) and trade:getItemCount() == 1) then -- Trade Giant Scale
player:tradeComplete();
npc:openDoor(RIVERNE_PORTERS);
player:messageSpecial(SD_HAS_GROWN);
end
end;
-----------------------------------
-- onTrigger
-----------------------------------
function onTrigger(player,npc)
if(npc:getAnimation() == 8) then
player:startEvent(0x16);
else
player:messageSpecial(SD_VERY_SMALL);
end;
return 1;
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end; | gpl-3.0 |
kitala1/darkstar | scripts/globals/mobskills/PW_Decussate.lua | 25 | 1030 | ---------------------------------------------
-- Decussate
--
-- Description: Performs a cross attack on nearby targets.
-- Type: Magical
-- Utsusemi/Blink absorb: 2-3 shadows?
-- Range: Less than or equal to 10.0
-- Notes: Only used by Gulool Ja Ja when below 35% health.
---------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------
function onMobSkillCheck(target,mob,skill)
local mobSkin = mob:getModelId();
if (mobSkin == 1863) then
return 0;
else
return 1;
end
end;
function onMobWeaponSkill(target, mob, skill)
local dmgmod = 1.2;
local info = MobMagicalMove(mob,target,skill,mob:getWeaponDmg()*3,ELE_EARTH,dmgmod,TP_NO_EFFECT);
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_MAGICAL,MOBPARAM_EARTH,math.random(2,3)*info.hitslanded);
target:delHP(dmg);
return dmg;
end;
| gpl-3.0 |
paulosalvatore/maruim_server | data/npc/lib/npcsystem/keywordhandler.lua | 1 | 6529 | if KeywordHandler == nil then
KeywordNode = {
keywords = nil,
callback = nil,
parameters = nil,
children = nil,
parent = nil,
condition = nil,
action = nil
}
-- Created a new keywordnode with the given keywords, callback function and parameters and without any childNodes.
function KeywordNode:new(keys, func, param, condition, action)
local obj = {}
obj.keywords = keys
obj.callback = func
obj.parameters = param
obj.children = {}
obj.condition = condition
obj.action = action
setmetatable(obj, self)
self.__index = self
return obj
end
-- Calls the underlying callback function if it is not nil.
function KeywordNode:processMessage(cid, message)
return (self.callback == nil or self.callback(cid, message, self.keywords, self.parameters, self))
end
-- Returns true if message contains all patterns/strings found in keywords.
function KeywordNode:checkMessage(cid, message)
if self.keywords.callback ~= nil then
local ret, data = self.keywords.callback(self.keywords, message)
if not ret then
return false
end
if self.condition and not self.condition(Player(cid), data) then
return false
end
return true
end
local data = {}
local last = 0
for i,v in ipairs(self.keywords) do
if type(v) == 'string' then
local a, b = string.find(message, v)
if a == nil or b == nil or a < last then
return false
end
if v:sub(1, 1) == '%' then
data[#data + 1] = tonumber(message:sub(a, b)) or nil
end
last = a
end
end
if self.condition and not self.condition(Player(cid), data) then
return false
end
return true
end
function KeywordNode:processAction(cid)
if not self.action then
return
end
local player = Player(cid)
if not player then
return
end
self.action(player, self.parameters.npcHandler)
end
-- Returns the parent of this node or nil if no such node exists.
function KeywordNode:getParent()
return self.parent
end
-- Returns an array of the callback function parameters assosiated with this node.
function KeywordNode:getParameters()
return self.parameters
end
-- Returns an array of the triggering keywords assosiated with this node.
function KeywordNode:getKeywords()
return self.keywords
end
-- Adds a childNode to this node. Creates the childNode based on the parameters (k = keywords, c = callback, p = parameters)
function KeywordNode:addChildKeyword(keywords, callback, parameters, condition, action)
local new = KeywordNode:new(keywords, callback, parameters, condition, action)
return self:addChildKeywordNode(new)
end
-- Adds multiples childNodes to this node.
function KeywordNode:addChildKeywords(keywords, callback, parameters, condition, action)
local ret = {}
for a, b in pairs(keywords) do
local add = self:addChildKeyword(b, callback, parameters, condition, action)
table.insert(ret, add)
end
return ret
end
-- Adds a pre-created childNode to this node. Should be used for example if several nodes should have a common child.
function KeywordNode:addChildKeywordNode(childNode)
self.children[#self.children + 1] = childNode
childNode.parent = self
return childNode
end
KeywordHandler = {
root = nil,
lastNode = nil
}
-- Creates a new keywordhandler with an empty rootnode.
function KeywordHandler:new()
local obj = {}
obj.root = KeywordNode:new(nil, nil, nil)
obj.lastNode = {}
setmetatable(obj, self)
self.__index = self
return obj
end
-- Resets the lastNode field, and this resetting the current position in the node hierarchy to root.
function KeywordHandler:reset(cid)
if self.lastNode[cid] then
self.lastNode[cid] = nil
end
end
-- Makes sure the correct childNode of lastNode gets a chance to process the message.
function KeywordHandler:processMessage(cid, message)
if message:find("-") then
message = message:gsub("-", " ")
end
local node = self:getLastNode(cid)
if node == nil then
print('No root node found.')
return false
end
local ret = self:processNodeMessage(node, cid, message)
if ret then
return true
end
if node:getParent() then
node = node:getParent() -- Search through the parent.
local ret = self:processNodeMessage(node, cid, message)
if ret then
return true
end
end
if node ~= self:getRoot() then
node = self:getRoot() -- Search through the root.
local ret = self:processNodeMessage(node, cid, message)
if ret then
return true
end
end
return false
end
-- Tries to process the given message using the node parameter's children and calls the node's callback function if found.
-- Returns the childNode which processed the message or nil if no such node was found.
function KeywordHandler:processNodeMessage(node, cid, message)
local messageLower = string.lower(message)
for i, childNode in pairs(node.children) do
if childNode:checkMessage(cid, messageLower) then
local oldLast = self.lastNode[cid]
self.lastNode[cid] = childNode
childNode.parent = node -- Make sure node is the parent of childNode (as one node can be parent to several nodes).
if childNode:processMessage(cid, message) then
childNode:processAction(cid)
return true
end
self.lastNode[cid] = oldLast
end
end
return false
end
-- Returns the root keywordnode
function KeywordHandler:getRoot()
return self.root
end
-- Returns the last processed keywordnode or root if no last node is found.
function KeywordHandler:getLastNode(cid)
return self.lastNode[cid] or self:getRoot()
end
-- Adds a new keyword to the root keywordnode. Returns the new node.
function KeywordHandler:addKeyword(keys, callback, parameters, condition, action)
return self:getRoot():addChildKeyword(keys, callback, parameters, condition, action)
end
-- Adds multiples new keywords to the root keywordnode.
function KeywordHandler:addKeywords(keys, callback, parameters, condition, action)
local ret = {}
for a, b in pairs(keys) do
local add = self:addKeyword(b, callback, parameters, condition, action)
table.insert(ret, add)
end
return ret
end
-- Moves the current position in the keyword hierarchy steps upwards. Steps defalut value = 1.
function KeywordHandler:moveUp(cid, steps)
if steps == nil or type(steps) ~= "number" then
steps = 1
end
for i = 1, steps do
if self.lastNode[cid] == nil then
return nil
end
self.lastNode[cid] = self.lastNode[cid]:getParent() or self:getRoot()
end
return self.lastNode[cid]
end
end
| gpl-2.0 |
kitala1/darkstar | scripts/globals/weaponskills/shark_bite.lua | 30 | 1459 | -----------------------------------
-- Shark Bite
-- Dagger weapon skill
-- Skill level: 225
-- Delivers a twofold attack. Damage varies with TP.
-- Will stack with Sneak Attack.
-- Will stack with Trick Attack.
-- Aligned with the Breeze Gorget & Thunder Gorget.
-- Aligned with the Breeze Belt & Thunder Belt.
-- Element: None
-- Modifiers: DEX:40% AGI:40%
-- 100%TP 200%TP 300%TP
-- 2.00 4 5.75
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID)
local params = {};
params.numHits = 2;
params.ftp100 = 2; params.ftp200 = 2.5; params.ftp300 = 3;
params.str_wsc = 0.0; params.dex_wsc = 0.5; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0;
params.canCrit = false;
params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0;
params.atkmulti = 1;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.ftp200 = 4; params.ftp300 = 5.75;
params.dex_wsc = 0.4; params.agi_wsc = 0.4;
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, params);
damage = damage * WEAPON_SKILL_POWER
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
fastmailops/prosody | tests/test_util_http.lua | 2 | 1726 | -- Prosody IM
-- Copyright (C) 2008-2010 Matthew Wild
-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
--
function urlencode(urlencode)
assert_equal(urlencode("helloworld123"), "helloworld123", "Normal characters not escaped");
assert_equal(urlencode("hello world"), "hello%20world", "Spaces escaped");
assert_equal(urlencode("This & that = something"), "This%20%26%20that%20%3d%20something", "Important URL chars escaped");
end
function urldecode(urldecode)
assert_equal("helloworld123", urldecode("helloworld123"), "Normal characters not escaped");
assert_equal("hello world", urldecode("hello%20world"), "Spaces escaped");
assert_equal("This & that = something", urldecode("This%20%26%20that%20%3d%20something"), "Important URL chars escaped");
assert_equal("This & that = something", urldecode("This%20%26%20that%20%3D%20something"), "Important URL chars escaped");
end
function formencode(formencode)
assert_equal(formencode({ { name = "one", value = "1"}, { name = "two", value = "2" } }), "one=1&two=2", "Form encoded");
assert_equal(formencode({ { name = "one two", value = "1"}, { name = "two one&", value = "2" } }), "one+two=1&two+one%26=2", "Form encoded");
end
function formdecode(formdecode)
local t = formdecode("one=1&two=2");
assert_table(t[1]);
assert_equal(t[1].name, "one"); assert_equal(t[1].value, "1");
assert_table(t[2]);
assert_equal(t[2].name, "two"); assert_equal(t[2].value, "2");
local t = formdecode("one+two=1&two+one%26=2");
assert_equal(t[1].name, "one two"); assert_equal(t[1].value, "1");
assert_equal(t[2].name, "two one&"); assert_equal(t[2].value, "2");
end
| mit |
kitala1/darkstar | scripts/globals/mobskills/Psychomancy.lua | 7 | 1125 | ---------------------------------------------------
-- Psychomancy
-- Steals MP from players in range.
-- Type: Magical
-- Utsusemi/Blink absorb: ignore shadow
---------------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------------
function onMobSkillCheck(target,mob,skill)
if (mob:AnimationSub() == 3) then
return 0;
end
return 1;
end;
function onMobWeaponSkill(target, mob, skill)
local dmgmod = 1;
local info = MobMagicalMove(mob,target,skill,mob:getWeaponDmg()*1.6,ELE_DARK,dmgmod,TP_MAB_BONUS,1);
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_MAGICAL,MOBPARAM_DARK,MOBPARAM_IGNORE_SHADOWS);
skill:setMsg(MSG_DRAIN_MP);
if(target:isUndead() == false) then
-- can't go over limited mp
if(target:getMP() < dmg) then
dmg = target:getMP();
end
target:delMP(dmg);
mob:addMP(dmg);
else
skill:setMsg(MSG_NO_EFFECT);
end
return dmg;
end;
| gpl-3.0 |
kitala1/darkstar | scripts/zones/Den_of_Rancor/npcs/Grounds_Tome.lua | 34 | 1136 | -----------------------------------
-- Area: Den of Rancor
-- NPC: Grounds Tome
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/groundsofvalor");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
startGov(GOV_EVENT_DEN_OF_RANCOR,player);
end;
-----------------------------------
-- onEventSelection
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
updateGov(player,csid,option,796,797,798,799,800,801,802,803,0,0);
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
finishGov(player,csid,option,796,797,798,799,800,801,802,803,0,0,GOV_MSG_DEN_OF_RANCOR);
end;
| gpl-3.0 |
kitala1/darkstar | scripts/zones/Apollyon/mobs/Gorynich.lua | 17 | 1399 | -----------------------------------
-- Area: Apollyon NW
-- NPC: Kaiser Behemoth
-----------------------------------
package.loaded["scripts/zones/Apollyon/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Apollyon/TextIDs");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob,killer)
local mobID = mob:getID();
-- print(mobID);
local mobX = mob:getXPos();
local mobY = mob:getYPos();
local mobZ = mob:getZPos();
if(mobID ==16932977)then -- recover
GetNPCByID(16932864+179):setPos(mobX,mobY,mobZ);
GetNPCByID(16932864+179):setStatus(STATUS_NORMAL);
elseif(mobID ==16932978)then -- timer 1
GetNPCByID(16932864+262):setPos(mobX,mobY,mobZ);
GetNPCByID(16932864+262):setStatus(STATUS_NORMAL);
elseif(mobID ==16932980)then -- timer 2
GetNPCByID(16932864+97):setPos(mobX,mobY,mobZ);
GetNPCByID(16932864+97):setStatus(STATUS_NORMAL);
elseif(mobID ==16932981)then -- timer 3
GetNPCByID(16932864+98):setPos(mobX,mobY,mobZ);
GetNPCByID(16932864+98):setStatus(STATUS_NORMAL);
end
end; | gpl-3.0 |
amiraga/amirbot-supergroups | plugins/groupmanager.lua | 24 | 7646 | do
local function add_by_reply(extra, success, result)
result = backward_msg_format(result)
local msg = result
local chat = msg.to.id
local user = msg.from.id
if msg.to.type == 'chat' then
chat_add_user('chat#id'..chat, 'user#id'..user, ok_cb, false)
elseif msg.to.type == 'channel' then
channel_invite_user('channel#id'..chat, 'user#id'..user, ok_cb, false)
end
end
local function add_by_username(cb_extra, success, result)
local chat_type = cb_extra.chat_type
local chat_id = cb_extra.chat_id
local user_id = result.peer_id
local user_username = result.username
print(chat_id)
if chat_type == 'chat' then
chat_add_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, false)
elseif chat_type == 'channel' then
channel_invite_user('channel#id'..chat_id, 'user#id'..user_id, ok_cb, false)
end
end
local function kick_user(user_id, chat_id)
local chat = 'chat#id'..chat_id
local user = 'user#id'..user_id
local channel = 'channel#id'..chat_id
if user_id == tostring(our_id) then
print("I won't kick myself!")
else
chat_del_user(chat, user, ok_cb, true)
channel_kick_user(channel, user, ok_cb, true)
end
end
local function chat_kick(extra, success, result)
result = backward_msg_format(result)
local msg = result
local chat = msg.to.id
local user = msg.from.id
local chat_type = msg.to.type
if chat_type == 'chat' then
chat_del_user('chat#id'..chat, 'user#id'..user, ok_cb, false)
elseif chat_type == 'channel' then
channel_kick_user('channel#id'..chat, 'user#id'..user, ok_cb, false)
end
end
local function kick_by_username(cb_extra, success, result)
chat_id = cb_extra.chat_id
user_id = result.peer_id
chat_type = cb_extra.chat_type
user_username = result.username
if chat_type == 'chat' then
chat_del_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, false)
elseif chat_type == 'channel' then
channel_kick_user('channel#id'..chat_id, 'user#id'..user_id, ok_cb, false)
end
end
local function run(msg, matches)
if matches[1] == 'setname' then
if permissions(msg.from.id, msg.to.id, "settings") then
local hash = 'name:enabled:'..msg.to.id
if not redis:get(hash) then
if msg.to.type == 'chat' then
rename_chat(msg.to.peer_id, matches[2], ok_cb, false)
elseif msg.to.type == 'channel' then
rename_channel(msg.to.peer_id, matches[2], ok_cb, false)
end
end
return
end
elseif matches[1] == 'newlink' then
if permissions(msg.from.id, msg.to.id, "setlink") then
local receiver = get_receiver(msg)
local hash = 'link:'..msg.to.id
local function cb(extra, success, result)
if result then
redis:set(hash, result)
end
if success == 0 then
return send_large_msg(receiver, 'Error*\nnewlink not saved\nYou are not the group administrator', ok_cb, true)
end
end
if msg.to.type == 'chat' then
result = export_chat_link(receiver, cb, true)
elseif msg.to.type == 'channel' then
result = export_channel_link(receiver, cb, true)
end
if result then
if msg.to.type == 'chat' then
send_msg('chat#id'..msg.to.id, 'New link created', ok_cb, true)
elseif msg.to.type == 'channel' then
send_msg('channel#id'..msg.to.id, 'New link created', ok_cb, true)
end
end
return
else
return '?? '..lang_text(msg.to.id, 'require_admin')
end
elseif matches[1] == 'link' then
if permissions(msg.from.id, msg.to.id, "link") then
hash = 'link:'..msg.to.id
local linktext = redis:get(hash)
if linktext then
if msg.to.type == 'chat' then
send_msg('user#id'..msg.from.id, 'Group Link :'..linktext, ok_cb, true)
elseif msg.to.type == 'channel' then
send_msg('user#id'..msg.from.id, 'SuperGroup Link :'..linktext, ok_cb, true)
end
return 'Link was sent in your pv'
else
if msg.to.type == 'chat' then
send_msg('chat#id'..msg.to.id, 'Error*\nplease send #newlink', ok_cb, true)
elseif msg.to.type == 'channel' then
send_msg('channel#id'..msg.to.id, 'Error*\nplease send #newlink', ok_cb, true)
end
end
return
end
elseif matches[1] == 'tosuper' then
if msg.to.type == 'chat' then
if permissions(msg.from.id, msg.to.id, "tosupergroup") then
chat_upgrade('chat#id'..msg.to.id, ok_cb, false)
return 'Chat Upgraded Successfully.'
end
else
return 'Error !'
end
elseif matches[1] == 'rmv' then
if permissions(msg.from.id, msg.to.id, "kick") then
local chat_id = msg.to.id
local chat_type = msg.to.type
if msg.reply_id then
get_message(msg.reply_id, chat_kick, false)
return
end
if not is_id(matches[2]) then
local member = string.gsub(matches[2], '@', '')
resolve_username(member, kick_by_username, {chat_id=chat_id, member=member, chat_type=chat_type})
return
else
local user_id = matches[2]
if msg.to.type == 'chat' then
chat_del_user('chat#id'..msg.to.id, 'user#id'..matches[2], ok_cb, false)
elseif msg.to.type == 'channel' then
channel_kick_user('channel#id'..msg.to.id, 'user#id'..matches[2], ok_cb, false)
end
end
end
elseif matches[1] == 'add' then
if permissions(msg.from.id, msg.to.id, "add") then
local chat_id = msg.to.id
local chat_type = msg.to.type
if msg.reply_id then
get_message(msg.reply_id, add_by_reply, false)
return
end
if not is_id(matches[2]) then
local member = string.gsub(matches[2], '@', '')
print(chat_id)
resolve_username(member, add_by_username, {chat_id=chat_id, member=member, chat_type=chat_type})
return
else
local user_id = matches[2]
if chat_type == 'chat' then
chat_add_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, false)
elseif chat_type == 'channel' then
channel_invite_user('channel#id'..chat_id, 'user#id'..user_id, ok_cb, false)
end
end
end
elseif matches[1] == 'setdes' then
if permissions(msg.from.id, msg.to.id, "description") then
local text = matches[2]
local chat = 'channel#id'..msg.to.id
if msg.to.type == 'channel' then
channel_set_about(chat, text, ok_cb, false)
return 'changed.'
end
end
end
end
return {
patterns = {
'^#(setname) (.*)$',
'^#(link)$',
'^#(newlink)$',
'^#(tosuper)$',
'^#(setdes) (.*)$',
"^#(rmv)$",
"^#(rmv) (.*)$",
"^#(add)$",
"^#(add) (.*)$",
},
run = run
}
end
| gpl-2.0 |
kitala1/darkstar | scripts/globals/items/loaf_of_hobgoblin_bread.lua | 35 | 1378 | -----------------------------------------
-- ID: 4328
-- Item: loaf_of_hobgoblin_bread
-- Food Effect: 60Min, All Races
-----------------------------------------
-- Health 10
-- Vitality 3
-- Charisma -7
-- Health Regen While Healing 2
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,3600,4328);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 10);
target:addMod(MOD_VIT, 3);
target:addMod(MOD_CHR, -7);
target:addMod(MOD_HPHEAL, 2);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 10);
target:delMod(MOD_VIT, 3);
target:delMod(MOD_CHR, -7);
target:delMod(MOD_HPHEAL, 2);
end;
| gpl-3.0 |
kitala1/darkstar | scripts/zones/Windurst_Woods/npcs/Soni-Muni.lua | 34 | 2634 | -----------------------------------
-- Area: Windurst Woods
-- NPC: Soni-Muni
-- Starts & Finishes Quest: The Amazin' Scorpio
-- @pos -17.073 1.749 -59.327 241
-----------------------------------
package.loaded["scripts/zones/Windurst_Woods/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/zones/Windurst_Woods/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
local AmazinScorpio = player:getQuestStatus(WINDURST,THE_AMAZIN_SCORPIO);
if (AmazinScorpio == QUEST_ACCEPTED) then
local count = trade:getItemCount();
local ScorpionStinger = trade:hasItemQty(1017,1);
if (ScorpionStinger == true and count == 1) then
player:startEvent(0x01e4);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local AmazinScorpio = player:getQuestStatus(WINDURST,THE_AMAZIN_SCORPIO);
local Fame = player:getFameLevel(WINDURST);
local WildcatWindurst = player:getVar("WildcatWindurst");
if (player:getQuestStatus(WINDURST,LURE_OF_THE_WILDCAT_WINDURST) == QUEST_ACCEPTED and player:getMaskBit(WildcatWindurst,0) == false) then
player:startEvent(0x02df);
elseif (AmazinScorpio == QUEST_COMPLETED) then
player:startEvent(0x01e5);
elseif (AmazinScorpio == QUEST_ACCEPTED) then
player:startEvent(0x01e2,0,0,1017);
elseif (AmazinScorpio == QUEST_AVAILABLE and Fame >= 2) then
player:startEvent(0x01e1,0,0,1017);
else
player:startEvent(0x01a5);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x01e1) then
player:addQuest(WINDURST,THE_AMAZIN_SCORPIO);
elseif (csid == 0x01e4) then
player:completeQuest(WINDURST,THE_AMAZIN_SCORPIO);
player:addFame(WINDURST,WIN_FAME*80);
player:addTitle(GREAT_GRAPPLER_SCORPIO);
player:addGil(GIL_RATE*1500);
player:messageSpecial(GIL_OBTAINED,GIL_RATE*1500);
player:tradeComplete();
elseif (csid == 0x02df) then
player:setMaskBit(player:getVar("WildcatWindurst"),"WildcatWindurst",0,true);
end
end;
| gpl-3.0 |
kitala1/darkstar | scripts/globals/effects/aftermath_lv2.lua | 17 | 1393 | -----------------------------------
--
-- EFFECT_AFTERMATH_LV2
--
-----------------------------------
require("scripts/globals/status");
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
local power = effect:getPower();
if(effect:getSubPower() == 1) then
target:addMod(MOD_ATT,power);
elseif(effect:getSubPower() == 2) then
target:addMod(MOD_ACC,power)
elseif(effect:getSubPower() == 3) then
target:addMod(MOD_MATT,power)
elseif(effect:getSubPower() == 4) then
target:addMod(MOD_RATT,power)
elseif(effect:getSubPower() == 5) then
target:addMod(MOD_MACC,power)
end
end;
-----------------------------------
-- onEffectTick Action
-----------------------------------
function onEffectTick(target,effect)
end;
-----------------------------------
-- onEffectLose Action
-----------------------------------
function onEffectLose(target,effect)
local power = effect:getPower();
if(effect:getSubPower() == 1) then
target:delMod(MOD_ATT,power);
elseif(effect:getSubPower() == 2) then
target:delMod(MOD_ACC,power)
elseif(effect:getSubPower() == 3) then
target:delMod(MOD_RACC,power)
elseif(effect:getSubPower() == 4) then
target:delMod(MOD_RATT,power)
elseif(effect:getSubPower() == 5) then
target:delMod(MOD_MACC,power)
end
end; | gpl-3.0 |
hwsyy/Atlas | lib/proxy/commands.lua | 43 | 3477 | --[[ $%BEGINLICENSE%$
Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; version 2 of the
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
$%ENDLICENSE%$ --]]
module("proxy.commands", package.seeall)
---
-- map the constants to strings
-- lua starts at 1
local command_names = {
"COM_SLEEP",
"COM_QUIT",
"COM_INIT_DB",
"COM_QUERY",
"COM_FIELD_LIST",
"COM_CREATE_DB",
"COM_DROP_DB",
"COM_REFRESH",
"COM_SHUTDOWN",
"COM_STATISTICS",
"COM_PROCESS_INFO",
"COM_CONNECT",
"COM_PROCESS_KILL",
"COM_DEBUG",
"COM_PING",
"COM_TIME",
"COM_DELAYED_INSERT",
"COM_CHANGE_USER",
"COM_BINLOG_DUMP",
"COM_TABLE_DUMP",
"COM_CONNECT_OUT",
"COM_REGISTER_SLAVE",
"COM_STMT_PREPARE",
"COM_STMT_EXECUTE",
"COM_STMT_SEND_LONG_DATA",
"COM_STMT_CLOSE",
"COM_STMT_RESET",
"COM_SET_OPTION",
"COM_STMT_FETCH",
"COM_DAEMON"
}
---
-- split a MySQL command packet into its parts
--
-- @param packet a network packet
-- @return a table with .type, .type_name and command specific fields
function parse(packet)
local cmd = {}
cmd.type = packet:byte()
cmd.type_name = command_names[cmd.type + 1]
if cmd.type == proxy.COM_QUERY then
cmd.query = packet:sub(2)
elseif cmd.type == proxy.COM_QUIT or
cmd.type == proxy.COM_PING or
cmd.type == proxy.COM_SHUTDOWN then
-- nothing to decode
elseif cmd.type == proxy.COM_STMT_PREPARE then
cmd.query = packet:sub(2)
-- the stmt_handler_id is at the same position for both STMT_EXECUTE and STMT_CLOSE
elseif cmd.type == proxy.COM_STMT_EXECUTE or cmd.type == proxy.COM_STMT_CLOSE then
cmd.stmt_handler_id = string.byte(packet, 2) + (string.byte(packet, 3) * 256) + (string.byte(packet, 4) * 256 * 256) + (string.byte(packet, 5) * 256 * 256 * 256)
elseif cmd.type == proxy.COM_FIELD_LIST then
cmd.table = packet:sub(2)
elseif cmd.type == proxy.COM_INIT_DB or
cmd.type == proxy.COM_CREATE_DB or
cmd.type == proxy.COM_DROP_DB then
cmd.schema = packet:sub(2)
elseif cmd.type == proxy.COM_SET_OPTION then
cmd.option = packet:sub(2)
else
print("[debug] (command) unhandled type name:" .. tostring(cmd.type_name) .. " byte:" .. tostring(cmd.type))
end
return cmd
end
function pretty_print(cmd)
if cmd.type == proxy.COM_QUERY or
cmd.type == proxy.COM_STMT_PREPARE then
return ("[%s] %s"):format(cmd.type_name, cmd.query)
elseif cmd.type == proxy.COM_INIT_DB then
return ("[%s] %s"):format(cmd.type_name, cmd.schema)
elseif cmd.type == proxy.COM_QUIT or
cmd.type == proxy.COM_PING or
cmd.type == proxy.COM_SHUTDOWN then
return ("[%s]"):format(cmd.type_name)
elseif cmd.type == proxy.COM_FIELD_LIST then
-- should have a table-name
return ("[%s]"):format(cmd.type_name)
elseif cmd.type == proxy.COM_STMT_EXECUTE then
return ("[%s] %s"):format(cmd.type_name, cmd.stmt_handler_id)
end
return ("[%s] ... no idea"):format(cmd.type_name)
end
| gpl-2.0 |
kitala1/darkstar | scripts/globals/spells/cure_iii.lua | 13 | 3821 | -----------------------------------------
-- Spell: Cure III
-- Restores target's HP.
-- Shamelessly stolen from http://members.shaw.ca/pizza_steve/cure/Cure_Calculator.html
-----------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
local divisor = 0;
local constant = 0;
local basepower = 0;
local power = 0;
local basecure = 0;
local final = 0;
local minCure = 130;
if(USE_OLD_CURE_FORMULA == true) then
power = getCurePowerOld(caster);
rate = 1;
constant = 70;
if(power > 300) then
rate = 15.6666;
constant = 180.43;
elseif(power > 180) then
rate = 2;
constant = 115;
end
else
power = getCurePower(caster);
if(power < 125) then
divisor = 2.2
constant = 130;
basepower = 70;
elseif(power < 200) then
divisor = 75/65;
constant = 155;
basepower = 125;
elseif(power < 300) then
divisor = 2.5;
constant = 220;
basepower = 200;
elseif(power < 700) then
divisor = 5;
constant = 260;
basepower = 300;
else
divisor = 999999;
constant = 340;
basepower = 0;
end
end
if(target:getAllegiance() == caster:getAllegiance() and (target:getObjType() == TYPE_PC or target:getObjType() == TYPE_MOB)) then
if(USE_OLD_CURE_FORMULA == true) then
basecure = getBaseCure(power,divisor,constant);
else
basecure = getBaseCure(power,divisor,constant,basepower);
end
final = getCureFinal(caster,spell,basecure,minCure,false);
if(caster:hasStatusEffect(EFFECT_AFFLATUS_SOLACE) and target:hasStatusEffect(EFFECT_STONESKIN) == false) then
local solaceStoneskin = 0;
local equippedBody = caster:getEquipID(SLOT_BODY);
if(equippedBody == 11186) then
solaceStoneskin = math.floor(final * 0.30);
elseif(equippedBody == 11086) then
solaceStoneskin = math.floor(final * 0.35);
else
solaceStoneskin = math.floor(final * 0.25);
end
target:addStatusEffect(EFFECT_STONESKIN,solaceStoneskin,0,25);
end;
final = final + (final * (target:getMod(MOD_CURE_POTENCY_RCVD)/100));
--Applying server mods....
final = final * CURE_POWER;
local diff = (target:getMaxHP() - target:getHP());
if(final > diff) then
final = diff;
end
target:addHP(final);
target:wakeUp();
caster:updateEnmityFromCure(target,final);
else
if(target:isUndead()) then
spell:setMsg(2);
local dmg = calculateMagicDamage(minCure,1,caster,spell,target,HEALING_MAGIC_SKILL,MOD_MND,false)*0.5;
local resist = applyResistance(caster,spell,target,caster:getStat(MOD_MND)-target:getStat(MOD_MND),HEALING_MAGIC_SKILL,1.0);
dmg = dmg*resist;
dmg = addBonuses(caster,spell,target,dmg);
dmg = adjustForTarget(target,dmg,spell:getElement());
dmg = finalMagicAdjustments(caster,target,spell,dmg);
final = dmg;
target:delHP(final);
target:updateEnmityFromDamage(caster,final);
elseif(caster:getObjType() == TYPE_PC) then
spell:setMsg(75);
else
-- e.g. monsters healing themselves.
if(USE_OLD_CURE_FORMULA == true) then
basecure = getBaseCureOld(power,divisor,constant);
else
basecure = getBaseCure(power,divisor,constant,basepower);
end
final = getCureFinal(caster,spell,basecure,minCure,false);
local diff = (target:getMaxHP() - target:getHP());
if(final > diff) then
final = diff;
end
target:addHP(final);
end
end
return final;
end; | gpl-3.0 |
shahabsaf1/uzz-bot | plugins/weather.lua | 351 | 1443 | do
local BASE_URL = "http://api.openweathermap.org/data/2.5/weather"
local function get_weather(location)
print("Finding weather in ", location)
local url = BASE_URL
url = url..'?q='..location
url = url..'&units=metric'
local b, c, h = http.request(url)
if c ~= 200 then return nil end
local weather = json:decode(b)
local city = weather.name
local country = weather.sys.country
local temp = 'The temperature in '..city
..' (' ..country..')'
..' is '..weather.main.temp..'°C'
local conditions = 'Current conditions are: '
.. weather.weather[1].description
if weather.weather[1].main == 'Clear' then
conditions = conditions .. ' ☀'
elseif weather.weather[1].main == 'Clouds' then
conditions = conditions .. ' ☁☁'
elseif weather.weather[1].main == 'Rain' then
conditions = conditions .. ' ☔'
elseif weather.weather[1].main == 'Thunderstorm' then
conditions = conditions .. ' ☔☔☔☔'
end
return temp .. '\n' .. conditions
end
local function run(msg, matches)
local city = 'Yogyakarta'
if matches[1] ~= '!weather' then
city = matches[1]
end
local text = get_weather(city)
if not text then
text = 'Can\'t get weather from that city.'
end
return text
end
return {
description = "weather in that city (Yogyakarta is default)",
usage = "!weather (city)",
patterns = {
"^!weather$",
"^!weather (.*)$"
},
run = run
}
end | gpl-2.0 |
kitala1/darkstar | scripts/zones/Windurst_Waters/npcs/Jatan-Paratan.lua | 36 | 3239 | -----------------------------------
-- Area: Windurst Waters
-- NPC: Jatan-Paratan
-- Starts and Finished Quest: Wondering Minstrel
-- Working 100%
-- @zone = 238
-- @pos = -59 -4 22
-----------------------------------
package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/zones/Windurst_Waters/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
wonderingstatus = player:getQuestStatus(WINDURST,WONDERING_MINSTREL);
if (wonderingstatus == 1 and trade:hasItemQty(718,1) == true and trade:getItemCount() == 1 and player:getVar("QuestWonderingMin_var") == 1) then
player:startEvent(0x027e); -- WONDERING_MINSTREL: Quest Finish
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
-- player:delQuest(WINDURST,WONDERING_MINSTREL);
wonderingstatus = player:getQuestStatus(WINDURST,WONDERING_MINSTREL);
fame = player:getFameLevel(WINDURST)
if (wonderingstatus == QUEST_AVAILABLE and fame >= 5) then
rand = math.random(1,2);
if (rand == 1) then
player:startEvent(0x0279); -- WONDERING_MINSTREL: Before Quest
else
player:startEvent(0x027a); -- WONDERING_MINSTREL: Quest Start
end
elseif (wonderingstatus == QUEST_ACCEPTED) then
player:startEvent(0x027b); -- WONDERING_MINSTREL: During Quest
elseif (wonderingstatus == QUEST_COMPLETED and player:needToZone()) then
player:startEvent(0x027f); -- WONDERING_MINSTREL: After Quest
else
hour = VanadielHour();
if (hour >= 18 or hour <= 6) then
player:startEvent(0x0263); -- Singing 1 (daytime < 6 or daytime >= 18)
else
rand = math.random(1,2);
if (rand == 1) then
player:startEvent(0x0262); -- Standard Conversation 1 (daytime)
else
player:startEvent(0x0267); -- Standard Conversation 2 (daytime)
end
end
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x027a) then -- WONDERING_MINSTREL: Quest Start
player:addQuest(WINDURST,WONDERING_MINSTREL);
elseif (csid == 0x027e) then -- WONDERING_MINSTREL: Quest Finish
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,17349);
else
player:tradeComplete(trade);
player:completeQuest(WINDURST,WONDERING_MINSTREL)
player:addItem(17349);
player:messageSpecial(ITEM_OBTAINED,17349);
player:addFame(WINDURST,WIN_FAME*75);
player:addTitle(DOWN_PIPER_PIPEUPPERER);
player:needToZone(true);
player:setVar("QuestWonderingMin_var",0);
end
end
end;
| gpl-3.0 |
kitala1/darkstar | scripts/globals/spells/curaga_ii.lua | 13 | 1215 | -----------------------------------------
-- Spell: Curaga II
-- Restores HP of all party members within area of effect.
-----------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
local minCure = 130;
local divisor = 1;
local constant = 70;
local power = getCurePowerOld(caster);
if(power > 300) then
divisor = 15.6666;
constant = 180.43;
elseif(power > 180) then
divisor = 2;
constant = 115;
end
local final = getCureFinal(caster,spell,getBaseCureOld(power,divisor,constant),minCure,false);
final = final + (final * (target:getMod(MOD_CURE_POTENCY_RCVD)/100));
--Applying server mods....
final = final * CURE_POWER;
local diff = (target:getMaxHP() - target:getHP());
if(final > diff) then
final = diff;
end
target:addHP(final);
target:wakeUp();
caster:updateEnmityFromCure(target,final);
spell:setMsg(367);
return final;
end; | gpl-3.0 |
kitala1/darkstar | scripts/zones/Pashhow_Marshlands/npcs/Stone_Monument.lua | 32 | 1300 | -----------------------------------
-- Area: Pashhow Marshlands
-- NPC: Stone Monument
-- Involved in quest "An Explorer's Footsteps"
-- @pos -300.672 21.620 304.179 109
-----------------------------------
package.loaded["scripts/zones/Pashhow_Marshlands/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Pashhow_Marshlands/TextIDs");
-----------------------------------
-- onTrigger
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x0384);
end;
-----------------------------------
-- onTrade
-----------------------------------
function onTrade(player,npc,trade)
if (trade:getItemCount() == 1 and trade:hasItemQty(571,1)) then
player:tradeComplete();
player:addItem(570);
player:messageSpecial(ITEM_OBTAINED,570);
player:setVar("anExplorer-CurrentTablet",0x00100);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end; | gpl-3.0 |
hassanhp/TOPNOB | plugins/invite.lua | 393 | 1225 | do
local function callbackres(extra, success, result) -- Callback for res_user in line 27
local user = 'user#id'..result.id
local chat = 'chat#id'..extra.chatid
if is_banned(result.id, extra.chatid) then -- Ignore bans
send_large_msg(chat, 'User is banned.')
elseif is_gbanned(result.id) then -- Ignore globall bans
send_large_msg(chat, 'User is globaly banned.')
else
chat_add_user(chat, user, ok_cb, false) -- Add user on chat
end
end
function run(msg, matches)
local data = load_data(_config.moderation.data)
if not is_realm(msg) then
if data[tostring(msg.to.id)] and data[tostring(msg.to.id)]['settings']['lock_member'] == 'yes' and not is_admin(msg) then
return 'Group is private.'
end
end
if msg.to.type ~= 'chat' then
return
end
if not is_momod(msg) then
return
end
--if not is_admin(msg) then -- For admins only !
--return 'Only admins can invite.'
--end
local cbres_extra = {chatid = msg.to.id}
local username = matches[1]
local username = username:gsub("@","")
res_user(username, callbackres, cbres_extra)
end
return {
patterns = {
"^[!/]invite (.*)$"
},
run = run
}
end
| gpl-2.0 |
ioiasff/DSA | plugins/invite.lua | 393 | 1225 | do
local function callbackres(extra, success, result) -- Callback for res_user in line 27
local user = 'user#id'..result.id
local chat = 'chat#id'..extra.chatid
if is_banned(result.id, extra.chatid) then -- Ignore bans
send_large_msg(chat, 'User is banned.')
elseif is_gbanned(result.id) then -- Ignore globall bans
send_large_msg(chat, 'User is globaly banned.')
else
chat_add_user(chat, user, ok_cb, false) -- Add user on chat
end
end
function run(msg, matches)
local data = load_data(_config.moderation.data)
if not is_realm(msg) then
if data[tostring(msg.to.id)] and data[tostring(msg.to.id)]['settings']['lock_member'] == 'yes' and not is_admin(msg) then
return 'Group is private.'
end
end
if msg.to.type ~= 'chat' then
return
end
if not is_momod(msg) then
return
end
--if not is_admin(msg) then -- For admins only !
--return 'Only admins can invite.'
--end
local cbres_extra = {chatid = msg.to.id}
local username = matches[1]
local username = username:gsub("@","")
res_user(username, callbackres, cbres_extra)
end
return {
patterns = {
"^[!/]invite (.*)$"
},
run = run
}
end
| gpl-2.0 |
Pulse-Eight/drivers | Control4/sky_hd_ip_pulse-eight/lib/json.lua | 9 | 34857 | -- -*- coding: utf-8 -*-
--
-- Simple JSON encoding and decoding in pure Lua.
--
-- Copyright 2010-2014 Jeffrey Friedl
-- http://regex.info/blog/
--
-- Latest version: http://regex.info/blog/lua/json
--
-- This code is released under a Creative Commons CC-BY "Attribution" License:
-- http://creativecommons.org/licenses/by/3.0/deed.en_US
--
-- It can be used for any purpose so long as the copyright notice above,
-- the web-page links above, and the 'AUTHOR_NOTE' string below are
-- maintained. Enjoy.
--
local VERSION = 20141223.14 -- version history at end of file
local AUTHOR_NOTE = "-[ JSON.lua package by Jeffrey Friedl (http://regex.info/blog/lua/json) version 20141223.14 ]-"
--
-- The 'AUTHOR_NOTE' variable exists so that information about the source
-- of the package is maintained even in compiled versions. It's also
-- included in OBJDEF below mostly to quiet warnings about unused variables.
--
local OBJDEF = {
VERSION = VERSION,
AUTHOR_NOTE = AUTHOR_NOTE,
}
JSON = OBJDEF
--
-- Simple JSON encoding and decoding in pure Lua.
-- http://www.json.org/
--
--
-- JSON = assert(loadfile "JSON.lua")() -- one-time load of the routines
--
-- local lua_value = JSON:decode(raw_json_text)
--
-- local raw_json_text = JSON:encode(lua_table_or_value)
-- local pretty_json_text = JSON:encode_pretty(lua_table_or_value) -- "pretty printed" version for human readability
--
--
--
-- DECODING (from a JSON string to a Lua table)
--
--
-- JSON = assert(loadfile "JSON.lua")() -- one-time load of the routines
--
-- local lua_value = JSON:decode(raw_json_text)
--
-- If the JSON text is for an object or an array, e.g.
-- { "what": "books", "count": 3 }
-- or
-- [ "Larry", "Curly", "Moe" ]
--
-- the result is a Lua table, e.g.
-- { what = "books", count = 3 }
-- or
-- { "Larry", "Curly", "Moe" }
--
--
-- The encode and decode routines accept an optional second argument,
-- "etc", which is not used during encoding or decoding, but upon error
-- is passed along to error handlers. It can be of any type (including nil).
--
--
--
-- ERROR HANDLING
--
-- With most errors during decoding, this code calls
--
-- JSON:onDecodeError(message, text, location, etc)
--
-- with a message about the error, and if known, the JSON text being
-- parsed and the byte count where the problem was discovered. You can
-- replace the default JSON:onDecodeError() with your own function.
--
-- The default onDecodeError() merely augments the message with data
-- about the text and the location if known (and if a second 'etc'
-- argument had been provided to decode(), its value is tacked onto the
-- message as well), and then calls JSON.assert(), which itself defaults
-- to Lua's built-in assert(), and can also be overridden.
--
-- For example, in an Adobe Lightroom plugin, you might use something like
--
-- function JSON:onDecodeError(message, text, location, etc)
-- LrErrors.throwUserError("Internal Error: invalid JSON data")
-- end
--
-- or even just
--
-- function JSON.assert(message)
-- LrErrors.throwUserError("Internal Error: " .. message)
-- end
--
-- If JSON:decode() is passed a nil, this is called instead:
--
-- JSON:onDecodeOfNilError(message, nil, nil, etc)
--
-- and if JSON:decode() is passed HTML instead of JSON, this is called:
--
-- JSON:onDecodeOfHTMLError(message, text, nil, etc)
--
-- The use of the fourth 'etc' argument allows stronger coordination
-- between decoding and error reporting, especially when you provide your
-- own error-handling routines. Continuing with the the Adobe Lightroom
-- plugin example:
--
-- function JSON:onDecodeError(message, text, location, etc)
-- local note = "Internal Error: invalid JSON data"
-- if type(etc) = 'table' and etc.photo then
-- note = note .. " while processing for " .. etc.photo:getFormattedMetadata('fileName')
-- end
-- LrErrors.throwUserError(note)
-- end
--
-- :
-- :
--
-- for i, photo in ipairs(photosToProcess) do
-- :
-- :
-- local data = JSON:decode(someJsonText, { photo = photo })
-- :
-- :
-- end
--
--
--
--
--
-- DECODING AND STRICT TYPES
--
-- Because both JSON objects and JSON arrays are converted to Lua tables,
-- it's not normally possible to tell which original JSON type a
-- particular Lua table was derived from, or guarantee decode-encode
-- round-trip equivalency.
--
-- However, if you enable strictTypes, e.g.
--
-- JSON = assert(loadfile "JSON.lua")() --load the routines
-- JSON.strictTypes = true
--
-- then the Lua table resulting from the decoding of a JSON object or
-- JSON array is marked via Lua metatable, so that when re-encoded with
-- JSON:encode() it ends up as the appropriate JSON type.
--
-- (This is not the default because other routines may not work well with
-- tables that have a metatable set, for example, Lightroom API calls.)
--
--
-- ENCODING (from a lua table to a JSON string)
--
-- JSON = assert(loadfile "JSON.lua")() -- one-time load of the routines
--
-- local raw_json_text = JSON:encode(lua_table_or_value)
-- local pretty_json_text = JSON:encode_pretty(lua_table_or_value) -- "pretty printed" version for human readability
-- local custom_pretty = JSON:encode(lua_table_or_value, etc, { pretty = true, indent = "| ", align_keys = false })
--
-- On error during encoding, this code calls:
--
-- JSON:onEncodeError(message, etc)
--
-- which you can override in your local JSON object.
--
-- The 'etc' in the error call is the second argument to encode()
-- and encode_pretty(), or nil if it wasn't provided.
--
--
-- PRETTY-PRINTING
--
-- An optional third argument, a table of options, allows a bit of
-- configuration about how the encoding takes place:
--
-- pretty = JSON:encode(val, etc, {
-- pretty = true, -- if false, no other options matter
-- indent = " ", -- this provides for a three-space indent per nesting level
-- align_keys = false, -- see below
-- })
--
-- encode() and encode_pretty() are identical except that encode_pretty()
-- provides a default options table if none given in the call:
--
-- { pretty = true, align_keys = false, indent = " " }
--
-- For example, if
--
-- JSON:encode(data)
--
-- produces:
--
-- {"city":"Kyoto","climate":{"avg_temp":16,"humidity":"high","snowfall":"minimal"},"country":"Japan","wards":11}
--
-- then
--
-- JSON:encode_pretty(data)
--
-- produces:
--
-- {
-- "city": "Kyoto",
-- "climate": {
-- "avg_temp": 16,
-- "humidity": "high",
-- "snowfall": "minimal"
-- },
-- "country": "Japan",
-- "wards": 11
-- }
--
-- The following three lines return identical results:
-- JSON:encode_pretty(data)
-- JSON:encode_pretty(data, nil, { pretty = true, align_keys = false, indent = " " })
-- JSON:encode (data, nil, { pretty = true, align_keys = false, indent = " " })
--
-- An example of setting your own indent string:
--
-- JSON:encode_pretty(data, nil, { pretty = true, indent = "| " })
--
-- produces:
--
-- {
-- | "city": "Kyoto",
-- | "climate": {
-- | | "avg_temp": 16,
-- | | "humidity": "high",
-- | | "snowfall": "minimal"
-- | },
-- | "country": "Japan",
-- | "wards": 11
-- }
--
-- An example of setting align_keys to true:
--
-- JSON:encode_pretty(data, nil, { pretty = true, indent = " ", align_keys = true })
--
-- produces:
--
-- {
-- "city": "Kyoto",
-- "climate": {
-- "avg_temp": 16,
-- "humidity": "high",
-- "snowfall": "minimal"
-- },
-- "country": "Japan",
-- "wards": 11
-- }
--
-- which I must admit is kinda ugly, sorry. This was the default for
-- encode_pretty() prior to version 20141223.14.
--
--
-- AMBIGUOUS SITUATIONS DURING THE ENCODING
--
-- During the encode, if a Lua table being encoded contains both string
-- and numeric keys, it fits neither JSON's idea of an object, nor its
-- idea of an array. To get around this, when any string key exists (or
-- when non-positive numeric keys exist), numeric keys are converted to
-- strings.
--
-- For example,
-- JSON:encode({ "one", "two", "three", SOMESTRING = "some string" }))
-- produces the JSON object
-- {"1":"one","2":"two","3":"three","SOMESTRING":"some string"}
--
-- To prohibit this conversion and instead make it an error condition, set
-- JSON.noKeyConversion = true
--
--
-- SUMMARY OF METHODS YOU CAN OVERRIDE IN YOUR LOCAL LUA JSON OBJECT
--
-- assert
-- onDecodeError
-- onDecodeOfNilError
-- onDecodeOfHTMLError
-- onEncodeError
--
-- If you want to create a separate Lua JSON object with its own error handlers,
-- you can reload JSON.lua or use the :new() method.
--
---------------------------------------------------------------------------
local default_pretty_indent = " "
local default_pretty_options = { pretty = true, align_keys = false, indent = default_pretty_indent }
local isArray = { __tostring = function() return "JSON array" end } isArray.__index = isArray
local isObject = { __tostring = function() return "JSON object" end } isObject.__index = isObject
function OBJDEF:newArray(tbl)
return setmetatable(tbl or {}, isArray)
end
function OBJDEF:newObject(tbl)
return setmetatable(tbl or {}, isObject)
end
local function unicode_codepoint_as_utf8(codepoint)
--
-- codepoint is a number
--
if codepoint <= 127 then
return string.char(codepoint)
elseif codepoint <= 2047 then
--
-- 110yyyxx 10xxxxxx <-- useful notation from http://en.wikipedia.org/wiki/Utf8
--
local highpart = math.floor(codepoint / 0x40)
local lowpart = codepoint - (0x40 * highpart)
return string.char(0xC0 + highpart,
0x80 + lowpart)
elseif codepoint <= 65535 then
--
-- 1110yyyy 10yyyyxx 10xxxxxx
--
local highpart = math.floor(codepoint / 0x1000)
local remainder = codepoint - 0x1000 * highpart
local midpart = math.floor(remainder / 0x40)
local lowpart = remainder - 0x40 * midpart
highpart = 0xE0 + highpart
midpart = 0x80 + midpart
lowpart = 0x80 + lowpart
--
-- Check for an invalid character (thanks Andy R. at Adobe).
-- See table 3.7, page 93, in http://www.unicode.org/versions/Unicode5.2.0/ch03.pdf#G28070
--
if ( highpart == 0xE0 and midpart < 0xA0 ) or
( highpart == 0xED and midpart > 0x9F ) or
( highpart == 0xF0 and midpart < 0x90 ) or
( highpart == 0xF4 and midpart > 0x8F )
then
return "?"
else
return string.char(highpart,
midpart,
lowpart)
end
else
--
-- 11110zzz 10zzyyyy 10yyyyxx 10xxxxxx
--
local highpart = math.floor(codepoint / 0x40000)
local remainder = codepoint - 0x40000 * highpart
local midA = math.floor(remainder / 0x1000)
remainder = remainder - 0x1000 * midA
local midB = math.floor(remainder / 0x40)
local lowpart = remainder - 0x40 * midB
return string.char(0xF0 + highpart,
0x80 + midA,
0x80 + midB,
0x80 + lowpart)
end
end
function OBJDEF:onDecodeError(message, text, location, etc)
if text then
if location then
message = string.format("%s at char %d of: %s", message, location, text)
else
message = string.format("%s: %s", message, text)
end
end
if etc ~= nil then
message = message .. " (" .. OBJDEF:encode(etc) .. ")"
end
if self.assert then
self.assert(false, message)
else
assert(false, message)
end
end
OBJDEF.onDecodeOfNilError = OBJDEF.onDecodeError
OBJDEF.onDecodeOfHTMLError = OBJDEF.onDecodeError
function OBJDEF:onEncodeError(message, etc)
if etc ~= nil then
message = message .. " (" .. OBJDEF:encode(etc) .. ")"
end
if self.assert then
self.assert(false, message)
else
assert(false, message)
end
end
local function grok_number(self, text, start, etc)
--
-- Grab the integer part
--
local integer_part = text:match('^-?[1-9]%d*', start)
or text:match("^-?0", start)
if not integer_part then
self:onDecodeError("expected number", text, start, etc)
end
local i = start + integer_part:len()
--
-- Grab an optional decimal part
--
local decimal_part = text:match('^%.%d+', i) or ""
i = i + decimal_part:len()
--
-- Grab an optional exponential part
--
local exponent_part = text:match('^[eE][-+]?%d+', i) or ""
i = i + exponent_part:len()
local full_number_text = integer_part .. decimal_part .. exponent_part
local as_number = tonumber(full_number_text)
if not as_number then
self:onDecodeError("bad number", text, start, etc)
end
return as_number, i
end
local function grok_string(self, text, start, etc)
if text:sub(start,start) ~= '"' then
self:onDecodeError("expected string's opening quote", text, start, etc)
end
local i = start + 1 -- +1 to bypass the initial quote
local text_len = text:len()
local VALUE = ""
while i <= text_len do
local c = text:sub(i,i)
if c == '"' then
return VALUE, i + 1
end
if c ~= '\\' then
VALUE = VALUE .. c
i = i + 1
elseif text:match('^\\b', i) then
VALUE = VALUE .. "\b"
i = i + 2
elseif text:match('^\\f', i) then
VALUE = VALUE .. "\f"
i = i + 2
elseif text:match('^\\n', i) then
VALUE = VALUE .. "\n"
i = i + 2
elseif text:match('^\\r', i) then
VALUE = VALUE .. "\r"
i = i + 2
elseif text:match('^\\t', i) then
VALUE = VALUE .. "\t"
i = i + 2
else
local hex = text:match('^\\u([0123456789aAbBcCdDeEfF][0123456789aAbBcCdDeEfF][0123456789aAbBcCdDeEfF][0123456789aAbBcCdDeEfF])', i)
if hex then
i = i + 6 -- bypass what we just read
-- We have a Unicode codepoint. It could be standalone, or if in the proper range and
-- followed by another in a specific range, it'll be a two-code surrogate pair.
local codepoint = tonumber(hex, 16)
if codepoint >= 0xD800 and codepoint <= 0xDBFF then
-- it's a hi surrogate... see whether we have a following low
local lo_surrogate = text:match('^\\u([dD][cdefCDEF][0123456789aAbBcCdDeEfF][0123456789aAbBcCdDeEfF])', i)
if lo_surrogate then
i = i + 6 -- bypass the low surrogate we just read
codepoint = 0x2400 + (codepoint - 0xD800) * 0x400 + tonumber(lo_surrogate, 16)
else
-- not a proper low, so we'll just leave the first codepoint as is and spit it out.
end
end
VALUE = VALUE .. unicode_codepoint_as_utf8(codepoint)
else
-- just pass through what's escaped
VALUE = VALUE .. text:match('^\\(.)', i)
i = i + 2
end
end
end
self:onDecodeError("unclosed string", text, start, etc)
end
local function skip_whitespace(text, start)
local _, match_end = text:find("^[ \n\r\t]+", start) -- [http://www.ietf.org/rfc/rfc4627.txt] Section 2
if match_end then
return match_end + 1
else
return start
end
end
local grok_one -- assigned later
local function grok_object(self, text, start, etc)
if text:sub(start,start) ~= '{' then
self:onDecodeError("expected '{'", text, start, etc)
end
local i = skip_whitespace(text, start + 1) -- +1 to skip the '{'
local VALUE = self.strictTypes and self:newObject { } or { }
if text:sub(i,i) == '}' then
return VALUE, i + 1
end
local text_len = text:len()
while i <= text_len do
local key, new_i = grok_string(self, text, i, etc)
i = skip_whitespace(text, new_i)
if text:sub(i, i) ~= ':' then
self:onDecodeError("expected colon", text, i, etc)
end
i = skip_whitespace(text, i + 1)
local new_val, new_i = grok_one(self, text, i)
VALUE[key] = new_val
--
-- Expect now either '}' to end things, or a ',' to allow us to continue.
--
i = skip_whitespace(text, new_i)
local c = text:sub(i,i)
if c == '}' then
return VALUE, i + 1
end
if text:sub(i, i) ~= ',' then
self:onDecodeError("expected comma or '}'", text, i, etc)
end
i = skip_whitespace(text, i + 1)
end
self:onDecodeError("unclosed '{'", text, start, etc)
end
local function grok_array(self, text, start, etc)
if text:sub(start,start) ~= '[' then
self:onDecodeError("expected '['", text, start, etc)
end
local i = skip_whitespace(text, start + 1) -- +1 to skip the '['
local VALUE = self.strictTypes and self:newArray { } or { }
if text:sub(i,i) == ']' then
return VALUE, i + 1
end
local VALUE_INDEX = 1
local text_len = text:len()
while i <= text_len do
local val, new_i = grok_one(self, text, i)
-- can't table.insert(VALUE, val) here because it's a no-op if val is nil
VALUE[VALUE_INDEX] = val
VALUE_INDEX = VALUE_INDEX + 1
i = skip_whitespace(text, new_i)
--
-- Expect now either ']' to end things, or a ',' to allow us to continue.
--
local c = text:sub(i,i)
if c == ']' then
return VALUE, i + 1
end
if text:sub(i, i) ~= ',' then
self:onDecodeError("expected comma or '['", text, i, etc)
end
i = skip_whitespace(text, i + 1)
end
self:onDecodeError("unclosed '['", text, start, etc)
end
grok_one = function(self, text, start, etc)
-- Skip any whitespace
start = skip_whitespace(text, start)
if start > text:len() then
self:onDecodeError("unexpected end of string", text, nil, etc)
end
if text:find('^"', start) then
return grok_string(self, text, start, etc)
elseif text:find('^[-0123456789 ]', start) then
return grok_number(self, text, start, etc)
elseif text:find('^%{', start) then
return grok_object(self, text, start, etc)
elseif text:find('^%[', start) then
return grok_array(self, text, start, etc)
elseif text:find('^true', start) then
return true, start + 4
elseif text:find('^false', start) then
return false, start + 5
elseif text:find('^null', start) then
return nil, start + 4
else
self:onDecodeError("can't parse JSON", text, start, etc)
end
end
function OBJDEF:decode(text, etc)
if type(self) ~= 'table' or self.__index ~= OBJDEF then
OBJDEF:onDecodeError("JSON:decode must be called in method format", nil, nil, etc)
end
if text == nil then
self:onDecodeOfNilError(string.format("nil passed to JSON:decode()"), nil, nil, etc)
elseif type(text) ~= 'string' then
self:onDecodeError(string.format("expected string argument to JSON:decode(), got %s", type(text)), nil, nil, etc)
end
if text:match('^%s*$') then
return nil
end
if text:match('^%s*<') then
-- Can't be JSON... we'll assume it's HTML
self:onDecodeOfHTMLError(string.format("html passed to JSON:decode()"), text, nil, etc)
end
--
-- Ensure that it's not UTF-32 or UTF-16.
-- Those are perfectly valid encodings for JSON (as per RFC 4627 section 3),
-- but this package can't handle them.
--
if text:sub(1,1):byte() == 0 or (text:len() >= 2 and text:sub(2,2):byte() == 0) then
self:onDecodeError("JSON package groks only UTF-8, sorry", text, nil, etc)
end
local success, value = pcall(grok_one, self, text, 1, etc)
if success then
return value
else
-- if JSON:onDecodeError() didn't abort out of the pcall, we'll have received the error message here as "value", so pass it along as an assert.
if self.assert then
self.assert(false, value)
else
assert(false, value)
end
-- and if we're still here, return a nil and throw the error message on as a second arg
return nil, value
end
end
local function backslash_replacement_function(c)
if c == "\n" then
return "\\n"
elseif c == "\r" then
return "\\r"
elseif c == "\t" then
return "\\t"
elseif c == "\b" then
return "\\b"
elseif c == "\f" then
return "\\f"
elseif c == '"' then
return '\\"'
elseif c == '\\' then
return '\\\\'
else
return string.format("\\u%04x", c:byte())
end
end
local chars_to_be_escaped_in_JSON_string
= '['
.. '"' -- class sub-pattern to match a double quote
.. '%\\' -- class sub-pattern to match a backslash
.. '%z' -- class sub-pattern to match a null
.. '\001' .. '-' .. '\031' -- class sub-pattern to match control characters
.. ']'
local function json_string_literal(value)
local newval = value:gsub(chars_to_be_escaped_in_JSON_string, backslash_replacement_function)
return '"' .. newval .. '"'
end
local function object_or_array(self, T, etc)
--
-- We need to inspect all the keys... if there are any strings, we'll convert to a JSON
-- object. If there are only numbers, it's a JSON array.
--
-- If we'll be converting to a JSON object, we'll want to sort the keys so that the
-- end result is deterministic.
--
local string_keys = { }
local number_keys = { }
local number_keys_must_be_strings = false
local maximum_number_key
for key in pairs(T) do
if type(key) == 'string' then
table.insert(string_keys, key)
elseif type(key) == 'number' then
table.insert(number_keys, key)
if key <= 0 or key >= math.huge then
number_keys_must_be_strings = true
elseif not maximum_number_key or key > maximum_number_key then
maximum_number_key = key
end
else
self:onEncodeError("can't encode table with a key of type " .. type(key), etc)
end
end
if #string_keys == 0 and not number_keys_must_be_strings then
--
-- An empty table, or a numeric-only array
--
if #number_keys > 0 then
return nil, maximum_number_key -- an array
elseif tostring(T) == "JSON array" then
return nil
elseif tostring(T) == "JSON object" then
return { }
else
-- have to guess, so we'll pick array, since empty arrays are likely more common than empty objects
return nil
end
end
table.sort(string_keys)
local map
if #number_keys > 0 then
--
-- If we're here then we have either mixed string/number keys, or numbers inappropriate for a JSON array
-- It's not ideal, but we'll turn the numbers into strings so that we can at least create a JSON object.
--
if self.noKeyConversion then
self:onEncodeError("a table with both numeric and string keys could be an object or array; aborting", etc)
end
--
-- Have to make a shallow copy of the source table so we can remap the numeric keys to be strings
--
map = { }
for key, val in pairs(T) do
map[key] = val
end
table.sort(number_keys)
--
-- Throw numeric keys in there as strings
--
for _, number_key in ipairs(number_keys) do
local string_key = tostring(number_key)
if map[string_key] == nil then
table.insert(string_keys , string_key)
map[string_key] = T[number_key]
else
self:onEncodeError("conflict converting table with mixed-type keys into a JSON object: key " .. number_key .. " exists both as a string and a number.", etc)
end
end
end
return string_keys, nil, map
end
--
-- Encode
--
-- 'options' is nil, or a table with possible keys:
-- pretty -- if true, return a pretty-printed version
-- indent -- a string (usually of spaces) used to indent each nested level
-- align_keys -- if true, align all the keys when formatting a table
--
local encode_value -- must predeclare because it calls itself
function encode_value(self, value, parents, etc, options, indent)
if value == nil then
return 'null'
elseif type(value) == 'string' then
return json_string_literal(value)
elseif type(value) == 'number' then
if value ~= value then
--
-- NaN (Not a Number).
-- JSON has no NaN, so we have to fudge the best we can. This should really be a package option.
--
return "null"
elseif value >= math.huge then
--
-- Positive infinity. JSON has no INF, so we have to fudge the best we can. This should
-- really be a package option. Note: at least with some implementations, positive infinity
-- is both ">= math.huge" and "<= -math.huge", which makes no sense but that's how it is.
-- Negative infinity is properly "<= -math.huge". So, we must be sure to check the ">="
-- case first.
--
return "1e+9999"
elseif value <= -math.huge then
--
-- Negative infinity.
-- JSON has no INF, so we have to fudge the best we can. This should really be a package option.
--
return "-1e+9999"
else
return tostring(value)
end
elseif type(value) == 'boolean' then
return tostring(value)
elseif type(value) ~= 'table' then
self:onEncodeError("can't convert " .. type(value) .. " to JSON", etc)
else
--
-- A table to be converted to either a JSON object or array.
--
local T = value
if type(options) ~= 'table' then
options = {}
end
if type(indent) ~= 'string' then
indent = ""
end
if parents[T] then
self:onEncodeError("table " .. tostring(T) .. " is a child of itself", etc)
else
parents[T] = true
end
local result_value
local object_keys, maximum_number_key, map = object_or_array(self, T, etc)
if maximum_number_key then
--
-- An array...
--
local ITEMS = { }
for i = 1, maximum_number_key do
table.insert(ITEMS, encode_value(self, T[i], parents, etc, options, indent))
end
if options.pretty then
result_value = "[ " .. table.concat(ITEMS, ", ") .. " ]"
else
result_value = "[" .. table.concat(ITEMS, ",") .. "]"
end
elseif object_keys then
--
-- An object
--
local TT = map or T
if options.pretty then
local KEYS = { }
local max_key_length = 0
for _, key in ipairs(object_keys) do
local encoded = encode_value(self, tostring(key), parents, etc, options, indent)
if options.align_keys then
max_key_length = math.max(max_key_length, #encoded)
end
table.insert(KEYS, encoded)
end
local key_indent = indent .. tostring(options.indent or "")
local subtable_indent = key_indent .. string.rep(" ", max_key_length) .. (options.align_keys and " " or "")
local FORMAT = "%s%" .. string.format("%d", max_key_length) .. "s: %s"
local COMBINED_PARTS = { }
for i, key in ipairs(object_keys) do
local encoded_val = encode_value(self, TT[key], parents, etc, options, subtable_indent)
table.insert(COMBINED_PARTS, string.format(FORMAT, key_indent, KEYS[i], encoded_val))
end
result_value = "{\n" .. table.concat(COMBINED_PARTS, ",\n") .. "\n" .. indent .. "}"
else
local PARTS = { }
for _, key in ipairs(object_keys) do
local encoded_val = encode_value(self, TT[key], parents, etc, options, indent)
local encoded_key = encode_value(self, tostring(key), parents, etc, options, indent)
table.insert(PARTS, string.format("%s:%s", encoded_key, encoded_val))
end
result_value = "{" .. table.concat(PARTS, ",") .. "}"
end
else
--
-- An empty array/object... we'll treat it as an array, though it should really be an option
--
result_value = "[]"
end
parents[T] = false
return result_value
end
end
function OBJDEF:encode(value, etc, options)
if type(self) ~= 'table' or self.__index ~= OBJDEF then
OBJDEF:onEncodeError("JSON:encode must be called in method format", etc)
end
return encode_value(self, value, {}, etc, options or nil)
end
function OBJDEF:encode_pretty(value, etc, options)
if type(self) ~= 'table' or self.__index ~= OBJDEF then
OBJDEF:onEncodeError("JSON:encode_pretty must be called in method format", etc)
end
return encode_value(self, value, {}, etc, options or default_pretty_options)
end
function OBJDEF.__tostring()
return "JSON encode/decode package"
end
OBJDEF.__index = OBJDEF
function OBJDEF:new(args)
local new = { }
if args then
for key, val in pairs(args) do
new[key] = val
end
end
return setmetatable(new, OBJDEF)
end
--return OBJDEF:new()
--
-- Version history:
--
-- 20141223.14 The encode_pretty() routine produced fine results for small datasets, but isn't really
-- appropriate for anything large, so with help from Alex Aulbach I've made the encode routines
-- more flexible, and changed the default encode_pretty() to be more generally useful.
--
-- Added a third 'options' argument to the encode() and encode_pretty() routines, to control
-- how the encoding takes place.
--
-- Updated docs to add assert() call to the loadfile() line, just as good practice so that
-- if there is a problem loading JSON.lua, the appropriate error message will percolate up.
--
-- 20140920.13 Put back (in a way that doesn't cause warnings about unused variables) the author string,
-- so that the source of the package, and its version number, are visible in compiled copies.
--
-- 20140911.12 Minor lua cleanup.
-- Fixed internal reference to 'JSON.noKeyConversion' to reference 'self' instead of 'JSON'.
-- (Thanks to SmugMug's David Parry for these.)
--
-- 20140418.11 JSON nulls embedded within an array were being ignored, such that
-- ["1",null,null,null,null,null,"seven"],
-- would return
-- {1,"seven"}
-- It's now fixed to properly return
-- {1, nil, nil, nil, nil, nil, "seven"}
-- Thanks to "haddock" for catching the error.
--
-- 20140116.10 The user's JSON.assert() wasn't always being used. Thanks to "blue" for the heads up.
--
-- 20131118.9 Update for Lua 5.3... it seems that tostring(2/1) produces "2.0" instead of "2",
-- and this caused some problems.
--
-- 20131031.8 Unified the code for encode() and encode_pretty(); they had been stupidly separate,
-- and had of course diverged (encode_pretty didn't get the fixes that encode got, so
-- sometimes produced incorrect results; thanks to Mattie for the heads up).
--
-- Handle encoding tables with non-positive numeric keys (unlikely, but possible).
--
-- If a table has both numeric and string keys, or its numeric keys are inappropriate
-- (such as being non-positive or infinite), the numeric keys are turned into
-- string keys appropriate for a JSON object. So, as before,
-- JSON:encode({ "one", "two", "three" })
-- produces the array
-- ["one","two","three"]
-- but now something with mixed key types like
-- JSON:encode({ "one", "two", "three", SOMESTRING = "some string" }))
-- instead of throwing an error produces an object:
-- {"1":"one","2":"two","3":"three","SOMESTRING":"some string"}
--
-- To maintain the prior throw-an-error semantics, set
-- JSON.noKeyConversion = true
--
-- 20131004.7 Release under a Creative Commons CC-BY license, which I should have done from day one, sorry.
--
-- 20130120.6 Comment update: added a link to the specific page on my blog where this code can
-- be found, so that folks who come across the code outside of my blog can find updates
-- more easily.
--
-- 20111207.5 Added support for the 'etc' arguments, for better error reporting.
--
-- 20110731.4 More feedback from David Kolf on how to make the tests for Nan/Infinity system independent.
--
-- 20110730.3 Incorporated feedback from David Kolf at http://lua-users.org/wiki/JsonModules:
--
-- * When encoding lua for JSON, Sparse numeric arrays are now handled by
-- spitting out full arrays, such that
-- JSON:encode({"one", "two", [10] = "ten"})
-- returns
-- ["one","two",null,null,null,null,null,null,null,"ten"]
--
-- In 20100810.2 and earlier, only up to the first non-null value would have been retained.
--
-- * When encoding lua for JSON, numeric value NaN gets spit out as null, and infinity as "1+e9999".
-- Version 20100810.2 and earlier created invalid JSON in both cases.
--
-- * Unicode surrogate pairs are now detected when decoding JSON.
--
-- 20100810.2 added some checking to ensure that an invalid Unicode character couldn't leak in to the UTF-8 encoding
--
-- 20100731.1 initial public release
-- | apache-2.0 |
apletnev/koreader | frontend/device/kobo/sysfs_light.lua | 1 | 3333 | -- Interface to the SysFS interface of the Kobo Aura One Frontlight.
-- This also supports the natural light, which consists of additional
-- red and green light LEDs.
local logger = require("logger")
local dbg = require("dbg")
local KoboSysfsLight = {
frontlight_white = "/sys/class/backlight/lm3630a_led1b",
frontlight_red = "/sys/class/backlight/lm3630a_led1a",
frontlight_green = "/sys/class/backlight/lm3630a_ledb",
current_brightness = 0,
current_warmth = 0,
white_gain = 25,
red_gain = 24,
green_gain = 24,
white_offset = -25,
red_offset = 0,
green_offset = -65,
}
function KoboSysfsLight:setBrightness(brightness)
self:setNaturalBrightness(brightness, self.current_warmth)
end
dbg:guard(KoboSysfsLight, 'setBrightness',
function(self, brightness)
assert(brightness >= 0 and brightness <= 100,
"Wrong brightness value given!")
end)
function KoboSysfsLight:setWarmth(warmth)
self:setNaturalBrightness(self.current_brightness, warmth)
end
dbg:guard(KoboSysfsLight, 'setWarmth',
function(self, warmth)
assert(warmth >= 0 and warmth <= 100,
"Wrong warmth value given!")
end)
function KoboSysfsLight:setNaturalBrightness(brightness, warmth)
-- On Nickel, the values for white/red/green are roughly linearly dependent
-- on the 4th root of brightness and warmth.
local white = math.min(self.white_gain * math.pow(brightness, 0.25) *
math.pow(100 - warmth, 0.25) + self.white_offset, 255)
local red = math.min(self.red_gain * math.pow(brightness, 0.25) *
math.pow(warmth, 0.25) + self.red_offset, 255)
local green = math.min(self.green_gain * math.pow(brightness, 0.25) *
math.pow(warmth, 0.25) + self.green_offset, 255)
white = math.max(white, 0)
red = math.max(red, 0)
green = math.max(green, 0)
self:_set_light_value(self.frontlight_white, math.floor(white))
self:_set_light_value(self.frontlight_green, math.floor(green))
self:_set_light_value(self.frontlight_red, math.floor(red))
self.current_brightness = brightness
self.current_warmth = warmth
end
dbg:guard(KoboSysfsLight, 'setNaturalBrightness',
function(self, brightness, warmth)
assert(brightness >= 0 and brightness <= 100,
"Wrong brightness value given!")
assert(warmth >= 0 and warmth <= 100,
"Wrong warmth value given!")
end)
function KoboSysfsLight:_set_light_value(sysfs_directory, value)
-- bl_power is '31' when the light is turned on, '0' otherwise.
if (value > 0) then
self:_write_value(sysfs_directory .. "/bl_power", 31)
else
self:_write_value(sysfs_directory .. "/bl_power", 0)
end
self:_write_value(sysfs_directory .. "/brightness", value)
end
function KoboSysfsLight:_write_value(file, value)
local f = io.open(file, "w")
if not f then
logger.err("Could not open file: ", file)
return false
end
local ret, err_msg, err_code = f:write(value)
io.close(f)
if not ret then
logger.err("Write error: ", err_msg, err_code)
return false
end
return true
end
return KoboSysfsLight
| agpl-3.0 |
kitala1/darkstar | scripts/globals/spells/drain.lua | 13 | 1636 | -----------------------------------------
-- Spell: Drain
-- Drain functions only on skill level!!
-----------------------------------------
require("scripts/globals/magic");
require("scripts/globals/status");
require("scripts/globals/settings");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
--calculate raw damage (unknown function -> only dark skill though) - using http://www.bluegartr.com/threads/44518-Drain-Calculations
-- also have small constant to account for 0 dark skill
local dmg = 10 + (1.035 * (caster:getSkillLevel(DARK_MAGIC_SKILL)) + caster:getMod(79 + DARK_MAGIC_SKILL));
if (dmg > (caster:getSkillLevel(DARK_MAGIC_SKILL) + 20)) then
dmg = (caster:getSkillLevel(DARK_MAGIC_SKILL) + 20);
end
--get resist multiplier (1x if no resist)
local resist = applyResistance(caster,spell,target,caster:getStat(MOD_INT)-target:getStat(MOD_INT),DARK_MAGIC_SKILL,1.0);
--get the resisted damage
dmg = dmg*resist;
--add on bonuses (staff/day/weather/jas/mab/etc all go in this function)
dmg = addBonuses(caster,spell,target,dmg);
--add in target adjustment
dmg = adjustForTarget(target,dmg,spell:getElement());
--add in final adjustments
if (dmg < 0) then
dmg = 0
end
if(target:isUndead()) then
spell:setMsg(75); -- No effect
return dmg;
end
dmg = finalMagicAdjustments(caster,target,spell,dmg);
dmg = (dmg * DRAIN_POWER);
caster:addHP(dmg);
return dmg;
end;
| gpl-3.0 |
apletnev/koreader | frontend/ui/elements/reader_menu_order.lua | 1 | 3143 | local order = {
["KOMenu:menu_buttons"] = {
"navi",
"typeset",
"setting",
"tools",
"search",
"filemanager",
"main",
},
navi = {
"table_of_contents",
"bookmarks",
"bookmark_browsing_mode",
"----------------------------",
"go_to",
"skim_to",
"----------------------------",
"go_to_previous_location",
"follow_links",
},
typeset = {
"page_overlap",
"switch_zoom_mode",
"set_render_style",
"----------------------------",
"highlight_options",
"----------------------------",
"floating_punctuation",
"change_font",
"hyphenation",
"----------------------------",
"speed_reading_module_perception_expander",
},
setting = {
"read_from_right_to_left",
-- common settings
-- those that don't exist will simply be skipped during menu gen
"frontlight", -- if Device:hasFrontlight()
"night_mode",
"----------------------------",
"network",
"screen",
"screensaver",
"document",
"----------------------------",
"language",
"time",
"----------------------------",
"djvu_render_mode",
"status_bar",
},
tools = {
"read_timer",
"calibre_wireless_connection",
"evernote",
"statistics",
"progress_sync",
"zsync",
"news_downloader",
"----------------------------",
"more_plugins",
},
more_plugins = {
"auto_frontlight",
"frontlight_gesture_controller",
"battery_statistics",
"synchronize_time",
"keep_alive",
"terminal",
"storage_stat",
},
search = {
"dictionary_lookup",
"dictionary_lookup_history",
"dictionary_settings",
"----------------------------",
"wikipedia_lookup",
"wikipedia_history",
"wikipedia_settings",
"----------------------------",
"goodreads",
"----------------------------",
"fulltext_search",
},
filemanager = {},
main = {
"history",
"book_status",
"book_info",
"----------------------------",
"system_statistics",
"----------------------------",
"ota_update", --[[ if Device:isKindle() or Device:isKobo() or
Device:isPocketBook() or Device:isAndroid() ]]--
"version",
"help",
"----------------------------",
"exit_menu",
},
help = {
"quickstart_guide",
"----------------------------",
"report_bug",
"----------------------------",
"about",
},
exit_menu = {
"restart_koreader",
"----------------------------",
"sleep", -- if Device:isKindle() or Device:isKobo()
"poweroff", -- if Device:isKobo()
"reboot", -- if Device:isKobo()
"----------------------------",
"exit",
}
}
return order
| agpl-3.0 |
paulosalvatore/maruim_server | data/actions/scripts/tools/rope.lua | 1 | 1417 | local holeId = {
294, 369, 370, 383, 392, 408, 409, 410, 427, 428, 429, 430, 462, 469, 470, 482,
484, 485, 489, 924, 1369, 3135, 3136, 4835, 4837, 7933, 7938, 8170, 8249, 8250,
8251, 8252, 8254, 8255, 8256, 8276, 8277, 8279, 8281, 8284, 8285, 8286, 8323,
8567, 8585, 8595, 8596, 8972, 9606, 9625, 13190, 14461, 19519, 21536
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local tile = Tile(toPosition)
if not tile then
return false
end
if isInArray(ropeSpots, tile:getGround():getId()) or tile:getItemById(14435) then
if Tile(toPosition:moveUpstairs()):hasFlag(TILESTATE_PROTECTIONZONE) and player:isPzLocked() then
player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_PLAYERISPZLOCKED))
return true
end
player:teleportTo(toPosition, false)
return true
elseif isInArray(holeId, target:getId()) then
toPosition.z = toPosition.z + 1
tile = Tile(toPosition)
if tile then
local thing = tile:getTopVisibleThing()
if thing:isPlayer() then
if Tile(toPosition:moveUpstairs()):hasFlag(TILESTATE_PROTECTIONZONE) and thing:isPzLocked() then
return false
end
return thing:teleportTo(toPosition, false)
end
if thing:isItem() and thing:getType():isMovable() then
return thing:moveTo(toPosition:moveUpstairs())
end
end
player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
return true
end
return false
end
| gpl-2.0 |
paulosalvatore/maruim_server | data/actions/scripts/other/potions.lua | 1 | 3651 | local potions = {
[8473] = {health = {650, 850}, mana = {}, level = 130, vocations = {4, 8}, emptyPot = 7635},
[7591] = {health = {425, 575}, mana = {}, level = 80, vocations = {4, 8}, emptyPot = 7635},
[7590] = {health = {}, mana = {150, 250}, level = 80, vocations = {1, 2, 5, 6}, emptyPot = 7635},
[8472] = {health = {250, 350}, mana = {100, 200}, level = 80, vocations = {3, 7}, emptyPot = 7635},
[7588] = {health = {250, 350}, mana = {}, level = 50, vocations = {3, 4, 7, 8}, emptyPot = 7634},
[7589] = {health = {}, mana = {115, 185}, level = 50, vocations = {1, 2, 3, 5, 6, 7}, emptyPot = 7634},
[7618] = {health = {125, 175}, mana = {}, level = 1, vocations = {}, emptyPot = 7636},
[7620] = {health = {}, mana = {75, 125}, level = 1, vocations = {}, emptyPot = 7636},
[8704] = {health = {20, 125}, mana = {}, level = 1, vocations = {}},
[8474] = {emptyPot = 7636},
}
local potionAntidote = 8474
local antidote = createCombatObject()
setCombatParam(antidote, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(antidote, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(antidote, COMBAT_PARAM_TARGETCASTERORTOPMOST, TRUE)
setCombatParam(antidote, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(antidote, COMBAT_PARAM_DISPEL, CONDITION_POISON)
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) - 100))
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if target == nil or not target:isPlayer() then
return true
end
if player:getCondition(CONDITION_EXHAUST_HEAL) then
player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
return true
end
if potions[item.itemid] then
local potion = potions[item.itemid]
if item.itemid == potionAntidote then
if(doCombat(target, antidote, numberToVariant(target)) == LUA_ERROR) then
return false
end
else
local msg = ""
if (#potion.vocations > 0) and not isInArray(potion.vocations, target:getVocation():getId()) then
local vocacoes = ""
for i = 1, #potion.vocations/2 do
local vocationName = string.lower(tostring(Vocation(potion.vocations[i]):getName())).."s"
if i == 1 then
vocacoes = vocationName
elseif i < #potion.vocations/2 then
vocacoes = vocacoes..", "..vocationName
else
vocacoes = vocacoes.." e "..vocationName
end
end
msg = msg.."Essa poção só pode ser usada por "..vocacoes
end
if target:getLevel() < potion.level or msg ~= "" then
msg = msg.." de level "..potion.level.." ou mais"
end
if player:getGroup():getId() >= 2 then
msg = ""
end
if msg ~= "" then
msg = msg.."."
target:say(msg, TALKTYPE_MONSTER_SAY)
return true
end
local health_min = potion.health[1] or 0
local health_max = potion.health[2] or 0
local mana_min = potion.mana[1] or 0
local mana_max = potion.mana[2] or 0
local health = item:getName():match("health: (.-)]")
local mana = item:getName():match("mana: (.-)]")
if health ~= nil then
health_min = health
health_max = health
end
if mana ~= nil then
mana_min = mana
mana_max = mana
end
if not doTargetCombatHealth(0, target, COMBAT_HEALING, health_min, health_max, CONST_ME_MAGIC_BLUE) or not doTargetCombatMana(0, player, mana_min, mana_max, CONST_ME_MAGIC_BLUE) then
return false
end
end
player:addCondition(exhaust)
target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
item:remove(1)
if potion.emptyPot ~= nil then
player:addItem(potion.emptyPot, 1)
end
end
return true
end | gpl-2.0 |
nicodinh/cuberite | MCServer/Plugins/APIDump/Hooks/OnPlayerJoined.lua | 44 | 1244 | return
{
HOOK_PLAYER_JOINED =
{
CalledWhen = "After Login and before Spawned, before being added to world. ",
DefaultFnName = "OnPlayerJoined", -- also used as pagename
Desc = [[
This hook is called whenever a {{cPlayer|player}} has completely logged in. If authentication is
enabled, this function is called after their name has been authenticated. It is called after
{{OnLogin|HOOK_LOGIN}} and before {{OnPlayerSpawned|HOOK_PLAYER_SPAWNED}}, right after the player's
entity is created, but not added to the world yet. The player is not yet visible to other players.
Returning true will block a join message from being broadcast, but otherwise, the player is still allowed to join.
Plugins wishing to refuse player's entry should kick the player using the {{cPlayer}}:Kick() function.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has joined the game" },
},
Returns = [[
If the function returns false or no value, other plugins' callbacks are called and a join message is broadcast. If the function
returns true, no other callbacks are called for this event and a join message is not sent. Either way the player is let in.
]],
}, -- HOOK_PLAYER_JOINED
}
| apache-2.0 |
zhaoluxyz/Hugula | Client/tools/luaTools/win/lua/jit/dis_ppc.lua | 74 | 20319 | ----------------------------------------------------------------------------
-- LuaJIT PPC disassembler module.
--
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- Released under the MIT/X license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module.
--
-- It disassembles all common, non-privileged 32/64 bit PowerPC instructions
-- plus the e500 SPE instructions and some Cell/Xenon extensions.
--
-- NYI: VMX, VMX128
------------------------------------------------------------------------------
local type = type
local sub, byte, format = string.sub, string.byte, string.format
local match, gmatch, gsub = string.match, string.gmatch, string.gsub
local concat = table.concat
local bit = require("bit")
local band, bor, tohex = bit.band, bit.bor, bit.tohex
local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift
------------------------------------------------------------------------------
-- Primary and extended opcode maps
------------------------------------------------------------------------------
local map_crops = {
shift = 1, mask = 1023,
[0] = "mcrfXX",
[33] = "crnor|crnotCCC=", [129] = "crandcCCC",
[193] = "crxor|crclrCCC%", [225] = "crnandCCC",
[257] = "crandCCC", [289] = "creqv|crsetCCC%",
[417] = "crorcCCC", [449] = "cror|crmoveCCC=",
[16] = "b_lrKB", [528] = "b_ctrKB",
[150] = "isync",
}
local map_rlwinm = setmetatable({
shift = 0, mask = -1,
},
{ __index = function(t, x)
local rot = band(rshift(x, 11), 31)
local mb = band(rshift(x, 6), 31)
local me = band(rshift(x, 1), 31)
if mb == 0 and me == 31-rot then
return "slwiRR~A."
elseif me == 31 and mb == 32-rot then
return "srwiRR~-A."
else
return "rlwinmRR~AAA."
end
end
})
local map_rld = {
shift = 2, mask = 7,
[0] = "rldiclRR~HM.", "rldicrRR~HM.", "rldicRR~HM.", "rldimiRR~HM.",
{
shift = 1, mask = 1,
[0] = "rldclRR~RM.", "rldcrRR~RM.",
},
}
local map_ext = setmetatable({
shift = 1, mask = 1023,
[0] = "cmp_YLRR", [32] = "cmpl_YLRR",
[4] = "twARR", [68] = "tdARR",
[8] = "subfcRRR.", [40] = "subfRRR.",
[104] = "negRR.", [136] = "subfeRRR.",
[200] = "subfzeRR.", [232] = "subfmeRR.",
[520] = "subfcoRRR.", [552] = "subfoRRR.",
[616] = "negoRR.", [648] = "subfeoRRR.",
[712] = "subfzeoRR.", [744] = "subfmeoRR.",
[9] = "mulhduRRR.", [73] = "mulhdRRR.", [233] = "mulldRRR.",
[457] = "divduRRR.", [489] = "divdRRR.",
[745] = "mulldoRRR.",
[969] = "divduoRRR.", [1001] = "divdoRRR.",
[10] = "addcRRR.", [138] = "addeRRR.",
[202] = "addzeRR.", [234] = "addmeRR.", [266] = "addRRR.",
[522] = "addcoRRR.", [650] = "addeoRRR.",
[714] = "addzeoRR.", [746] = "addmeoRR.", [778] = "addoRRR.",
[11] = "mulhwuRRR.", [75] = "mulhwRRR.", [235] = "mullwRRR.",
[459] = "divwuRRR.", [491] = "divwRRR.",
[747] = "mullwoRRR.",
[971] = "divwouRRR.", [1003] = "divwoRRR.",
[15] = "iselltRRR", [47] = "iselgtRRR", [79] = "iseleqRRR",
[144] = { shift = 20, mask = 1, [0] = "mtcrfRZ~", "mtocrfRZ~", },
[19] = { shift = 20, mask = 1, [0] = "mfcrR", "mfocrfRZ", },
[371] = { shift = 11, mask = 1023, [392] = "mftbR", [424] = "mftbuR", },
[339] = {
shift = 11, mask = 1023,
[32] = "mferR", [256] = "mflrR", [288] = "mfctrR", [16] = "mfspefscrR",
},
[467] = {
shift = 11, mask = 1023,
[32] = "mtxerR", [256] = "mtlrR", [288] = "mtctrR", [16] = "mtspefscrR",
},
[20] = "lwarxRR0R", [84] = "ldarxRR0R",
[21] = "ldxRR0R", [53] = "lduxRRR",
[149] = "stdxRR0R", [181] = "stduxRRR",
[341] = "lwaxRR0R", [373] = "lwauxRRR",
[23] = "lwzxRR0R", [55] = "lwzuxRRR",
[87] = "lbzxRR0R", [119] = "lbzuxRRR",
[151] = "stwxRR0R", [183] = "stwuxRRR",
[215] = "stbxRR0R", [247] = "stbuxRRR",
[279] = "lhzxRR0R", [311] = "lhzuxRRR",
[343] = "lhaxRR0R", [375] = "lhauxRRR",
[407] = "sthxRR0R", [439] = "sthuxRRR",
[54] = "dcbst-R0R", [86] = "dcbf-R0R",
[150] = "stwcxRR0R.", [214] = "stdcxRR0R.",
[246] = "dcbtst-R0R", [278] = "dcbt-R0R",
[310] = "eciwxRR0R", [438] = "ecowxRR0R",
[470] = "dcbi-RR",
[598] = {
shift = 21, mask = 3,
[0] = "sync", "lwsync", "ptesync",
},
[758] = "dcba-RR",
[854] = "eieio", [982] = "icbi-R0R", [1014] = "dcbz-R0R",
[26] = "cntlzwRR~", [58] = "cntlzdRR~",
[122] = "popcntbRR~",
[154] = "prtywRR~", [186] = "prtydRR~",
[28] = "andRR~R.", [60] = "andcRR~R.", [124] = "nor|notRR~R=.",
[284] = "eqvRR~R.", [316] = "xorRR~R.",
[412] = "orcRR~R.", [444] = "or|mrRR~R=.", [476] = "nandRR~R.",
[508] = "cmpbRR~R",
[512] = "mcrxrX",
[532] = "ldbrxRR0R", [660] = "stdbrxRR0R",
[533] = "lswxRR0R", [597] = "lswiRR0A",
[661] = "stswxRR0R", [725] = "stswiRR0A",
[534] = "lwbrxRR0R", [662] = "stwbrxRR0R",
[790] = "lhbrxRR0R", [918] = "sthbrxRR0R",
[535] = "lfsxFR0R", [567] = "lfsuxFRR",
[599] = "lfdxFR0R", [631] = "lfduxFRR",
[663] = "stfsxFR0R", [695] = "stfsuxFRR",
[727] = "stfdxFR0R", [759] = "stfduxFR0R",
[855] = "lfiwaxFR0R",
[983] = "stfiwxFR0R",
[24] = "slwRR~R.",
[27] = "sldRR~R.", [536] = "srwRR~R.",
[792] = "srawRR~R.", [824] = "srawiRR~A.",
[794] = "sradRR~R.", [826] = "sradiRR~H.", [827] = "sradiRR~H.",
[922] = "extshRR~.", [954] = "extsbRR~.", [986] = "extswRR~.",
[539] = "srdRR~R.",
},
{ __index = function(t, x)
if band(x, 31) == 15 then return "iselRRRC" end
end
})
local map_ld = {
shift = 0, mask = 3,
[0] = "ldRRE", "lduRRE", "lwaRRE",
}
local map_std = {
shift = 0, mask = 3,
[0] = "stdRRE", "stduRRE",
}
local map_fps = {
shift = 5, mask = 1,
{
shift = 1, mask = 15,
[0] = false, false, "fdivsFFF.", false,
"fsubsFFF.", "faddsFFF.", "fsqrtsF-F.", false,
"fresF-F.", "fmulsFF-F.", "frsqrtesF-F.", false,
"fmsubsFFFF~.", "fmaddsFFFF~.", "fnmsubsFFFF~.", "fnmaddsFFFF~.",
}
}
local map_fpd = {
shift = 5, mask = 1,
[0] = {
shift = 1, mask = 1023,
[0] = "fcmpuXFF", [32] = "fcmpoXFF", [64] = "mcrfsXX",
[38] = "mtfsb1A.", [70] = "mtfsb0A.", [134] = "mtfsfiA>>-A>",
[8] = "fcpsgnFFF.", [40] = "fnegF-F.", [72] = "fmrF-F.",
[136] = "fnabsF-F.", [264] = "fabsF-F.",
[12] = "frspF-F.",
[14] = "fctiwF-F.", [15] = "fctiwzF-F.",
[583] = "mffsF.", [711] = "mtfsfZF.",
[392] = "frinF-F.", [424] = "frizF-F.",
[456] = "fripF-F.", [488] = "frimF-F.",
[814] = "fctidF-F.", [815] = "fctidzF-F.", [846] = "fcfidF-F.",
},
{
shift = 1, mask = 15,
[0] = false, false, "fdivFFF.", false,
"fsubFFF.", "faddFFF.", "fsqrtF-F.", "fselFFFF~.",
"freF-F.", "fmulFF-F.", "frsqrteF-F.", false,
"fmsubFFFF~.", "fmaddFFFF~.", "fnmsubFFFF~.", "fnmaddFFFF~.",
}
}
local map_spe = {
shift = 0, mask = 2047,
[512] = "evaddwRRR", [514] = "evaddiwRAR~",
[516] = "evsubwRRR~", [518] = "evsubiwRAR~",
[520] = "evabsRR", [521] = "evnegRR",
[522] = "evextsbRR", [523] = "evextshRR", [524] = "evrndwRR",
[525] = "evcntlzwRR", [526] = "evcntlswRR",
[527] = "brincRRR",
[529] = "evandRRR", [530] = "evandcRRR", [534] = "evxorRRR",
[535] = "evor|evmrRRR=", [536] = "evnor|evnotRRR=",
[537] = "eveqvRRR", [539] = "evorcRRR", [542] = "evnandRRR",
[544] = "evsrwuRRR", [545] = "evsrwsRRR",
[546] = "evsrwiuRRA", [547] = "evsrwisRRA",
[548] = "evslwRRR", [550] = "evslwiRRA",
[552] = "evrlwRRR", [553] = "evsplatiRS",
[554] = "evrlwiRRA", [555] = "evsplatfiRS",
[556] = "evmergehiRRR", [557] = "evmergeloRRR",
[558] = "evmergehiloRRR", [559] = "evmergelohiRRR",
[560] = "evcmpgtuYRR", [561] = "evcmpgtsYRR",
[562] = "evcmpltuYRR", [563] = "evcmpltsYRR",
[564] = "evcmpeqYRR",
[632] = "evselRRR", [633] = "evselRRRW",
[634] = "evselRRRW", [635] = "evselRRRW",
[636] = "evselRRRW", [637] = "evselRRRW",
[638] = "evselRRRW", [639] = "evselRRRW",
[640] = "evfsaddRRR", [641] = "evfssubRRR",
[644] = "evfsabsRR", [645] = "evfsnabsRR", [646] = "evfsnegRR",
[648] = "evfsmulRRR", [649] = "evfsdivRRR",
[652] = "evfscmpgtYRR", [653] = "evfscmpltYRR", [654] = "evfscmpeqYRR",
[656] = "evfscfuiR-R", [657] = "evfscfsiR-R",
[658] = "evfscfufR-R", [659] = "evfscfsfR-R",
[660] = "evfsctuiR-R", [661] = "evfsctsiR-R",
[662] = "evfsctufR-R", [663] = "evfsctsfR-R",
[664] = "evfsctuizR-R", [666] = "evfsctsizR-R",
[668] = "evfststgtYRR", [669] = "evfststltYRR", [670] = "evfststeqYRR",
[704] = "efsaddRRR", [705] = "efssubRRR",
[708] = "efsabsRR", [709] = "efsnabsRR", [710] = "efsnegRR",
[712] = "efsmulRRR", [713] = "efsdivRRR",
[716] = "efscmpgtYRR", [717] = "efscmpltYRR", [718] = "efscmpeqYRR",
[719] = "efscfdR-R",
[720] = "efscfuiR-R", [721] = "efscfsiR-R",
[722] = "efscfufR-R", [723] = "efscfsfR-R",
[724] = "efsctuiR-R", [725] = "efsctsiR-R",
[726] = "efsctufR-R", [727] = "efsctsfR-R",
[728] = "efsctuizR-R", [730] = "efsctsizR-R",
[732] = "efststgtYRR", [733] = "efststltYRR", [734] = "efststeqYRR",
[736] = "efdaddRRR", [737] = "efdsubRRR",
[738] = "efdcfuidR-R", [739] = "efdcfsidR-R",
[740] = "efdabsRR", [741] = "efdnabsRR", [742] = "efdnegRR",
[744] = "efdmulRRR", [745] = "efddivRRR",
[746] = "efdctuidzR-R", [747] = "efdctsidzR-R",
[748] = "efdcmpgtYRR", [749] = "efdcmpltYRR", [750] = "efdcmpeqYRR",
[751] = "efdcfsR-R",
[752] = "efdcfuiR-R", [753] = "efdcfsiR-R",
[754] = "efdcfufR-R", [755] = "efdcfsfR-R",
[756] = "efdctuiR-R", [757] = "efdctsiR-R",
[758] = "efdctufR-R", [759] = "efdctsfR-R",
[760] = "efdctuizR-R", [762] = "efdctsizR-R",
[764] = "efdtstgtYRR", [765] = "efdtstltYRR", [766] = "efdtsteqYRR",
[768] = "evlddxRR0R", [769] = "evlddRR8",
[770] = "evldwxRR0R", [771] = "evldwRR8",
[772] = "evldhxRR0R", [773] = "evldhRR8",
[776] = "evlhhesplatxRR0R", [777] = "evlhhesplatRR2",
[780] = "evlhhousplatxRR0R", [781] = "evlhhousplatRR2",
[782] = "evlhhossplatxRR0R", [783] = "evlhhossplatRR2",
[784] = "evlwhexRR0R", [785] = "evlwheRR4",
[788] = "evlwhouxRR0R", [789] = "evlwhouRR4",
[790] = "evlwhosxRR0R", [791] = "evlwhosRR4",
[792] = "evlwwsplatxRR0R", [793] = "evlwwsplatRR4",
[796] = "evlwhsplatxRR0R", [797] = "evlwhsplatRR4",
[800] = "evstddxRR0R", [801] = "evstddRR8",
[802] = "evstdwxRR0R", [803] = "evstdwRR8",
[804] = "evstdhxRR0R", [805] = "evstdhRR8",
[816] = "evstwhexRR0R", [817] = "evstwheRR4",
[820] = "evstwhoxRR0R", [821] = "evstwhoRR4",
[824] = "evstwwexRR0R", [825] = "evstwweRR4",
[828] = "evstwwoxRR0R", [829] = "evstwwoRR4",
[1027] = "evmhessfRRR", [1031] = "evmhossfRRR", [1032] = "evmheumiRRR",
[1033] = "evmhesmiRRR", [1035] = "evmhesmfRRR", [1036] = "evmhoumiRRR",
[1037] = "evmhosmiRRR", [1039] = "evmhosmfRRR", [1059] = "evmhessfaRRR",
[1063] = "evmhossfaRRR", [1064] = "evmheumiaRRR", [1065] = "evmhesmiaRRR",
[1067] = "evmhesmfaRRR", [1068] = "evmhoumiaRRR", [1069] = "evmhosmiaRRR",
[1071] = "evmhosmfaRRR", [1095] = "evmwhssfRRR", [1096] = "evmwlumiRRR",
[1100] = "evmwhumiRRR", [1101] = "evmwhsmiRRR", [1103] = "evmwhsmfRRR",
[1107] = "evmwssfRRR", [1112] = "evmwumiRRR", [1113] = "evmwsmiRRR",
[1115] = "evmwsmfRRR", [1127] = "evmwhssfaRRR", [1128] = "evmwlumiaRRR",
[1132] = "evmwhumiaRRR", [1133] = "evmwhsmiaRRR", [1135] = "evmwhsmfaRRR",
[1139] = "evmwssfaRRR", [1144] = "evmwumiaRRR", [1145] = "evmwsmiaRRR",
[1147] = "evmwsmfaRRR",
[1216] = "evaddusiaawRR", [1217] = "evaddssiaawRR",
[1218] = "evsubfusiaawRR", [1219] = "evsubfssiaawRR",
[1220] = "evmraRR",
[1222] = "evdivwsRRR", [1223] = "evdivwuRRR",
[1224] = "evaddumiaawRR", [1225] = "evaddsmiaawRR",
[1226] = "evsubfumiaawRR", [1227] = "evsubfsmiaawRR",
[1280] = "evmheusiaawRRR", [1281] = "evmhessiaawRRR",
[1283] = "evmhessfaawRRR", [1284] = "evmhousiaawRRR",
[1285] = "evmhossiaawRRR", [1287] = "evmhossfaawRRR",
[1288] = "evmheumiaawRRR", [1289] = "evmhesmiaawRRR",
[1291] = "evmhesmfaawRRR", [1292] = "evmhoumiaawRRR",
[1293] = "evmhosmiaawRRR", [1295] = "evmhosmfaawRRR",
[1320] = "evmhegumiaaRRR", [1321] = "evmhegsmiaaRRR",
[1323] = "evmhegsmfaaRRR", [1324] = "evmhogumiaaRRR",
[1325] = "evmhogsmiaaRRR", [1327] = "evmhogsmfaaRRR",
[1344] = "evmwlusiaawRRR", [1345] = "evmwlssiaawRRR",
[1352] = "evmwlumiaawRRR", [1353] = "evmwlsmiaawRRR",
[1363] = "evmwssfaaRRR", [1368] = "evmwumiaaRRR",
[1369] = "evmwsmiaaRRR", [1371] = "evmwsmfaaRRR",
[1408] = "evmheusianwRRR", [1409] = "evmhessianwRRR",
[1411] = "evmhessfanwRRR", [1412] = "evmhousianwRRR",
[1413] = "evmhossianwRRR", [1415] = "evmhossfanwRRR",
[1416] = "evmheumianwRRR", [1417] = "evmhesmianwRRR",
[1419] = "evmhesmfanwRRR", [1420] = "evmhoumianwRRR",
[1421] = "evmhosmianwRRR", [1423] = "evmhosmfanwRRR",
[1448] = "evmhegumianRRR", [1449] = "evmhegsmianRRR",
[1451] = "evmhegsmfanRRR", [1452] = "evmhogumianRRR",
[1453] = "evmhogsmianRRR", [1455] = "evmhogsmfanRRR",
[1472] = "evmwlusianwRRR", [1473] = "evmwlssianwRRR",
[1480] = "evmwlumianwRRR", [1481] = "evmwlsmianwRRR",
[1491] = "evmwssfanRRR", [1496] = "evmwumianRRR",
[1497] = "evmwsmianRRR", [1499] = "evmwsmfanRRR",
}
local map_pri = {
[0] = false, false, "tdiARI", "twiARI",
map_spe, false, false, "mulliRRI",
"subficRRI", false, "cmpl_iYLRU", "cmp_iYLRI",
"addicRRI", "addic.RRI", "addi|liRR0I", "addis|lisRR0I",
"b_KBJ", "sc", "bKJ", map_crops,
"rlwimiRR~AAA.", map_rlwinm, false, "rlwnmRR~RAA.",
"oriNRR~U", "orisRR~U", "xoriRR~U", "xorisRR~U",
"andi.RR~U", "andis.RR~U", map_rld, map_ext,
"lwzRRD", "lwzuRRD", "lbzRRD", "lbzuRRD",
"stwRRD", "stwuRRD", "stbRRD", "stbuRRD",
"lhzRRD", "lhzuRRD", "lhaRRD", "lhauRRD",
"sthRRD", "sthuRRD", "lmwRRD", "stmwRRD",
"lfsFRD", "lfsuFRD", "lfdFRD", "lfduFRD",
"stfsFRD", "stfsuFRD", "stfdFRD", "stfduFRD",
false, false, map_ld, map_fps,
false, false, map_std, map_fpd,
}
------------------------------------------------------------------------------
local map_gpr = {
[0] = "r0", "sp", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
}
local map_cond = { [0] = "lt", "gt", "eq", "so", "ge", "le", "ne", "ns", }
-- Format a condition bit.
local function condfmt(cond)
if cond <= 3 then
return map_cond[band(cond, 3)]
else
return format("4*cr%d+%s", rshift(cond, 2), map_cond[band(cond, 3)])
end
end
------------------------------------------------------------------------------
-- Output a nicely formatted line with an opcode and operands.
local function putop(ctx, text, operands)
local pos = ctx.pos
local extra = ""
if ctx.rel then
local sym = ctx.symtab[ctx.rel]
if sym then extra = "\t->"..sym end
end
if ctx.hexdump > 0 then
ctx.out(format("%08x %s %-7s %s%s\n",
ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra))
else
ctx.out(format("%08x %-7s %s%s\n",
ctx.addr+pos, text, concat(operands, ", "), extra))
end
ctx.pos = pos + 4
end
-- Fallback for unknown opcodes.
local function unknown(ctx)
return putop(ctx, ".long", { "0x"..tohex(ctx.op) })
end
-- Disassemble a single instruction.
local function disass_ins(ctx)
local pos = ctx.pos
local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4)
local op = bor(lshift(b0, 24), lshift(b1, 16), lshift(b2, 8), b3)
local operands = {}
local last = nil
local rs = 21
ctx.op = op
ctx.rel = nil
local opat = map_pri[rshift(b0, 2)]
while type(opat) ~= "string" do
if not opat then return unknown(ctx) end
opat = opat[band(rshift(op, opat.shift), opat.mask)]
end
local name, pat = match(opat, "^([a-z0-9_.]*)(.*)")
local altname, pat2 = match(pat, "|([a-z0-9_.]*)(.*)")
if altname then pat = pat2 end
for p in gmatch(pat, ".") do
local x = nil
if p == "R" then
x = map_gpr[band(rshift(op, rs), 31)]
rs = rs - 5
elseif p == "F" then
x = "f"..band(rshift(op, rs), 31)
rs = rs - 5
elseif p == "A" then
x = band(rshift(op, rs), 31)
rs = rs - 5
elseif p == "S" then
x = arshift(lshift(op, 27-rs), 27)
rs = rs - 5
elseif p == "I" then
x = arshift(lshift(op, 16), 16)
elseif p == "U" then
x = band(op, 0xffff)
elseif p == "D" or p == "E" then
local disp = arshift(lshift(op, 16), 16)
if p == "E" then disp = band(disp, -4) end
if last == "r0" then last = "0" end
operands[#operands] = format("%d(%s)", disp, last)
elseif p >= "2" and p <= "8" then
local disp = band(rshift(op, rs), 31) * p
if last == "r0" then last = "0" end
operands[#operands] = format("%d(%s)", disp, last)
elseif p == "H" then
x = band(rshift(op, rs), 31) + lshift(band(op, 2), 4)
rs = rs - 5
elseif p == "M" then
x = band(rshift(op, rs), 31) + band(op, 0x20)
elseif p == "C" then
x = condfmt(band(rshift(op, rs), 31))
rs = rs - 5
elseif p == "B" then
local bo = rshift(op, 21)
local cond = band(rshift(op, 16), 31)
local cn = ""
rs = rs - 10
if band(bo, 4) == 0 then
cn = band(bo, 2) == 0 and "dnz" or "dz"
if band(bo, 0x10) == 0 then
cn = cn..(band(bo, 8) == 0 and "f" or "t")
end
if band(bo, 0x10) == 0 then x = condfmt(cond) end
name = name..(band(bo, 1) == band(rshift(op, 15), 1) and "-" or "+")
elseif band(bo, 0x10) == 0 then
cn = map_cond[band(cond, 3) + (band(bo, 8) == 0 and 4 or 0)]
if cond > 3 then x = "cr"..rshift(cond, 2) end
name = name..(band(bo, 1) == band(rshift(op, 15), 1) and "-" or "+")
end
name = gsub(name, "_", cn)
elseif p == "J" then
x = arshift(lshift(op, 27-rs), 29-rs)*4
if band(op, 2) == 0 then x = ctx.addr + pos + x end
ctx.rel = x
x = "0x"..tohex(x)
elseif p == "K" then
if band(op, 1) ~= 0 then name = name.."l" end
if band(op, 2) ~= 0 then name = name.."a" end
elseif p == "X" or p == "Y" then
x = band(rshift(op, rs+2), 7)
if x == 0 and p == "Y" then x = nil else x = "cr"..x end
rs = rs - 5
elseif p == "W" then
x = "cr"..band(op, 7)
elseif p == "Z" then
x = band(rshift(op, rs-4), 255)
rs = rs - 10
elseif p == ">" then
operands[#operands] = rshift(operands[#operands], 1)
elseif p == "0" then
if last == "r0" then
operands[#operands] = nil
if altname then name = altname end
end
elseif p == "L" then
name = gsub(name, "_", band(op, 0x00200000) ~= 0 and "d" or "w")
elseif p == "." then
if band(op, 1) == 1 then name = name.."." end
elseif p == "N" then
if op == 0x60000000 then name = "nop"; break end
elseif p == "~" then
local n = #operands
operands[n-1], operands[n] = operands[n], operands[n-1]
elseif p == "=" then
local n = #operands
if last == operands[n-1] then
operands[n] = nil
name = altname
end
elseif p == "%" then
local n = #operands
if last == operands[n-1] and last == operands[n-2] then
operands[n] = nil
operands[n-1] = nil
name = altname
end
elseif p == "-" then
rs = rs - 5
else
assert(false)
end
if x then operands[#operands+1] = x; last = x end
end
return putop(ctx, name, operands)
end
------------------------------------------------------------------------------
-- Disassemble a block of code.
local function disass_block(ctx, ofs, len)
if not ofs then ofs = 0 end
local stop = len and ofs+len or #ctx.code
stop = stop - stop % 4
ctx.pos = ofs - ofs % 4
ctx.rel = nil
while ctx.pos < stop do disass_ins(ctx) end
end
-- Extended API: create a disassembler context. Then call ctx:disass(ofs, len).
local function create_(code, addr, out)
local ctx = {}
ctx.code = code
ctx.addr = addr or 0
ctx.out = out or io.write
ctx.symtab = {}
ctx.disass = disass_block
ctx.hexdump = 8
return ctx
end
-- Simple API: disassemble code (a string) at address and output via out.
local function disass_(code, addr, out)
create_(code, addr, out):disass()
end
-- Return register name for RID.
local function regname_(r)
if r < 32 then return map_gpr[r] end
return "f"..(r-32)
end
-- Public module functions.
module(...)
create = create_
disass = disass_
regname = regname_
| mit |
fqrouter/luci | applications/luci-watchcat/luasrc/model/cbi/watchcat/watchcat.lua | 45 | 2111 | --[[
LuCI - Lua Configuration Interface
Copyright 2012 Christian Gagneraud <chris@techworks.ie>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
]]--
m = Map("system",
translate("Watchcat"),
translate("Watchcat allows to configure a periodic reboot and/or when " ..
"internet connection has been lost for a certain period of time."
))
s = m:section(TypedSection, "watchcat")
s.anonymous = true
s.addremove = true
mode = s:option(ListValue, "mode",
translate("Operating mode"))
mode.default = "allways"
mode:value("ping", "Reboot on internet connection lost")
mode:value("allways", "Periodic reboot")
forcedelay = s:option(Value, "forcedelay",
translate("Forced reboot delay"),
translate("When rebooting the system the watchcat will trigger a soft reboot, " ..
"Entering a non zero value here, will trigger a delayed hard reboot " ..
"if the soft reboot fails. Enter a number of seconds to enable, " ..
"use 0 to disable"))
forcedelay.datatype = "uinteger"
forcedelay.default = "0"
period = s:option(Value, "period",
translate("Period"),
translate("In periodic mode, it defines the reboot period. " ..
"In internet mode, it defines the longest period of " ..
"time without internet access before a reboot is engaged." ..
"Default unit is seconds, you can use the " ..
"suffix 'm' for minutes, 'h' for hours or 'd' " ..
"for days"))
pinghost = s:option(Value, "pinghost",
translate("Ping host"),
translate("Host address to ping"))
pinghost.datatype = "host"
pinghost.default = "8.8.8.8"
pinghost:depends({mode="ping"})
pingperiod = s:option(Value, "pingperiod",
translate("Ping period"),
translate("How often to check internet connection. " ..
"Default unit is seconds, you can you use the " ..
"suffix 'm' for minutes, 'h' for hours or 'd' " ..
"for days"))
pingperiod:depends({mode="ping"})
return m
| apache-2.0 |
patrikrm13/feri | plugins/pluginns.lua | 285 | 6096 | do
-- Returns the key (index) in the config.enabled_plugins table
local function plugin_enabled( name )
for k,v in pairs(_config.enabled_plugins) do
if name == v then
return k
end
end
-- If not found
return false
end
-- Returns true if file exists in plugins folder
local function plugin_exists( name )
for k,v in pairs(plugins_names()) do
if name..'.lua' == v then
return true
end
end
return false
end
local function list_all_plugins(only_enabled)
local text = ''
local nsum = 0
for k, v in pairs( plugins_names( )) do
-- ✅ enabled, ⛔️ disabled
local status = '⛔️'
nsum = nsum+1
nact = 0
-- Check if is enabled
for k2, v2 in pairs(_config.enabled_plugins) do
if v == v2..'.lua' then
status = '✅'
end
nact = nact+1
end
if not only_enabled or status == '✅' then
-- get the name
v = string.match (v, "(.*)%.lua")
text = text..nsum..'. '..v..' '..status..'\n'
end
end
local text = text..'\nThere are '..nsum..' plugins installed.\n'..nact..' plugins enabled and '..nsum-nact..' disabled'
return text
end
local function list_plugins(only_enabled)
local text = ''
local nsum = 0
for k, v in pairs( plugins_names( )) do
-- ✅ enabled, ⛔️ disabled
local status = '⛔️'
nsum = nsum+1
nact = 0
-- Check if is enabled
for k2, v2 in pairs(_config.enabled_plugins) do
if v == v2..'.lua' then
status = '✅'
end
nact = nact+1
end
if not only_enabled or status == '✅' then
-- get the name
v = string.match (v, "(.*)%.lua")
text = text..v..' '..status..'\n'
end
end
local text = text..'\n'..nact..' plugins enabled from '..nsum..' plugins installed.'
return text
end
local function reload_plugins( )
plugins = {}
load_plugins()
return list_plugins(true)
end
local function enable_plugin( plugin_name )
print('checking if '..plugin_name..' exists')
-- Check if plugin is enabled
if plugin_enabled(plugin_name) then
return 'Plugin '..plugin_name..' is enabled'
end
-- Checks if plugin exists
if plugin_exists(plugin_name) then
-- Add to the config table
table.insert(_config.enabled_plugins, plugin_name)
print(plugin_name..' added to _config table')
save_config()
-- Reload the plugins
return reload_plugins( )
else
return 'Plugin '..plugin_name..' does not exists'
end
end
local function disable_plugin( name, chat )
-- Check if plugins exists
if not plugin_exists(name) then
return 'Plugin '..name..' does not exists'
end
local k = plugin_enabled(name)
-- Check if plugin is enabled
if not k then
return 'Plugin '..name..' not enabled'
end
-- Disable and reload
table.remove(_config.enabled_plugins, k)
save_config( )
return reload_plugins(true)
end
local function disable_plugin_on_chat(receiver, plugin)
if not plugin_exists(plugin) then
return "Plugin doesn't exists"
end
if not _config.disabled_plugin_on_chat then
_config.disabled_plugin_on_chat = {}
end
if not _config.disabled_plugin_on_chat[receiver] then
_config.disabled_plugin_on_chat[receiver] = {}
end
_config.disabled_plugin_on_chat[receiver][plugin] = true
save_config()
return 'Plugin '..plugin..' disabled on this chat'
end
local function reenable_plugin_on_chat(receiver, plugin)
if not _config.disabled_plugin_on_chat then
return 'There aren\'t any disabled plugins'
end
if not _config.disabled_plugin_on_chat[receiver] then
return 'There aren\'t any disabled plugins for this chat'
end
if not _config.disabled_plugin_on_chat[receiver][plugin] then
return 'This plugin is not disabled'
end
_config.disabled_plugin_on_chat[receiver][plugin] = false
save_config()
return 'Plugin '..plugin..' is enabled again'
end
local function run(msg, matches)
-- Show the available plugins
if matches[1] == '!plugins' and is_sudo(msg) then --after changed to moderator mode, set only sudo
return list_all_plugins()
end
-- Re-enable a plugin for this chat
if matches[1] == '+' and matches[3] == 'chat' then
local receiver = get_receiver(msg)
local plugin = matches[2]
print("enable "..plugin..' on this chat')
return reenable_plugin_on_chat(receiver, plugin)
end
-- Enable a plugin
if matches[1] == '+' and is_sudo(msg) then --after changed to moderator mode, set only sudo
local plugin_name = matches[2]
print("enable: "..matches[2])
return enable_plugin(plugin_name)
end
-- Disable a plugin on a chat
if matches[1] == '-' and matches[3] == 'chat' then
local plugin = matches[2]
local receiver = get_receiver(msg)
print("disable "..plugin..' on this chat')
return disable_plugin_on_chat(receiver, plugin)
end
-- Disable a plugin
if matches[1] == '-' and is_sudo(msg) then --after changed to moderator mode, set only sudo
if matches[2] == 'plugins' then
return 'This plugin can\'t be disabled'
end
print("disable: "..matches[2])
return disable_plugin(matches[2])
end
-- Reload all the plugins!
if matches[1] == '?' and is_sudo(msg) then --after changed to moderator mode, set only sudo
return reload_plugins(true)
end
end
return {
description = "Plugin to manage other plugins. Enable, disable or reload.",
usage = {
moderator = {
"!plugins - [plugin] chat : disable plugin only this chat.",
"!plugins + [plugin] chat : enable plugin only this chat.",
},
sudo = {
"!plugins : list all plugins.",
"!plugins + [plugin] : enable plugin.",
"!plugins - [plugin] : disable plugin.",
"!plugins ? : reloads all plugins." },
},
patterns = {
"^!plugins$",
"^!plugins? (+) ([%w_%.%-]+)$",
"^!plugins? (-) ([%w_%.%-]+)$",
"^!plugins? (+) ([%w_%.%-]+) (chat)",
"^!plugins? (-) ([%w_%.%-]+) (chat)",
"^!plugins? (?)$" },
run = run,
moderated = true, -- set to moderator mode
--privileged = true
}
end
| gpl-2.0 |
kitala1/darkstar | scripts/commands/mobhere.lua | 26 | 1312 | ---------------------------------------------------------------------------------------------------
-- func: @mobhere <mobId>
-- desc: Spawns a MOB and then moves it to the current position, if in same zone.
-- Errors will despawn the mobID unless "noDepop" was specified (any value works).
---------------------------------------------------------------------------------------------------
cmdprops =
{
permission = 1,
parameters = "ii"
};
function onTrigger(player, mobId, noDepop)
if (mobId == nil) then
player:PrintToPlayer("You must enter a valid MobID.");
return;
end
local mob = GetMobByID(mobId);
if (mob == nil) then
player:PrintToPlayer( string.format( "Mob with ID '%i' not found!", mobId ) );
return;
end
SpawnMob( mobId );
if (player:getZoneID() == mob:getZoneID()) then
mob:setPos( player:getXPos(), player:getYPos(), player:getZPos(), player:getRotPos(), player:getZoneID() );
else
if (noDepop == nil or noDepop == 0) then
DespawnMob( mobId );
player:PrintToPlayer("Despawned the mob because of an error.");
end
player:PrintToPlayer("Mob could not be moved to current pos - you are probably in the wrong zone.");
end
end; | gpl-3.0 |
kitala1/darkstar | scripts/zones/Dynamis-Windurst/bcnms/dynamis_windurst.lua | 10 | 1174 | -----------------------------------
-- Area: Dynamis Windurst
-- Name: Dynamis Windurst
-----------------------------------
-- After registering the BCNM via bcnmRegister(bcnmid)
function onBcnmRegister(player,instance)
SetServerVariable("[DynaWindurst]UniqueID",player:getDynamisUniqueID(1282));
SetServerVariable("[DynaWindurst]Boss_Trigger",0);
SetServerVariable("[DynaWindurst]Already_Received",0);
end;
-- Physically entering the BCNM via bcnmEnter(bcnmid)
function onBcnmEnter(player,instance)
player:setVar("DynamisID",GetServerVariable("[DynaWindurst]UniqueID"));
local realDay = os.time();
local dynaWaitxDay = player:getVar("dynaWaitxDay");
if ((dynaWaitxDay + (BETWEEN_2DYNA_WAIT_TIME * 24 * 60 * 60)) < realDay) then
player:setVar("dynaWaitxDay",realDay);
end
end;
-- Leaving the Dynamis by every mean possible, given by the LeaveCode
-- 3=Disconnected or warped out (if dyna is empty: launch 4 after 3)
-- 4=Finish he dynamis
function onBcnmLeave(player,instance,leavecode)
--print("leave code "..leavecode);
if(leavecode == 4) then
GetNPCByID(17543480):setStatus(2);
SetServerVariable("[DynaWindurst]UniqueID",0);
end
end; | gpl-3.0 |
kitala1/darkstar | scripts/globals/items/bowl_of_yayla_corbasi_+1.lua | 35 | 1485 | -----------------------------------------
-- ID: 5580
-- Item: bowl_of_yayla_corbasi_+1
-- Food Effect: 4Hrs, All Races
-----------------------------------------
-- HP 25
-- Dexterity -1
-- Vitality 3
-- HP Recovered While Healing 5
-- MP Recovered While Healing 2
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,14400,5580);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 25);
target:addMod(MOD_DEX, -1);
target:addMod(MOD_VIT, 3);
target:addMod(MOD_HPHEAL, 5);
target:addMod(MOD_MPHEAL, 2);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 25);
target:delMod(MOD_DEX, -1);
target:delMod(MOD_VIT, 3);
target:delMod(MOD_HPHEAL, 5);
target:delMod(MOD_MPHEAL, 2);
end;
| gpl-3.0 |
paulosalvatore/maruim_server | data/actions/scripts/geral.lua | 1 | 34541 | local fire_source = {1786, 1788, 1790, 1792, 1481, 1482, 1483, 1484, 6356, 6358, 6360, 6362}
local fruits = {2673, 2674, 2675, 2677, 2679, 2680, 2681, 2682, 5097, 8840, 12415}
local ice_shrine = {7508, 7509, 7510, 7511}
local fire_shrine = {7504, 7505, 7506, 7507}
local earth_shrine = {7516, 7517, 7518, 7519}
local energy_shrine = {7512, 7513, 7514, 7515}
local ferro = {5866, 5868}
local carvao = {8748, 8749, 8750, 8751}
local config = {
-- [item_id ou "action" ou "unique"] = {
-- [target_id ou "fire_source" ou "fruits" ou "sparkling" ou "default"] = {
-- itensPlayer = {{id, quantidade ou {min, max}}},
-- removerItensPlayer = {{id, quantidade}},
-- transformarAleatorio = {{id, quantidade, chance}},
-- itensGame = {{id, quantidade {min, max}, posicao}},
-- removerItem = 0 ou 1,
-- removerTarget = 0 ou 1,
-- transformar = {id, quantidade ou {min, max}},
-- efeito = {efeito, posicao},
-- criatura = {nome_criatura, chance}
-- tempo = milissegundos,
-- chanceSucesso = 1% = 100,
-- chanceNeutra = 1% = 100,
-- profissao = "nome da profissão",
-- sons = {"som"},
-- checarPz = true
-- },
-- }
[6277] = {
["fire_source"] = {
itensPlayer = {{6278, 1}},
removerItem = 1,
efeito = {"fire"}
},
[6574] = {
transformar = {8846, 1},
removerItem = 1,
efeito = {"hit"}
},
[2561] = {
transformar = {8848, 1},
efeito = {"hit"}
},
},
[8846] = {
["fire_source"] = {
itensPlayer = {{8847, 1}},
removerItem = 1,
efeito = {"fire"}
}
},
[8848] = {
["fire_source"] = {
itensPlayer = {{2561, 1}, {2687, 12}},
efeito = {"fire"}
}
},
[9112] = {
[9114] = {
itensPlayer = {{9113, 1}},
removerItem = 1,
removerTarget = 1,
efeito = {"hit"}
}
},
[5467] = {
[5469] = {
removerItem = 1,
transformar = {5513, 1},
efeito = {"hit"}
},
[5470] = {
removerItem = 1,
transformar = {5514, 1},
efeito = {"hit"}
},
[2694] = {
removerItem = 1,
transformar = {13939, 1},
efeito = {"hit"}
}
},
[2565] = {
["sparkling"] = {
[4184] = {
itensPlayer = {{7251, 1}},
removerTarget = 1,
efeito = {"hit"},
tempo = 5*60*1000
},
[8573] = {
itensPlayer = {{7247, 1}},
removerTarget = 1,
efeito = {"hit"},
tempo = 5*60*1000
}
}
},
[2566] = {
[2674] = {
itensPlayer = {{6279, 1}},
removerItensPlayer = {{6278, 1}},
removerTarget = 1,
},
[2677] = {
itensPlayer = {{6279, 1}},
removerItensPlayer = {{6278, 1}},
removerTarget = 1,
},
[2679] = {
itensPlayer = {{6279, 1}},
removerItensPlayer = {{6278, 1}},
removerTarget = 1,
},
[2680] = {
itensPlayer = {{6279, 1}},
removerItensPlayer = {{6278, 1}},
removerTarget = 1,
},
[2683] = {
transformar = {2096, 1},
efeito = {"hit"}
},
["sparkling"] = {
[7261] = {
itensPlayer = {{7248, 1}},
removerTarget = 1,
efeito = {"hit"},
tempo = 5*60*1000,
chanceSucesso = 2000,
chanceNeutra = 4000,
profissao = "alquimista"
},
[4017] = {
itensPlayer = {{7249, 1}},
removerTarget = 1,
efeito = {"hit"},
tempo = 5*60*1000,
chanceSucesso = 2000,
chanceNeutra = 4000,
profissao = "alquimista"
},
[2733] = {
itensPlayer = {{7245, 1}},
removerTarget = 1,
efeito = {"hit"},
tempo = 5*60*1000,
chanceSucesso = 2000,
chanceNeutra = 4000,
profissao = "alquimista"
},
[2720] = {
itensPlayer = {{2798, 1}},
removerTarget = 1,
efeito = {"hit"},
tempo = 5*60*1000,
chanceSucesso = 2000,
chanceNeutra = 4000,
profissao = "alquimista"
},
[4018] = {
itensPlayer = {{2801, 1}},
removerTarget = 1,
efeito = {"hit"},
tempo = 5*60*1000,
chanceSucesso = 2000,
chanceNeutra = 4000,
profissao = "alquimista"
}
}
},
[4006] = {
["default"] = {
itensPlayer = {{2675, {1, 8}}},
transformar = {4008, 1, "item"},
efeito = {"hit"},
criatura = {"Squirrel", 1000}
}
},
[5157] = {
["default"] = {
itensPlayer = {{5097, {1, 8}}},
transformar = {5156, 1, "item"},
efeito = {"hit"},
criatura = {"Squirrel", 1000}
}
},
[12014] = {
["default"] = {
transformar = {12016, 1, "item"}
}
},
[12015] = {
["default"] = {
transformar = {12017, 1, "item"}
}
},
[12016] = {
["default"] = {
transformar = {12014, 1, "item"}
}
},
[12017] = {
["default"] = {
transformar = {12015, 1, "item"}
}
},
[5865] = {
["fruits"] = {
itensPlayer = {{2006, 1, 21}},
removerItensPlayer = {{2006, 1, 0}},
removerTarget = 1,
},
[2678] = {
itensPlayer = {{2006, 1, 14}},
removerItensPlayer = {{2006, 1, 0}},
removerTarget = 1,
},
[8841] = {
itensPlayer = {{2006, 1, 5}},
removerItensPlayer = {{2006, 1, 0}},
removerTarget = 1,
}
},
[18336] = {
["default"] = {
itensPlayer = {{18337, 1}},
transformar = {18333, 1, "item"},
efeito = {"hit"},
chanceSucesso = 2000,
chanceNeutra = 4000,
profissao = "ferreiro"
}
},
[5908] = {
[7441] = {
transformar = {7442, 1},
efeito = {"hit"},
chanceQuebrar = 4000
},
[7442] = {
transformar = {7444, 1},
efeito = {"hit"},
chanceQuebrar = 3000
},
[7444] = {
transformar = {7445, 1},
efeito = {"hit"},
chanceQuebrar = 2000
},
[7445] = {
transformar = {7446, 1},
efeito = {"hit"},
chanceQuebrar = 1000
},
[11343] = {
transformarAleatorio = {{11344, 1, 4500}, {11345, 1, 4500}, {11346, 1, 1000}},
efeito = {"hit"}
},
[7339] = {
itensPlayer = {{11209, 1}},
transformar = {7340, 1},
efeito = {"hit"},
chanceSucesso = 2000,
profissao = "alfaiate"
},
[2905] = {
itensPlayer = {{11236, 1}},
transformar = {2906, 1},
efeito = {"hit"},
chanceSucesso = 2000,
profissao = "alfaiate"
},
[2914] = {
itensPlayer = {{12404, 1}},
transformar = {2915, 1},
efeito = {"hit"},
chanceSucesso = 2000,
profissao = "alfaiate"
},
["sparkling"] = {
[10803] = {
itensPlayer = {{13219, 1}},
removerTarget = 1,
efeito = {"hit"},
tempo = 5*60*1000,
chanceSucesso = 2000,
chanceNeutra = 4000,
profissao = "alquimista"
},
[10917] = {
itensPlayer = {{13216, 1}},
removerTarget = 1,
efeito = {"hit"},
tempo = 5*60*1000,
chanceSucesso = 2000,
chanceNeutra = 4000,
profissao = "alquimista"
},
[11671] = {
itensPlayer = {{13222, 1}},
removerTarget = 1,
efeito = {"hit"},
tempo = 5*60*1000,
chanceSucesso = 2000,
chanceNeutra = 4000,
profissao = "alquimista"
},
[11672] = {
itensPlayer = {{13217, 1}},
removerTarget = 1,
efeito = {"hit"},
tempo = 5*60*1000,
chanceSucesso = 2000,
chanceNeutra = 4000,
profissao = "alquimista"
},
[11673] = {
itensPlayer = {{13220, 1}},
removerTarget = 1,
efeito = {"hit"},
tempo = 5*60*1000,
chanceSucesso = 2000,
chanceNeutra = 4000,
profissao = "alquimista"
},
[11675] = {
itensPlayer = {{13221, 1}},
removerTarget = 1,
efeito = {"hit"},
tempo = 5*60*1000,
chanceSucesso = 2000,
chanceNeutra = 4000,
profissao = "alquimista"
},
[11676] = {
itensPlayer = {{13218, 1}},
removerTarget = 1,
efeito = {"hit"},
tempo = {5*60*1000, 10*60*1000},
chanceSucesso = 2000,
chanceNeutra = 4000,
profissao = "alquimista"
}
}
},
[11339] = {
["default"] = {
transformarAleatorio = {{11340, 1, 4500}, {11341, 1, 4500}, {11342, 1, 1000}},
transformarAleatorioTipo = "item",
efeito = {"hit"}
}
},
[19948] = {
[19959] = {
transformar = {19960, 1},
removerItem = 1,
efeito = {"hit"}
}
},
[10317] = {
["default"] = {
transformar = {10363, 1, "item"},
efeito = {"rage_skies", "player"}
}
},
[7286] = {
[7106] = {
itensGame = {{7108, 1}}
}
},
[13193] = {
[13215] = {
transformar = {13197, 1},
removerItem = 1,
efeito = {"hit"}
},
[13214] = {
transformar = {13198, 1},
removerItem = 1,
efeito = {"hit"}
}
},
[13194] = {
[13213] = {
transformar = {13198, 1},
removerItem = 1,
efeito = {"hit"}
},
[13215] = {
transformar = {13196, 1},
removerItem = 1,
efeito = {"hit"}
}
},
[13195] = {
[13214] = {
transformar = {13196, 1},
removerItem = 1,
efeito = {"hit"}
},
[13213] = {
transformar = {13197, 1},
removerItem = 1,
efeito = {"hit"}
}
},
[11421] = {
["sparkling"] = {
["ferro"] = {
itensPlayerAleatorio = {{5892, 1, 100}, {5880, 1, 3900}, {2225, {1, 2}, 6000}},
removerTarget = 1,
efeito = {"hit"},
tempo = 3*60*1000,
chanceSucesso = 2000,
chanceNeutra = 4000,
profissao = "ferreiro",
expProfissao = 10
},
["carvao"] = {
itensPlayer = {{13757, 1}},
removerTarget = 1,
efeito = {"hit"},
tempo = 5*60*1000,
chanceSucesso = 2000,
chanceNeutra = 4000,
profissao = "ferreiro",
expProfissao = 10
}
}
},
[2559] = {
["sparkling"] = {
["arvores"] = {
itensPlayerAleatorio = {{5901, 1, 10000}},
removerTarget = 1,
efeito = {"hit"},
tempo = 3*60*1000,
chanceSucesso = 3000,
chanceNeutra = 3000,
profissao = "ferreiro",
expProfissao = 5
}
}
},
["sparkling"] = {
["default"] = {
checarItem = 2743,
itensPlayerAleatorio = {{5921, 1, 10000}},
removerItem = 1,
efeito = {"hit"},
tempo = 2*60*1000,
chanceSucesso = 5000,
chanceNeutra = 2000,
-- profissao = "alquimista",
-- expProfissao = 10
}
},
[13757] = {
[7131] = {
transformar = {10037, 1},
removerItem = 1
}
},
[2146] = {
["ice_shrine"] = {
itensPlayer = {{7759, 1}},
removerItensPlayer = {{21246, 1}},
efeito = {42},
removerItem = 1
},
["sparkling"] = {
actionId = 3300,
adicionarStorage = {3300, 1},
efeito = {44},
removerItem = 1
}
},
[2147] = {
["fire_shrine"] = {
itensPlayer = {{7760, 1}},
removerItensPlayer = {{21246, 1}},
efeito = {7},
removerItem = 1
}
},
[2149] = {
["earth_shrine"] = {
itensPlayer = {{7761, 1}},
removerItensPlayer = {{21246, 1}},
efeito = {9},
removerItem = 1
},
["sparkling"] = {
actionId = 3301,
adicionarStorage = {3301, 1},
efeito = {46},
removerItem = 1
}
},
[2150] = {
["energy_shrine"] = {
itensPlayer = {{7762, 1}},
removerItensPlayer = {{21246, 1}},
efeito = {"choque_roxo"},
removerItem = 1
}
},
[21247] = {
[21430] = {
itensPlayer = {{21446, 1}},
transformar = {21431, 1},
efeito = {"choque_roxo"},
removerItem = 1
}
},
[2093] = {
["default"] = {
efeito = {"smoke", {y = -1}}
}
},
[2099] = {
["default"] = {
efeito = {"smoke", {y = -1}}
}
},
[3421] = {
["default"] = {
actionId = 2902,
verificarPosicaoTeleportar = {
{{y = -1}, {y = 1}, "item", "sul"},
{{y = 1}, {y = -1}, "item", "norte"}
},
efeitoTeleport = "poff",
checarPz = true
}
},
[14756] = {
["default"] = {
verificarPosicaoTeleportar = {
{{y = -1}, {y = 1}, "item", "sul"},
{{y = 1}, {y = -1}, "item", "norte"}
},
efeitoTeleport = "poff"
}
},
[14768] = {
["default"] = {
verificarPosicaoTeleportar = {
{{x = -1}, {x = 1}, "item", "leste"},
{{x = 1}, {x = -1}, "item", "oeste"}
},
efeitoTeleport = "poff"
}
},
[11754] = {
["default"] = {
transformar = {11755, 1, "item"},
sons = {
"NO ONE WILL STOP ME THIS TIME!",
"THE POWER IS MINE!",
"Mwahaha!"
}
}
},
[7552] = {
["default"] = {
chances = {
[1000] = {
transformar = {7553, 1, "item"},
itensPlayer = {{7632, 1}},
mensagemPlayer = '"Você encontrou uma bela pérola!"',
efeito = {"hit"}
},
[2000] = {
transformar = {7553, 1, "item"},
itensPlayer = {{7633, 1}},
mensagemPlayer = '"Você encontrou uma bela pérola!"',
efeito = {"hit"}
},
[6000] = {
transformar = {7553, 1, "item"},
dano = {"físico", "fixo", -200},
mensagemPlayer = '"Você esmagou seus dedos!"',
efeito = {"hit"}
},
[10000] = {
transformar = {7553, 1, "item"},
mensagemPlayer = '"Parece estar vazia."',
efeito = {"hit"}
},
}
}
},
[10153] = {
[9802] = {
chances = {
[1500] = {
transformar = {9803, 1},
itensPlayer = {{10151, 1}},
mensagemPlayer = '"Você salvou uma parte do golem."',
efeito = {"hit"}
},
[3500] = {
transformar = {9803, 1},
criatura = "Rat",
mensagemPlayer = '"Algo estava preso no golem."'
},
[5500] = {
transformar = {9803, 1},
dano = {"energia", "cargas", 8, 8000, -35},
mensagemPlayer = '"Que experiência eletrificante!"',
efeito = {"hit"}
},
[7500] = {
transformar = {9803, 1},
itensPlayer = {{8309, {1, 8}}},
mensagemPlayer = '"Você recuperou algumas sucatas!"',
efeito = {"hit"}
},
[10000] = {
transformar = {9803, 1},
mensagemPlayer = '"Você arruinou o que sobrou do golem."',
efeito = {"poff"}
}
}
}
},
[23875] = {
[5880] = {
itensGamePlayer = {{12505, 1}},
removerItem = 1,
removerTarget = 1,
efeito = {"green", "player_target"},
chanceSucesso = 5000,
profissao = "ferreiro",
nivelProfissao = 2,
expProfissao = 40
},
[5901] = {
itensGamePlayer = {{12503, 1}},
removerItem = 1,
removerTarget = 1,
efeito = {"green", "player_target"},
chanceSucesso = 1000
},
[5920] = {
itensGamePlayer = {{12506, 1}},
removerItem = 1,
removerTarget = 1,
efeito = {"green", "player_target"},
chanceSucesso = 1000
},
[7242] = {
itensGamePlayer = {{12508, 1}},
removerItem = 1,
removerTarget = 1,
removerItem = 1,
efeito = {"green", "player_target"},
chanceSucesso = 1000
},
[8860] = {
itensGamePlayer = {{12501, 1}},
removerItem = 1,
removerTarget = 1,
efeito = {"green", "player_target"},
chanceSucesso = 1000
},
[2193] = {
itensGamePlayer = {{2354, 1}},
removerItem = 1,
removerTarget = 1,
efeito = {"green", "player_target"},
chanceSucesso = 5000,
profissao = "ferreiro",
expProfissao = 40
}
},
[2225] = {
["default"] = {
itensGamePlayer = {{5880, 1}},
removerItensNecessarios = 1,
quantidadeItemNecessaria = 3,
profissao = "ferreiro",
efeito = {"green", "player_item"},
expProfissao = 10
}
},
[2327] = {
[6104] = {
transformar = {2354, 1, "item"},
removerTarget = 1,
efeito = {"green", "player_item"}
}
},
[13559] = {
["default"] = {
transformar = {13581, 1, "item"},
sons = {
"Mhausheausheu! What a FAIL! Mwahaha!",
"Hail |PLAYERNAME|! You are wearing old socks!",
"You are so unpopular even your own shadow refuses to follow you."
}
}
},
[13028] = {
["default"] = {
transformar = {13029, 1, "item"},
sons = {
"The world was born from the love",
"Look after the frozen heart. I've left it with you",
"Could a dead, frozen heart beat again? It felt like mine was about to.",
"Hail |PLAYERNAME|!"
}
}
},
[13030] = {
["default"] = {
transformar = {13031, 1, "item"},
sons = {
"For zze emperor!",
"Hail |PLAYERNAME|!!"
}
}
},
[13032] = {
["default"] = {
transformar = {13033, 1, "item"}
}
},
[16105] = {
["default"] = {
transformar = {16106, 1, "item"},
sons = {
"Where isss my body !? I'll kill you!!!",
"Hail mighty |PLAYERNAME|",
"I will petrify thiss moment! Ssstones are forever!"
}
}
},
[23496] = {
["default"] = {
transformar = {23500, 1, "item"}
}
},
[23497] = {
["default"] = {
transformar = {23501, 1, "item"}
}
},
[23498] = {
["default"] = {
transformar = {23502, 1, "item"}
}
},
[23499] = {
["default"] = {
transformar = {23503, 1, "item"}
}
},
[23500] = {
["default"] = {
transformar = {23496, 1, "item"}
}
},
[23501] = {
["default"] = {
transformar = {23497, 1, "item"}
}
},
[23502] = {
["default"] = {
transformar = {23498, 1, "item"}
}
},
[23503] = {
["default"] = {
transformar = {23499, 1, "item"}
}
},
[7537] = {
["default"] = {
chances = {
[7000] = {
transformar = {7536, 1, "item"},
efeito = {"hit"},
criatura = {"Spider", 10000}
},
[10000] = {
transformar = {7536, 1, "item"},
efeito = {"hit"},
criatura = {"Poison Spider", 10000}
},
}
}
},
[7585] = {
["default"] = {
chances = {
[7000] = {
transformar = {7586, 1, "item"},
efeito = {"hit"},
criatura = {"Spider", 10000}
},
[10000] = {
transformar = {7586, 1, "item"},
efeito = {"hit"},
criatura = {"Poison Spider", 10000}
},
}
}
},
[3743] = {
["default"] = {
transformar = {4404, 1, "item"},
}
},
[4404] = {
["default"] = {
transformar = {3743, 1, "item"},
}
},
["action"] = {
[3901] = {
["default"] = {
itensPlayer = {{2554, 1}, {2120, 1}},
removerItem = 1
}
}
},
["unique"] = {
}
}
local condition = {}
for a, b in pairs(config) do
if condition[a] == nil then
local adicionarCondition = 0
local dano
for c, d in pairs(b) do
if c == "dano" then
adicionarCondition = a
dano = d
elseif type(d) == "table" then
for e, f in pairs(d) do
if e == "dano" then
adicionarCondition = a
dano = f
elseif type(f) == "table" then
for g, h in pairs(f) do
if g == "dano" then
adicionarCondition = a
dano = h
elseif type(h) == "table" then
for i, j in pairs(h) do
if i == "dano" then
adicionarCondition = a
dano = j
end
end
end
end
end
end
end
end
if adicionarCondition > 0 then
if dano[2] == "cargas" then
condition[adicionarCondition] = createConditionObject(conditionsDamage[dano[1]][1])
addDamageCondition(condition[adicionarCondition], dano[3], dano[4], dano[5])
end
end
end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if isInArray(itensMovimentoDesativado, target.actionid) then
self:sendCancelMessage("Você não pode realizar essa ação.")
return false
end
if config[item.itemid] ~= nil or
config["action"][item.actionid] ~= nil or
config["unique"][item.uid] ~= nil or
(isInArray(sparkling, item.itemid) and config["sparkling"] ~= nil) then
local i
if config[item.itemid] ~= nil then
i = config[item.itemid]
elseif config["action"][item.actionid] ~= nil then
i = config["action"][item.actionid]
elseif config["unique"][item.uid] ~= nil then
i = config["unique"][item.uid]
elseif isInArray(sparkling, item.itemid) and config["sparkling"] ~= nil then
i = config["sparkling"]
end
if i == nil then
return false
end
local piso = Tile(toPosition)
local topItem = 0
if piso ~= nil and piso:getTopVisibleThing() ~= nil then
topItem = piso:getTopVisibleThing():getId()
end
local adicionarEvento = false
local cancelarEvento = false
if i["default"] ~= nil then
i = i["default"]
if i.checarItem ~= nil and topItem ~= i.checarItem then
return false
elseif i.tempo ~= nil and i.tempo > 0 then
adicionarEvento = true
end
elseif isInArray(sparkling, target.itemid) and #piso:getItems() >= 2 and
(i["sparkling"][topItem] ~= nil or
(i["sparkling"]["ferro"] ~= nil and isInArray(ferro, topItem)) or
(i["sparkling"]["carvao"] ~= nil and isInArray(carvao, topItem)) or
(i["sparkling"]["arvores"] ~= nil and isInArray(arvores, topItem)) or
i["sparkling"] ~= nil) then
if i["sparkling"]["ferro"] ~= nil and isInArray(ferro, topItem) then
i = i["sparkling"]["ferro"]
elseif i["sparkling"]["carvao"] ~= nil and isInArray(carvao, topItem) then
i = i["sparkling"]["carvao"]
elseif i["sparkling"]["arvores"] ~= nil and isInArray(arvores, topItem) then
i = i["sparkling"]["arvores"]
verificarNovoPontoColetaMadeira = true
gerarNovoPontoColetaMadeira = true
elseif i["sparkling"][topItem] ~= nil then
i = i["sparkling"][topItem]
else
for a, b in pairs(i["sparkling"]) do
if type(a) == "number" then
return false
end
end
i = i["sparkling"]
cancelarEvento = true
end
if not cancelarEvento then
adicionarEvento = true
end
elseif isInArray(fire_source, target.itemid) and i["fire_source"] ~= nil then
i = i["fire_source"]
elseif isInArray(fruits, target.itemid) and i["fruits"] ~= nil then
i = i["fruits"]
elseif isInArray(ice_shrine, target.itemid) and i["ice_shrine"] ~= nil then
i = i["ice_shrine"]
elseif isInArray(fire_shrine, target.itemid) and i["fire_shrine"] ~= nil then
i = i["fire_shrine"]
elseif isInArray(earth_shrine, target.itemid) and i["earth_shrine"] ~= nil then
i = i["earth_shrine"]
elseif isInArray(energy_shrine, target.itemid) and i["energy_shrine"] ~= nil then
i = i["energy_shrine"]
elseif i[target.itemid] ~= nil then
i = i[target.itemid]
elseif i["action"] ~= nil and i["action"][item.actionid] ~= nil then
i = i["action"][item.actionid]
elseif i["unique"] ~= nil and i["unique"][item.uid] ~= nil then
i = i["unique"][item.uid]
else
return false
end
if i == nil then
return false
end
if i.chances ~= nil then
local chance = math.random(1, 10000)
local keys = {}
for key in pairs(i.chances) do
table.insert(keys, key)
end
table.sort(keys)
for a, b in pairs(keys) do
if chance <= b then
i = i.chances[b]
break
end
end
end
if i.actionId ~= nil then
if item.actionid ~= i.actionId and target.actionid ~= i.actionId then
return false
end
end
if i.checarPz ~= nil then
if player:isPzLocked() then
return player:sendCancelMessage("Você não pode entrar nessa área depois de atacar outro jogador.")
end
end
if i.quantidadeItemNecessaria ~= nil and player:getItemCount(item.itemid) < i.quantidadeItemNecessaria then
return false
end
if i.verificarPosicao ~= nil then
local verificarPosicao
if(i.verificarPosicao[2] == "item") then
verificarPosicao = fromPosition
elseif(i.verificarPosicao[2] == "target") then
verificarPosicao = toPosition
end
if i.verificarPosicao[1].x ~= nil and player:getPosition().x ~= verificarPosicao.x+i.verificarPosicao[1].x then
return false
end
if i.verificarPosicao[1].y ~= nil and player:getPosition().y ~= verificarPosicao.y+i.verificarPosicao[1].y then
return false
end
if i.verificarPosicao[1].z ~= nil and player:getPosition().z ~= verificarPosicao.z+i.verificarPosicao[1].z then
return false
end
end
if i.adicionarStorage ~= nil then
if player:getStorageValue(i.adicionarStorage[1]) == i.adicionarStorage[2] then
return false
end
player:setStorageValue(i.adicionarStorage[1], i.adicionarStorage[2])
end
local profissaoId = 0
local profissaoSkill = 0
if i.profissao ~= nil then
profissaoId = verificiarProfissaoPorNome(i.profissao)
profissaoSkill = player:getProfissaoSkill(profissaoId)
if i.nivelProfissao ~= nil and i.nivelProfissao > 0 and profissaoSkill < i.nivelProfissao then
return player:sendCancelMessage("Você precisa possuir nível " .. i.nivelProfissao .. " de " .. i.profissao .. " para realizar essa ação.")
end
if i.expProfissao ~= nil and i.expProfissao > 0 then
player:addProfissaoSkillExp(profissaoId, i.expProfissao)
end
end
local chanceSucesso = 10000
local chanceQuebrar = 0
if i.chanceSucesso ~= nil then
chanceSucesso = i.chanceSucesso
end
if i.chanceQuebrar ~= nil then
chanceQuebrar = i.chanceQuebrar
end
local efeito
if i.efeito ~= nil then
efeito = i.efeito
end
if i.profissao ~= nil and verificiarProfissaoPorNome(i.profissao) and chanceSucesso ~= nil and chanceSucesso <= 10000 then
chanceSucesso = chanceSucesso+player:getProfissaoChanceColetaAdicional(profissaoId)
end
local chance = 10000
if (chanceSucesso ~= nil and chanceSucesso <= 10000) or
(chanceQuebrar ~= nil and chanceQuebrar <= 10000) or
(i.transformarAleatorio ~= nil and #i.transformarAleatorio >= 2) then
chance = math.random(10000)
else
chanceSucesso = 10000
end
if i.removerItensPlayer ~= nil then
for c, v in pairs(i.removerItensPlayer) do
local v3 = -1
if v[3] ~= nil then
v3 = v[3]
end
if player:getItemCount(v[1], v3) < v[2] then
return false
end
end
for c, v in pairs(i.removerItensPlayer) do
local v3 = -1
if v[3] ~= nil then
v3 = v[3]
end
player:getItemById(v[1], v3):remove(v[2])
end
end
if i.removerItensNecessarios ~= nil and i.removerItensNecessarios == 1 and not player:removeItem(item.itemid, i.quantidadeItemNecessaria) then
return false
end
if i.removerItem ~= nil and i.removerItem == 1 and not item:remove(1) then
return false
end
if i.itensGamePlayer ~= nil then
if chance <= chanceSucesso then
for c, v in pairs(i.itensGamePlayer) do
local itemGamePlayerAdicionar = v[1]
local quantidadeItemGamePlayerAdicionar = v[2]
local typeItemGamePlayerAdicionar = v[3] or 1
if type(quantidadeItemGamePlayerAdicionar) == "table" then
quantidadeItemGamePlayerAdicionar = math.random(quantidadeItemGamePlayerAdicionar[1], quantidadeItemGamePlayerAdicionar[2])
end
if toPosition.x == 65535 then
player:addItem(itemGamePlayerAdicionar, quantidadeItemGamePlayerAdicionar, true, typeItemGamePlayerAdicionar)
else
Game.createItem(itemGamePlayerAdicionar, quantidadeItemGamePlayerAdicionar, toPosition)
end
end
else
efeito = {"poff"}
end
end
if i.itensPlayer ~= nil then
if chance <= chanceSucesso then
for c, v in pairs(i.itensPlayer) do
local itemPlayerAdicionar = v[1]
local quantidadeItemPlayerAdicionar = v[2]
local typeItemPlayerAdicionar = v[3] or 1
if type(quantidadeItemPlayerAdicionar) == "table" then
quantidadeItemPlayerAdicionar = math.random(quantidadeItemPlayerAdicionar[1], quantidadeItemPlayerAdicionar[2])
end
player:addItem(itemPlayerAdicionar, quantidadeItemPlayerAdicionar, true, typeItemPlayerAdicionar)
end
else
efeito = {"poff"}
end
end
if i.itensPlayerAleatorio ~= nil then
if chance <= chanceSucesso then
local chanceItemAleatorio = math.random(10000)
local chanceItem = 0
for c, v in pairs(i.itensPlayerAleatorio) do
chanceItem = chanceItem+v[3]
if chanceItemAleatorio <= chanceItem then
local itemAleatorioAdicionar = v[1]
local quantidadeItemAleatorioAdicionar = v[2]
if type(quantidadeItemAleatorioAdicionar) == "table" then
quantidadeItemAleatorioAdicionar = math.random(v[2][1], v[2][2])
end
local typeItemAleatorioAdicionar = v[4] or 1
player:addItem(itemAleatorioAdicionar, quantidadeItemAleatorioAdicionar, true, typeItemAleatorioAdicionar)
chanceItemAleatorio = 100000
end
end
else
efeito = {"poff"}
end
end
if i.itensGame ~= nil then
for c, v in pairs(i.itensGame) do
local itemGameAdicionar = v[1]
local quantidadeGameAdicionar = v[2]
local posicaoGameAdicionar = nil
if type(quantidadeGameAdicionar) == "table" then
quantidadeGameAdicionar = math.random(quantidadeGameAdicionar[1], quantidadeGameAdicionar[2])
end
if (v[3]) and (v[3] ~= "to") then
if v[3] == "from" then
posicaoGameAdicionar = fromPosition
elseif v[3] == "player" then
posicaoGameAdicionar = getPlayerPosition(player)
end
end
if posicaoGameAdicionar == nil then
posicaoGameAdicionar = toPosition
end
local itemGame = Game.createItem(itemGameAdicionar, quantidadeGameAdicionar, posicaoGameAdicionar)
itemGame:decay()
end
end
if i.transformar ~= nil and #i.transformar >= 2 then
local transformar = target
local itemTransformar = i.transformar[1]
local quantidadeTransformar = i.transformar[2]
local realizarTransformacao = true
if type(quantidadeTransformar) == "table" then
quantidadeTransformar = math.random(quantidadeTransformar[1], quantidadeTransformar[2])
end
if i.transformar[3] ~= nil and i.transformar[3] == "item" then
transformar = item
end
if i.chanceNeutra ~= nil and i.chanceNeutra <= 10000 then
local chanceNeutra = i.chanceNeutra+chanceSucesso
if (not (chance <= chanceSucesso)) and (chance <= chanceNeutra) then
efeito = {"poff"}
realizarTransformacao = false
elseif (not (chance <= chanceSucesso)) then
efeito = {"poff"}
end
end
if realizarTransformacao then
transformar:transform(itemTransformar, quantidadeTransformar)
transformar:decay()
end
end
if i.transformarAleatorio ~= nil and #i.transformarAleatorio >= 2 then
local chanceTransformar = 0
for c, v in pairs(i.transformarAleatorio) do
chanceTransformar = chanceTransformar+v[3]
if chance <= chanceTransformar then
if i.transformarAleatorioTipo == "item" then
item:transform(v[1], v[2])
else
if i.transformarAleatorioTipo == "target" or target then
target:transform(v[1], v[2])
else
item:transform(v[1], v[2])
end
end
break
end
end
end
if i.removerTarget == 1 then
if i.chanceNeutra ~= nil and i.chanceNeutra <= 10000 then
local chanceNeutra = i.chanceNeutra+chanceSucesso
if (not (chance <= chanceSucesso)) and (chance <= chanceNeutra) then
adicionarEvento = false
if verificarNovoPontoColetaMadeira then
gerarNovoPontoColetaMadeira = false
end
efeito = {"poff"}
elseif (not (chance <= chanceSucesso)) then
efeito = {"poff"}
target:remove(1)
else
target:remove(1)
end
else
target:remove(1)
end
end
if chanceQuebrar ~= nil and chanceQuebrar <= 10000 and chance <= chanceQuebrar then
target:remove(1)
end
if efeito ~= nil and #efeito > 0 then
local posicaoEfeito = nil
if i.efeito[2] and i.efeito[2] ~= "to" then
if type(i.efeito[2]) == "table" then
posicaoEfeito = fromPosition+i.efeito[2]
elseif i.efeito[2] == "from" then
posicaoEfeito = fromPosition
elseif i.efeito[2] == "player" then
posicaoEfeito = player:getPosition()
elseif i.efeito[2] == "player_item" or i.efeito[2] == "player_target" then
if i.efeito[2] == "player_item" then
posicaoEfeito = fromPosition
elseif i.efeito[2] == "player_target" then
posicaoEfeito = toPosition
end
if toPosition.x == 65535 then
posicaoEfeito = player:getPosition()
end
end
end
if posicaoEfeito == nil then
posicaoEfeito = toPosition
end
local exibirEfeito = efeito[1]
if type(efeito[1]) ~= "number" then
exibirEfeito = efeitos[efeito[1]]
end
posicaoEfeito:sendMagicEffect(exibirEfeito)
end
if i.criatura ~= nil then
local chanceCriatura = 10000
local criatura = i.criatura
if type(criatura) == "table" then
if criatura[2] and type(criatura[2]) == "number" and criatura[2] >= 1 and criatura[2] <= 10000 then
chanceCriatura = criatura[2]
end
criatura = criatura[1]
end
if math.random(10000) <= chanceCriatura then
Game.createMonster(criatura, toPosition)
end
end
if i.teleportar ~= nil then
local posicaoTeleportar
if(i.teleportar[2] == "item") then
posicaoTeleportar = fromPosition
elseif(i.teleportar[2] == "target") then
posicaoTeleportar = toPosition
end
if i.teleportar[1].x ~= nil then
posicaoTeleportar.x = posicaoTeleportar.x+i.teleportar[1].x
end
if i.teleportar[1].y ~= nil then
posicaoTeleportar.y = posicaoTeleportar.y+i.teleportar[1].y
end
if i.teleportar[1].z ~= nil then
posicaoTeleportar.z = posicaoTeleportar.z+i.teleportar[1].z
end
player:teleportTo(posicaoTeleportar, true)
local exibirEfeito = "teleport"
if i.efeitoTeleport ~= nil then
exibirEfeito = i.efeitoTeleport
end
posicaoTeleportar:sendMagicEffect(efeitos[exibirEfeito])
end
if i.direcionar ~= nil then
player:setDirection(direcoes[i.direcionar])
end
if i.verificarPosicaoTeleportar ~= nil then
for a, b in pairs(i.verificarPosicaoTeleportar) do
local verificarPosicaoTeleportar
if(b[3] == "item") then
verificarPosicaoTeleportar = fromPosition
elseif(b[3] == "target") then
verificarPosicaoTeleportar = toPosition
end
local posicaoTeleportar = verificarPosicaoTeleportar
if ((b[1].x ~= nil and player:getPosition().x == verificarPosicaoTeleportar.x+b[1].x) or
(b[1].y ~= nil and player:getPosition().y == verificarPosicaoTeleportar.y+b[1].y) or
(b[1].z ~= nil and player:getPosition().z == verificarPosicaoTeleportar.z+b[1].z)) then
if b[2].x ~= nil then
posicaoTeleportar.x = posicaoTeleportar.x+b[2].x
end
if b[2].y ~= nil then
posicaoTeleportar.y = posicaoTeleportar.y+b[2].y
end
if b[2].z ~= nil then
posicaoTeleportar.z = posicaoTeleportar.z+b[2].z
end
player:teleportTo(posicaoTeleportar, true)
local exibirEfeito = "teleport"
if i.efeitoTeleport ~= nil then
exibirEfeito = i.efeitoTeleport
end
posicaoTeleportar:sendMagicEffect(efeitos[exibirEfeito])
if b[4] ~= nil then
player:setDirection(direcoes[b[4]])
end
end
end
end
if i.sons ~= nil and type(i.sons) == "table" and #i.sons > 0 then
player:say(formatarFrase(i.sons[math.random(1, #i.sons)], player.uid), TALKTYPE_ORANGE_1, false, 0, toPosition)
end
if i.mensagemPlayer ~= nil then
player:sendTextMessage(MESSAGE_INFO_DESCR, i.mensagemPlayer)
end
if i.dano ~= nil then
if i.dano[2] == "fixo" then
local danoMin = i.dano[3]
local danoMax = danoMin
if i.dano[4] ~= nil then
danoMax = i.dano[4]
end
doTargetCombatHealth(0, player, conditionsDamage[i.dano[1]][2], danoMin, danoMax, CONST_ME_NONE)
elseif i.dano[2] == "cargas" then
player:addCondition(condition[item.itemid])
end
end
if gerarNovoPontoColetaMadeira then
gerarPontoColetaMadeira(toPosition.x .. "," .. toPosition.y .. "," .. toPosition.z)
elseif adicionarEvento then
local adicionarItemEvento = target.itemid
if target.itemid == 0 then
adicionarItemEvento = item.itemid
end
addEvent(function(posicao, item)
Game.createItem(item, 1, posicao)
end, i.tempo, toPosition, adicionarItemEvento)
end
return true
end
return false
end | gpl-2.0 |
hanxi/cocos2d-x-v3.1 | frameworks/cocos2d-x/cocos/scripting/lua-bindings/auto/api/GLProgram.lua | 3 | 4971 |
--------------------------------
-- @module GLProgram
-- @extend Ref
--------------------------------
-- @function [parent=#GLProgram] getFragmentShaderLog
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#GLProgram] initWithByteArrays
-- @param self
-- @param #char char
-- @param #char char
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWithMatrix4fv
-- @param self
-- @param #int int
-- @param #float float
-- @param #unsigned int int
--------------------------------
-- @function [parent=#GLProgram] initWithFilenames
-- @param self
-- @param #string str
-- @param #string str
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#GLProgram] getUniformLocationForName
-- @param self
-- @param #char char
-- @return int#int ret (return value: int)
--------------------------------
-- @function [parent=#GLProgram] use
-- @param self
--------------------------------
-- @function [parent=#GLProgram] getVertexShaderLog
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#GLProgram] getUniform
-- @param self
-- @param #string str
-- @return Uniform#Uniform ret (return value: cc.Uniform)
--------------------------------
-- overload function: setUniformsForBuiltins(cc.Mat4)
--
-- overload function: setUniformsForBuiltins()
--
-- @function [parent=#GLProgram] setUniformsForBuiltins
-- @param self
-- @param #cc.Mat4 mat4
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWith3i
-- @param self
-- @param #int int
-- @param #int int
-- @param #int int
-- @param #int int
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWith3iv
-- @param self
-- @param #int int
-- @param #int int
-- @param #unsigned int int
--------------------------------
-- @function [parent=#GLProgram] updateUniforms
-- @param self
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWith4iv
-- @param self
-- @param #int int
-- @param #int int
-- @param #unsigned int int
--------------------------------
-- @function [parent=#GLProgram] getUniformLocation
-- @param self
-- @param #string str
-- @return int#int ret (return value: int)
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWith1i
-- @param self
-- @param #int int
-- @param #int int
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWith2iv
-- @param self
-- @param #int int
-- @param #int int
-- @param #unsigned int int
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWithMatrix3fv
-- @param self
-- @param #int int
-- @param #float float
-- @param #unsigned int int
--------------------------------
-- @function [parent=#GLProgram] reset
-- @param self
--------------------------------
-- @function [parent=#GLProgram] bindAttribLocation
-- @param self
-- @param #string str
-- @param #unsigned int int
--------------------------------
-- @function [parent=#GLProgram] getAttribLocation
-- @param self
-- @param #string str
-- @return int#int ret (return value: int)
--------------------------------
-- @function [parent=#GLProgram] getVertexAttrib
-- @param self
-- @param #string str
-- @return VertexAttrib#VertexAttrib ret (return value: cc.VertexAttrib)
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWithMatrix2fv
-- @param self
-- @param #int int
-- @param #float float
-- @param #unsigned int int
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWith4i
-- @param self
-- @param #int int
-- @param #int int
-- @param #int int
-- @param #int int
-- @param #int int
--------------------------------
-- @function [parent=#GLProgram] link
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWith2i
-- @param self
-- @param #int int
-- @param #int int
-- @param #int int
--------------------------------
-- @function [parent=#GLProgram] createWithByteArrays
-- @param self
-- @param #char char
-- @param #char char
-- @return GLProgram#GLProgram ret (return value: cc.GLProgram)
--------------------------------
-- @function [parent=#GLProgram] createWithFilenames
-- @param self
-- @param #string str
-- @param #string str
-- @return GLProgram#GLProgram ret (return value: cc.GLProgram)
--------------------------------
-- @function [parent=#GLProgram] GLProgram
-- @param self
return nil
| mit |
kitala1/darkstar | scripts/zones/Windurst_Walls/npcs/Luuh_Koplehn.lua | 36 | 1169 | -----------------------------------
-- Area: Windurst Walls
-- NPC: Luuh Koplehn
-- Standard Info NPC
-- Involved in Quest: Star Struck
-- @zone = 239
-- @pos = -93 -5 130
-----------------------------------
require("scripts/globals/quests");
require("scripts/globals/settings");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
qStarStruck = player:getQuestStatus(WINDURST,STAR_STRUCK);
if (qStarStruck == QUEST_ACCEPTED) then
player:startEvent(0x00c8);
else
player:startEvent(0x142);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
kitala1/darkstar | scripts/globals/spells/bluemagic/blastbomb.lua | 9 | 1834 | -----------------------------------------
-- Spell: Blastbomb
-- Deals fire damage to enemies within area of effect. Additional effect: "Bind"
-- Spell cost: 36 MP
-- Monster Type: Beastmen
-- Spell Type: Magical (Fire)
-- Blue Magic Points: 2
-- Stat Bonus: STR+1
-- Level: 18
-- Casting Time: 2.25 seconds
-- Recast Time: 15 seconds
-- Magic Bursts on: Liquefaction, Fusion, Light
-- Combos: None
-----------------------------------------
require("scripts/globals/magic");
require("scripts/globals/status");
require("scripts/globals/bluemagic");
-----------------------------------------
-- OnMagicCastingCheck
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onSpellCast(caster,target,spell)
local params = {};
params.multiplier = 1.375;
params.tMultiplier = 1.0;
params.duppercap = 30;
params.str_wsc = 0.0;
params.dex_wsc = 0.0;
params.vit_wsc = 0.0;
params.agi_wsc = 0.0;
params.int_wsc = 0.2;
params.mnd_wsc = 0.0;
params.chr_wsc = 0.0;
damage = BlueMagicalSpell(caster, target, spell, params, INT_BASED);
damage = BlueFinalAdjustments(caster, target, spell, damage, params);
local resist = applyResistance(caster,spell,target,caster:getStat(MOD_INT) - target:getStat(MOD_INT),BLUE_SKILL,1.0);
if(damage > 0 and resist > 0.125) then
local typeEffect = EFFECT_BIND;
target:delStatusEffect(typeEffect); -- Wiki says it can overwrite itself or other binds
target:addStatusEffect(typeEffect,1,0,getBlueEffectDuration(caster,resist,typeEffect));
end
return damage;
end;
| gpl-3.0 |
iotcafe/nodemcu-firmware-lua5.3.0 | lua_examples/onewire-ds18b20.lua | 60 | 1505 | --'
-- 18b20 one wire example for NODEMCU
-- NODEMCU TEAM
-- LICENCE: http://opensource.org/licenses/MIT
-- Vowstar <vowstar@nodemcu.com>
--'
pin = 9
ow.setup(pin)
count = 0
repeat
count = count + 1
addr = ow.reset_search(pin)
addr = ow.search(pin)
tmr.wdclr()
until((addr ~= nil) or (count > 100))
if (addr == nil) then
print("No more addresses.")
else
print(addr:byte(1,8))
crc = ow.crc8(string.sub(addr,1,7))
if (crc == addr:byte(8)) then
if ((addr:byte(1) == 0x10) or (addr:byte(1) == 0x28)) then
print("Device is a DS18S20 family device.")
repeat
ow.reset(pin)
ow.select(pin, addr)
ow.write(pin, 0x44, 1)
tmr.delay(1000000)
present = ow.reset(pin)
ow.select(pin, addr)
ow.write(pin,0xBE,1)
print("P="..present)
data = nil
data = string.char(ow.read(pin))
for i = 1, 8 do
data = data .. string.char(ow.read(pin))
end
print(data:byte(1,9))
crc = ow.crc8(string.sub(data,1,8))
print("CRC="..crc)
if (crc == data:byte(9)) then
t = (data:byte(1) + data:byte(2) * 256) * 625
t1 = t / 10000
t2 = t % 10000
print("Temperature= "..t1.."."..t2.." Centigrade")
end
tmr.wdclr()
until false
else
print("Device family is not recognized.")
end
else
print("CRC is not valid!")
end
end
| mit |
kitala1/darkstar | scripts/zones/AlTaieu/mobs/Absolute_Virtue.lua | 23 | 2388 | -----------------------------------
-- Area: Al'Taieu
-- HNM: Absolute Virtue
-----------------------------------
require("scripts/globals/titles");
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
-- setMod
mob:setMod(MOD_REGEN, 500);
local JoL = GetMobByID(16912848);
-- Special check for regen modification by JoL pets killed
if (JoL:getLocalVar("JoL_Qn_xzomit_Killed") == 9) then
mob:addMod(MOD_REGEN, -130)
end
if (JoL:getLocalVar("JoL_Qn_hpemde_Killed") == 9) then
mob:addMod(MOD_REGEN, -130)
end
end;
-----------------------------------
-- onMobFight Action
-----------------------------------
function onMobFight(mob, target)
end;
------------------------------------
-- onSpellPrecast
------------------------------------
function onSpellPrecast(mob, spell)
if (spell:getID() == 218) then -- Meteor
spell:setAoE(SPELLAOE_RADIAL);
spell:setFlag(SPELLFLAG_HIT_ALL);
spell:setRadius(30);
spell:setAnimation(280); -- AoE Meteor Animation
spell:setMPCost(1);
end
end;
------------------------------------
-- onMonsterMagicPrepare
------------------------------------
function onMonsterMagicPrepare(caster, target)
end;
-----------------------------------
-- onMagicHit
-----------------------------------
function onMagicHit(caster, target, spell)
local REGEN = target:getMod(MOD_REGEN);
local DAY = VanadielDayElement();
local ELEM = spell:getElement();
if (GetServerVariable("AV_Regen_Reduction") < 60) then
-- Had to serverVar the regen instead of localVar because localVar reset on claim loss.
if (ELEM == DAY and (caster:isPC() or caster:isPet())) then
SetServerVariable("AV_Regen_Reduction", 1+GetServerVariable("AV_Regen_Reduction"));
target:addMod(MOD_REGEN, -2);
end
end
return 1;
end;
-----------------------------------
-- onMobDespawn
-----------------------------------
function onMobDespawn(mob)
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, killer)
killer:addTitle(VIRTUOUS_SAINT);
end; | gpl-3.0 |
kitala1/darkstar | scripts/globals/magiantrials.lua | 33 | 9671 | -------------------------------------------
-- Magian trial functions, vars, tables
-------------------------------------------
-----------------------------------
-- getTrialInfo
-----------------------------------
-- once fully filled out, these info tables might get large enough to need their own file, we'll see...
function getTrialInfo(ItemID)
local TrialInfo = {};
if (ItemID == 19327) then -- Pugilists
TrialInfo.t1 = 68;
TrialInfo.t2 = 82;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 19332) then -- Peeler
TrialInfo.t1 = 2;
TrialInfo.t2 = 16;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 19337) then -- Side-sword
TrialInfo.t1 = 150;
TrialInfo.t2 = 164;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 19342) then -- Break Blade
TrialInfo.t1 = 216;
TrialInfo.t2 = 230;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 19347) then -- Chopper
TrialInfo.t1 = 282;
TrialInfo.t2 = 296;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 19352) then -- Lumberjack
TrialInfo.t1 = 364;
TrialInfo.t2 = 378;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 19357) then -- Farmhand
TrialInfo.t1 = 512;
TrialInfo.t2 = 526;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 19362) then -- Ranseur
TrialInfo.t1 = 430;
TrialInfo.t2 = 444;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 19367) then -- KibaShiri
TrialInfo.t1 = 578;
TrialInfo.t2 = 592;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 19372) then -- Donto
TrialInfo.t1 = 644;
TrialInfo.t2 = 658;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 19377) then -- Stenz
TrialInfo.t1 = 710;
TrialInfo.t2 = 724;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 19382) then -- Crook
TrialInfo.t1 = 776;
TrialInfo.t2 = 790;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 19387) then -- Sparrow
TrialInfo.t1 = 0;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 19392) then -- Thunderstick
TrialInfo.t1 = 941;
TrialInfo.t2 = 891;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
-- elsif
--
else -- Not a valid Item, return zeros for all.
TrialInfo.t1 = 0;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
end
end;
-----------------------------------
-- getEmoteTrialInfo
-----------------------------------
function getEmoteTrialInfo(ItemID)
local TrialInfo = {};
if (ItemID == 11988) then -- Fighter's Torque
TrialInfo.t1 = 4424;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 11989) then -- Temple Torque
TrialInfo.t1 = 4425;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 11990) then -- Healer's Torque
TrialInfo.t1 = 4426;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 11991) then -- Wizard's Torque
TrialInfo.t1 = 4427;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 11992) then -- Warlock's Torque
TrialInfo.t1 = 4428;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 11993) then -- Rogue's Torque
TrialInfo.t1 = 4429;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 11994) then -- Gallant Torque
TrialInfo.t1 = 4430;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 11995) then -- Chaos Torque
TrialInfo.t1 = 4431;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 11996) then -- Beast Torque
TrialInfo.t1 = 4432;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 11997) then -- Choral Torque
TrialInfo.t1 = 4433;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 11998) then -- Hunter's Torque
TrialInfo.t1 = 4434;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 11999) then -- Myochin Shusa
TrialInfo.t1 = 4435;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 12000) then -- Ninja Shusa
TrialInfo.t1 = 4436;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 12001) then -- Drachen Torque
TrialInfo.t1 = 4437;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 12002) then -- Evoker's Torque
TrialInfo.t1 = 4438;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 12003) then -- Magus Torque
TrialInfo.t1 = 4439;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 12004) then -- Corsair's Torque
TrialInfo.t1 = 4440;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 12005) then -- Puppetry Torque
TrialInfo.t1 = 4441;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 12006) then -- Dancer's Torque
TrialInfo.t1 = 4442;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
elseif (ItemID == 12007) then -- Scholar's Torque
TrialInfo.t1 = 4443;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
else -- Not a valid Item, return zeros for all.
TrialInfo.t1 = 0;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
end
end;
-----------------------------------
-- getRelicTrialInfo
-----------------------------------
function getRelicTrialInfo(ItemID)
local TrialInfo = {};
if (ItemID == 19327) then --
TrialInfo.t1 = 0;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
else -- Not a valid Item, return zeros for all.
TrialInfo.t1 = 0;
TrialInfo.t2 = 0;
TrialInfo.t3 = 0;
TrialInfo.t4 = 0;
return TrialInfo;
end
end;
-----------------------------------
-- magianOrangeEventUpdate
-----------------------------------
function magianOrangeEventUpdate(player,ItemID,csid,option)
-- DO NOT try to convert into "elseif" !
-- Probably need to table all this too, for now I'm just mapping it out.
if (csid == 10124 and option == 4456449) then
local ReqItemAugFlag = 2; -- 2 = ON, anything else = OFF.
local ReqItemAug1 = 1;
local ReqItemAug2 = 1;
local ReqItem = 19332;
local TrialID = 9;
player:updateEvent(ReqItemAugFlag, ReqItemAug1, ReqItemAug2, ReqItem, 0, 0, TrialID);
end
if (csid == 10124 and option == 4456450) then
local TotalObjectives = 11;
player:updateEvent(TotalObjectives);
end
if (csid == 10124 and option == 4456451) then
local RewardAugFlag = 2; -- 2 = ON, anything else = OFF.
local RewardAug1 = 1;
local RewardAug2 = 1;
local RewardItem = 19328;
player:updateEvent(RewardAugFlag, RewardAug1, RewardAug2, RewardItem);
end
if (csid == 10124 and option == 4456452) then
local ResultTrial1 = 69;
local ResultTrial2 = 0;
local ResultTrial3 = 0;
local ResultTrial4 = 0;
local PrevTrial = 0;
player:updateEvent(ResultTrial1, ResultTrial2, ResultTrial3, ResultTrial4, PrevTrial);
end
end;
-----------------------------------
-- magianGreenEventUpdate
-----------------------------------
function magianGreenEventUpdate(player,ItemID,csid,option)
end;
-----------------------------------
-- magianBlueEventUpdate
-----------------------------------
function magianBlueEventUpdate(player,ItemID,csid,option)
end; | gpl-3.0 |
tetoali605/THETETOO_A7A | plugins/ar_me (2).lua | 6 | 3670 | --[[
▀▄ ▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀
▀▄ ▄▀ ▀▄ ▄▀
▀▄ ▄▀ BY tetoo ▀▄ ▄▀
▀▄ ▄▀ BY nmore (@l_l_lo) ▀▄ ▄▀
▀▄ ▄▀ JUST WRITED BY l_l_ll ▀▄ ▄▀
▀▄ ▄▀ broadcast : موقــعي ▀▄ ▄▀
▀▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀
--]]
do
local function run(msg, matches)
if is_sudo(msg) then
local sudo = "حــبيبـي ♥️♥️انـته موقعـك و معلـوماتك هنـا ☻☻☹️☻ تابع من فضلك @no_no2 👇🏌"..msg.from.first_name.."\n"
.."🎀🎖ايديك :("..msg.from.id..")\n"
.."🎀🎖ايدي الكروب :("..msg.to.id..")\n"
.."🎀🎖معرفك :(@"..(msg.from.username or "لا يوجد")..")\n"
.."🎀🎖رقمك :("..(msg.from.phone or " لا يوجد")..")\n"
.."موقعك👤: انته مطور مالتي☂☂افـيش يا ريـحت هلي و ناسـي الله يحـفضـك 🎀🎗 "
return reply_msg(msg.id, sudo, ok_cb, true)
end
if is_owner(msg) then
local owner = "♥️حـبــيبي انتــه موقعـك و معلـوماتك هنا 🎀🎗"..msg.from.first_name.."\n"
.."🎀🎖ايديك :("..msg.from.id..")\n"
.."🎀🎖ايدي الكروب :("..msg.to.id..")\n"
.."🎀🎖معرفك :(@"..(msg.from.username or "لا يوجد")..")\n"
.."🎀🎖رقمك :("..(msg.from.phone or " لا يوجد ")..")\n"
.."🎀🎗موقعك :انته مدير المجموعه 🚨 👥 »"
return reply_msg(msg.id, owner, ok_cb, true)
end
if is_admin1(msg) then
local admin1 = "♥️حــبيـبي قــلبي معـلوماتك و موقعـك 🎀🎗"
.."🎀🎖ايديك :("..msg.from.id..")\n"
.."🎀🎖ايدي الكروب :("..msg.to.id..")\n"
.."🎀🎖معرفك :(@"..(msg.from.username or "لا يوجد")..")\n"
.."🎀🎖رقمك :("..(msg.from.phone or " لايوجد ")..")\n"
.."🎀🎗موقعك :انته ادراي☂ 🙋» "
return reply_msg(msg.id, admin1, ok_cb, true)
end
if is_momod(msg) then
local admin = "♥️حـبــيبي انتـه موقعـك و معلـماتك 🎀🎗" ..msg.from.first_name.. "\n"
.."🎀🎖ايديك :("..msg.from.id..")\n"
.."🎀🎖️ايدي الكروب :("..msg.to.id..")\n"
.."🎀🎖️معرفك :(@"..(msg.from.username or "لا يوجد")..")\n"
.."🎀🎖️رقمك :("..(msg.from.phone or " لا يوجد ")..")\n"
.."🎀🎗موقعك :انته ادمن المحترم ☻🎩"
return reply_msg(msg.id, admin, ok_cb, true)
end
if not is_momod(msg) then
local member = "♥️حبيــب قـلبي موقعـك و معلـوماتك هنـا 👇🏼" ..msg.from.first_name.. "\n"
.."🎀🎖️ايديك :("..msg.from.id..")\n"
.."🎀🎖️ايدي الكروب :("..msg.to.id..")\n"
.."🎀🎖️معرفك :(@"..(msg.from.username or "لا يوجد")..")\n"
.."🎀🎖️رقمك :("..(msg.from.phone or "لايوجد " )..")\n"
.."🎀🎗موقعك :انته دايــح و مســقـط و دور بنات بهـذا كروب. ☻قصــدي عضـو 😂 😹💔» "
return reply_msg(msg.id, member, ok_cb, true)
end
end
return {
patterns = {
"^(موقعي)$",
"^(me)$",
"^(/me)$",
},
run = run,
}
end
| gpl-2.0 |
cdettmering/fancyland | graphics/GraphicUtility.lua | 1 | 2466 | --- GraphicUtility ---
-- Setup local access
local Camera = require('Camera')
local LineSegment = require(MATHPATH .. 'LineSegment')
local GraphicUtility = {}
GraphicUtility.__index = GraphicUtility
GraphicUtility.line = LineSegment:new()
local points = {}
local function drawLine(line, r, g, b, a)
local _r, _g, _b, _a = love.graphics.getColor()
love.graphics.setColor(r, g, b, a)
--love.graphics.line(line:startPoint().x, line:startPoint().y, line:endPoint().x, line:endPoint().y)
love.graphics.setLine(2, 'smooth')
love.graphics.line(980, 447, 1040, 447)
love.graphics.setColor(_r, _g, _b, _a)
end
local function drawShape(shape, r, g, b, a)
local vertices = {}
for _, line in ipairs(shape.lines) do
table.insert(vertices, line.p1.x)
table.insert(vertices, line.p1.y)
table.insert(vertices, line.p2.x)
table.insert(vertices, line.p2.y)
end
local _r, _g, _b, _a = love.graphics.getColor()
love.graphics.setColor(r, g, b, a)
love.graphics.polygon('fill', vertices)
love.graphics.setColor(_r, _g, _b, _a)
end
local function drawBody(body, r, g, b, a)
for _, part in ipairs(body.parts) do
drawShape(part:shape(), r, g, b, a)
end
end
function GraphicUtility.drawActor(actor)
-- get body position
local position = actor:body():position()
-- position is the center of the body and by default LOVE draws image from the top left
-- make sure LOVE draws at center
local x = actor:sprite():getWidth() / 2
local y = actor:sprite():getHeight() / 2
love.graphics.draw(actor:sprite(), position.x, position.y, actor:body():orientation(), 1, 1, x, y)
end
function GraphicUtility.drawDebugLevel(level)
for _, body in ipairs(level.engine:bodies()) do
drawBody(body, 255, 0, 0, 255)
end
GraphicUtility.addPoint(GraphicUtility.line:startPoint())
GraphicUtility.addPoint(GraphicUtility.line:endPoint())
GraphicUtility.drawPoints(0, 255, 0, 255)
GraphicUtility.clearPoints()
end
function GraphicUtility.drawPoints(r, g, b, a)
local _r, _g, _b, _a = love.graphics.getColor()
love.graphics.setColor(r, g, b, a)
for _, p in ipairs(points) do
love.graphics.circle('fill', p.x, p.y, 5)
end
love.graphics.setColor(_r, _g, _b, _a)
end
function GraphicUtility.addPoint(point)
table.insert(points, point)
end
function GraphicUtility.clearPoints()
points = {}
end
return GraphicUtility
| gpl-3.0 |
kitala1/darkstar | scripts/globals/spells/addle.lua | 52 | 1497 | -----------------------------------------
-- Spell: Addle
-- Increases the casting time of the target
-- Exact formula is unknown.
--
-- Raw Value is said to be 30%
-- It is said to increase to 50% w/ Saboteur
-----------------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
local dMND = (caster:getStat(MOD_MND) - target:getStat(MOD_MND));
-- Power: Cast Time Modifier
local power = 30;
if (caster:hasStatusEffect(EFFECT_SABOTEUR)) then
power = 50;
end
-- Sub Power: Magic Accuracy Modifier
local targetMagicAccuracy = target:getMod(MOD_MACC);
local subPower = math.floor( targetMagicAccuracy * (power / 100) );
--Duration, including resistance.
local duration = 180 * applyResistanceEffect(caster,spell,target,dMND,35,0,EFFECT_ADDLE);
if (duration >= 60) then -- Do it!
if (caster:hasStatusEffect(EFFECT_SABOTEUR)) then
duration = duration * 2;
caster:delStatusEffect(EFFECT_SABOTEUR);
end
if (target:addStatusEffect(EFFECT_ADDLE, power, 0, duration, 0, subPower)) then
spell:setMsg(236);
else
spell:setMsg(75);
end
else
spell:setMsg(85);
end
return EFFECT_ADDLE;
end; | gpl-3.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.