The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled PHP Code
Posted by: Fish | June 4, 2010 @ 6:22pm
PHP Code
[
Download
]
function CreateRandomPortal(user,cell,ent) if not InfiniDungeon.HandleHook("OnCreateRandomPortal",user,cell,ent) then return end local name = ent:GetName() if not name then return end local room = GetRoom(ent) if table.getn(ID_DOORS) < 1 then PopulateDoors() end local theme = GetTheme(ent) -- Before we do ANY selecting, we need to check if this door is a THEME-CHANGER local contr = GetDoorController(ent) if (contr) then if contr.oldtheme then -- This door is, indeed, a theme-changer. Set the new theme to whatever theme it changes to. local changetheme=true if contr.themelogic_name then -- This theme is controlled by logic; let's abide by that logic! local logic = contr.themelogic_name changetheme=false --[[if ID_LOGIC_COUNTERS[logic] then if contr.themelogic_operator=="ltet" then -- "Less Than Equal To" if ID_LOGIC_COUNTERS[logic] <= tonumber(contr.themelogic_value) then changetheme=true end end if contr.themelogic_operator=="gtet" then -- "Greater Than Equal To" if ID_LOGIC_COUNTERS[logic] >= tonumber(contr.themelogic_value) then changetheme=true end end end]] if not user.LogicCounters then user.LogicCounters = {} end if not user.LogicCounters[logic] then user.LogicCounters[logic] = 0 end --if user.LogicCounters[logic] then if contr.themelogic_operator=="ltet" then -- "Less Than Equal To" if user.LogicCounters[logic] <= tonumber(contr.themelogic_value) then changetheme=true end end if contr.themelogic_operator=="gtet" then -- "Greater Than Equal To" if user.LogicCounters[logic] >= tonumber(contr.themelogic_value) then changetheme=true end end --end end if changetheme then theme = contr.newtheme -- In theory, this should be all we need to do. How this system is set up should allow seamless transition between themes. end end end local door = ID_THEMEDOORS[theme][math.random(#ID_THEMEDOORS[theme])] local room2 = string.sub(door:GetName(),2,3) if (room==room2) or (not CanBeLinked(door,cell,ent)) then -- Same room; try to pick a different door! for j=1,6 do door = ID_THEMEDOORS[theme][math.random(#ID_THEMEDOORS[theme])] room2 = GetRoom(door) if (room~=room2) and (CanBeLinked(door,cell,ent)) then break end end end room = string.gsub(room,"d","") room2 = string.gsub(room2,"d","") print("ROOM1:"..room,"ROOM2: "..room2) if room==room2 then return end if (not CanBeLinked(door,cell,ent)) then return end -- If door A has a forced link, link to its forced counterpart if HasForcedLink(ent) then door = GetForcedLink(ent) end -- If door B has a forced link, link to its forced counterpart if HasForcedLink(door) then ent = GetForcedLink(door) end if ID_NEXTROOM then local d = DoorsInRoom(ID_NEXTROOM) door = d[math.random(1,#d)] ID_NEXTROOM = nil end LinkInCell(cell,ent,door) InfiniDungeon.HandleHook("RandomPortalCreated",cell,ent,door) end
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.63 / 8
52 Votes