[MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Topics and discussion about specific mods
joran
Burner Inserter
Burner Inserter
Posts: 15
Joined: Fri Apr 22, 2016 7:54 am
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by joran »

no worries :) glad its up and running for you
SamyLerari
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sun Apr 17, 2016 1:12 pm
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by SamyLerari »

I can see on GitHub you deleted myline so it looks like my commit led to another bug :-( Sorry
joran
Burner Inserter
Burner Inserter
Posts: 15
Joined: Fri Apr 22, 2016 7:54 am
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by joran »

no not really ... it was a minor graphical glitch ... I just refactored your code (its not really recognizable anymore but its there ;P) ... the bug that was mentioned wasnt your fault ... it was just an extra edge case that I tried to handle all of them in the same place :) I really appreciate your patch :)
Sunnova
Fast Inserter
Fast Inserter
Posts: 169
Joined: Mon May 16, 2016 12:10 pm
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by Sunnova »

Thanks for the mod, I got it working in Multiplayer, took a few changes to the control.lua, seems to be working just fine.
Teebs
Manual Inserter
Manual Inserter
Posts: 3
Joined: Mon Jun 13, 2016 2:46 am
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by Teebs »

Hey Joran (OP = Original Poster),

I downloaded this mod today and couldn't see the "spawn ore" option. Any ideas on what I am doing wrong? I believe i have your latest and greatest version. Do I need the previous version?

Let me know what you think and if you need more info, I will try to get it to you.

Peace out,
Teebs
Teebs
Manual Inserter
Manual Inserter
Posts: 3
Joined: Mon Jun 13, 2016 2:46 am
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by Teebs »

I figured out how to deploy resources. I Thought i had tried clicking on the red X but apparently I did not. Thank you for the mod and hopefully i didn't cause you to worry about some ghost bug that i was experiencing. It trully is one of those ID 10 T errors (ID10T). Lol :lol:
bartaslondon
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sat Apr 16, 2016 3:06 pm
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by bartaslondon »

Hi,

Do you know how to upgrade this mod make make it work with 0.13?
Sunnova
Fast Inserter
Fast Inserter
Posts: 169
Joined: Mon May 16, 2016 12:10 pm
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by Sunnova »

I can't remember everything I changed, so I'll post the code I 'm using till the author can update the mod. I've been using this on multiplayer without a problem.

info.json

Code: Select all

{"name": "Peace_And_Prosperity", 
  "author": "Joran Beasley", 
  "title": "Peace And Prosperity", 
  "contact": "",
  "factorio_version": "0.13",
  "dependencies": ["base >= 0.13"],     
  "version": "0.1.56", 
  "homepage": "", "description": "Adds Toggle for peaceful mode, and also adds a tool to create resource patches"}
control.lua

Code: Select all


require("utils_peaceprosperity")

local current_button = 0
local player
-- local is_first_load = nil
--------------------------------------------------------------------------------------
function create_gui(player)
    player.gui.top.add({type = "frame", name = "jmod_main_frameA", caption = "", direction = "horizontal", style = "jmod_frame_style"})
	player.gui.top.jmod_main_frameA.add({type="flow",name="container",direction="vertical"})
    player.gui.top.jmod_main_frameA.container.add({type="flow",name="main",direction="horizontal"})
    player.gui.top.jmod_main_frameA.container.add({type="flow",name="bottom",direction="horizontal"})

    player.gui.top.jmod_main_frameA.container.main.add({type = "button", name = "but_mobs", caption = "Mobs Aggressive", font_color = red, style = "jmod_button_style"})
    player.gui.top.jmod_main_frameA.container.main.add({type = "button", name = "but_resources", style = "jmod_button_none_style"})
    player.gui.top.jmod_main_frameA.container.main.add({type = "button", name = "but_deploy", caption = "Deploy Resource" , font_color = white, style = "jmod_button_style"})

    player.gui.top.jmod_main_frameA.container.bottom.add({type="label",name="lbl_deploy",caption="test",font_color="white"})
    player.gui.top.jmod_main_frameA.container.bottom.add({type="checkbox",name="cb_minify",caption="tiny",state=false,font_color="white"})
end
-- This function allows pre 0.1.5 version existing games to load

function create_maximizer(player)
    player.gui.left.add({type = "button", name = "jmod_frameB", caption = "", direction = "horizontal", style = "jmod_button_angry_style"})
end

function on_player_created(event)
  local player = game.players[event.player_index]
  create_gui(player)
  update_buttons(player)
end

-- function on_init()
-- 	is_first_load = true
--  	surf = game.surfaces[1]
--   for _, player in ipairs(game.players) do
--   if player.gui.top.jmod_main_frameA ~= nil and player.gui.top.jmod_main_frameA.container == nil then
-- 		player.gui.top.jmod_main_frameA.destroy()
-- 	end
-- 	if player.gui.top.jmod_main_frameA == nil and player.gui.left.jmod_frameB == nil then
--     create_gui(player)
-- 	end
-- 	update_buttons(player)
-- 	end
-- end

function toggle_gui(player)
    if player.gui.top.jmod_main_frameA ~= nil then
        player.gui.top.jmod_main_frameA.destroy()
        create_maximizer(player)
    else
        if player.gui.left.jmod_frameB ~= nil then
            player.gui.left.jmod_frameB.destroy()
        end
        create_gui(player)
    end
end

script.on_event(defines.events.on_player_created, on_player_created)

-- script.on_event(defines.events.on_tick, 
    --runs every tick ... really I would like to just call once when world is first loaded but meh...
-- 	function(event)
-- 		if is_first_load == nil then -- instructions run once, when the world is first loaded (not after a save)
-- 			on_init()
-- 		end
-- 	end
-- )

--------------------------------------------------------------------------------------
script.on_event(defines.events.on_gui_click, 
    -- handle when a user clicks our gui
	function(event)
	  local player = game.players[event.element.player_index]
		if event.element.name == "but_mobs" then
			game.surfaces[1].peaceful_mode = not game.surfaces[1].peaceful_mode
			if game.surfaces[1].peaceful_mode then
			  game.evolution_factor = 0; 
				game.forces["enemy"].kill_all_units()
				debug_print("Peaceful Enabled")
			else
				debug_print("Aggressive Enabled!")
			end
		elseif event.element.name == "but_resources" then
			current_button = current_button + 1
		elseif event.element.name == "but_deploy" then
			current_button,resource = resource_from_index(current_button)
			local surface = game.surfaces[1]
			if resource.item_name == "crude-oil" then
         local positions = {{-2,-2},{2,2},{0,0},{-2,2},{2,-2}}
				 for i, pair in ipairs(positions) do
					 local x,y = pair[1],pair[2]
					 surface.create_entity({name="crude-oil", amount=50000, position={player.position.x+x, player.position.y+y}})
         end
      elseif resource.item_name == "clear" then
         local area = {{player.position.x-2,player.position.y-2},{player.position.x+2,player.position.y+2}}
			  	for i,entity in ipairs(surface.find_entities(area)) do
				  	if entity.name ~= "player" then
					     entity.destroy()
            end
          end
			else
				for y=-2,2 do
					for x=-2,2 do
						surface.create_entity({name=resource.item_name, amount=50000, position={player.position.x+x, player.position.y+y}})
					end
				end
			end	
			debug_print("Deployed : %s",resource.item_name)
        elseif event.element.name == "cb_minify" or event.element.name == "jmod_frameB" then
            toggle_gui(player)
        end
		update_buttons(player)
	end
)

--------------------------------------------------------------------------------------
function update_minigui(player)
    if game.surfaces[1].peaceful_mode then
            player.gui.left.jmod_frameB.style ="jmod_button_happy_style"
    else
        player.gui.left.jmod_frameB.style ="jmod_button_angry_style"
    end
end

function update_maingui(player)
    current_button,resource = resource_from_index(current_button)
    player.gui.top.jmod_main_frameA.container.main.but_resources.style =  resource.style
    local caption,caption2,font_color

    if resource.item_name == "clear" then
          caption = "Clear Area"
          caption2 = "Clear Area"
          font_color = red
    else
          caption = "Deploy: "..resource.item_name.."      "
          caption2 = "Deploy Resource"
          font_color = white
    end

    player.gui.top.jmod_main_frameA.container.bottom.lbl_deploy.caption = caption
    player.gui.top.jmod_main_frameA.container.main.but_deploy.style.font_color = font_color
    player.gui.top.jmod_main_frameA.container.main.but_deploy.caption = caption2

    if not game.surfaces[1].peaceful_mode then
        player.gui.top.jmod_main_frameA.container.main.but_mobs.style.font_color = red
        player.gui.top.jmod_main_frameA.container.main.but_mobs.caption = "Mobs Aggressive"
    else
        player.gui.top.jmod_main_frameA.container.main.but_mobs.style.font_color = green
        player.gui.top.jmod_main_frameA.container.main.but_mobs.caption = "Mobs Peaceful  "
    end
end

function update_buttons(player)  
    -- update buttons ... it should only be called explicitly after a state change event (gui click for example)  	
    if player.gui.top.jmod_main_frameA ~= nil then
        update_maingui(player)
    elseif player.gui.left.jmod_frameB ~= nil then
        update_minigui(player)
    end
end


in the prototypes folder, styles.lua

Code: Select all

require("utils_peaceprosperity")
data:extend(
	{
		{
			type = "font",
			name = "jmod_font",
			from = "default",
			border = false,
			size = 15
		},
		{
			type = "font",
			name = "jmod_font_bold",
			from = "default-bold",
			border = false,
			size = 15
		},
	}
)

local default_gui = data.raw["gui-style"].default

default_gui.jmod_frame_style = 
{
	type="frame_style",
	parent="frame_style",
	top_padding = 0,
	right_padding = 0,
	bottom_padding = 0,
	left_padding = 0,
}

default_gui.jmod_label_style =
{
	type="label_style",
	parent="label_style",
	font="jmod_font",
	align = "left",
	default_font_color={r=1, g=1, b=1},
	hover_font_color={r=0, g=1, b=0},
	top_padding = 0,
	right_padding = 0,
	bottom_padding = 0,
	left_padding = 0,
}

default_gui.jmod_button_style = 
{
	type="button_style",
	parent="button_style",
	font="jmod_font_bold",
	align = "center",
	default_font_color={r=1, g=1, b=1},
	hover_font_color={r=0, g=1, b=0},
	top_padding = 0,
	right_padding = 0,
	bottom_padding = 0,
	left_padding = 0,
	left_click_sound =
	{
		{
		  filename = "__core__/sound/gui-click.ogg",
		  volume = 1
		}
	},
}

function extract_monolith(xx, yy)
	return {
		type = "monolith",

		top_monolith_border = 0,
		right_monolith_border = 0,
		bottom_monolith_border = 0,
		left_monolith_border = 0,

		monolith_image = {
			filename = "__Peace_And_Prosperity__/graphics/happy_angry.png",
			priority = "extra-high-no-scale",
			width = 32,
			height = 32,
			x = xx,
			y = yy,
		},
	}
end


default_gui.jmod_button_none_style = 
{
    type = "button_style",
	parent="jmod_button_style",

	scalable = false,

	top_padding = 0,
	right_padding = 0,
	bottom_padding = 0,
	left_padding = 0,

	width = 32,
	height = 32,

	default_graphical_set = extract_monolith(64,  0),
	hovered_graphical_set = extract_monolith(64,  0),--extract_monolith(23,  30),
	clicked_graphical_set = extract_monolith(64,  0),--extract_monolith(46,  30),
}

default_gui.jmod_button_angry_style =
{
    type = "button_style",
	parent="jmod_button_style",

	scalable = false,

	top_padding = 0,
	right_padding = 0,
	bottom_padding = 0,
	left_padding = 0,

	width = 16,
	height = 16,

	default_graphical_set = extract_monolith(32,  0),
	hovered_graphical_set = extract_monolith(32,  0),--extract_monolith(23,  30),
	clicked_graphical_set = extract_monolith(32,  0),--extract_monolith(46,  30),
}
default_gui.jmod_button_happy_style =
{
    type = "button_style",
	parent="jmod_button_style",

	scalable = false,

	top_padding = 0,
	right_padding = 0,
	bottom_padding = 0,
	left_padding = 0,

	width = 16,
	height = 16,

	default_graphical_set = extract_monolith(0,  0),
	hovered_graphical_set = extract_monolith(0,  0),--extract_monolith(23,  30),
	clicked_graphical_set = extract_monolith(0,  0),--extract_monolith(46,  30),
}


utils_peaceprosperity.lua

Code: Select all

 
require ("constants")

debug_level = 1  -- eventually change this in on_init()/on_load() of the mod

white = {r = 1, g = 1, b = 1}
red = {r = 1, g = 0.3, b = 0.3}
green = {r = 0, g = 1, b = 0}
blue = {r = 0, g = 0, b = 1}
yellow = {r = 1, g = 1, b = 0}
orange = {r = 1, g = 0.5, b = 0}






function string.startswith(String,Start)
   return string.sub(String,1,string.len(Start))==Start
end

function string.endswith(String,End)
   return End=='' or string.sub(String,-string.len(End))==End
end
table.filter = function(t, filterIter)
  local out = {}

  for k, v in pairs(t) do
    if filterIter(v, k, t) then out[k] = v end
  end

  return out
end


--------------------------------------------------------------------------------------
function debug_log(s,...)
	if debug_level >= 0 then return end
	--if not args then s,args="%s",{s,} end
	local file = io.open("peaceandprosperity.log.txt", "a")
	--if arg then
		file:write(string.format(s+"\n",...))
	--else
	--    file:write(s+"\n")
	-- end
end
function debug_print( s, ... )
	if debug_level >= 0 then return end
	--if not args then s,args="%s",{s,} end
	--if arg then
	game.players[1].print(string.format(s,...))
	--else
	--	game.players[1].print(s)
	--end
end

function item_picture (icon, highlight)
	local pic = {
		filename = icon,
		width = 32,
		height = 32
	}
	if USE_CHECKBOXES then
		pic.shift = { 0, -8 }
	end
	if highlight then
		-- setting values > 1 seems to just make the image disappear. in any case this
		-- is just temporary until i figure out how to draw a slot-style highlighted bg.
		pic.tint = {r=0.5,g=0.5,b=0.5,a=1}
	end
	return pic
end
--[[
Returns a graphical_set table given an icon filename, optionally highlighted (a boolean)
as in the case of click / hover.
--]]

function item_graphical_set (icon, highlight)
	return {
		type = "monolith",
		monolith_image = item_picture(icon, highlight)
	}
end

--[[
Check if an object has a flag set. Note that data.raw is not LuaItemPrototype yet, so there is
no .has_flag() function. We just check in .flags.
--]]

function has_flag (flags, flag)
	if not flags then
		return false
	end
	for _,f in pairs(flags) do
		if f == flag then
			return true
		end
	end
end
--------------------------------------------------------------------------------------
function square_area( origin, radius )
	return {
		{x=origin.x - radius, y=origin.y - radius},
		{x=origin.x + radius, y=origin.y + radius}
	}
end

--------------------------------------------------------------------------------------
function min( val1, val2 )
	if val1 < val2 then
		return val1
	else
		return val2
	end
end

--------------------------------------------------------------------------------------
function max( val1, val2 )
	if val1 > val2 then
		return val1
	else
		return val2
	end
end

--------------------------------------------------------------------------------------
function iif( cond, val1, val2 )
	if cond then
		return val1
	else
		return val2
	end
end

function arrayLength(T)
   local count = 0
   for k,v in pairs(tbl) do count = count + 1 end
   return count
end
function explode(div,str)
    if (div=='') then return false end
    local pos,arr,ct = 0,{},0
    for st,sp in function() return string.find(str,div,pos,true) end do
        table.insert(arr,string.sub(str,pos,st-1))
        pos = sp + 1
		ct = ct + 1
    end
    table.insert(arr,string.sub(str,pos))
    return arr,ct
end
----------------------------------------------


function looping_index0_into_array(idx,T,sizeT)
    local safe_index = idx%sizeT
	return safe_index,T[safe_index+1]
end

local g_item_info = nil
function ensure_item_info_initialized ()

	if g_item_info then
		return
	end


	g_item_info = {
        {
                style = "jmod_button_none_style",
				item_name = "clear",
				stack_size = stack_size
        },
    }
    --game.write_file("items.log","Start File")
    for _,item_list in pairs({game.entity_prototypes,game.item_prototypes}) do
        for name,item in pairs(item_list) do
            if item.type == "resource" then
                local stack_size = 1
--                game.write_file("items.log",string.format("%s=>%s\n","name",item.name),"a")
--                game.write_file("items.log",string.format("%s=>%s\n","type",item.type),"a")
--                game.write_file("items.log","\n-------\n\n","a")
                table.insert(g_item_info,{
                    style = ITEM_BUTTON_STYLE_PREFIX..name,
                    item_name = name,
                    stack_size = stack_size
                })

            end
        end
    end
end
function get_resources()
    ensure_item_info_initialized()
    return g_item_info


end

function resource_from_index(idx)
    resources = get_resources()
	return looping_index0_into_array(idx,resources,#resources)

end
function style_from_index(idx)
    safe_index,resource = resource_from_index(idx)
	return safe_index,resource["style"]
end

bartaslondon
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sat Apr 16, 2016 3:06 pm
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by bartaslondon »

Thank you for that.

I can see in mods menu it's working however when I'm on my map I can't see the box on the top of the map where I could switch on/off bitters or add resources
Sunnova
Fast Inserter
Fast Inserter
Posts: 169
Joined: Mon May 16, 2016 12:10 pm
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by Sunnova »

hmm, just started a new game to test, it's showing just fine for me. Not sure what is going on. Do you see a small smiley face? If so, click on that.
bartaslondon
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sat Apr 16, 2016 3:06 pm
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by bartaslondon »

Unfortunately no, I can' t see the face ( I know what you mean as I played this mod on 0.12 version)

I just created a new map and it's working fine but with my save not at all.
Sunnova
Fast Inserter
Fast Inserter
Posts: 169
Joined: Mon May 16, 2016 12:10 pm
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by Sunnova »

Try changing the version number in the info.json file, something like Peace_And_Prosperity_0.1.01 and rename the folder to match, see if it loads the changes.
bartaslondon
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sat Apr 16, 2016 3:06 pm
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by bartaslondon »

Still no luck
Sunnova
Fast Inserter
Fast Inserter
Posts: 169
Joined: Mon May 16, 2016 12:10 pm
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by Sunnova »

Try this control lua, I had commented out some stuff, see if it works with it back in.

Code: Select all


require("utils_peaceprosperity")

local current_button = 0
local player
-- local is_first_load = nil
--------------------------------------------------------------------------------------
function create_gui(player)
    player.gui.top.add({type = "frame", name = "jmod_main_frameA", caption = "", direction = "horizontal", style = "jmod_frame_style"})
	player.gui.top.jmod_main_frameA.add({type="flow",name="container",direction="vertical"})
    player.gui.top.jmod_main_frameA.container.add({type="flow",name="main",direction="horizontal"})
    player.gui.top.jmod_main_frameA.container.add({type="flow",name="bottom",direction="horizontal"})

    player.gui.top.jmod_main_frameA.container.main.add({type = "button", name = "but_mobs", caption = "Mobs Aggressive", font_color = red, style = "jmod_button_style"})
    player.gui.top.jmod_main_frameA.container.main.add({type = "button", name = "but_resources", style = "jmod_button_none_style"})
    player.gui.top.jmod_main_frameA.container.main.add({type = "button", name = "but_deploy", caption = "Deploy Resource" , font_color = white, style = "jmod_button_style"})

    player.gui.top.jmod_main_frameA.container.bottom.add({type="label",name="lbl_deploy",caption="test",font_color="white"})
    player.gui.top.jmod_main_frameA.container.bottom.add({type="checkbox",name="cb_minify",caption="tiny",state=false,font_color="white"})
end
-- This function allows pre 0.1.5 version existing games to load

function create_maximizer(player)
    player.gui.left.add({type = "button", name = "jmod_frameB", caption = "", direction = "horizontal", style = "jmod_button_angry_style"})
end

function on_player_created(event)
  local player = game.players[event.player_index]
  create_gui(player)
  update_buttons(player)
end

function on_init()
 	is_first_load = true
  	surf = game.surfaces[1]
   for _, player in ipairs(game.players) do
   if player.gui.top.jmod_main_frameA ~= nil and player.gui.top.jmod_main_frameA.container == nil then
 		player.gui.top.jmod_main_frameA.destroy()
 	end
 	if player.gui.top.jmod_main_frameA == nil and player.gui.left.jmod_frameB == nil then
     create_gui(player)
 	end
 	update_buttons(player)
 	end
 end

function toggle_gui(player)
    if player.gui.top.jmod_main_frameA ~= nil then
        player.gui.top.jmod_main_frameA.destroy()
        create_maximizer(player)
    else
        if player.gui.left.jmod_frameB ~= nil then
            player.gui.left.jmod_frameB.destroy()
        end
        create_gui(player)
    end
end

script.on_event(defines.events.on_player_created, on_player_created)

script.on_event(defines.events.on_tick, 
    --runs every tick ... really I would like to just call once when world is first loaded but meh...
function(event)
		if is_first_load == nil then -- instructions run once, when the world is first loaded (not after a save)
			on_init()
		end
	end
)

--------------------------------------------------------------------------------------
script.on_event(defines.events.on_gui_click, 
    -- handle when a user clicks our gui
	function(event)
	  local player = game.players[event.element.player_index]
		if event.element.name == "but_mobs" then
			game.surfaces[1].peaceful_mode = not game.surfaces[1].peaceful_mode
			if game.surfaces[1].peaceful_mode then
			  game.evolution_factor = 0; 
				game.forces["enemy"].kill_all_units()
				debug_print("Peaceful Enabled")
			else
				debug_print("Aggressive Enabled!")
			end
		elseif event.element.name == "but_resources" then
			current_button = current_button + 1
		elseif event.element.name == "but_deploy" then
			current_button,resource = resource_from_index(current_button)
			local surface = game.surfaces[1]
			if resource.item_name == "crude-oil" then
         local positions = {{-2,-2},{2,2},{0,0},{-2,2},{2,-2}}
				 for i, pair in ipairs(positions) do
					 local x,y = pair[1],pair[2]
					 surface.create_entity({name="crude-oil", amount=50000, position={player.position.x+x, player.position.y+y}})
         end
      elseif resource.item_name == "clear" then
         local area = {{player.position.x-2,player.position.y-2},{player.position.x+2,player.position.y+2}}
			  	for i,entity in ipairs(surface.find_entities(area)) do
				  	if entity.name ~= "player" then
					     entity.destroy()
            end
          end
			else
				for y=-2,2 do
					for x=-2,2 do
						surface.create_entity({name=resource.item_name, amount=50000, position={player.position.x+x, player.position.y+y}})
					end
				end
			end	
			debug_print("Deployed : %s",resource.item_name)
        elseif event.element.name == "cb_minify" or event.element.name == "jmod_frameB" then
            toggle_gui(player)
        end
		update_buttons(player)
	end
)

--------------------------------------------------------------------------------------
function update_minigui(player)
    if game.surfaces[1].peaceful_mode then
            player.gui.left.jmod_frameB.style ="jmod_button_happy_style"
    else
        player.gui.left.jmod_frameB.style ="jmod_button_angry_style"
    end
end

function update_maingui(player)
    current_button,resource = resource_from_index(current_button)
    player.gui.top.jmod_main_frameA.container.main.but_resources.style =  resource.style
    local caption,caption2,font_color

    if resource.item_name == "clear" then
          caption = "Clear Area"
          caption2 = "Clear Area"
          font_color = red
    else
          caption = "Deploy: "..resource.item_name.."      "
          caption2 = "Deploy Resource"
          font_color = white
    end

    player.gui.top.jmod_main_frameA.container.bottom.lbl_deploy.caption = caption
    player.gui.top.jmod_main_frameA.container.main.but_deploy.style.font_color = font_color
    player.gui.top.jmod_main_frameA.container.main.but_deploy.caption = caption2

    if not game.surfaces[1].peaceful_mode then
        player.gui.top.jmod_main_frameA.container.main.but_mobs.style.font_color = red
        player.gui.top.jmod_main_frameA.container.main.but_mobs.caption = "Mobs Aggressive"
    else
        player.gui.top.jmod_main_frameA.container.main.but_mobs.style.font_color = green
        player.gui.top.jmod_main_frameA.container.main.but_mobs.caption = "Mobs Peaceful  "
    end
end

function update_buttons(player)  
    -- update buttons ... it should only be called explicitly after a state change event (gui click for example)  	
    if player.gui.top.jmod_main_frameA ~= nil then
        update_maingui(player)
    elseif player.gui.left.jmod_frameB ~= nil then
        update_minigui(player)
    end
end

bartaslondon
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sat Apr 16, 2016 3:06 pm
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by bartaslondon »

Still nothing, thank you for trying
Sunnova
Fast Inserter
Fast Inserter
Posts: 169
Joined: Mon May 16, 2016 12:10 pm
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by Sunnova »

Sorry, I wish I knew what it was, at least it's working with new maps.
bartaslondon
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sat Apr 16, 2016 3:06 pm
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by bartaslondon »

Thank you for your help.
I think I'll start new map, I'm only 15 hours on my recent save.
It's very strange as on my previous map I was about 400 hours on the map and this mod was working without any issue
Sunnova
Fast Inserter
Fast Inserter
Posts: 169
Joined: Mon May 16, 2016 12:10 pm
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by Sunnova »

I've only been playing since end of April, lots of fun for sure. My oldest map is still working fine though for this mod.
adick898
Manual Inserter
Manual Inserter
Posts: 1
Joined: Sun Sep 11, 2016 12:49 pm
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by adick898 »

could you update this mod to the newest version it would be a big help to play this game thainks
joran
Burner Inserter
Burner Inserter
Posts: 15
Joined: Fri Apr 22, 2016 7:54 am
Contact:

Re: [MOD 0.12.x] Peace_And_Prosperity v0.1.5 [29APR16]

Post by joran »

whoa sorry... I did not know it was broken ... yeah I will see if i can update it this weekend when I have time ... sorry about that
Post Reply

Return to “Mods”