Правило Shape. Например Wall Is Shape. Объекты с правилом Shape будут двигаться синхронно и если один из объектов встретит преграду то и все остальные также не будут двигаться.
Пиши на lua.
Вот примеры скриптов из оригинальной игры
1 Код:
function brokenblock(ids)
local checkthese = {}
if (ids == nil) then
checkthese = units
else
checkthese = ids
end
for i,unit in ipairs(checkthese) do
local name = unit.strings[UNITNAME]
local realbroken = unit.broken
unit.broken = 0
local broken = hasfeature(name,"is","broken",unit.fixed)
unit.broken = realbroken
if (broken ~= nil) and (unit.broken == 0) then
unit.broken = 1
addundo({"broken",1,unit.values[ID],unit.strings[UNITNAME]})
elseif (broken == nil) and (unit.broken == 1) then
unit.broken = 0
addundo({"broken",0,unit.values[ID],unit.strings[UNITNAME]})
end
end
end
2 код:
function diceblock()
condstatus = {}
if (condfeatureindex["often"] ~= nil) then
for i,v in ipairs(condfeatureindex["often"]) do
local conds = v[2]
local identifier = tostring(conds)
if (condstatus[identifier] == nil) then
condstatus[identifier] = {}
end
local data = condstatus[identifier]
--[[
for a,b in ipairs(conds) do
if (b[1] == "often") or (b[1] == "not often") then
local rnd = fixedrandom(1,4)
local id = "often" .. tostring(a)
data[id] = rnd
end
end
]]--
end
end
if (condfeatureindex["seldom"] ~= nil) then
for i,v in ipairs(condfeatureindex["seldom"]) do
local conds = v[2]
local identifier = tostring(conds)
if (condstatus[identifier] == nil) then
condstatus[identifier] = {}
end
local data = condstatus[identifier]
--[[
for a,b in ipairs(conds) do
if (b[1] == "seldom") or (b[1] == "not seldom") then
local rnd = fixedrandom(1,6)
local id = "seldom" .. tostring(a)
data[id] = rnd
end
end
]]--
end
end
end
3 Код:
function moveblock(onlystartblock_)
local onlystartblock = onlystartblock_ or false
local isshift,istele = {},{}
local isfollow = findfeature(nil,"follow",nil,true)
if (onlystartblock == false) then
isshift = findallfeature(nil,"is","shift",true)
istele = findallfeature(nil,"is","tele",true)
end
local doned = {}
if (isfollow ~= nil) then
for h,j in ipairs(isfollow) do
local allfollows = findall(j)
if (#allfollows > 0) then
for k,l in ipairs(allfollows) do
if (issleep(l) == false) then
local unit = mmf.newObject(l)
local x,y,name,dir = unit.values[XPOS],unit.values[YPOS],unit.strings[UNITNAME],unit.values[DIR]
local unitrules = {}
local followedfound = false
if (unit.strings[UNITTYPE] == "text") then
name = "text"
end
if (featureindex[name] ~= nil) then
for a,b in ipairs(featureindex[name]) do
local baserule = b[1]
local conds = b[2]
local verb = baserule[2]
if (verb == "follow") then
if testcond(conds,l) then
table.insert(unitrules, b)
end
end
end
end
local follow = xthis(unitrules,name,"follow")
if (#follow > 0) and (unit.flags[DEAD] == false) then
local distance = 9999
local targetdir = -1
local stophere = false
local highesttarget = false
local counterclockwise = false
local priorityfollow = -1
local priorityfollowdir = -1
local highpriorityfollow = -1
local highpriorityfollowdir = -1
for i,v in ipairs(follow) do
local these = findall({v})
if (#these > 0) and (stophere == false) then
for a,b in ipairs(these) do
if (b ~= unit.fixed) and (stophere == false) then
local funit = mmf.newObject(b)
local fx,fy = funit.values[XPOS],funit.values[YPOS]
local xdir = fx-x
local ydir = fy-y
local dist = math.abs(xdir) + math.abs(ydir)
local fdir = -1
if (math.abs(xdir) <= math.abs(ydir)) then
if (ydir >= 0) then
fdir = 3
else
fdir = 1
end
else
if (xdir > 0) then
fdir = 0
else
fdir = 2
end
end
if (dist <= distance) and (dist > 0) then
distance = dist
targetdir = fdir
--MF_alert(name .. ": suggested dir " .. tostring(targetdir))
if (dist == 1) then
if (unit.followed ~= funit.values[ID]) then
local ndrs = ndirs[dir + 1]
local ox,oy = ndrs[1],ndrs[2]
priorityfollow = funit.values[ID]
priorityfollowdir = targetdir
if (x + ox == fx) and (y + oy == fy) then
highpriorityfollow = funit.values[ID]
highpriorityfollowdir = targetdir
highesttarget = true
--MF_alert(tostring(unit.fixed) .. " moves forward: " .. tostring(dir) .. ", " .. tostring(targetdir))
elseif (highesttarget == false) then
local turnl = (dir + 1 + 4) % 4
local ndrsl = ndirs[turnl + 1]
local oxl,oyl = ndrsl[1],ndrsl[2]
if (x + oxl == fx) and (y + oyl == fy) then
highpriorityfollow = funit.values[ID]
highpriorityfollowdir = targetdir
counterclockwise = true
--MF_alert(tostring(unit.fixed) .. " turns left: " .. tostring(dir) .. ", " .. tostring(turnl) .. ", " .. tostring(targetdir))
elseif (counterclockwise == false) then
local turnr = (dir - 1 + 4) % 4
local ndrsr = ndirs[turnr + 1]
local oxr,oyr = ndrsr[1],ndrsr[2]
if (x + oxr == fx) and (y + oyr == fy) then
highpriorityfollow = funit.values[ID]
highpriorityfollowdir = targetdir
--MF_alert(tostring(unit.fixed) .. " turns right: " .. tostring(dir) .. ", " .. tostring(turnr) .. ", " .. tostring(targetdir))
end
end
end
else
followedfound = true
stophere = true
break
end
end
end
end
end
if stophere then
break
end
end
if stophere then
break
end
end
if (followedfound == false) then
if (highpriorityfollow > -1) then
if (onlystartblock == false) then
addundo({"followed",unit.values[ID],unit.followed,highpriorityfollow,unit.strings[UNITNAME]},unit.fixed)
end
unit.followed = highpriorityfollow
targetdir = highpriorityfollowdir
stophere = true
followedfound = true
elseif (priorityfollow > -1) then
if (onlystartblock == false) then
addundo({"followed",unit.values[ID],unit.followed,priorityfollow,unit.strings[UNITNAME]},unit.fixed)
end
unit.followed = priorityfollow
targetdir = priorityfollowdir
stophere = true
followedfound = true
elseif (unit.followed > -1) then
if (onlystartblock == false) then
addundo({"followed",unit.values[ID],unit.followed,0,unit.strings[UNITNAME]},unit.fixed)
end
unit.followed = -1
end
end
if (targetdir >= 0) then
--MF_alert(unit.strings[UNITNAME] .. " faces to " .. tostring(targetdir))
updatedir(unit.fixed,targetdir,onlystartblock)
end
end
end
end
end
end
end
if (onlystartblock == false) then
local isback = findallfeature(nil,"is","back",true)
for i,unitid in ipairs(isback) do
local unit = mmf.newObject(unitid)
local undooffset = #undobuffer - unit.back_init
local undotargetid = undooffset * 2 + 1
if (undotargetid <= #undobuffer) and (unit.back_init > 0) and (unit.flags[DEAD] == false) then
local currentundo = undobuffer[undotargetid]
particles("wonder",unit.values[XPOS],unit.values[YPOS],1,{3,0})
updateundo = true
if (currentundo ~= nil) then
for a,line in ipairs(currentundo) do
local style = line[1]
if (style == "update") and (line[9] == unit.values[ID]) then
local uid = line[9]
if (paradox[uid] == nil) then
local ux,uy = unit.values[XPOS],unit.values[YPOS]
local oldx,oldy = line[6],line[7]
local x,y,dir = line[3],line[4],line[5]
local ox = x - oldx
local oy = y - oldy
--[[
Enable this to make the Back effect relative to current position
x = ux + ox
y = uy + oy
]]--
--MF_alert(unit.strings[UNITNAME] .. " is being updated from " .. tostring(ux) .. ", " .. tostring(uy) .. ", offset " .. tostring(ox) .. ", " .. tostring(oy))
if (ox ~= 0) or (oy ~= 0) then
addaction(unitid,{"update",x,y,dir})
else
addaction(unitid,{"updatedir",dir})
end
updateundo = true
if (objectdata[unitid] == nil) then
objectdata[unitid] = {}
end
local odata = objectdata[unitid]
odata.tele = 1
else
particles("hot",line[3],line[4],1,{1, 1})
updateundo = true
end
elseif (style == "create") and (line[3] == unit.values[ID]) then
local uid = line[4]
--MF_alert(unit.strings[UNITNAME] .. " back: " .. tostring(uid) .. ", " .. tostring(line[3]))
if (paradox[uid] == nil) then
local name = unit.strings[UNITNAME]
local delname = {}
for b,bline in ipairs(currentundo) do
--MF_alert(" -- " .. bline[1] .. ", " .. tostring(bline[6]))
if (bline[1] == "remove") and (bline[6] == uid) then
local x,y,dir,levelfile,levelname,vislevel,complete,visstyle,maplevel,colour,clearcolour,followed,back_init = bline[3],bline[4],bline[5],bline[8],bline[9],bline[10],bline[11],bline[12],bline[13],bline[14],bline[15],bline[16],bline[17]
local newname = bline[2]
local newunitname = ""
local newunitid = 0
local ux,uy = unit.values[XPOS],unit.values[YPOS]
newunitname = unitreference[newname]
newunitid = MF_emptycreate(newunitname,ux,uy)
local newunit = mmf.newObject(newunitid)
newunit.values[ONLINE] = 1
newunit.values[XPOS] = ux
newunit.values[YPOS] = uy
newunit.values[DIR] = dir
newunit.values[ID] = bline[6]
newunit.flags[9] = true
newunit.strings[U_LEVELFILE] = levelfile
newunit.strings[U_LEVELNAME] = levelname
newunit.flags[MAPLEVEL] = maplevel
newunit.values[VISUALLEVEL] = vislevel
newunit.values[VISUALSTYLE] = visstyle
newunit.values[COMPLETED] = complete
newunit.strings[COLOUR] = colour
newunit.strings[CLEARCOLOUR] = clearcolour
if (newunit.className == "level") then
MF_setcolourfromstring(newunitid,colour)
end
addunit(newunitid,true)
addunitmap(newunitid,x,y,newunit.strings[UNITNAME])
dynamic(unitid)
newunit.followed = followed
newunit.back_init = back_init
if (newunit.strings[UNITTYPE] == "text") then
updatecode = 1
end
local undowordunits = currentundo.wordunits
local undowordrelatedunits = currentundo.wordrelatedunits
if (#undowordunits > 0) then
for a,b in ipairs(undowordunits) do
if (b == bline[6]) then
updatecode = 1
end
end
end
if (#undowordrelatedunits > 0) then
for a,b in ipairs(undowordrelatedunits) do
if (b == bline[6]) then
updatecode = 1
end
end
end
table.insert(delname, {newunit.strings[UNITNAME], bline[6], newunit.values[XPOS], newunit.values[YPOS], newunit.values[DIR]})
end
end
addundo({"remove",unit.strings[UNITNAME],unit.values[XPOS],unit.values[YPOS],unit.values[DIR],unit.values[ID],unit.values[ID],unit.strings[U_LEVELFILE],unit.strings[U_LEVELNAME],unit.values[VISUALLEVEL],unit.values[COMPLETED],unit.values[VISUALSTYLE],unit.flags[MAPLEVEL],unit.strings[COLOUR],unit.strings[CLEARCOLOUR],unit.followed,unit.back_init,unit.originalname,unit.strings[UNITSIGNTEXT]})
for a,b in ipairs(delname) do
MF_alert("added undo for " .. b[1] .. " with ID " .. tostring(b[2]))
addundo({"create",b[1],b[2],b[2],"back",b[3],b[4],b[5]})
end
delunit(unitid)
dynamic(unitid)
MF_specialremove(unitid,2)
end
end
end
end
end
end
doupdate()
for i,unitid in ipairs(istele) do
if (isgone(unitid) == false) then
local unit = mmf.newObject(unitid)
-- METATEXT
local name = getname(unit)
local x,y = unit.values[XPOS],unit.values[YPOS]
local targets = findallhere(x,y)
local telethis = false
local telethisx,telethisy = 0,0
if (#targets > 0) then
for i,v in ipairs(targets) do
local vunit = mmf.newObject(v)
local thistype = vunit.strings[UNITTYPE]
local vname = vunit.strings[UNITNAME]
local targetvalid = isgone(v)
local targetstill = hasfeature(vname,"is","still",v,x,y)
-- Luultavasti ei väliä onko kohde tuhoutumassa?
if (targetstill == nil) and floating(v,unitid,x,y) and (vunit.flags[DEAD] == false) then
local targetname = getname(vunit)
if (objectdata[v] == nil) then
objectdata[v] = {}
end
local odata = objectdata[v]
if (odata.tele == nil) then
if (targetname ~= name) and (v ~= unitid) then
local teles = istele
if (#teles > 1) then
local teletargets = {}
local targettele = 0
for a,b in ipairs(teles) do
local tele = mmf.newObject(b)
local telename = getname(tele)
if (b ~= unitid) and (telename == name) and (tele.flags[DEAD] == false) then
table.insert(teletargets, b)
end
end
if (#teletargets > 0) then
local randomtarget = fixedrandom(1, #teletargets)
targettele = teletargets[randomtarget]
local limit = 0
while (targettele == unitid) and (limit < 10) do
randomtarget = fixedrandom(1, #teletargets)
targettele = teletargets[randomtarget]
limit = limit + 1
end
odata.tele = 1
local tele = mmf.newObject(targettele)
local tx,ty = tele.values[XPOS],tele.values[YPOS]
local vx,vy = vunit.values[XPOS],vunit.values[YPOS]
update(v,tx,ty)
local pmult,sound = checkeffecthistory("tele")
MF_particles("glow",vx,vy,5 * pmult,1,4,1,1)
MF_particles("glow",tx,ty,5 * pmult,1,4,1,1)
setsoundname("turn",6,sound)
end
end
end
end
end
end
end
end
end
for a,unitid in ipairs(isshift) do
if (unitid ~= 2) and (unitid ~= 1) then
local unit = mmf.newObject(unitid)
local x,y,dir = unit.values[XPOS],unit.values[YPOS],unit.values[DIR]
local things = findallhere(x,y,unitid)
if (#things > 0) and (isgone(unitid) == false) then
for e,f in ipairs(things) do
if floating(unitid,f,x,y) and (issleep(unitid,x,y) == false) then
local newunit = mmf.newObject(f)
local name = newunit.strings[UNITNAME]
if (featureindex["reverse"] ~= nil) then
local turndir = unit.values[DIR]
turndir = reversecheck(newunit.fixed,unit.values[DIR],x,y)
end
if (newunit.flags[DEAD] == false) then
addundo({"update",name,x,y,newunit.values[DIR],x,y,unit.values[DIR],newunit.values[ID]})
newunit.values[DIR] = unit.values[DIR]
end
end
end
end
end
end
doupdate()
end
end
Модхуки:
mod_hook_functions =
{
level_start =
{
-- Functions added to this table will be called on level start.
},
level_end =
{
-- Functions added to this table will be called on level end.
},
level_win =
{
-- Functions added to this table will be called on level win, before running any of the winning-related code.
},
level_win_after =
{
-- Functions added to this table will be called on level win, after running the winning-related code.
},
level_restart =
{
-- Functions added to this table will be called when the player restarts a level.
},
rule_update =
{
-- Functions added to this table will be called when rules are updated. Extra data: {is_this_a_repeated_update [false = no, true = yes]} <-- the extra variable is true e.g. when Word-related rules require the rules to be refreshed multiple times in a row.
},
rule_baserules =
{
-- Functions added to this table will be called as the game adds the base rules into the rule list (i.e. ones that aren't visible in the rule list). You can use addbaserule(word 1, word 2, word 3) here to add your own base rules.
},
rule_update_after =
{
-- Functions added to this table will be called after rules have been updated. Extra data: {is_this_a_repeated_update [false = no, true = yes]} <-- the extra variable is true e.g. when Word-related rules require the rules to be refreshed multiple times in a row.
},
command_given =
{
-- Functions added to this table will be called when a player command starts resolving. Extra data: {command, player_id}
},
turn_auto =
{
-- Functions added to this table will be called when a turn starts resolving due to 'Level Is Auto'. Extra data: {player_1_direction, player_2_direction, is_a_player_moving [false = no, true = yes]}
},
turn_end =
{
-- Functions added to this table will be called when a turn end. Extra data: {player_found [0 = no, 1 = yes]}
},
always =
{
-- Functions added to this table will be called every frame. This can get quite slow, so be aware of that! Extra data: {time_from_game_start}
},
effect_once =
{
-- Functions added to this table will be called once at the end of every turn.
},
effect_always =
{
-- Functions added to this table will be called every frame when you're playing a level.
},
undoed =
{
-- Functions added to this table will be called when the player does an undo input.
},
undoed_after =
{
-- Functions added to this table will be called after undo has taken effect.
},
levelpack_end =
{
-- Functions added to this table will be called when the player does the Level Is End ending in a levelpack. Note that if any functions are run here, the normal victory effects won't be displayed.
},
levelpack_done =
{
-- Functions added to this table will be called when the player does the All Is Done ending in a levelpack. Note that if any functions are run here, the normal victory effects won't be displayed.
},
text_input_ok =
{
-- Functions added to this table will be called when the user has input text in the text input dialogue and pressed OK. Extra data: {sanitized_text}
},
}
buttonclick_list = {}
function do_mod_hook(name,extra_)
local extra = extra_ or {}
local mods_run = false
if (mod_hook_functions[name] ~= nil) then
for i,v in pairs(mod_hook_functions[name]) do
if (type(v) == "function") then
v(extra)
mods_run = true
end
end
end
return mods_run
end
function buttonclicked(name,unitid)
if (string.len(name) > 0) and (buttonclick_list[name] ~= nil) then
buttonclick_listname
end
end
function setupmods_global()
local files = MF_filelist("Data/Lua/","*.lua")
table.sort(files)
for i,file in ipairs(files) do
print("Added custom lua file " .. file)
dofile("Data/Lua/" .. file)
end
end
function setupmods_levelpack()
local world = generaldata.strings[WORLD]
local files = MF_filelist("Data/Worlds/" .. world .. "/Lua/","*.lua")
--MF_alert(world .. ": " .. tostring(#files))
table.sort(files)
for i,file in ipairs(files) do
print("Added custom levelpack (" .. world .. ") lua file " .. file)
dofile("Data/Worlds/" .. world .. "/Lua/" .. file)
end
modsinuse = true
end
Пиши скрипт полностью