Cuberite Forum

Full Version: INI Files
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hey guys,

If anyone gets a chance do you think you could explain basic usage of reading/writing to ini files, at the moment im just giving myself a headache trying to figure it outTongue
(02-27-2011, 09:16 AM)Tim Wrote: [ -> ]Hey guys,

If anyone gets a chance do you think you could explain basic usage of reading/writing to ini files, at the moment im just giving myself a headache trying to figure it outTongue

Look at Area Plugin.
I created a page for INI files over here http://mc-server.org/wiki/doku.php?id=api:cinifile
see if you find it useful
(02-27-2011, 05:41 PM)Tybor Wrote: [ -> ]
(02-27-2011, 09:16 AM)Tim Wrote: [ -> ]Hey guys,

If anyone gets a chance do you think you could explain basic usage of reading/writing to ini files, at the moment im just giving myself a headache trying to figure it outTongue

Look at Area Plugin.
yeah, had a look at that - it was useful for some stuff then i started getting confused, might just have been due to it getting kinda late to be fair :p

(02-27-2011, 11:22 PM)FakeTruth Wrote: [ -> ]I created a page for INI files over here http://mc-server.org/wiki/doku.php?id=api:cinifile
see if you find it useful

thats very useful, didnt notice that page before!


Thanks guys Smile
You didn't notice that page because it wasn't there before, haha. I just created it
I'm having issues getting it to write to the files, have you got any advice for me? It reads perfectly but I can't change settings, I'm trying to make a plugin for scores/money.
(02-28-2011, 06:46 AM)codename_B Wrote: [ -> ]I'm having issues getting it to write to the files, have you got any advice for me? It reads perfectly but I can't change settings, I'm trying to make a plugin for scores/money.

Look how it is handled in Area Plugin as I make extensive usage of INI file.
(02-28-2011, 03:13 AM)FakeTruth Wrote: [ -> ]You didn't notice that page because it wasn't there before, haha. I just created it
Ahh thanks haha
(02-28-2011, 06:46 AM)codename_B Wrote: [ -> ]I'm having issues getting it to write to the files, have you got any advice for me? It reads perfectly but I can't change settings, I'm trying to make a plugin for scores/money.

dont forget to use WriteFile() , i kept forgetting that one and couldnt understand why it wasnt workingTongue


How can i check if a key exists, like
Code:
if(specified-key-exists) then
--do something
else
--do something else
end
I realised that and got it workingTongue Thanks!
(02-28-2011, 09:02 PM)Tim Wrote: [ -> ]How can i check if a key exists, like
Code:
if(specified-key-exists) then
--do something
else
--do something else
end

Example from my Area Plugin:
PHP Code:
-- check if Owners already available
  
if(AreaPlugin.IniFile:FindValue(AreaID"Owners") < 0then
    
-- create new value
    AreaPlugin
.IniFile:SetValue(AreaPlugin:GetAreaKey(AreaID), "Owners"'"' .. PlayerName .. '",'true)
  else
    -- 
check if already Owner
    
if(AreaPlugin:IsOwner(AreaIDPlayerName)) then
      
return truePlayerName .. " already owner of Area " .. AreaID
    
else
      -- 
add new Owner
      local Owners 
AreaPlugin.IniFile:GetValue(AreaPlugin:GetAreaKey(AreaID), "Owners")
      
Owners Owners .. '"' .. PlayerName .. '",'
      
AreaPlugin.IniFile:SetValue(AreaPlugin:GetAreaKey(AreaID), "Owners"Ownersfalse)
    
end
  end 
Pages: 1 2