Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Most the code was writen by Mr.Stump - To him I am greatful!
- function onLoad()
- --Starts a repeating timer that goes off once per second
- Timer.create({
- identifier="statusReportTimer",
- function_name = "updateCounts_timer",
- function_owner = Global, --If this script is on an object, use self
- delay = 1,
- repetitions = 0
- })
- --Creates buttons that will be used as displays
- --The first for loop goes through the main entries (YELLOW/BLUE/RED/GREEN)
- --The second for loop goes through each entry for that color
- for color, dataTable in pairs(ref_playerZones) do
- for _, entries in ipairs(dataTable) do
- local obj = getObjectFromGUID(entries.guid_button)
- obj.createButton({
- click_function="none", function_owner=Global,
- position=entries.pos_button, height=0, width=0,
- font_size=entries.font_size, scale = {0.45,0.45,0.45}
- })
- end
- end
- end
- --Goes off once per second
- function updateCounts_timer()
- --Go through every zone in ref_playerData
- for color, dataTable in pairs(ref_playerZones) do
- for i, entries in ipairs(dataTable) do
- local zone = getObjectFromGUID(entries.guid_zone)
- --Finds object types by their tag
- --Whatever the tag of your markers are, that is what you use here
- --I looked, it was Tile
- local zoneObjList = getObjectTypesInZone(zone, "Tile")
- --This adds the # of entries in zone object list to ref_playerZones
- ref_playerZones[color][i].total = #zoneObjList
- end
- end
- updateDisplays()
- end
- function updateDisplays()
- for color, dataTable in pairs(ref_playerZones) do
- for i, entries in ipairs(dataTable) do
- local obj = getObjectFromGUID(entries.guid_button)
- -- Checks to see if lable is ment for weapons or colony station hp
- --If it is not will format normally otherwise it will change the values
- if i ~= 2 and i ~= 5 then
- obj.editButton({
- index = i-1,
- label = entries.total
- })
- else
- --Finds the corisponding weapon lable for die value
- if i == 2 then
- if entries.total < 1 then
- label = "X"
- else
- if entries.total < 4 then
- label = "D2"
- else
- if entries.total < 6 then
- label = "D4"
- else
- if entries.total < 8 then
- label = "D6"
- else
- if entries.total < 10 then
- label = "D8"
- else
- if entries.total < 12 then
- label = "D10"
- else
- label = "D12"
- end
- end
- end
- end
- end
- end
- else
- --Fins the corisponing life value for the colony station
- if entries.total == 4 then
- label = "100%"
- else
- if entries.total == 3 then
- label = "75%"
- else
- if entries.total == 2 then
- label = "50%"
- else
- if entries.total == 1 then
- label = "25%"
- else
- label = "XXX"
- end
- end
- end
- end
- end
- obj.editButton({
- index = i-1,
- label = label,
- })
- end
- end
- end
- end
- --Returns table of objects of given types using their tags
- function getObjectTypesInZone(zone, ...)
- local foundTypes, tagList = {}, {...}
- for _, object in ipairs(zone.getObjects()) do
- for _, tag in ipairs(tagList) do
- if object.tag == tag then
- table.insert(foundTypes, object)
- break
- end
- end
- end
- return foundTypes
- end
- --Each player color's scripting zone
- --You would need to change the colors to match your table's player colors
- --You would need to enter the GUID for the item that gets the button on it
- --You would need to enter the guid for the script zone for that buttons
- --You would need to enter the position for that button on that object.
- --Remember these buttons are displays to show the totals
- --Zone Ref Scale 5.18 - .08 .14
- ref_playerZones = {
- ["Yellow"] = {
- {guid_button="0e46ea", guid_zone="18c7ed", pos_button={-1.71,0.12,-0.32}, total=0, font_size=220},
- {guid_button="0e46ea", guid_zone="88fcfc", pos_button={-1.57,0.12,-0.09}, total=0, font_size=180},
- {guid_button="0e46ea", guid_zone="b73789", pos_button={-1.71,0.12, 0.16}, total=0, font_size=220},
- {guid_button="0e46ea", guid_zone="45ac57", pos_button={-1.57,0.12, 0.38}, total=0, font_size=220},
- {guid_button="0e46ea", guid_zone="06a0e3", pos_button={-1.55,0.12, 0.73}, total=0, font_size=180},
- },
- ["Blue"] = {
- {guid_button="e29147", guid_zone="b9cbf9", pos_button={-1.71,0.12,-0.32}, total=0, font_size=220},
- {guid_button="e29147", guid_zone="960736", pos_button={-1.57,0.12,-0.09}, total=0, font_size=180},
- {guid_button="e29147", guid_zone="92ce0f", pos_button={-1.71,0.12, 0.16}, total=0, font_size=220},
- {guid_button="e29147", guid_zone="f6b3e5", pos_button={-1.57,0.12, 0.38}, total=0, font_size=220},
- {guid_button="e29147", guid_zone="3e96b2", pos_button={-1.55,0.12, 0.73}, total=0, font_size=180},
- },
- ["Red"] = {
- {guid_button="ed2021", guid_zone="60667f", pos_button={-1.71,0.12,-0.32}, total=0, font_size=220},
- {guid_button="ed2021", guid_zone="004da6", pos_button={-1.57,0.12,-0.09}, total=0, font_size=180},
- {guid_button="ed2021", guid_zone="931665", pos_button={-1.71,0.12, 0.16}, total=0, font_size=220},
- {guid_button="ed2021", guid_zone="819a0c", pos_button={-1.57,0.12, 0.38}, total=0, font_size=220},
- {guid_button="ed2021", guid_zone="ec3d94", pos_button={-1.55,0.12, 0.73}, total=0, font_size=180},
- },
- ["Green"] = {
- {guid_button="7fee02", guid_zone="c33ccf", pos_button={-1.71,0.12,-0.32}, total=0, font_size=220},
- {guid_button="7fee02", guid_zone="fdf690", pos_button={-1.57,0.12,-0.09}, total=0, font_size=180},
- {guid_button="7fee02", guid_zone="d30b05", pos_button={-1.71,0.12, 0.16}, total=0, font_size=220},
- {guid_button="7fee02", guid_zone="2a1bc7", pos_button={-1.57,0.12, 0.38}, total=0, font_size=220},
- {guid_button="7fee02", guid_zone="27087b", pos_button={-1.55,0.12, 0.73}, total=0, font_size=180},
- },
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement