Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not really rewrite mod system #1072

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
478eb07
Test
SweetSea-ButImNotSweet Jan 1, 2024
b3ca43f
Final push
SweetSea-ButImNotSweet Jan 2, 2024
7723288
small update
SweetSea-ButImNotSweet Jan 3, 2024
8252f85
Fix some bugs
SweetSea-ButImNotSweet Jan 4, 2024
e6f416e
Shorten code, remove ``unranked``
SweetSea-ButImNotSweet Jan 4, 2024
47fc75b
Modify some mods' behavior
SweetSea-ButImNotSweet Jan 4, 2024
b8ec5df
Fix redundant "end"
SweetSea-ButImNotSweet Jan 4, 2024
1117b53
Fix bug (again)
SweetSea-ButImNotSweet Jan 4, 2024
c47ddf2
Merge remote-tracking branch 'upstream/main' into mod-patch
SweetSea-ButImNotSweet Jan 5, 2024
72d5e46
Change "modSystem" to "modApplyAt"
SweetSea-ButImNotSweet Jan 6, 2024
4c3abc4
Add TABLE.newWithLockMetamethod()
SweetSea-ButImNotSweet Jan 6, 2024
f0a45b8
Change most mods' configuration
SweetSea-ButImNotSweet Jan 6, 2024
2cd330f
Modify how executing mods again
SweetSea-ButImNotSweet Jan 6, 2024
6873317
Fix mods, update UI
SweetSea-ButImNotSweet Jan 6, 2024
3825b7c
Add VI translation
SweetSea-ButImNotSweet Jan 6, 2024
869135a
Add English translation
SweetSea-ButImNotSweet Jan 6, 2024
766b32b
Final update
SweetSea-ButImNotSweet Jan 6, 2024
70558e8
Add viewLog
SweetSea-ButImNotSweet Jan 6, 2024
6594b4a
Fix viewLog
SweetSea-ButImNotSweet Jan 6, 2024
d09f5b0
update viewlog
SweetSea-ButImNotSweet Jan 7, 2024
898539c
update viewLog
SweetSea-ButImNotSweet Jan 7, 2024
65c050f
Small update for viewLog
SweetSea-ButImNotSweet Jan 7, 2024
2816a76
Fix bugs and small changes to other thing
SweetSea-ButImNotSweet Jan 7, 2024
d61372c
Small tweak
SweetSea-ButImNotSweet Jan 7, 2024
3cda61b
Add a short delay before displaying username
SweetSea-ButImNotSweet Jan 7, 2024
dc8488f
Clean-up
SweetSea-ButImNotSweet Jan 7, 2024
5361742
Resolves change requests
SweetSea-ButImNotSweet Jan 8, 2024
888f2f6
Resolve change requests part 2
SweetSea-ButImNotSweet Jan 8, 2024
f2686fb
Resolve change requests part 3
SweetSea-ButImNotSweet Jan 8, 2024
c20e4ac
Add short delay before showing nickname (again)
SweetSea-ButImNotSweet Jan 8, 2024
9c47e95
Revert the default username from SweetSea to <nil>
SweetSea-ButImNotSweet Jan 8, 2024
4928f19
Remove an unused arg
SweetSea-ButImNotSweet Jan 8, 2024
97b1abb
Resolve change request part Tetra
SweetSea-ButImNotSweet Jan 9, 2024
d399f3c
Moving part 1
SweetSea-ButImNotSweet Jan 11, 2024
519687a
Moving part 2
SweetSea-ButImNotSweet Jan 11, 2024
c143e8e
Moving part 3
SweetSea-ButImNotSweet Jan 11, 2024
58648f7
Remove some texts (most deprecated)
SweetSea-ButImNotSweet Jan 11, 2024
378d88c
Small edit to manual_vi
SweetSea-ButImNotSweet Jan 11, 2024
44ff5e8
Merge branch 'main' of https://github.com/26F-Studio/Techmino into mo…
SweetSea-ButImNotSweet Jan 21, 2024
387bbfa
Moving changes to #1085
SweetSea-ButImNotSweet Jan 21, 2024
271769c
Merge branch 'main' into mod-patch
SweetSea-ButImNotSweet Jun 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Zframework/tableExtend.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@ function TABLE.new(val,count)
return L
end

-- Get a new empty table with __lock() and __unlock() to protect changes
function TABLE.newWithLockMetamethod()
local t
do
local lockedKey={}
local realTable={}
t=setmetatable( -- This is the fake table, act like a wrapper of realTable
{
__lock =function(k) if k then lockedKey[k]=true end end,
__unlock=function(k)
if k then lockedKey[k]=false else TABLE.cut(lockedKey) end
end,
},{
__index =realTable,
__newindex=function(_,k,v) if not lockedKey[k] then realTable[k]=v end end,
__len =function(_,_,_) return #realTable end,
__tostring=function(_,_,_) return tostring(realTable) end,
}
)
end
return t
end

-- Get a copy of [1~#] elements
function TABLE.shift(org,depth)
if not depth then depth=1e99 end
Expand Down
2 changes: 2 additions & 0 deletions parts/data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ do-- function DATA.saveReplay()
seed=GAME.seed,
setting=GAME.setting,
mod=_getModList(),
modApplyAt=GAME.modApplyAt,
tasUsed=GAME.tasUsed,
}
if GAME.curMode.savePrivate then
Expand Down Expand Up @@ -393,6 +394,7 @@ function DATA.parseReplayData(fileName,fileData,ifFull)
seed=metaData.seed,
setting=metaData.setting,
mod=metaData.mod,
modApplyAt=metaData.modApplyAt,
tasUsed=metaData.tasUsed,
}
if ifFull then rep.data=fileData end
Expand Down
31 changes: 17 additions & 14 deletions parts/gameFuncs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,8 @@ function mergeStat(stat,delta)-- Merge delta stat. to global stat.
end
end
function scoreValid()-- Check if any unranked mods are activated
for number,sel in next,GAME.mod do
if sel>0 and MODOPT[number].unranked then
return false
end
for _,sel in next,GAME.mod do
if sel>0 then return false end
end
if GAME.playing and GAME.tasUsed then
return false
Expand Down Expand Up @@ -1000,23 +998,28 @@ do-- function dumpBasicConfig()
end
end
do-- function resetGameData(args)
local function task_showMods() -- TODO
local function task_showMods()
coroutine.yield()
local counter=0
for number,sel in next,GAME.mod do
if sel>0 then
if counter==0 then
coroutine.yield()
else

if usingMod() then
SFX.play('collect',.2)
TEXT.show(GAME.modApplyAt,640,26,45,'spin')
for _=1,90 do coroutine.yield() end

for number,sel in next,GAME.mod do
if sel>0 then
for _=1,20 do
coroutine.yield()
end
Comment on lines 1012 to 1014
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a TEST.yieldN() thing you could use instead. @MrZ626 would you recommend using that, or is that just a temporary thing?

local M=MODOPT[number]
SFX.play('collect',.2)
TEXT.show(M.id,640+(counter%5-2)*80,26,45,'spin')
counter=counter+1
end
local M=MODOPT[number]
SFX.play('collect',.2)
TEXT.show(M.id,640+(counter%5-2)*80,26,45,'spin')
counter=counter+1
end
for _=1,(counter%5)*20+90 do coroutine.yield() end
if GAME.playing then PLAYERS[1].showUsername=true end
end
end
local gameSetting={
Expand Down
120 changes: 75 additions & 45 deletions parts/gameTables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -354,144 +354,172 @@ do-- Mod data
local function _disableKey(P,key)
table.insert(P.gameEnv.keyCancel,key)
end
local _invisibleTime={
['easy'] =300,
['slow'] =100,
['medium']=60,
['fast'] =20,
['none'] =0,
}
local function _lockVfunc(k) do
local K=k
return function(P,O)
P.gameEnv[K]=O or true
P.gameEnv.__lock(K)
end
end end
MODOPT={-- Mod options
{no=0,id="NX",name="next",
key="q",x=80,y=230,color='lO',
list={0,1,2,3,4,5,6},
func=function(P,O) P.gameEnv.nextCount=O end,
unranked=true,
funcInit =function(P,O) P.gameEnv.nextCount=O end,
funcOnce =_lockVfunc('nextCount'),
},
{no=1,id="HL",name="hold",
key="w",x=200,y=230,color='lO',
list={0,1,2,3,4,5,6},
func=function(P,O) P.gameEnv.holdCount=O end,
unranked=true,
funcInit =function(P,O) P.gameEnv.holdCount=O end,
funcOnce =_lockVfunc('holdCount'),
},
{no=2,id="FL",name="hideNext",
key="e",x=320,y=230,color='lA',
list={1,2,3,4,5},
func=function(P,O) P.gameEnv.nextStartPos=O+1 end,
unranked=true,
funcInit =function(P,O) P.gameEnv.nextStartPos=O+1 end,
funcOnce =_lockVfunc('nextStartPos'),
},
{no=3,id="IH",name="infHold",
key="r",x=440,y=230,color='lA',
func=function(P) P.gameEnv.infHold=true end,
unranked=true,
funcInit =function(P) P.gameEnv.infHold=true end,
funcOnce =_lockVfunc('infHold'),
},
{no=4,id="HB",name="hideBlock",
key="y",x=680,y=230,color='lV',
func=function(P) P.gameEnv.block=false end,
unranked=true,
funcInit =function(P) P.gameEnv.block=false end,
funcOnce =_lockVfunc('block'),
},
{no=5,id="HG",name="hideGhost",
key="u",x=800,y=230,color='lV',
func=function(P) P.gameEnv.ghost=false end,
unranked=true,
funcInit =function(P) P.gameEnv.ghost=false end,
funcOnce =function(P) P.gameEnv.ghost=false; P.gameEnv.__lock('ghost') end,
},
{no=6,id="HD",name="hidden",
key="i",x=920,y=230,color='lP',
list={'easy','slow','medium','fast','none'},
func=function(P,O) P.gameEnv.visible=O end,
unranked=true,
funcInit =function(P,O) P.gameEnv.visible=O end,
funcRepeat=function(P,O)
if P.showTime~=_invisibleTime[O] then
P:setInvisible(_invisibleTime[O])
end
end,
},
{no=7,id="HB",name="hideBoard",
key="o",x=1040,y=230,color='lP',
list={'down','up','all'},
func=function(P,O) P.gameEnv.hideBoard=O end,
unranked=true,
funcInit =function(P,O) P.gameEnv.hideBoard=O end,
},
{no=8,id="FB",name="flipBoard",
key="p",x=1160,y=230,color='lJ',
list={'U-D','L-R','180'},
func=function(P,O) P.gameEnv.flipBoard=O end,
unranked=true,
funcInit =function(P,O) P.gameEnv.flipBoard=O end,
funcOnce =_lockVfunc('flipBoard'),
},

{no=9,id="DT",name="dropDelay",
key="a",x=140,y=350,color='lR',
list={0,.125,.25,.5,1,2,3,4,5,6,7,8,9,10,12,14,16,18,20,25,30,40,60,180,1e99},
func=function(P,O) P.gameEnv.drop=O end,
unranked=true,
funcInit =function(P,O) P.gameEnv.drop=O end,
funcRepeat=function(P,O)
if P.dropDelay~=O then
P.gameEnv.drop=O
P:set20G(O==0)
end
end,
},
{no=10,id="LT",name="lockDelay",
key="s",x=260,y=350,color='lR',
list={0,1,2,3,4,5,6,7,8,9,10,12,14,16,18,20,25,30,40,60,180,1e99},
func=function(P,O) P.gameEnv.lock=O end,
unranked=true,
funcInit =function(P,O) P.gameEnv.lock=O end,
funcRepeat=function(P,O) P.dropDelay=O end,
},
{no=11,id="ST",name="waitDelay",
key="d",x=380,y=350,color='lR',
list={0,1,2,3,4,5,6,7,8,10,15,20,30,60},
func=function(P,O) P.gameEnv.wait=O end,
unranked=true,
funcInit =function(P,O) P.gameEnv.wait=O end,
funcOnce =_lockVfunc('waitDelay'),
},
{no=12,id="CT",name="fallDelay",
key="f",x=500,y=350,color='lR',
list={0,1,2,3,4,5,6,7,8,10,15,20,30,60},
func=function(P,O) P.gameEnv.fall=O end,
unranked=true,
funcInit =function(P,O) P.gameEnv.fall=O end,
funcOnce =_lockVfunc('fallDelay'),
},
{no=13,id="LF",name="life",
key="j",x=860,y=350,color='lY',
list={0,1,2,3,5,10,15,26,42,87,500},
func=function(P,O) P.gameEnv.life=O end,
unranked=true,
funcInit =function(P,O) P.gameEnv.life=O end,
funcOnce =_lockVfunc('life'),
},
{no=14,id="FB",name="forceB2B",
key="k",x=980,y=350,color='lY',
func=function(P) P.gameEnv.b2bKill=true end,
unranked=true,
funcInit =function(P) P.gameEnv.b2bKill=true end,
funcOnce =_lockVfunc('b2bKill'),
},
{no=15,id="PF",name="forceFinesse",
key="l",x=1100,y=350,color='lY',
func=function(P) P.gameEnv.fineKill=true end,
unranked=true,
funcInit =function(P) P.gameEnv.fineKill=true end,
funcOnce =_lockVfunc('fineKill'),
},

{no=16,id="TL",name="tele",
key="z",x=200,y=470,color='lH',
func=function(P)
funcInit =function(P)
P.gameEnv.das,P.gameEnv.arr=0,0
P.gameEnv.sddas,P.gameEnv.sdarr=0,0
end,
unranked=true,
funcOnce =function(P)
for _,k in pairs{'das','arr','sddas','sdarr'} do
P.gameEnv[k]=0
P.gameEnv.__lock(k)
end
end
},
{no=17,id="FX",name="noRotation",
key="x",x=320,y=470,color='lH',
func=function(P)
funcInit =function(P)
_disableKey(P,3)
_disableKey(P,4)
_disableKey(P,5)
end,
unranked=true,
},
{no=18,id="GL",name="noMove",
key="c",x=440,y=470,color='lH',
func=function(P)
_disableKey(P,1)_disableKey(P,2)
funcInit =function(P)
_disableKey(P,1) _disableKey(P,2)
_disableKey(P,11)_disableKey(P,12)
_disableKey(P,17)_disableKey(P,18)
_disableKey(P,19)_disableKey(P,20)
end,
unranked=true,
},
{no=19,id="CS",name="customSeq",
key="b",x=680,y=470,color='lB',
list={'bag','bagES','his','hisPool','c2','bagP1inf','rnd','mess','reverb'},
func=function(P,O) P.gameEnv.sequence=O end,
unranked=true,
funcInit =function(P,O) P.gameEnv.sequence=O end,
funcOnce =_lockVfunc('sequence'),
},
{no=20,id="PS",name="pushSpeed",
key="n",x=800,y=470,color='lB',
list={.5,1,2,3,5,15,1e99},
func=function(P,O) P.gameEnv.pushSpeed=O end,
unranked=true,
funcInit =function(P,O) P.gameEnv.pushSpeed=O end,
funcOnce =_lockVfunc('pushSpeed'),
},
{no=21,id="BN",name="boneBlock",
key="m",x=920,y=470,color='lB',
list={'on','off'},
func=function(P,O) P.gameEnv.bone=O=='on' end,
unranked=true,
funcInit =function(P,O) P.gameEnv.bone=O=='on' end,
funcOnce =function(P,O)
P.gameEnv.bone=O=='on'
P.gameEnv.__lock('bone')
end
},
}
for i=1,#MODOPT do
Expand Down Expand Up @@ -521,7 +549,9 @@ do-- Game data tables
seed=1046101471, -- Game seed
curMode=false, -- Current gamemode object
initPlayerCount=0, -- Player count when init game
modUsed=false,
mod=TABLE.new(0,#MODOPT),-- List of loaded mods
modApplyAt='postInit', -- Apply mod when? (preInit, postInit, always)
modeEnv=false, -- Current gamemode environment
setting={}, -- Game settings
rep={}, -- Recording list, key,time,key,time...
Expand Down
2 changes: 2 additions & 0 deletions parts/language/lang_en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ return {
tryAnotherBuild="UTF-8 decoding error. If you are using Microsoft Windows, please try to download the build with the different architecture. If you are using the x86 version of Techmino, try downloading the x64 version and vice versa.",

modInstruction="Choose your modifiers here!\nMods allow you to change the rules in various ways, but they can also crash the game. Feel free to play the game your way!\nNote that scores are not saved when using mods. You can also toggle mods using your keyboard keys (hold Shift to reverse).",
modApplyAtInstruction="Choose when you want the modifier to be applied.\npreInit: Before loading the modes. The default option in V0.17.15 and earlier, but may cause problems with certain mods.\npostInit: After loading the game. This can fix some bugs in preInit, but some mods can still be disabled by modes in some situations.\nalways: Throughout the entire game. Keeps the effects of the mods in all situations.",
modInfo={
next="NEXT\nOverrides the number of Next pieces displayed.",
hold="HOLD\nOverrides the number of Hold pieces displayed.",
Expand Down Expand Up @@ -449,6 +450,7 @@ C. Gamepad
},
mod={
title="Mods",
applyAt="Apply during",
reset="Reset (tab)",
unranked="Unranked",
},
Expand Down
2 changes: 2 additions & 0 deletions parts/language/lang_es.lua
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ return {
tryAnotherBuild="[UTF-8 Inválido] Si estás usando Windows, intenta descargar Techmino-win32 o Techmino-win64 (el que no estés usando ahora).",

modInstruction="¡Elige tus mods!\nLos mods permiten modificar el juego,\npero también es posible que lo crasheen.\nLos scores no se guardan durante el uso de mods.",
-- modApplyAtInstruction="Choose when you want the modifier to be applied.\npreInit: Before loading the modes. The default option in V0.17.15 and earlier, but may cause problems with certain mods.\npostInit: After loading the game. This can fix some bugs in preInit, but some mods can still be disabled by modes in some situations.\nalways: Throughout the entire game. Keeps the effects of the mods in all situations. ",
modInfo={
next="NEXT\nSobreescribe el nro. de piezas siguientes a mostrar.",
hold="HOLD\nSobreescribe el nro. de piezas en reserva disponibles.",
Expand Down Expand Up @@ -411,6 +412,7 @@ return {
mod={
title="Mods",
reset="Reinic. (tab)",
-- applyAt="Apply during",
unranked="Sin rango",
},
pause={
Expand Down
2 changes: 2 additions & 0 deletions parts/language/lang_fr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ return {
-- tryAnotherBuild="[Invalid UTF-8] If you are on Windows, try downloading Techmino-win32 or Techmino-win64 (different from what you are using now).",

modInstruction="",
-- modApplyAtInstruction="Choose when you want the modifier to be applied.\npreInit: Before loading the modes. The default option in V0.17.15 and earlier, but may cause problems with certain mods.\npostInit: After loading the game. This can fix some bugs in preInit, but some mods can still be disabled by modes in some situations.\nalways: Throughout the entire game. Keeps the effects of the mods in all situations. ",
modInfo={},-- See lang_en.lua
pauseStat={
"Temps :",
Expand Down Expand Up @@ -386,6 +387,7 @@ return {
mod={
title="Mods",
reset="Réinitialiser (tab)",
-- applyAt="Apply during",
unranked="Unranked",
},
pause={
Expand Down
2 changes: 2 additions & 0 deletions parts/language/lang_id.lua
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ return {
errorMsg="Techmino mengalami eror dan harus memuat ulang.\nAnda bisa mengirim log eror ke developer.",

modInstruction="Pilih mod Anda!\nMod memungkinkan Anda untuk mengubah permainan,\ntetapi juga bisa menghancur permainan.\nNilai-nilai tidak akan disimpan saat menggunakan mod.",
-- modApplyAtInstruction="Choose when you want the modifier to be applied.\npreInit: Before loading the modes. The default option in V0.17.15 and earlier, but may cause problems with certain mods.\npostInit: After loading the game. This can fix some bugs in preInit, but some mods can still be disabled by modes in some situations.\nalways: Throughout the entire game. Keeps the effects of the mods in all situations. ",
modInfo={
next="BLOK LANJUT\nMengubah jumlah pratinjau blok lanjut yang ditampilkan.",
hold="SIMPAN\nMengubah jumlah blok yang bisa disimpan.",
Expand Down Expand Up @@ -412,6 +413,7 @@ return {
mod={
title="Mod",
reset="Reset (tab)",
-- applyAt="Apply during",
unranked="Tidak Berperingkat",
},
pause={
Expand Down
Loading
Loading